Hide the optional permission stuff, not making it in to JB.

Also lock down the rest of the development tools permissions to
be development permissions that must be granted through an
explicit shell command.

Change-Id: I1ba216fffe1aab4bb9f83fcef108efc504f892f4
diff --git a/core/java/android/content/pm/PackageInfo.java b/core/java/android/content/pm/PackageInfo.java
index 415d58a..85f7aa5 100644
--- a/core/java/android/content/pm/PackageInfo.java
+++ b/core/java/android/content/pm/PackageInfo.java
@@ -154,7 +154,7 @@
     /**
      * Flag for {@link #requestedPermissionsFlags}: the requested permission
      * is required for the application to run; the user can not optionally
-     * disable it.
+     * disable it.  Currently all permissions are required.
      */
     public static final int REQUESTED_PERMISSION_REQUIRED = 1<<0;
 
diff --git a/core/java/android/content/pm/PackageParser.java b/core/java/android/content/pm/PackageParser.java
index 7ff9bfa..9bed8f0 100644
--- a/core/java/android/content/pm/PackageParser.java
+++ b/core/java/android/content/pm/PackageParser.java
@@ -989,14 +989,16 @@
                 // that may change.
                 String name = sa.getNonResourceString(
                         com.android.internal.R.styleable.AndroidManifestUsesPermission_name);
+                /* Not supporting optional permissions yet.
                 boolean required = sa.getBoolean(
                         com.android.internal.R.styleable.AndroidManifestUsesPermission_required, true);
+                */
 
                 sa.recycle();
 
                 if (name != null && !pkg.requestedPermissions.contains(name)) {
                     pkg.requestedPermissions.add(name.intern());
-                    pkg.requestedPermissionsRequired.add(required ? Boolean.TRUE : Boolean.FALSE);
+                    pkg.requestedPermissionsRequired.add(Boolean.TRUE);
                 }
 
                 XmlUtils.skipCurrentTag(parser);
diff --git a/core/java/android/widget/AppSecurityPermissions.java b/core/java/android/widget/AppSecurityPermissions.java
index e6184d5..b409e26 100755
--- a/core/java/android/widget/AppSecurityPermissions.java
+++ b/core/java/android/widget/AppSecurityPermissions.java
@@ -490,13 +490,7 @@
         // Development permissions are only shown to the user if they are already
         // granted to the app -- if we are installing an app and they are not
         // already granted, they will not be granted as part of the install.
-        // Note we also need the app to have specified this permission is not
-        // required -- this is not technically needed, but it helps various things
-        // if we ensure apps always mark development permissions as option, so that
-        // even not knowing what a permission is we can still know whether it will
-        // be granted to the app when it is installed.
         if ((existingReqFlags&PackageInfo.REQUESTED_PERMISSION_GRANTED) != 0
-                && (newReqFlags&PackageInfo.REQUESTED_PERMISSION_REQUIRED) == 0
                 && (pInfo.protectionLevel & PermissionInfo.PROTECTION_FLAG_DEVELOPMENT) != 0) {
             return true;
         }
diff --git a/core/res/AndroidManifest.xml b/core/res/AndroidManifest.xml
index 00faa41..3ee2377 100644
--- a/core/res/AndroidManifest.xml
+++ b/core/res/AndroidManifest.xml
@@ -1082,7 +1082,7 @@
     <!-- Configure an application for debugging. -->
     <permission android:name="android.permission.SET_DEBUG_APP"
         android:permissionGroup="android.permission-group.DEVELOPMENT_TOOLS"
-        android:protectionLevel="dangerous"
+        android:protectionLevel="signature|system|development"
         android:label="@string/permlab_setDebugApp"
         android:description="@string/permdesc_setDebugApp" />
 
@@ -1090,7 +1090,7 @@
          application processes that can be running. -->
     <permission android:name="android.permission.SET_PROCESS_LIMIT"
         android:permissionGroup="android.permission-group.DEVELOPMENT_TOOLS"
-        android:protectionLevel="dangerous"
+        android:protectionLevel="signature|system|development"
         android:label="@string/permlab_setProcessLimit"
         android:description="@string/permdesc_setProcessLimit" />
 
@@ -1098,14 +1098,14 @@
          finished when put in the background. -->
     <permission android:name="android.permission.SET_ALWAYS_FINISH"
         android:permissionGroup="android.permission-group.DEVELOPMENT_TOOLS"
-        android:protectionLevel="dangerous"
+        android:protectionLevel="signature|system|development"
         android:label="@string/permlab_setAlwaysFinish"
         android:description="@string/permdesc_setAlwaysFinish" />
 
     <!-- Allow an application to request that a signal be sent to all persistent processes -->
     <permission android:name="android.permission.SIGNAL_PERSISTENT_PROCESSES"
         android:permissionGroup="android.permission-group.DEVELOPMENT_TOOLS"
-        android:protectionLevel="dangerous"
+        android:protectionLevel="signature|system|development"
         android:label="@string/permlab_signalPersistentProcesses"
         android:description="@string/permdesc_signalPersistentProcesses" />
 
diff --git a/core/res/res/values/attrs_manifest.xml b/core/res/res/values/attrs_manifest.xml
index d414c7f..0ac2ad74 100644
--- a/core/res/res/values/attrs_manifest.xml
+++ b/core/res/res/values/attrs_manifest.xml
@@ -948,8 +948,9 @@
               permission, and it must always be granted when it is installed.
               If you set this to false, then in some cases the application may
               be installed with it being granted the permission, and it will
-              need to request the permission later if it needs it. -->
+              need to request the permission later if it needs it.
         <attr name="required" format="boolean" />
+        -->
     </declare-styleable>
 
     <!-- The <code>uses-configuration</code> tag specifies
@@ -992,7 +993,7 @@
               don't support it.  If you set this to false, then this will
               not impose a restriction on where the application can be
               installed. -->
-        <attr name="required" />
+        <attr name="required" format="boolean" />
     </declare-styleable>
 
     <!-- The <code>uses-sdk</code> tag describes the SDK features that the