Skip to content

Commit bd6abed

Browse files
Xavier DucrohetAndroid Code Review
authored andcommitted
Merge "Add a --debug-mode option to aapt."
2 parents 75a2ae9 + 8e9bfab commit bd6abed

File tree

3 files changed

+18
-2
lines changed

3 files changed

+18
-2
lines changed

tools/aapt/Bundle.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ class Bundle {
4545
mRClassDir(NULL), mResourceIntermediatesDir(NULL), mManifestMinSdkVersion(NULL),
4646
mMinSdkVersion(NULL), mTargetSdkVersion(NULL), mMaxSdkVersion(NULL),
4747
mVersionCode(NULL), mVersionName(NULL), mCustomPackage(NULL),
48+
mDebugMode(false),
4849
mArgc(0), mArgv(NULL)
4950
{}
5051
~Bundle(void) {}
@@ -134,6 +135,8 @@ class Bundle {
134135
void setVersionName(const char* val) { mVersionName = val; }
135136
const char* getCustomPackage() const { return mCustomPackage; }
136137
void setCustomPackage(const char* val) { mCustomPackage = val; }
138+
bool getDebugMode() { return mDebugMode; }
139+
void setDebugMode(bool val) { mDebugMode = val; }
137140

138141
/*
139142
* Set and get the file specification.
@@ -230,6 +233,7 @@ class Bundle {
230233
const char* mVersionCode;
231234
const char* mVersionName;
232235
const char* mCustomPackage;
236+
bool mDebugMode;
233237

234238
/* file specification */
235239
int mArgc;

tools/aapt/Main.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ void usage(void)
5757
fprintf(stderr,
5858
" %s p[ackage] [-d][-f][-m][-u][-v][-x][-z][-M AndroidManifest.xml] \\\n"
5959
" [-0 extension [-0 extension ...]] [-g tolerance] [-j jarfile] \\\n"
60-
" [--min-sdk-version VAL] [--target-sdk-version VAL] \\\n"
60+
" [--debug-mode] [--min-sdk-version VAL] [--target-sdk-version VAL] \\\n"
6161
" [--app-version VAL] [--app-version-name TEXT] [--custom-package VAL] \\\n"
6262
" [--rename-manifest-package PACKAGE] \\\n"
6363
" [--rename-instrumentation-target-package PACKAGE] \\\n"
@@ -123,6 +123,9 @@ void usage(void)
123123
" -0 specifies an additional extension for which such files will not\n"
124124
" be stored compressed in the .apk. An empty string means to not\n"
125125
" compress any files at all.\n"
126+
" --debug-mode\n"
127+
" inserts android:debuggable=\"true\" in to the application node of the\n"
128+
" manifest, making the application debuggable even on production devices.\n"
126129
" --min-sdk-version\n"
127130
" inserts android:minSdkVersion in to manifest. If the version is 7 or\n"
128131
" higher, the default encoding for resources will be in UTF-8.\n"
@@ -389,7 +392,9 @@ int main(int argc, char* const argv[])
389392
}
390393
break;
391394
case '-':
392-
if (strcmp(cp, "-min-sdk-version") == 0) {
395+
if (strcmp(cp, "-debug-mode") == 0) {
396+
bundle.setDebugMode(true);
397+
} else if (strcmp(cp, "-min-sdk-version") == 0) {
393398
argc--;
394399
argv++;
395400
if (!argc) {

tools/aapt/Resource.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -678,6 +678,13 @@ status_t massageManifest(Bundle* bundle, sp<XMLNode> root)
678678
bundle->getMaxSdkVersion());
679679
}
680680

681+
if (bundle->getDebugMode()) {
682+
sp<XMLNode> application = root->getChildElement(String16(), String16("application"));
683+
if (application != NULL) {
684+
addTagAttribute(application, RESOURCES_ANDROID_NAMESPACE, "debuggable", "true");
685+
}
686+
}
687+
681688
// Deal with manifest package name overrides
682689
const char* manifestPackageNameOverride = bundle->getManifestPackageNameOverride();
683690
if (manifestPackageNameOverride != NULL) {

0 commit comments

Comments
 (0)