]> git.saurik.com Git - android/aapt.git/blobdiff - Command.cpp
am f1871e27: Merge change 26009 into eclair
[android/aapt.git] / Command.cpp
index d8215e77ae889c3a781d54c5a7a1645be591123a..3019bd0f5e9e828dc8c68a961fcd9336044c8bdf 100644 (file)
@@ -233,7 +233,7 @@ static ssize_t indexOfAttribute(const ResXMLTree& tree, uint32_t attrRes)
     return -1;
 }
 
-static String8 getAttribute(const ResXMLTree& tree, const char* ns,
+String8 getAttribute(const ResXMLTree& tree, const char* ns,
                             const char* attr, String8* outError)
 {
     ssize_t idx = tree.indexOfAttribute(ns, attr);
@@ -332,9 +332,11 @@ enum {
     TARGET_SDK_VERSION_ATTR = 0x01010270,
     TEST_ONLY_ATTR = 0x01010272,
     DENSITY_ATTR = 0x0101026c,
+    GL_ES_VERSION_ATTR = 0x01010281,
     SMALL_SCREEN_ATTR = 0x01010284,
     NORMAL_SCREEN_ATTR = 0x01010285,
     LARGE_SCREEN_ATTR = 0x01010286,
+    REQUIRED_ATTR = 0x0101028e,
 };
 
 const char *getComponentName(String8 &pkgName, String8 &componentName) {
@@ -399,7 +401,7 @@ int doDump(Bundle* bundle)
             ResXMLTree tree;
             asset = assets.openNonAsset(resname, Asset::ACCESS_BUFFER);
             if (asset == NULL) {
-                fprintf(stderr, "ERROR: dump failed because resource %p found\n", resname);
+                fprintf(stderr, "ERROR: dump failed because resource %s found\n", resname);
                 goto bail;
             }
 
@@ -425,7 +427,7 @@ int doDump(Bundle* bundle)
             ResXMLTree tree;
             asset = assets.openNonAsset(resname, Asset::ACCESS_BUFFER);
             if (asset == NULL) {
-                fprintf(stderr, "ERROR: dump failed because resource %p found\n", resname);
+                fprintf(stderr, "ERROR: dump failed because resource %s found\n", resname);
                 goto bail;
             }
 
@@ -520,6 +522,8 @@ int doDump(Bundle* bundle)
             bool actWidgetReceivers = false;
             bool actImeService = false;
             bool actWallpaperService = false;
+            bool specCameraFeature = false;
+            bool hasCameraPermission = false;
             int targetSdk = 0;
             int smallScreen = 1;
             int normalScreen = 1;
@@ -706,6 +710,36 @@ int doDump(Bundle* bundle)
                                 NORMAL_SCREEN_ATTR, NULL, 1);
                         largeScreen = getIntegerAttribute(tree,
                                 LARGE_SCREEN_ATTR, NULL, 1);
+                    } else if (tag == "uses-feature") {
+                        String8 name = getAttribute(tree, NAME_ATTR, &error);
+
+                        if (name != "" && error == "") {
+                            int req = getIntegerAttribute(tree,
+                                    REQUIRED_ATTR, NULL, 1);
+                            if (name == "android.hardware.camera") {
+                                specCameraFeature = true;
+                            }
+                            printf("uses-feature%s:'%s'\n",
+                                    req ? "" : "-not-required", name.string());
+                        } else {
+                            int vers = getIntegerAttribute(tree,
+                                    GL_ES_VERSION_ATTR, &error);
+                            if (error == "") {
+                                printf("uses-gl-es:'0x%x'\n", vers);
+                            }
+                        }
+                    } else if (tag == "uses-permission") {
+                        String8 name = getAttribute(tree, NAME_ATTR, &error);
+                        if (name != "" && error == "") {
+                            if (name == "android.permission.CAMERA") {
+                                hasCameraPermission = true;
+                            }
+                            printf("uses-permission:'%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;
@@ -737,7 +771,10 @@ int doDump(Bundle* bundle)
                             fprintf(stderr, "ERROR getting 'android:name' attribute for uses-library: %s\n", error.string());
                             goto bail;
                         }
-                        printf("uses-library:'%s'\n", libraryName.string());
+                        int req = getIntegerAttribute(tree,
+                                REQUIRED_ATTR, NULL, 1);
+                        printf("uses-library%s:'%s'\n",
+                                req ? "" : "-not-required", libraryName.string());
                     } else if (tag == "receiver") {
                         withinReceiver = true;
                         receiverName = getAttribute(tree, NAME_ATTR, &error);
@@ -803,6 +840,15 @@ int doDump(Bundle* bundle)
                 }
             }
 
+            if (!specCameraFeature && hasCameraPermission) {
+                // For applications that have not explicitly stated their
+                // camera feature requirements, but have requested the camera
+                // permission, we are going to give them compatibility treatment
+                // of requiring the equivalent to original android devices.
+                printf("uses-feature:'android.hardware.camera'\n");
+                printf("uses-feature:'android.hardware.camera.autofocus'\n");
+            }
+            
             if (hasMainActivity) {
                 printf("main\n");
             }
@@ -1113,6 +1159,12 @@ int doPackage(Bundle* bundle)
         }
     }
 
+    // Write out the ProGuard file
+    err = writeProguardFile(bundle, assets);
+    if (err < 0) {
+        goto bail;
+    }
+
     // Write the apk
     if (outputAPKFile) {
         err = writeAPK(bundle, assets, String8(outputAPKFile));