Robert Craig avatar Robert Craig committed a42eb83

Expose AppOps management console.

Also included is a change to lock
the switches that control operations.
This simply gives the user some feedback
about locked operations.

Change-Id: I73adca92c6a497a6a18477de90a2fce3f60dd90d

Conflicts:
AndroidManifest.xml

Comments (0)

Files changed (4)

AndroidManifest.xml

             </intent-filter>
             <meta-data android:name="com.android.settings.FRAGMENT_CLASS"
                 android:value="com.android.settings.applications.AppOpsSummary" />
-            <!--
             <meta-data android:name="com.android.settings.TOP_LEVEL_HEADER_ID"
-                android:resource="@id/application_settings" /> -->
+                android:resource="@id/app_ops_settings" />
         </activity>
-        
+
         <activity android:name="Settings$LocationSettingsActivity"
                 android:label="@string/location_settings_title"
                 android:configChanges="orientation|keyboardHidden|screenSize"

res/xml/settings_headers.xml

         android:title="@string/user_settings_title"
         android:id="@+id/user_settings" />
 
+    <!-- App Ops -->
+    <header
+        android:fragment="com.android.settings.applications.AppOpsSummary"
+        android:icon="@drawable/ic_settings_applications"
+        android:title="@string/app_ops_settings"
+        android:id="@+id/app_ops_settings" />
+
     <!-- Manufacturer hook -->
     <header
         android:fragment="com.android.settings.WirelessSettings"

src/com/android/settings/applications/AppOpsDetails.java

 import android.content.pm.PermissionGroupInfo;
 import android.content.pm.PermissionInfo;
 import android.content.res.Resources;
+import android.graphics.Color;
 import android.os.Bundle;
 import android.preference.PreferenceActivity;
 import android.util.Log;
                 final int switchOp = AppOpsManager.opToSwitch(firstOp.getOp());
                 sw.setChecked(mAppOps.checkOp(switchOp, entry.getPackageOps().getUid(),
                         entry.getPackageOps().getPackageName()) == AppOpsManager.MODE_ALLOWED);
-                sw.setOnCheckedChangeListener(new Switch.OnCheckedChangeListener() {
-                    @Override
-                    public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
-                        mAppOps.setMode(switchOp, entry.getPackageOps().getUid(),
-                                entry.getPackageOps().getPackageName(), isChecked
-                                ? AppOpsManager.MODE_ALLOWED : AppOpsManager.MODE_IGNORED);
-                    }
-                });
+                // Lock switch if policy in place.
+                if (firstOp.getLocked()) {
+                    sw.setEnabled(false);
+                    TextView v = (TextView)view.findViewById(R.id.op_time);
+                    v.setText("(Locked)");
+                    v.setTextColor(Color.RED);
+                } else {
+                    sw.setOnCheckedChangeListener(new Switch.OnCheckedChangeListener() {
+                            @Override
+                            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
+                                mAppOps.setMode(switchOp, entry.getPackageOps().getUid(),
+                                                entry.getPackageOps().getPackageName(), isChecked
+                                                ? AppOpsManager.MODE_ALLOWED : AppOpsManager.MODE_IGNORED);
+                            }
+                        });
+                }
             }
         }
 

src/com/android/settings/applications/AppOpsState.java

 
                         }
                         AppOpsManager.OpEntry opEntry = new AppOpsManager.OpEntry(
-                                permOps.get(k), AppOpsManager.MODE_ALLOWED, 0, 0, 0);
+                                permOps.get(k), AppOpsManager.MODE_ALLOWED, 0, 0, 0, false);
                         dummyOps.add(opEntry);
                         addOp(entries, pkgOps, appEntry, opEntry, packageName == null,
                                 packageName == null ? 0 : opToOrder[opEntry.getOp()]);
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.