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