From: Xavier Ducrohet Date: Tue, 31 Aug 2010 21:32:53 +0000 (-0700) Subject: am 23827557: Merge "Add a --debug-mode option to aapt." into gingerbread X-Git-Url: https://git.saurik.com/android/aapt.git/commitdiff_plain/a539f228b523c712fb9e61d4e5e4799a185b64ff?hp=7c9ec0e77a95e7fb409db502f8ece3f0515f93d0 am 23827557: Merge "Add a --debug-mode option to aapt." into gingerbread Merge commit '2382755730206da52b64bf7bd2fad421f9a6fd0d' into gingerbread-plus-aosp * commit '2382755730206da52b64bf7bd2fad421f9a6fd0d': Add a --debug-mode option to aapt. --- diff --git a/Bundle.h b/Bundle.h index 6a1f2d5..a1bc241 100644 --- a/Bundle.h +++ b/Bundle.h @@ -45,7 +45,7 @@ public: mRClassDir(NULL), mResourceIntermediatesDir(NULL), mManifestMinSdkVersion(NULL), mMinSdkVersion(NULL), mTargetSdkVersion(NULL), mMaxSdkVersion(NULL), mVersionCode(NULL), mVersionName(NULL), mCustomPackage(NULL), - mMaxResVersion(NULL), + mMaxResVersion(NULL), mDebugMode(false), mArgc(0), mArgv(NULL) {} ~Bundle(void) {} @@ -137,6 +137,8 @@ public: void setCustomPackage(const char* val) { mCustomPackage = val; } const char* getMaxResVersion() const { return mMaxResVersion; } void setMaxResVersion(const char * val) { mMaxResVersion = val; } + bool getDebugMode() { return mDebugMode; } + void setDebugMode(bool val) { mDebugMode = val; } /* * Set and get the file specification. @@ -234,6 +236,7 @@ private: const char* mVersionName; const char* mCustomPackage; const char* mMaxResVersion; + bool mDebugMode; /* file specification */ int mArgc; diff --git a/Main.cpp b/Main.cpp index f457cc8..71c023d 100644 --- a/Main.cpp +++ b/Main.cpp @@ -57,7 +57,7 @@ void usage(void) fprintf(stderr, " %s p[ackage] [-d][-f][-m][-u][-v][-x][-z][-M AndroidManifest.xml] \\\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" " [--rename-manifest-package PACKAGE] \\\n" " [--rename-instrumentation-target-package PACKAGE] \\\n" @@ -124,6 +124,9 @@ void usage(void) " -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" " 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" " 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" @@ -392,7 +395,9 @@ int main(int argc, char* const argv[]) } break; 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--; argv++; if (!argc) { diff --git a/Resource.cpp b/Resource.cpp index bd84e23..9c5fcda 100644 --- a/Resource.cpp +++ b/Resource.cpp @@ -678,6 +678,13 @@ status_t massageManifest(Bundle* bundle, sp root) bundle->getMaxSdkVersion()); } + if (bundle->getDebugMode()) { + sp application = root->getChildElement(String16(), String16("application")); + if (application != NULL) { + addTagAttribute(application, RESOURCES_ANDROID_NAMESPACE, "debuggable", "true"); + } + } + // Deal with manifest package name overrides const char* manifestPackageNameOverride = bundle->getManifestPackageNameOverride(); if (manifestPackageNameOverride != NULL) {