]> git.saurik.com Git - android/aapt.git/blobdiff - Command.cpp
Merge "Fix potential aapt crash when processing overlay."
[android/aapt.git] / Command.cpp
index db4ac974da0875dfe3169ddeb72643de7d15833a..537ae5e7716b00675f321789288daf8e3ca4e0ef 100644 (file)
@@ -412,6 +412,7 @@ int doDump(Bundle* bundle)
             }
             tree.restart();
             printXMLBlock(&tree);
             }
             tree.restart();
             printXMLBlock(&tree);
+            tree.uninit();
             delete asset;
             asset = NULL;
         }
             delete asset;
             asset = NULL;
         }
@@ -524,6 +525,8 @@ int doDump(Bundle* bundle)
             bool actWallpaperService = false;
             bool specCameraFeature = false;
             bool hasCameraPermission = false;
             bool actWallpaperService = false;
             bool specCameraFeature = false;
             bool hasCameraPermission = false;
+            bool specGpsFeature = false;
+            bool hasGpsPermission = false;
             int targetSdk = 0;
             int smallScreen = 1;
             int normalScreen = 1;
             int targetSdk = 0;
             int smallScreen = 1;
             int normalScreen = 1;
@@ -678,7 +681,7 @@ int doDump(Bundle* bundle)
                                 REQ_NAVIGATION_ATTR, NULL, 0);
                         int32_t reqFiveWayNav = getIntegerAttribute(tree,
                                 REQ_FIVE_WAY_NAV_ATTR, NULL, 0);
                                 REQ_NAVIGATION_ATTR, NULL, 0);
                         int32_t reqFiveWayNav = getIntegerAttribute(tree,
                                 REQ_FIVE_WAY_NAV_ATTR, NULL, 0);
-                        printf("uses-configuation:");
+                        printf("uses-configuration:");
                         if (reqTouchScreen != 0) {
                             printf(" reqTouchScreen='%d'", reqTouchScreen);
                         }
                         if (reqTouchScreen != 0) {
                             printf(" reqTouchScreen='%d'", reqTouchScreen);
                         }
@@ -712,11 +715,14 @@ int doDump(Bundle* bundle)
                                 LARGE_SCREEN_ATTR, NULL, 1);
                     } else if (tag == "uses-feature") {
                         String8 name = getAttribute(tree, NAME_ATTR, &error);
                                 LARGE_SCREEN_ATTR, NULL, 1);
                     } else if (tag == "uses-feature") {
                         String8 name = getAttribute(tree, NAME_ATTR, &error);
-                        if (error == "") {
+
+                        if (name != "" && error == "") {
                             int req = getIntegerAttribute(tree,
                                     REQUIRED_ATTR, NULL, 1);
                             if (name == "android.hardware.camera") {
                                 specCameraFeature = true;
                             int req = getIntegerAttribute(tree,
                                     REQUIRED_ATTR, NULL, 1);
                             if (name == "android.hardware.camera") {
                                 specCameraFeature = true;
+                            } else if (name == "android.hardware.location.gps") {
+                                specGpsFeature = true;
                             }
                             printf("uses-feature%s:'%s'\n",
                                     req ? "" : "-not-required", name.string());
                             }
                             printf("uses-feature%s:'%s'\n",
                                     req ? "" : "-not-required", name.string());
@@ -729,9 +735,11 @@ int doDump(Bundle* bundle)
                         }
                     } else if (tag == "uses-permission") {
                         String8 name = getAttribute(tree, NAME_ATTR, &error);
                         }
                     } else if (tag == "uses-permission") {
                         String8 name = getAttribute(tree, NAME_ATTR, &error);
-                        if (error == "") {
+                        if (name != "" && error == "") {
                             if (name == "android.permission.CAMERA") {
                                 hasCameraPermission = true;
                             if (name == "android.permission.CAMERA") {
                                 hasCameraPermission = true;
+                            } else if (name == "android.permission.ACCESS_FINE_LOCATION") {
+                                hasGpsPermission = true;
                             }
                             printf("uses-permission:'%s'\n", name.string());
                         } else {
                             }
                             printf("uses-permission:'%s'\n", name.string());
                         } else {
@@ -739,6 +747,15 @@ int doDump(Bundle* bundle)
                                     error.string());
                             goto bail;
                         }
                                     error.string());
                             goto bail;
                         }
