]>
Commit | Line | Data |
---|---|---|
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> | |
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> | |
16 | ||
17 | /* | |
18 | * Things we can do. | |
19 | */ | |
20 | typedef 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 | */ | |
33 | class Bundle { | |
34 | public: | |
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), | |
40 | mCompressionMethod(0), mOutputAPKFile(NULL), | |
41 | mAssetSourceDir(NULL), | |
42 | mAndroidManifestFile(NULL), mPublicOutputFile(NULL), | |
43 | mRClassDir(NULL), mResourceIntermediatesDir(NULL), | |
44 | mMinSdkVersion(NULL), mTargetSdkVersion(NULL), mMaxSdkVersion(NULL), | |
45 | mVersionCode(NULL), mVersionName(NULL), | |
46 | mArgc(0), mArgv(NULL) | |
47 | {} | |
48 | ~Bundle(void) {} | |
49 | ||
50 | /* | |
51 | * Set the command value. Returns "false" if it was previously set. | |
52 | */ | |
53 | Command getCommand(void) const { return mCmd; } | |
54 | void setCommand(Command cmd) { mCmd = cmd; } | |
55 | ||
56 | /* | |
57 | * Command modifiers. Not all modifiers are appropriate for all | |
58 | * commands. | |
59 | */ | |
60 | bool getVerbose(void) const { return mVerbose; } | |
61 | void setVerbose(bool val) { mVerbose = val; } | |
62 | bool getAndroidList(void) const { return mAndroidList; } | |
63 | void setAndroidList(bool val) { mAndroidList = val; } | |
64 | bool getForce(void) const { return mForce; } | |
65 | void setForce(bool val) { mForce = val; } | |
66 | void setGrayscaleTolerance(int val) { mGrayscaleTolerance = val; } | |
67 | int getGrayscaleTolerance() { return mGrayscaleTolerance; } | |
68 | bool getMakePackageDirs(void) const { return mMakePackageDirs; } | |
69 | void setMakePackageDirs(bool val) { mMakePackageDirs = val; } | |
70 | bool getUpdate(void) const { return mUpdate; } | |
71 | void setUpdate(bool val) { mUpdate = val; } | |
72 | bool getExtending(void) const { return mExtending; } | |
73 | void setExtending(bool val) { mExtending = val; } | |
74 | bool getRequireLocalization(void) const { return mRequireLocalization; } | |
75 | void setRequireLocalization(bool val) { mRequireLocalization = val; } | |
76 | bool getPseudolocalize(void) const { return mPseudolocalize; } | |
77 | void setPseudolocalize(bool val) { mPseudolocalize = val; } | |
78 | int getCompressionMethod(void) const { return mCompressionMethod; } | |
79 | void setCompressionMethod(int val) { mCompressionMethod = val; } | |
80 | const char* getOutputAPKFile() const { return mOutputAPKFile; } | |
81 | void setOutputAPKFile(const char* val) { mOutputAPKFile = val; } | |
82 | ||
83 | /* | |
84 | * Input options. | |
85 | */ | |
86 | const char* getAssetSourceDir() const { return mAssetSourceDir; } | |
87 | void setAssetSourceDir(const char* dir) { mAssetSourceDir = dir; } | |
88 | const android::Vector<const char*>& getResourceSourceDirs() const { return mResourceSourceDirs; } | |
89 | void addResourceSourceDir(const char* dir) { mResourceSourceDirs.insertAt(dir,0); } | |
90 | const char* getAndroidManifestFile() const { return mAndroidManifestFile; } | |
91 | void setAndroidManifestFile(const char* file) { mAndroidManifestFile = file; } | |
92 | const char* getPublicOutputFile() const { return mPublicOutputFile; } | |
93 | void setPublicOutputFile(const char* file) { mPublicOutputFile = file; } | |
94 | const char* getRClassDir() const { return mRClassDir; } | |
95 | void setRClassDir(const char* dir) { mRClassDir = dir; } | |
96 | const char* getConfigurations() const { return mConfigurations.size() > 0 ? mConfigurations.string() : NULL; } | |
97 | void addConfigurations(const char* val) { if (mConfigurations.size() > 0) { mConfigurations.append(","); mConfigurations.append(val); } else { mConfigurations = val; } } | |
98 | const char* getResourceIntermediatesDir() const { return mResourceIntermediatesDir; } | |
99 | void setResourceIntermediatesDir(const char* dir) { mResourceIntermediatesDir = dir; } | |
100 | const android::Vector<const char*>& getPackageIncludes() const { return mPackageIncludes; } | |
101 | void addPackageInclude(const char* file) { mPackageIncludes.add(file); } | |
102 | const android::Vector<const char*>& getJarFiles() const { return mJarFiles; } | |
103 | void addJarFile(const char* file) { mJarFiles.add(file); } | |
104 | const android::Vector<const char*>& getNoCompressExtensions() const { return mNoCompressExtensions; } | |
105 | void addNoCompressExtension(const char* ext) { mNoCompressExtensions.add(ext); } | |
106 | ||
107 | const char* getMinSdkVersion() const { return mMinSdkVersion; } | |
108 | void setMinSdkVersion(const char* val) { mMinSdkVersion = val; } | |
109 | const char* getTargetSdkVersion() const { return mTargetSdkVersion; } | |
110 | void setTargetSdkVersion(const char* val) { mTargetSdkVersion = val; } | |
111 | const char* getMaxSdkVersion() const { return mMaxSdkVersion; } | |
112 | void setMaxSdkVersion(const char* val) { mMaxSdkVersion = val; } | |
113 | const char* getVersionCode() const { return mVersionCode; } | |
114 | void setVersionCode(const char* val) { mVersionCode = val; } | |
115 | const char* getVersionName() const { return mVersionName; } | |
116 | void setVersionName(const char* val) { mVersionName = val; } | |
117 | ||
118 | /* | |
119 | * Set and get the file specification. | |
120 | * | |
121 | * Note this does NOT make a copy of argv. | |
122 | */ | |
123 | void setFileSpec(char* const argv[], int argc) { | |
124 | mArgc = argc; | |
125 | mArgv = argv; | |
126 | } | |
127 | int getFileSpecCount(void) const { return mArgc; } | |
128 | const char* getFileSpecEntry(int idx) const { return mArgv[idx]; } | |
129 | void eatArgs(int n) { | |
130 | if (n > mArgc) n = mArgc; | |
131 | mArgv += n; | |
132 | mArgc -= n; | |
133 | } | |
134 | ||
135 | #if 0 | |
136 | /* | |
137 | * Package count. Nothing to do with anything else here; this is | |
138 | * just a convenient place to stuff it so we don't have to pass it | |
139 | * around everywhere. | |
140 | */ | |
141 | int getPackageCount(void) const { return mPackageCount; } | |
142 | void setPackageCount(int val) { mPackageCount = val; } | |
143 | #endif | |
144 | ||
145 | private: | |
146 | /* commands & modifiers */ | |
147 | Command mCmd; | |
148 | bool mVerbose; | |
149 | bool mAndroidList; | |
150 | bool mForce; | |
151 | int mGrayscaleTolerance; | |
152 | bool mMakePackageDirs; | |
153 | bool mUpdate; | |
154 | bool mExtending; | |
155 | bool mRequireLocalization; | |
156 | bool mPseudolocalize; | |
157 | int mCompressionMethod; | |
158 | const char* mOutputAPKFile; | |
159 | const char* mAssetSourceDir; | |
160 | const char* mAndroidManifestFile; | |
161 | const char* mPublicOutputFile; | |
162 | const char* mRClassDir; | |
163 | const char* mResourceIntermediatesDir; | |
164 | android::String8 mConfigurations; | |
165 | android::Vector<const char*> mPackageIncludes; | |
166 | android::Vector<const char*> mJarFiles; | |
167 | android::Vector<const char*> mNoCompressExtensions; | |
168 | android::Vector<const char*> mResourceSourceDirs; | |
169 | ||
170 | const char* mMinSdkVersion; | |
171 | const char* mTargetSdkVersion; | |
172 | const char* mMaxSdkVersion; | |
173 | const char* mVersionCode; | |
174 | const char* mVersionName; | |
175 | ||
176 | /* file specification */ | |
177 | int mArgc; | |
178 | char* const* mArgv; | |
179 | ||
180 | #if 0 | |
181 | /* misc stuff */ | |
182 | int mPackageCount; | |
183 | #endif | |
184 | }; | |
185 | ||
186 | #endif // __BUNDLE_H |