diff options
Diffstat (limited to 'tools/aapt/Command.cpp')
| -rw-r--r-- | tools/aapt/Command.cpp | 192 | 
1 files changed, 130 insertions, 62 deletions
diff --git a/tools/aapt/Command.cpp b/tools/aapt/Command.cpp index 76a5acdb4c6f..d8215e77ae88 100644 --- a/tools/aapt/Command.cpp +++ b/tools/aapt/Command.cpp @@ -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,76 +746,88 @@ 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) { -                        if (tag == "action") { -                            //printf("LOG: action tag\n"); -                            String8 action = getAttribute(tree, NAME_ATTR, &error); -                            if (error != "") { -                                fprintf(stderr, "ERROR getting 'android:name' attribute: %s\n", error.string()); -                                goto bail; -                            } +                } 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") { +                        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 (tag == "category") { -                            String8 category = getAttribute(tree, NAME_ATTR, &error); -                            if (error != "") { -                                fprintf(stderr, "ERROR getting 'name' attribute: %s\n", error.string()); -                                goto bail; +                        } else if (withinReceiver) { +                            if (action == "android.appwidget.action.APPWIDGET_UPDATE") { +                                actWidgetReceivers = true;                              } -                            if (category == "android.intent.category.LAUNCHER") { -                                isLauncherActivity = true; -                                //printf("LOG: isLauncherActivity==true\n"); +                        } else if (withinService) { +                            if (action == "android.view.InputMethod") { +                                actImeService = true; +                            } else if (action == "android.service.wallpaper.WallpaperService") { +                                actWallpaperService = true;                              }                          } -                    } 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 (action == "android.intent.action.SEARCH") { +                            isSearchable = true;                          }                      } -                } -                if (depth < 2) { -                    withinApplication = false; -                } -                if (depth < 3) { -                    //if (withinActivity) printf("LOG: withinActivity==false\n"); -                    withinActivity = false; -                    withinReceiver = false; -                } - -                if (depth < 5) { -                    //if (isMainActivity) printf("LOG: isMainActivity==false\n"); -                    //if (isLauncherActivity) printf("LOG: isLauncherActivity==false\n"); -                    isMainActivity = false; -                    isLauncherActivity = false; -                } - -                if (withinActivity && isMainActivity && isLauncherActivity) { -                    printf("launchable activity:"); -                    const char *aName = getComponentName(pkg, activityName); -                    if (aName != NULL) { -                        printf(" name='%s'", aName); +                    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("label='%s' icon='%s'\n", -                           activityLabel.string(), -                           activityIcon.string());                  }              } -             + +            if (hasMainActivity) { +                printf("main\n"); +            } +            if (hasWidgetReceivers) { +                printf("app-widget\n"); +            } +            if (hasImeService) { +                printf("ime\n"); +            } +            if (hasWallpaperService) { +                printf("wallpaper\n"); +            } +            if (hasOtherActivities) { +                printf("other-activities\n"); +            } +            if (isSearchable) { +                printf("search\n"); +            } +            if (hasOtherReceivers) { +                printf("other-receivers\n"); +            } +            if (hasOtherServices) { +                printf("other-services\n"); +            } +              // Determine default values for any unspecified screen sizes,              // based on the target SDK of the package.  As of 4 (donut)              // the screen size support was introduced, so all default to @@ -778,7 +846,7 @@ int doDump(Bundle* bundle)              if (normalScreen != 0) printf(" 'normal'");              if (largeScreen != 0) printf(" 'large'");              printf("\n"); -             +              printf("locales:");              Vector<String8> locales;              res.getLocales(&locales); @@ -791,7 +859,7 @@ int doDump(Bundle* bundle)                  printf(" '%s'", localeStr);              }              printf("\n"); -             +              Vector<ResTable_config> configs;              res.getConfigurations(&configs);              SortedVector<int> densities; @@ -801,14 +869,14 @@ int doDump(Bundle* bundle)                  if (dens == 0) dens = 160;                  densities.add(dens);              } -             +              printf("densities:");              const size_t ND = densities.size();              for (size_t i=0; i<ND; i++) {                  printf(" '%d'", densities[i]);              }              printf("\n"); -             +              AssetDir* dir = assets.openNonAssetDir(assetsCookie, "lib");              if (dir != NULL) {                  if (dir->getFileCount() > 0) {  |