+                    } else if (tag == "original-package") {
+                        String8 name = getAttribute(tree, NAME_ATTR, &error);
+                        if (name != "" && error == "") {
+                            printf("original-package:'%s'\n", name.string());
+                        } else {
+                            fprintf(stderr, "ERROR getting 'android:name' attribute: %s\n",
+                                    error.string());
+                                goto bail;
+                        }
                     }
                 } else if (depth == 3 && withinApplication) {
                     withinActivity = false;
                     }
                 } else if (depth == 3 && withinApplication) {
                     withinActivity = false;
@@ -847,7 +864,15 @@ int doDump(Bundle* bundle)
                 printf("uses-feature:'android.hardware.camera'\n");
                 printf("uses-feature:'android.hardware.camera.autofocus'\n");
             }
                 printf("uses-feature:'android.hardware.camera'\n");
                 printf("uses-feature:'android.hardware.camera.autofocus'\n");
             }
-            
+
+            if (!specGpsFeature && hasGpsPermission) {
+                // For applications that have not explicitly stated their
+                // GPS feature requirements, but have requested the "fine" (GPS)
+                // permission, we are going to give them compatibility treatment
+                // of requiring the equivalent to original android devices.
+                printf("uses-feature:'android.hardware.location.gps'\n");
+            }
+
             if (hasMainActivity) {
                 printf("main\n");
             }
             if (hasMainActivity) {
                 printf("main\n");
             }
@@ -996,8 +1021,15 @@ int doAdd(Bundle* bundle)
             printf(" '%s'... (from gzip)\n", fileName);
             result = zip->addGzip(fileName, String8(fileName).getBasePath().string(), NULL);
         } else {
             printf(" '%s'... (from gzip)\n", fileName);
             result = zip->addGzip(fileName, String8(fileName).getBasePath().string(), NULL);
         } else {
-            printf(" '%s'...\n", fileName);
-            result = zip->add(fileName, bundle->getCompressionMethod(), NULL);
+            if (bundle->getJunkPath()) {
+                String8 storageName = String8(fileName).getPathLeaf();
+                printf(" '%s' as '%s'...\n", fileName, storageName.string());
+                result = zip->add(fileName, storageName.string(),
+                                  bundle->getCompressionMethod(), NULL);
+            } else {
+                printf(" '%s'...\n", fileName);
+                result = zip->add(fileName, bundle->getCompressionMethod(), NULL);
+            }
         }
         if (result != NO_ERROR) {
             fprintf(stderr, "Unable to add '%s' to '%s'", bundle->getFileSpecEntry(i), zipFileName);
         }
         if (result != NO_ERROR) {
             fprintf(stderr, "Unable to add '%s' to '%s'", bundle->getFileSpecEntry(i), zipFileName);
@@ -1143,7 +1175,12 @@ int doPackage(Bundle* bundle)
 
     // Write out R.java constants
     if (assets->getPackage() == assets->getSymbolsPrivatePackage()) {
 
     // Write out R.java constants
     if (assets->getPackage() == assets->getSymbolsPrivatePackage()) {
-        err = writeResourceSymbols(bundle, assets, assets->getPackage(), true);
+        if (bundle->getCustomPackage() == NULL) {
+            err = writeResourceSymbols(bundle, assets, assets->getPackage(), true);
+        } else {
+            const String8 customPkg(bundle->getCustomPackage());
+            err = writeResourceSymbols(bundle, assets, customPkg, true);
+        }
         if (err < 0) {
             goto bail;
         }
         if (err < 0) {
             goto bail;
         }