Fix issue #2448075: aapt doesn't fix up activity-alias android:targetActivity links

And related:

- The aapt tool now sets a resource configurations sdk level to match any configs
  that have been set (for example if you specify density your sdk level will be
  at least 4).
- New option to modify the targetPackage attribute of instrumentation.
- Clean up of aapt options help.
- Fix of UI type values to leave 0 for "unspecified".
- Make the UI mode config APIs public.
diff --git a/tools/aapt/Command.cpp b/tools/aapt/Command.cpp
index ee07415..537ae5e 100644
--- a/tools/aapt/Command.cpp
+++ b/tools/aapt/Command.cpp
@@ -525,6 +525,8 @@
             bool actWallpaperService = false;
             bool specCameraFeature = false;
             bool hasCameraPermission = false;
+            bool specGpsFeature = false;
+            bool hasGpsPermission = false;
             int targetSdk = 0;
             int smallScreen = 1;
             int normalScreen = 1;
@@ -719,6 +721,8 @@
                                     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());
@@ -734,6 +738,8 @@
                         if (name != "" && error == "") {
                             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 {
@@ -859,6 +865,14 @@
                 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");
             }