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