Merge "Add a --debug-mode option to aapt."

This commit is contained in:
Xavier Ducrohet
2010-09-02 11:08:03 -07:00
committed by Android Code Review
3 changed files with 18 additions and 2 deletions

View File

@@ -45,6 +45,7 @@ public:
mRClassDir(NULL), mResourceIntermediatesDir(NULL), mManifestMinSdkVersion(NULL), mRClassDir(NULL), mResourceIntermediatesDir(NULL), mManifestMinSdkVersion(NULL),
mMinSdkVersion(NULL), mTargetSdkVersion(NULL), mMaxSdkVersion(NULL), mMinSdkVersion(NULL), mTargetSdkVersion(NULL), mMaxSdkVersion(NULL),
mVersionCode(NULL), mVersionName(NULL), mCustomPackage(NULL), mVersionCode(NULL), mVersionName(NULL), mCustomPackage(NULL),
mDebugMode(false),
mArgc(0), mArgv(NULL) mArgc(0), mArgv(NULL)
{} {}
~Bundle(void) {} ~Bundle(void) {}
@@ -134,6 +135,8 @@ public:
void setVersionName(const char* val) { mVersionName = val; } void setVersionName(const char* val) { mVersionName = val; }
const char* getCustomPackage() const { return mCustomPackage; } const char* getCustomPackage() const { return mCustomPackage; }
void setCustomPackage(const char* val) { mCustomPackage = val; } void setCustomPackage(const char* val) { mCustomPackage = val; }
bool getDebugMode() { return mDebugMode; }
void setDebugMode(bool val) { mDebugMode = val; }
/* /*
* Set and get the file specification. * Set and get the file specification.
@@ -230,6 +233,7 @@ private:
const char* mVersionCode; const char* mVersionCode;
const char* mVersionName; const char* mVersionName;
const char* mCustomPackage; const char* mCustomPackage;
bool mDebugMode;
/* file specification */ /* file specification */
int mArgc; int mArgc;

View File

@@ -57,7 +57,7 @@ void usage(void)
fprintf(stderr, fprintf(stderr,
" %s p[ackage] [-d][-f][-m][-u][-v][-x][-z][-M AndroidManifest.xml] \\\n" " %s p[ackage] [-d][-f][-m][-u][-v][-x][-z][-M AndroidManifest.xml] \\\n"
" [-0 extension [-0 extension ...]] [-g tolerance] [-j jarfile] \\\n" " [-0 extension [-0 extension ...]] [-g tolerance] [-j jarfile] \\\n"
" [--min-sdk-version VAL] [--target-sdk-version VAL] \\\n" " [--debug-mode] [--min-sdk-version VAL] [--target-sdk-version VAL] \\\n"
" [--app-version VAL] [--app-version-name TEXT] [--custom-package VAL] \\\n" " [--app-version VAL] [--app-version-name TEXT] [--custom-package VAL] \\\n"
" [--rename-manifest-package PACKAGE] \\\n" " [--rename-manifest-package PACKAGE] \\\n"
" [--rename-instrumentation-target-package PACKAGE] \\\n" " [--rename-instrumentation-target-package PACKAGE] \\\n"
@@ -123,6 +123,9 @@ void usage(void)
" -0 specifies an additional extension for which such files will not\n" " -0 specifies an additional extension for which such files will not\n"
" be stored compressed in the .apk. An empty string means to not\n" " be stored compressed in the .apk. An empty string means to not\n"
" compress any files at all.\n" " compress any files at all.\n"
" --debug-mode\n"
" inserts android:debuggable=\"true\" in to the application node of the\n"
" manifest, making the application debuggable even on production devices.\n"
" --min-sdk-version\n" " --min-sdk-version\n"
" inserts android:minSdkVersion in to manifest. If the version is 7 or\n" " inserts android:minSdkVersion in to manifest. If the version is 7 or\n"
" higher, the default encoding for resources will be in UTF-8.\n" " higher, the default encoding for resources will be in UTF-8.\n"
@@ -389,7 +392,9 @@ int main(int argc, char* const argv[])
} }
break; break;
case '-': case '-':
if (strcmp(cp, "-min-sdk-version") == 0) { if (strcmp(cp, "-debug-mode") == 0) {
bundle.setDebugMode(true);
} else if (strcmp(cp, "-min-sdk-version") == 0) {
argc--; argc--;
argv++; argv++;
if (!argc) { if (!argc) {

View File

@@ -678,6 +678,13 @@ status_t massageManifest(Bundle* bundle, sp<XMLNode> root)
bundle->getMaxSdkVersion()); bundle->getMaxSdkVersion());
} }
if (bundle->getDebugMode()) {
sp<XMLNode> application = root->getChildElement(String16(), String16("application"));
if (application != NULL) {
addTagAttribute(application, RESOURCES_ANDROID_NAMESPACE, "debuggable", "true");
}
}
// Deal with manifest package name overrides // Deal with manifest package name overrides
const char* manifestPackageNameOverride = bundle->getManifestPackageNameOverride(); const char* manifestPackageNameOverride = bundle->getManifestPackageNameOverride();
if (manifestPackageNameOverride != NULL) { if (manifestPackageNameOverride != NULL) {