]> git.saurik.com Git - android/aapt.git/blame - Bundle.h
Add ability for some manifest attributes to reference resources.
[android/aapt.git] / Bundle.h
CommitLineData
a534180c
TAOSP
1//
2// Copyright 2006 The Android Open Source Project
3//
4// State bundle. Used to pass around stuff like command-line args.
5//
6#ifndef __BUNDLE_H
7#define __BUNDLE_H
8
9#include <stdlib.h>
79e5d372
MA
10#include <utils/Log.h>
11#include <utils/threads.h>
12#include <utils/List.h>
13#include <utils/Errors.h>
a534180c
TAOSP
14#include <utils/String8.h>
15#include <utils/Vector.h>
16
17/*
18 * Things we can do.
19 */
20typedef enum Command {
21 kCommandUnknown = 0,
22 kCommandVersion,
23 kCommandList,
24 kCommandDump,
25 kCommandAdd,
26 kCommandRemove,
27 kCommandPackage,
28} Command;
29
30/*
31 * Bundle of goodies, including everything specified on the command line.
32 */
33class Bundle {
34public:
35 Bundle(void)
36 : mCmd(kCommandUnknown), mVerbose(false), mAndroidList(false),
37 mForce(false), mGrayscaleTolerance(0), mMakePackageDirs(false),
38 mUpdate(false), mExtending(false),
39 mRequireLocalization(false), mPseudolocalize(false),
28de9b93 40 mUTF8(false), mEncodingSpecified(false), mValues(false),
af945cf3
DH
41 mCompressionMethod(0), mOutputAPKFile(NULL),
42 mManifestPackageNameOverride(NULL), mInstrumentationPackageNameOverride(NULL),
636d3b70 43 mAutoAddOverlay(false), mAssetSourceDir(NULL), mProguardFile(NULL),
a534180c
TAOSP
44 mAndroidManifestFile(NULL), mPublicOutputFile(NULL),
45 mRClassDir(NULL), mResourceIntermediatesDir(NULL),
53288885 46 mMinSdkVersion(NULL), mTargetSdkVersion(NULL), mMaxSdkVersion(NULL),
fa19db5e 47 mVersionCode(NULL), mVersionName(NULL), mCustomPackage(NULL),
a534180c
TAOSP
48 mArgc(0), mArgv(NULL)
49 {}
50 ~Bundle(void) {}
51
52 /*
53 * Set the command value. Returns "false" if it was previously set.
54 */
55 Command getCommand(void) const { return mCmd; }
56 void setCommand(Command cmd) { mCmd = cmd; }
57
58 /*
59 * Command modifiers. Not all modifiers are appropriate for all
60 * commands.
61 */
62 bool getVerbose(void) const { return mVerbose; }
63 void setVerbose(bool val) { mVerbose = val; }
64 bool getAndroidList(void) const { return mAndroidList; }
65 void setAndroidList(bool val) { mAndroidList = val; }
66 bool getForce(void) const { return mForce; }
67 void setForce(bool val) { mForce = val; }
68 void setGrayscaleTolerance(int val) { mGrayscaleTolerance = val; }
69 int getGrayscaleTolerance() { return mGrayscaleTolerance; }
70 bool getMakePackageDirs(void) const { return mMakePackageDirs; }
71 void setMakePackageDirs(bool val) { mMakePackageDirs = val; }
72 bool getUpdate(void) const { return mUpdate; }
73 void setUpdate(bool val) { mUpdate = val; }
74 bool getExtending(void) const { return mExtending; }
75 void setExtending(bool val) { mExtending = val; }
76 bool getRequireLocalization(void) const { return mRequireLocalization; }
77 void setRequireLocalization(bool val) { mRequireLocalization = val; }
78 bool getPseudolocalize(void) const { return mPseudolocalize; }
79 void setPseudolocalize(bool val) { mPseudolocalize = val; }
15c62a5b
KR
80 bool getUTF8(void) const { return mUTF8; }
81 void setUTF8(bool val) { mUTF8 = val; }
28de9b93
KR
82 bool getEncodingSpecified(void) const { return mEncodingSpecified; }
83 void setEncodingSpecified(bool val) { mEncodingSpecified = val; }
7751daa4
DH
84 bool getValues(void) const { return mValues; }
85 void setValues(bool val) { mValues = val; }
a534180c
TAOSP
86 int getCompressionMethod(void) const { return mCompressionMethod; }
87 void setCompressionMethod(int val) { mCompressionMethod = val; }
1e8883fc
DZ
88 bool getJunkPath(void) const { return mJunkPath; }
89 void setJunkPath(bool val) { mJunkPath = val; }
a534180c
TAOSP
90 const char* getOutputAPKFile() const { return mOutputAPKFile; }
91 void setOutputAPKFile(const char* val) { mOutputAPKFile = val; }
094e8965
JH
92 const char* getManifestPackageNameOverride() const { return mManifestPackageNameOverride; }
93 void setManifestPackageNameOverride(const char * val) { mManifestPackageNameOverride = val; }
af945cf3
DH
94 const char* getInstrumentationPackageNameOverride() const { return mInstrumentationPackageNameOverride; }
95 void setInstrumentationPackageNameOverride(const char * val) { mInstrumentationPackageNameOverride = val; }
636d3b70
XD
96 bool getAutoAddOverlay() { return mAutoAddOverlay; }
97 void setAutoAddOverlay(bool val) { mAutoAddOverlay = val; }
a534180c 98
1e8883fc
DZ
99 /*
100 * Input options.
a534180c
TAOSP
101 */
102 const char* getAssetSourceDir() const { return mAssetSourceDir; }
103 void setAssetSourceDir(const char* dir) { mAssetSourceDir = dir; }
6648ff78
JO
104 const char* getProguardFile() const { return mProguardFile; }
105 void setProguardFile(const char* file) { mProguardFile = file; }
a534180c
TAOSP
106 const android::Vector<const char*>& getResourceSourceDirs() const { return mResourceSourceDirs; }
107 void addResourceSourceDir(const char* dir) { mResourceSourceDirs.insertAt(dir,0); }
108 const char* getAndroidManifestFile() const { return mAndroidManifestFile; }
109 void setAndroidManifestFile(const char* file) { mAndroidManifestFile = file; }
110 const char* getPublicOutputFile() const { return mPublicOutputFile; }
111 void setPublicOutputFile(const char* file) { mPublicOutputFile = file; }
112 const char* getRClassDir() const { return mRClassDir; }
113 void setRClassDir(const char* dir) { mRClassDir = dir; }
114 const char* getConfigurations() const { return mConfigurations.size() > 0 ? mConfigurations.string() : NULL; }
115 void addConfigurations(const char* val) { if (mConfigurations.size() > 0) { mConfigurations.append(","); mConfigurations.append(val); } else { mConfigurations = val; } }
116 const char* getResourceIntermediatesDir() const { return mResourceIntermediatesDir; }
117 void setResourceIntermediatesDir(const char* dir) { mResourceIntermediatesDir = dir; }
118 const android::Vector<const char*>& getPackageIncludes() const { return mPackageIncludes; }
119 void addPackageInclude(const char* file) { mPackageIncludes.add(file); }
120 const android::Vector<const char*>& getJarFiles() const { return mJarFiles; }
121 void addJarFile(const char* file) { mJarFiles.add(file); }
122 const android::Vector<const char*>& getNoCompressExtensions() const { return mNoCompressExtensions; }
123 void addNoCompressExtension(const char* ext) { mNoCompressExtensions.add(ext); }
124
7e486e33 125 const char* getMinSdkVersion() const { return mMinSdkVersion; }
7dc0cd41
KR
126 void setMinSdkVersion(const char* val) {
127 mMinSdkVersion = val;
28de9b93
KR
128 if (!mEncodingSpecified) {
129 setUTF8(isUTF8Available());
130 }
7dc0cd41 131 }
7e486e33
DH
132 const char* getTargetSdkVersion() const { return mTargetSdkVersion; }
133 void setTargetSdkVersion(const char* val) { mTargetSdkVersion = val; }
134 const char* getMaxSdkVersion() const { return mMaxSdkVersion; }
135 void setMaxSdkVersion(const char* val) { mMaxSdkVersion = val; }
136 const char* getVersionCode() const { return mVersionCode; }
137 void setVersionCode(const char* val) { mVersionCode = val; }
138 const char* getVersionName() const { return mVersionName; }
139 void setVersionName(const char* val) { mVersionName = val; }
fa19db5e
XD
140 const char* getCustomPackage() const { return mCustomPackage; }
141 void setCustomPackage(const char* val) { mCustomPackage = val; }
1e8883fc 142
a534180c
TAOSP
143 /*
144 * Set and get the file specification.
145 *
146 * Note this does NOT make a copy of argv.
147 */
148 void setFileSpec(char* const argv[], int argc) {
149 mArgc = argc;
150 mArgv = argv;
151 }
152 int getFileSpecCount(void) const { return mArgc; }
153 const char* getFileSpecEntry(int idx) const { return mArgv[idx]; }
154 void eatArgs(int n) {
155 if (n > mArgc) n = mArgc;
156 mArgv += n;
157 mArgc -= n;
158 }
159
160#if 0
161 /*
162 * Package count. Nothing to do with anything else here; this is
163 * just a convenient place to stuff it so we don't have to pass it
164 * around everywhere.
165 */
166 int getPackageCount(void) const { return mPackageCount; }
167 void setPackageCount(int val) { mPackageCount = val; }
168#endif
169
170private:
171 /* commands & modifiers */
172 Command mCmd;
173 bool mVerbose;
174 bool mAndroidList;
175 bool mForce;
176 int mGrayscaleTolerance;
177 bool mMakePackageDirs;
178 bool mUpdate;
179 bool mExtending;
180 bool mRequireLocalization;
181 bool mPseudolocalize;
15c62a5b 182 bool mUTF8;
28de9b93 183 bool mEncodingSpecified;
7751daa4 184 bool mValues;
a534180c 185 int mCompressionMethod;
1e8883fc 186 bool mJunkPath;
a534180c 187 const char* mOutputAPKFile;
094e8965 188 const char* mManifestPackageNameOverride;
af945cf3 189 const char* mInstrumentationPackageNameOverride;
636d3b70 190 bool mAutoAddOverlay;
a534180c 191 const char* mAssetSourceDir;
6648ff78 192 const char* mProguardFile;
a534180c
TAOSP
193 const char* mAndroidManifestFile;
194 const char* mPublicOutputFile;
195 const char* mRClassDir;
196 const char* mResourceIntermediatesDir;
197 android::String8 mConfigurations;
198 android::Vector<const char*> mPackageIncludes;
199 android::Vector<const char*> mJarFiles;
200 android::Vector<const char*> mNoCompressExtensions;
201 android::Vector<const char*> mResourceSourceDirs;
1e8883fc 202
7e486e33
DH
203 const char* mMinSdkVersion;
204 const char* mTargetSdkVersion;
205 const char* mMaxSdkVersion;
206 const char* mVersionCode;
207 const char* mVersionName;
fa19db5e 208 const char* mCustomPackage;
1e8883fc 209
a534180c
TAOSP
210 /* file specification */
211 int mArgc;
212 char* const* mArgv;
213
214#if 0
215 /* misc stuff */
216 int mPackageCount;
217#endif
7dc0cd41
KR
218
219 /* UTF-8 is only available on APIs 7 or above or
220 * SDK levels that have code names.
221 */
222 bool isUTF8Available() {
223 char *end;
224 int minSdkNum = (int)strtol(mMinSdkVersion, &end, 0);
225 if (*end == '\0') {
226 if (minSdkNum < 7) {
227 return false;
228 }
229 }
230 return true;
231 }
a534180c
TAOSP
232};
233
234#endif // __BUNDLE_H