2 // Copyright 2006 The Android Open Source Project
4 // State bundle. Used to pass around stuff like command-line args.
10 #include <utils/Log.h>
11 #include <utils/threads.h>
12 #include <utils/List.h>
13 #include <utils/Errors.h>
14 #include <utils/String8.h>
15 #include <utils/Vector.h>
20 typedef enum Command
{
31 * Bundle of goodies, including everything specified on the command line.
36 : mCmd(kCommandUnknown
), mVerbose(false), mAndroidList(false),
37 mForce(false), mGrayscaleTolerance(0), mMakePackageDirs(false),
38 mUpdate(false), mExtending(false),
39 mRequireLocalization(false), mPseudolocalize(false),
40 mUTF8(false), mEncodingSpecified(false), mValues(false),
41 mCompressionMethod(0), mOutputAPKFile(NULL
),
42 mManifestPackageNameOverride(NULL
), mInstrumentationPackageNameOverride(NULL
),
43 mAutoAddOverlay(false), mAssetSourceDir(NULL
), mProguardFile(NULL
),
44 mAndroidManifestFile(NULL
), mPublicOutputFile(NULL
),
45 mRClassDir(NULL
), mResourceIntermediatesDir(NULL
),
46 mMinSdkVersion(NULL
), mTargetSdkVersion(NULL
), mMaxSdkVersion(NULL
),
47 mVersionCode(NULL
), mVersionName(NULL
), mCustomPackage(NULL
),
53 * Set the command value. Returns "false" if it was previously set.
55 Command
getCommand(void) const { return mCmd
; }
56 void setCommand(Command cmd
) { mCmd
= cmd
; }
59 * Command modifiers. Not all modifiers are appropriate for all
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
; }
80 bool getUTF8(void) const { return mUTF8
; }
81 void setUTF8(bool val
) { mUTF8
= val
; }
82 bool getEncodingSpecified(void) const { return mEncodingSpecified
; }
83 void setEncodingSpecified(bool val
) { mEncodingSpecified
= val
; }
84 bool getValues(void) const { return mValues
; }
85 void setValues(bool val
) { mValues
= val
; }
86 int getCompressionMethod(void) const { return mCompressionMethod
; }
87 void setCompressionMethod(int val
) { mCompressionMethod
= val
; }
88 bool getJunkPath(void) const { return mJunkPath
; }
89 void setJunkPath(bool val
) { mJunkPath
= val
; }
90 const char* getOutputAPKFile() const { return mOutputAPKFile
; }
91 void setOutputAPKFile(const char* val
) { mOutputAPKFile
= val
; }
92 const char* getManifestPackageNameOverride() const { return mManifestPackageNameOverride
; }
93 void setManifestPackageNameOverride(const char * val
) { mManifestPackageNameOverride
= val
; }
94 const char* getInstrumentationPackageNameOverride() const { return mInstrumentationPackageNameOverride
; }
95 void setInstrumentationPackageNameOverride(const char * val
) { mInstrumentationPackageNameOverride
= val
; }
96 bool getAutoAddOverlay() { return mAutoAddOverlay
; }
97 void setAutoAddOverlay(bool val
) { mAutoAddOverlay
= val
; }
102 const char* getAssetSourceDir() const { return mAssetSourceDir
; }
103 void setAssetSourceDir(const char* dir
) { mAssetSourceDir
= dir
; }
104 const char* getProguardFile() const { return mProguardFile
; }
105 void setProguardFile(const char* file
) { mProguardFile
= file
; }
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
); }
125 const char* getMinSdkVersion() const { return mMinSdkVersion
; }
126 void setMinSdkVersion(const char* val
) {
127 mMinSdkVersion
= val
;
128 if (!mEncodingSpecified
) {
129 setUTF8(isUTF8Available());
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
; }
140 const char* getCustomPackage() const { return mCustomPackage
; }
141 void setCustomPackage(const char* val
) { mCustomPackage
= val
; }
144 * Set and get the file specification.
146 * Note this does NOT make a copy of argv.
148 void setFileSpec(char* const argv
[], int argc
) {
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
;
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
166 int getPackageCount(void) const { return mPackageCount
; }
167 void setPackageCount(int val
) { mPackageCount
= val
; }
171 /* commands & modifiers */
176 int mGrayscaleTolerance
;
177 bool mMakePackageDirs
;
180 bool mRequireLocalization
;
181 bool mPseudolocalize
;
183 bool mEncodingSpecified
;
185 int mCompressionMethod
;
187 const char* mOutputAPKFile
;
188 const char* mManifestPackageNameOverride
;
189 const char* mInstrumentationPackageNameOverride
;
190 bool mAutoAddOverlay
;
191 const char* mAssetSourceDir
;
192 const char* mProguardFile
;
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
;
203 const char* mMinSdkVersion
;
204 const char* mTargetSdkVersion
;
205 const char* mMaxSdkVersion
;
206 const char* mVersionCode
;
207 const char* mVersionName
;
208 const char* mCustomPackage
;
210 /* file specification */
219 /* UTF-8 is only available on APIs 7 or above or
220 * SDK levels that have code names.
222 bool isUTF8Available() {
224 int minSdkNum
= (int)strtol(mMinSdkVersion
, &end
, 0);