Loading tools/aapt/Command.cpp +142 −69 Original line number Diff line number Diff line Loading @@ -318,8 +318,23 @@ enum { VERSION_NAME_ATTR = 0x0101021c, LABEL_ATTR = 0x01010001, ICON_ATTR = 0x01010002, MIN_SDK_VERSION_ATTR = 0x0101020c }; const char *getComponentName(String8 &pkgName, String8 &componentName) { ssize_t idx = componentName.find("."); String8 retStr(pkgName); if (idx == 0) { retStr += componentName; } else if (idx < 0) { retStr += "."; retStr += componentName; } else { return componentName.string(); } return retStr.string(); } /* * Handle the "dump" command, to extract select data from an archive. */ Loading Loading @@ -471,9 +486,13 @@ int doDump(Bundle* bundle) bool withinActivity = false; bool isMainActivity = false; bool isLauncherActivity = false; bool withinApplication = false; bool withinReceiver = false; String8 pkg; String8 activityName; String8 activityLabel; String8 activityIcon; String8 receiverName; while ((code=tree.next()) != ResXMLTree::END_DOCUMENT && code != ResXMLTree::BAD_DOCUMENT) { if (code == ResXMLTree::END_TAG) { depth--; Loading @@ -490,7 +509,7 @@ int doDump(Bundle* bundle) fprintf(stderr, "ERROR: manifest does not start with <manifest> tag\n"); goto bail; } String8 pkg = getAttribute(tree, NULL, "package", NULL); pkg = getAttribute(tree, NULL, "package", NULL); printf("package: name='%s' ", pkg.string()); int32_t versionCode = getIntegerAttribute(tree, VERSION_CODE_ATTR, &error); if (error != "") { Loading @@ -508,24 +527,37 @@ int doDump(Bundle* bundle) goto bail; } printf("versionName='%s'\n", versionName.string()); } else if (depth == 2 && tag == "application") { } else if (depth == 2) { withinApplication = false; if (tag == "application") { withinApplication = true; String8 label = getResolvedAttribute(&res, tree, LABEL_ATTR, &error); if (error != "") { fprintf(stderr, "ERROR getting 'android:label' attribute: %s\n", error.string()); goto bail; } printf("application: label='%s' ", label.string()); String8 icon = getResolvedAttribute(&res, tree, ICON_ATTR, &error); if (error != "") { fprintf(stderr, "ERROR getting 'android:icon' attribute: %s\n", error.string()); goto bail; } printf("icon='%s'\n", icon.string()); } else if (depth == 3 && tag == "activity") { } else if (tag == "uses-sdk") { int32_t sdkVersion = getIntegerAttribute(tree, MIN_SDK_VERSION_ATTR, &error); if (error != "") { fprintf(stderr, "ERROR getting 'android:minSdkVersion' attribute: %s\n", error.string()); goto bail; } if (sdkVersion != -1) { printf("sdkVersion:'%d'\n", sdkVersion); } } } else if (depth == 3 && withinApplication) { withinActivity = false; withinReceiver = false; if(tag == "activity") { withinActivity = true; //printf("LOG: withinActivity==true\n"); activityName = getAttribute(tree, NAME_ATTR, &error); if (error != "") { fprintf(stderr, "ERROR getting 'android:name' attribute: %s\n", error.string()); Loading @@ -543,7 +575,24 @@ int doDump(Bundle* bundle) fprintf(stderr, "ERROR getting 'android:icon' attribute: %s\n", error.string()); goto bail; } } else if (depth == 5 && withinActivity) { } else if (tag == "uses-library") { String8 libraryName = getAttribute(tree, NAME_ATTR, &error); if (error != "") { fprintf(stderr, "ERROR getting 'android:name' attribute for uses-library: %s\n", error.string()); goto bail; } printf("uses-library:'%s'\n", libraryName.string()); } else if (tag == "receiver") { withinReceiver = true; receiverName = getAttribute(tree, NAME_ATTR, &error); if (error != "") { fprintf(stderr, "ERROR getting 'android:name' attribute for receiver: %s\n", error.string()); goto bail; } } } else if (depth == 5) { if (withinActivity) { if (tag == "action") { //printf("LOG: action tag\n"); String8 action = getAttribute(tree, NAME_ATTR, &error); Loading @@ -566,11 +615,30 @@ int doDump(Bundle* bundle) //printf("LOG: isLauncherActivity==true\n"); } } } else if (withinReceiver) { if (tag == "action") { String8 action = getAttribute(tree, NAME_ATTR, &error); if (error != "") { fprintf(stderr, "ERROR getting 'android:name' attribute for receiver: %s\n", error.string()); goto bail; } if (action == "android.appwidget.action.APPWIDGET_UPDATE") { const char *rName = getComponentName(pkg, receiverName); if (rName != NULL) { printf("gadget-receiver:'%s/%s'\n", pkg.string(), rName); } } } } } if (depth < 2) { withinApplication = false; } if (depth < 3) { //if (withinActivity) printf("LOG: withinActivity==false\n"); withinActivity = false; withinReceiver = false; } if (depth < 5) { Loading @@ -581,8 +649,13 @@ int doDump(Bundle* bundle) } if (withinActivity && isMainActivity && isLauncherActivity) { printf("launchable activity: name='%s' label='%s' icon='%s'\n", activityName.string(), activityLabel.string(), printf("launchable activity:"); const char *aName = getComponentName(pkg, activityName); if (aName != NULL) { printf(" name='%s'", aName); } printf("label='%s' icon='%s'\n", activityLabel.string(), activityIcon.string()); } } Loading Loading
tools/aapt/Command.cpp +142 −69 Original line number Diff line number Diff line Loading @@ -318,8 +318,23 @@ enum { VERSION_NAME_ATTR = 0x0101021c, LABEL_ATTR = 0x01010001, ICON_ATTR = 0x01010002, MIN_SDK_VERSION_ATTR = 0x0101020c }; const char *getComponentName(String8 &pkgName, String8 &componentName) { ssize_t idx = componentName.find("."); String8 retStr(pkgName); if (idx == 0) { retStr += componentName; } else if (idx < 0) { retStr += "."; retStr += componentName; } else { return componentName.string(); } return retStr.string(); } /* * Handle the "dump" command, to extract select data from an archive. */ Loading Loading @@ -471,9 +486,13 @@ int doDump(Bundle* bundle) bool withinActivity = false; bool isMainActivity = false; bool isLauncherActivity = false; bool withinApplication = false; bool withinReceiver = false; String8 pkg; String8 activityName; String8 activityLabel; String8 activityIcon; String8 receiverName; while ((code=tree.next()) != ResXMLTree::END_DOCUMENT && code != ResXMLTree::BAD_DOCUMENT) { if (code == ResXMLTree::END_TAG) { depth--; Loading @@ -490,7 +509,7 @@ int doDump(Bundle* bundle) fprintf(stderr, "ERROR: manifest does not start with <manifest> tag\n"); goto bail; } String8 pkg = getAttribute(tree, NULL, "package", NULL); pkg = getAttribute(tree, NULL, "package", NULL); printf("package: name='%s' ", pkg.string()); int32_t versionCode = getIntegerAttribute(tree, VERSION_CODE_ATTR, &error); if (error != "") { Loading @@ -508,24 +527,37 @@ int doDump(Bundle* bundle) goto bail; } printf("versionName='%s'\n", versionName.string()); } else if (depth == 2 && tag == "application") { } else if (depth == 2) { withinApplication = false; if (tag == "application") { withinApplication = true; String8 label = getResolvedAttribute(&res, tree, LABEL_ATTR, &error); if (error != "") { fprintf(stderr, "ERROR getting 'android:label' attribute: %s\n", error.string()); goto bail; } printf("application: label='%s' ", label.string()); String8 icon = getResolvedAttribute(&res, tree, ICON_ATTR, &error); if (error != "") { fprintf(stderr, "ERROR getting 'android:icon' attribute: %s\n", error.string()); goto bail; } printf("icon='%s'\n", icon.string()); } else if (depth == 3 && tag == "activity") { } else if (tag == "uses-sdk") { int32_t sdkVersion = getIntegerAttribute(tree, MIN_SDK_VERSION_ATTR, &error); if (error != "") { fprintf(stderr, "ERROR getting 'android:minSdkVersion' attribute: %s\n", error.string()); goto bail; } if (sdkVersion != -1) { printf("sdkVersion:'%d'\n", sdkVersion); } } } else if (depth == 3 && withinApplication) { withinActivity = false; withinReceiver = false; if(tag == "activity") { withinActivity = true; //printf("LOG: withinActivity==true\n"); activityName = getAttribute(tree, NAME_ATTR, &error); if (error != "") { fprintf(stderr, "ERROR getting 'android:name' attribute: %s\n", error.string()); Loading @@ -543,7 +575,24 @@ int doDump(Bundle* bundle) fprintf(stderr, "ERROR getting 'android:icon' attribute: %s\n", error.string()); goto bail; } } else if (depth == 5 && withinActivity) { } else if (tag == "uses-library") { String8 libraryName = getAttribute(tree, NAME_ATTR, &error); if (error != "") { fprintf(stderr, "ERROR getting 'android:name' attribute for uses-library: %s\n", error.string()); goto bail; } printf("uses-library:'%s'\n", libraryName.string()); } else if (tag == "receiver") { withinReceiver = true; receiverName = getAttribute(tree, NAME_ATTR, &error); if (error != "") { fprintf(stderr, "ERROR getting 'android:name' attribute for receiver: %s\n", error.string()); goto bail; } } } else if (depth == 5) { if (withinActivity) { if (tag == "action") { //printf("LOG: action tag\n"); String8 action = getAttribute(tree, NAME_ATTR, &error); Loading @@ -566,11 +615,30 @@ int doDump(Bundle* bundle) //printf("LOG: isLauncherActivity==true\n"); } } } else if (withinReceiver) { if (tag == "action") { String8 action = getAttribute(tree, NAME_ATTR, &error); if (error != "") { fprintf(stderr, "ERROR getting 'android:name' attribute for receiver: %s\n", error.string()); goto bail; } if (action == "android.appwidget.action.APPWIDGET_UPDATE") { const char *rName = getComponentName(pkg, receiverName); if (rName != NULL) { printf("gadget-receiver:'%s/%s'\n", pkg.string(), rName); } } } } } if (depth < 2) { withinApplication = false; } if (depth < 3) { //if (withinActivity) printf("LOG: withinActivity==false\n"); withinActivity = false; withinReceiver = false; } if (depth < 5) { Loading @@ -581,8 +649,13 @@ int doDump(Bundle* bundle) } if (withinActivity && isMainActivity && isLauncherActivity) { printf("launchable activity: name='%s' label='%s' icon='%s'\n", activityName.string(), activityLabel.string(), printf("launchable activity:"); const char *aName = getComponentName(pkg, activityName); if (aName != NULL) { printf(" name='%s'", aName); } printf("label='%s' icon='%s'\n", activityLabel.string(), activityIcon.string()); } } Loading