]> git.saurik.com Git - android/aapt.git/blame - Bundle.h
resolved conflicts for merge of 2c311be7 to honeycomb-plus-aosp
[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),
5af43148 40 mWantUTF16(false), mValues(false),
af945cf3
DH
41 mCompressionMethod(0), mOutputAPKFile(NULL),
42 mManifestPackageNameOverride(NULL), mInstrumentationPackageNameOverride(NULL),
b1bccba1 43 mIsOverlayPackage(false),
52ffc169
JG
44 mAutoAddOverlay(false), mGenDependencies(false),
45 mAssetSourceDir(NULL), mProguardFile(NULL),
a534180c 46 mAndroidManifestFile(NULL), mPublicOutputFile(NULL),
5af43148 47 mRClassDir(NULL), mResourceIntermediatesDir(NULL), mManifestMinSdkVersion(NULL),
53288885 48 mMinSdkVersion(NULL), mTargetSdkVersion(NULL), mMaxSdkVersion(NULL),
bc7b4f40 49 mVersionCode(NULL), mVersionName(NULL), mCustomPackage(NULL), mExtraPackages(NULL),
54f200b0 50 mMaxResVersion(NULL), mDebugMode(false), mNonConstantId(false), mProduct(NULL),
a534180c
TAOSP
51 mArgc(0), mArgv(NULL)
52 {}
53 ~Bundle(void) {}
54
55 /*
56 * Set the command value. Returns "false" if it was previously set.
57 */
58 Command getCommand(void) const { return mCmd; }
59 void setCommand(Command cmd) { mCmd = cmd; }
60
61 /*
62 * Command modifiers. Not all modifiers are appropriate for all
63 * commands.
64 */
65 bool getVerbose(void) const { return mVerbose; }
66 void setVerbose(bool val) { mVerbose = val; }
67 bool getAndroidList(void) const { return mAndroidList; }
68 void setAndroidList(bool val) { mAndroidList = val; }
69 bool getForce(void) const { return mForce; }
70 void setForce(bool val) { mForce = val; }
71 void setGrayscaleTolerance(int val) { mGrayscaleTolerance = val; }
72 int getGrayscaleTolerance() { return mGrayscaleTolerance; }
73 bool getMakePackageDirs(void) const { return mMakePackageDirs; }
74 void setMakePackageDirs(bool val) { mMakePackageDirs = val; }
75 bool getUpdate(void) const { return mUpdate; }
76 void setUpdate(bool val) { mUpdate = val; }
77 bool getExtending(void) const { return mExtending; }
78 void setExtending(bool val) { mExtending = val; }
79 bool getRequireLocalization(void) const { return mRequireLocalization; }
80 void setRequireLocalization(bool val) { mRequireLocalization = val; }
81 bool getPseudolocalize(void) const { return mPseudolocalize; }
82 void setPseudolocalize(bool val) { mPseudolocalize = val; }
5af43148
KR
83 bool getWantUTF16(void) const { return mWantUTF16; }
84 void setWantUTF16(bool val) { mWantUTF16 = val; }
7751daa4
DH
85 bool getValues(void) const { return mValues; }
86 void setValues(bool val) { mValues = val; }
a534180c
TAOSP
87 int getCompressionMethod(void) const { return mCompressionMethod; }
88 void setCompressionMethod(int val) { mCompressionMethod = val; }
1e8883fc
DZ
89 bool getJunkPath(void) const { return mJunkPath; }
90 void setJunkPath(bool val) { mJunkPath = val; }
a534180c
TAOSP
91 const char* getOutputAPKFile() const { return mOutputAPKFile; }
92 void setOutputAPKFile(const char* val) { mOutputAPKFile = val; }
094e8965
JH
93 const char* getManifestPackageNameOverride() const { return mManifestPackageNameOverride; }
94 void setManifestPackageNameOverride(const char * val) { mManifestPackageNameOverride = val; }
af945cf3
DH
95 const char* getInstrumentationPackageNameOverride() const { return mInstrumentationPackageNameOverride; }
96 void setInstrumentationPackageNameOverride(const char * val) { mInstrumentationPackageNameOverride = val; }
b1bccba1
MK
97 bool getIsOverlayPackage() const { return mIsOverlayPackage; }
98 void setIsOverlayPackage(bool val) { mIsOverlayPackage = val; }
636d3b70
XD
99 bool getAutoAddOverlay() { return mAutoAddOverlay; }
100 void setAutoAddOverlay(bool val) { mAutoAddOverlay = val; }
52ffc169
JG
101 bool getGenDependencies() { return mGenDependencies; }
102 void setGenDependencies(bool val) { mGenDependencies = val; }
a534180c 103
1e8883fc
DZ
104 /*
105 * Input options.
a534180c
TAOSP
106 */
107 const char* getAssetSourceDir() const { return mAssetSourceDir; }
108 void setAssetSourceDir(const char* dir) { mAssetSourceDir = dir; }
6648ff78
JO
109 const char* getProguardFile() const { return mProguardFile; }
110 void setProguardFile(const char* file) { mProguardFile = file; }
a534180c
TAOSP
111 const android::Vector<const char*>& getResourceSourceDirs() const { return mResourceSourceDirs; }
112 void addResourceSourceDir(const char* dir) { mResourceSourceDirs.insertAt(dir,0); }
113 const char* getAndroidManifestFile() const { return mAndroidManifestFile; }
114 void setAndroidManifestFile(const char* file) { mAndroidManifestFile = file; }
115 const char* getPublicOutputFile() const { return mPublicOutputFile; }
116 void setPublicOutputFile(const char* file) { mPublicOutputFile = file; }
117 const char* getRClassDir() const { return mRClassDir; }
118 void setRClassDir(const char* dir) { mRClassDir = dir; }
119 const char* getConfigurations() const { return mConfigurations.size() > 0 ? mConfigurations.string() : NULL; }
120 void addConfigurations(const char* val) { if (mConfigurations.size() > 0) { mConfigurations.append(","); mConfigurations.append(val); } else { mConfigurations = val; } }
121 const char* getResourceIntermediatesDir() const { return mResourceIntermediatesDir; }
122 void setResourceIntermediatesDir(const char* dir) { mResourceIntermediatesDir = dir; }
123 const android::Vector<const char*>& getPackageIncludes() const { return mPackageIncludes; }
124 void addPackageInclude(const char* file) { mPackageIncludes.add(file); }
125 const android::Vector<const char*>& getJarFiles() const { return mJarFiles; }
126 void addJarFile(const char* file) { mJarFiles.add(file); }
127 const android::Vector<const char*>& getNoCompressExtensions() const { return mNoCompressExtensions; }
128 void addNoCompressExtension(const char* ext) { mNoCompressExtensions.add(ext); }
129
5af43148
KR
130 const char* getManifestMinSdkVersion() const { return mManifestMinSdkVersion; }
131 void setManifestMinSdkVersion(const char* val) { mManifestMinSdkVersion = val; }
7e486e33 132 const char* getMinSdkVersion() const { return mMinSdkVersion; }
5af43148 133 void setMinSdkVersion(const char* val) { mMinSdkVersion = val; }
7e486e33
DH
134 const char* getTargetSdkVersion() const { return mTargetSdkVersion; }
135 void setTargetSdkVersion(const char* val) { mTargetSdkVersion = val; }
136 const char* getMaxSdkVersion() const { return mMaxSdkVersion; }
137 void setMaxSdkVersion(const char* val) { mMaxSdkVersion = val; }
138 const char* getVersionCode() const { return mVersionCode; }
139 void setVersionCode(const char* val) { mVersionCode = val; }
140 const char* getVersionName() const { return mVersionName; }
141 void setVersionName(const char* val) { mVersionName = val; }
fa19db5e
XD
142 const char* getCustomPackage() const { return mCustomPackage; }
143 void setCustomPackage(const char* val) { mCustomPackage = val; }
bc7b4f40
JG
144 const char* getExtraPackages() const { return mExtraPackages; }
145 void setExtraPackages(const char* val) { mExtraPackages = val; }
73412e58
FK
146 const char* getMaxResVersion() const { return mMaxResVersion; }
147 void setMaxResVersion(const char * val) { mMaxResVersion = val; }
f04c74b7
XD
148 bool getDebugMode() { return mDebugMode; }
149 void setDebugMode(bool val) { mDebugMode = val; }
54f200b0
XD
150 bool getNonConstantId() { return mNonConstantId; }
151 void setNonConstantId(bool val) { mNonConstantId = val; }
b8ea3a3f
EF
152 const char* getProduct() const { return mProduct; }
153 void setProduct(const char * val) { mProduct = val; }
1e8883fc 154
a534180c
TAOSP
155 /*
156 * Set and get the file specification.
157 *
158 * Note this does NOT make a copy of argv.
159 */
160 void setFileSpec(char* const argv[], int argc) {
161 mArgc = argc;
162 mArgv = argv;
163 }
164 int getFileSpecCount(void) const { return mArgc; }
165 const char* getFileSpecEntry(int idx) const { return mArgv[idx]; }
166 void eatArgs(int n) {
167 if (n > mArgc) n = mArgc;
168 mArgv += n;
169 mArgc -= n;
170 }
171
172#if 0
173 /*
174 * Package count. Nothing to do with anything else here; this is
175 * just a convenient place to stuff it so we don't have to pass it
176 * around everywhere.
177 */
178 int getPackageCount(void) const { return mPackageCount; }
179 void setPackageCount(int val) { mPackageCount = val; }
180#endif
181
1bad9d29
KR
182 /* Certain features may only be available on a specific SDK level or
183 * above. SDK levels that have a non-numeric identifier are assumed
184 * to be newer than any SDK level that has a number designated.
5af43148 185 */
1bad9d29 186 bool isMinSdkAtLeast(int desired) {
5af43148
KR
187 /* If the application specifies a minSdkVersion in the manifest
188 * then use that. Otherwise, check what the user specified on
189 * the command line. If neither, it's not available since
190 * the minimum SDK version is assumed to be 1.
191 */
192 const char *minVer;
193 if (mManifestMinSdkVersion != NULL) {
194 minVer = mManifestMinSdkVersion;
195 } else if (mMinSdkVersion != NULL) {
196 minVer = mMinSdkVersion;
197 } else {
198 return false;
199 }
200
201 char *end;
202 int minSdkNum = (int)strtol(minVer, &end, 0);
203 if (*end == '\0') {
1bad9d29 204 if (minSdkNum < desired) {
5af43148
KR
205 return false;
206 }
207 }
208 return true;
209 }
210
a534180c
TAOSP
211private:
212 /* commands & modifiers */
213 Command mCmd;
214 bool mVerbose;
215 bool mAndroidList;
216 bool mForce;
217 int mGrayscaleTolerance;
218 bool mMakePackageDirs;
219 bool mUpdate;
220 bool mExtending;
221 bool mRequireLocalization;
222 bool mPseudolocalize;
5af43148 223 bool mWantUTF16;
7751daa4 224 bool mValues;
a534180c 225 int mCompressionMethod;
1e8883fc 226 bool mJunkPath;
a534180c 227 const char* mOutputAPKFile;
094e8965 228 const char* mManifestPackageNameOverride;
af945cf3 229 const char* mInstrumentationPackageNameOverride;
b1bccba1 230 bool mIsOverlayPackage;
636d3b70 231 bool mAutoAddOverlay;
52ffc169 232 bool mGenDependencies;
a534180c 233 const char* mAssetSourceDir;
6648ff78 234 const char* mProguardFile;
a534180c
TAOSP
235 const char* mAndroidManifestFile;
236 const char* mPublicOutputFile;
237 const char* mRClassDir;
238 const char* mResourceIntermediatesDir;
239 android::String8 mConfigurations;
240 android::Vector<const char*> mPackageIncludes;
241 android::Vector<const char*> mJarFiles;
242 android::Vector<const char*> mNoCompressExtensions;
243 android::Vector<const char*> mResourceSourceDirs;
1e8883fc 244
5af43148 245 const char* mManifestMinSdkVersion;
7e486e33
DH
246 const char* mMinSdkVersion;
247 const char* mTargetSdkVersion;
248 const char* mMaxSdkVersion;
249 const char* mVersionCode;
250 const char* mVersionName;
fa19db5e 251 const char* mCustomPackage;
bc7b4f40 252 const char* mExtraPackages;
73412e58 253 const char* mMaxResVersion;
f04c74b7 254 bool mDebugMode;
54f200b0 255 bool mNonConstantId;
b8ea3a3f 256 const char* mProduct;
1e8883fc 257
a534180c
TAOSP
258 /* file specification */
259 int mArgc;
260 char* const* mArgv;
261
262#if 0
263 /* misc stuff */
264 int mPackageCount;
265#endif
7dc0cd41 266
a534180c
TAOSP
267};
268
269#endif // __BUNDLE_H