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