Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9abcba3c authored by Android (Google) Code Review's avatar Android (Google) Code Review
Browse files

Merge change 21764 into eclair

* changes:
  Add aapt extensions to dump badging to print more info about activities, receivers and services Fix issue with checking end tags. Earlier some boolean variables were being set once a new tag is detected at the same level which causes some incorrect values to be overwritten. we should be doing this when we detect the end tag.
parents 12c9561b 1b125980
Loading
Loading
Loading
Loading
+130 −62
Original line number Diff line number Diff line
@@ -503,8 +503,23 @@ int doDump(Bundle* bundle)
            bool withinActivity = false;
            bool isMainActivity = false;
            bool isLauncherActivity = false;
            bool isSearchable = false;
            bool withinApplication = false;
            bool withinReceiver = false;
            bool withinService = false;
            bool withinIntentFilter = false;
            bool hasMainActivity = false;
            bool hasOtherActivities = false;
            bool hasOtherReceivers = false;
            bool hasOtherServices = false;
            bool hasWallpaperService = false;
            bool hasImeService = false;
            bool hasWidgetReceivers = false;
            bool hasIntentFilter = false;
            bool actMainActivity = false;
            bool actWidgetReceivers = false;
            bool actImeService = false;
            bool actWallpaperService = false;
            int targetSdk = 0;
            int smallScreen = 1;
            int normalScreen = 1;
@@ -514,9 +529,48 @@ int doDump(Bundle* bundle)
            String8 activityLabel;
            String8 activityIcon;
            String8 receiverName;
            String8 serviceName;
            while ((code=tree.next()) != ResXMLTree::END_DOCUMENT && code != ResXMLTree::BAD_DOCUMENT) {
                if (code == ResXMLTree::END_TAG) {
                    depth--;
                    if (depth < 2) {
                        withinApplication = false;
                    } else if (depth < 3) {
                        if (withinActivity && isMainActivity && isLauncherActivity) {
                            const char *aName = getComponentName(pkg, activityName);
                            if (aName != NULL) {
                                printf("launchable activity name='%s'", aName);
                            }
                            printf("label='%s' icon='%s'\n",
                                    activityLabel.string(),
                                    activityIcon.string());
                        }
                        if (!hasIntentFilter) {
                            hasOtherActivities |= withinActivity;
                            hasOtherReceivers |= withinReceiver;
                            hasOtherServices |= withinService;
                        }
                        withinActivity = false;
                        withinService = false;
                        withinReceiver = false;
                        hasIntentFilter = false;
                        isMainActivity = isLauncherActivity = false;
                    } else if (depth < 4) {
                        if (withinIntentFilter) {
                            if (withinActivity) {
                                hasMainActivity |= actMainActivity;
                                hasOtherActivities |= !actMainActivity;
                            } else if (withinReceiver) {
                                hasWidgetReceivers |= actWidgetReceivers;
                                hasOtherReceivers |= !actWidgetReceivers;
                            } else if (withinService) {
                                hasImeService |= actImeService;
                                hasWallpaperService |= actWallpaperService;
                                hasOtherServices |= (!actImeService && !actWallpaperService);
                            }
                        }
                        withinIntentFilter = false;
                    }
                    continue;
                }
                if (code != ResXMLTree::START_TAG) {
@@ -524,7 +578,7 @@ int doDump(Bundle* bundle)
                }
                depth++;
                String8 tag(tree.getElementName(&len));
                //printf("Depth %d tag %s\n", depth, tag.string());
                //printf("Depth %d,  %s\n", depth, tag.string());
                if (depth == 1) {
                    if (tag != "manifest") {
                        fprintf(stderr, "ERROR: manifest does not start with <manifest> tag\n");
@@ -656,6 +710,8 @@ int doDump(Bundle* bundle)
                } else if (depth == 3 && withinApplication) {
                    withinActivity = false;
                    withinReceiver = false;
                    withinService = false;
                    hasIntentFilter = false;
                    if(tag == "activity") {
                        withinActivity = true;
                        activityName = getAttribute(tree, NAME_ATTR, &error);
@@ -690,74 +746,86 @@ int doDump(Bundle* bundle)
                            fprintf(stderr, "ERROR getting 'android:name' attribute for receiver: %s\n", error.string());
                            goto bail;
                        }
                    } else if (tag == "service") {
                        withinService = true;
                        serviceName = getAttribute(tree, NAME_ATTR, &error);

                        if (error != "") {
                            fprintf(stderr, "ERROR getting 'android:name' attribute for service: %s\n", error.string());
                            goto bail;
                        }
                    }
                } else if (depth == 5) {
                    if (withinActivity) {
                } else if ((depth == 4) && (tag == "intent-filter")) {
                    hasIntentFilter = true;
                    withinIntentFilter = true;
                    actMainActivity = actWidgetReceivers = actImeService = actWallpaperService = false;
                } else if ((depth == 5) && withinIntentFilter){
                    String8 action;
                    if (tag == "action") {
                            //printf("LOG: action tag\n");
                            String8 action = getAttribute(tree, NAME_ATTR, &error);
                        action = getAttribute(tree, NAME_ATTR, &error);
                        if (error != "") {
                            fprintf(stderr, "ERROR getting 'android:name' attribute: %s\n", error.string());
                            goto bail;
                        }
                        if (withinActivity) {
                            if (action == "android.intent.action.MAIN") {
                                isMainActivity = true;
                                //printf("LOG: isMainActivity==true\n");
                                actMainActivity = true;
                            }
                        } else if (withinReceiver) {
                            if (action == "android.appwidget.action.APPWIDGET_UPDATE") {
                                actWidgetReceivers = true;
                            }
                        } else if (tag == "category") {
                        } else if (withinService) {
                            if (action == "android.view.InputMethod") {
                                actImeService = true;
                            } else if (action == "android.service.wallpaper.WallpaperService") {
                                actWallpaperService = true;
                            }
                        }
                        if (action == "android.intent.action.SEARCH") {
                            isSearchable = true;
                        }
                    }

                    if (tag == "category") {
                        String8 category = getAttribute(tree, NAME_ATTR, &error);
                        if (error != "") {
                            fprintf(stderr, "ERROR getting 'name' attribute: %s\n", error.string());
                            goto bail;
                        }
                        if (withinActivity) {
                            if (category == "android.intent.category.LAUNCHER") {
                                isLauncherActivity = true;
                                //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 (hasMainActivity) {
                printf("main\n");
            }
            if (hasWidgetReceivers) {
                printf("app-widget\n");
            }
            if (hasImeService) {
                printf("ime\n");
            }

                if (depth < 2) {
                    withinApplication = false;
            if (hasWallpaperService) {
                printf("wallpaper\n");
            }
                if (depth < 3) {
                    //if (withinActivity) printf("LOG: withinActivity==false\n");
                    withinActivity = false;
                    withinReceiver = false;
            if (hasOtherActivities) {
                printf("other-activities\n");
            }

                if (depth < 5) {
                    //if (isMainActivity) printf("LOG: isMainActivity==false\n");
                    //if (isLauncherActivity) printf("LOG: isLauncherActivity==false\n");
                    isMainActivity = false;
                    isLauncherActivity = false;
            if (isSearchable) {
                printf("search\n");
            }

                if (withinActivity && isMainActivity && isLauncherActivity) {
                    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());
            if (hasOtherReceivers) {
                printf("other-receivers\n");
            }
            if (hasOtherServices) {
                printf("other-services\n");
            }

            // Determine default values for any unspecified screen sizes,