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