summaryrefslogtreecommitdiffstats
path: root/src/com/android/settings/applications/AppOpsDetails.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/android/settings/applications/AppOpsDetails.java')
-rw-r--r--src/com/android/settings/applications/AppOpsDetails.java98
1 files changed, 90 insertions, 8 deletions
diff --git a/src/com/android/settings/applications/AppOpsDetails.java b/src/com/android/settings/applications/AppOpsDetails.java
index a8320b1..12da8b8 100644
--- a/src/com/android/settings/applications/AppOpsDetails.java
+++ b/src/com/android/settings/applications/AppOpsDetails.java
@@ -33,9 +33,11 @@ import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
+import android.widget.AdapterView;
import android.widget.CompoundButton;
import android.widget.ImageView;
import android.widget.LinearLayout;
+import android.widget.Spinner;
import android.widget.Switch;
import android.widget.TextView;
@@ -60,13 +62,48 @@ public class AppOpsDetails extends InstrumentedFragment {
private View mRootView;
private LinearLayout mOperationsSection;
+ private final int MODE_ALLOWED = 0;
+ private final int MODE_IGNORED = 1;
+ private final int MODE_ASK = 2;
+
+ private int modeToPosition (int mode) {
+ switch(mode) {
+ case AppOpsManager.MODE_ALLOWED:
+ return MODE_ALLOWED;
+ case AppOpsManager.MODE_IGNORED:
+ return MODE_IGNORED;
+ case AppOpsManager.MODE_ASK:
+ return MODE_ASK;
+ };
+
+ return MODE_IGNORED;
+ }
+
+ private int positionToMode (int position) {
+ switch(position) {
+ case MODE_ALLOWED:
+ return AppOpsManager.MODE_ALLOWED;
+ case MODE_IGNORED:
+ return AppOpsManager.MODE_IGNORED;
+ case MODE_ASK:
+ return AppOpsManager.MODE_ASK;
+ };
+
+ return AppOpsManager.MODE_IGNORED;
+ }
+
+ private boolean isPlatformSigned() {
+ final int match = mPm.checkSignatures("android", mPackageInfo.packageName);
+ return match >= PackageManager.SIGNATURE_MATCH;
+ }
+
// Utility method to set application label and icon.
private void setAppLabelAndIcon(PackageInfo pkgInfo) {
final View appSnippet = mRootView.findViewById(R.id.app_snippet);
CharSequence label = mPm.getApplicationLabel(pkgInfo.applicationInfo);
Drawable icon = mPm.getApplicationIcon(pkgInfo.applicationInfo);
InstalledAppDetails.setupAppSnippet(appSnippet, label, icon,
- pkgInfo != null ? pkgInfo.versionName : null);
+ pkgInfo != null ? pkgInfo.versionName : null, null);
}
private String retrieveAppEntry() {
@@ -102,7 +139,15 @@ public class AppOpsDetails extends InstrumentedFragment {
mOperationsSection.removeAllViews();
String lastPermGroup = "";
+ boolean isPlatformSigned = isPlatformSigned();
for (AppOpsState.OpsTemplate tpl : AppOpsState.ALL_TEMPLATES) {
+ /* If we are platform signed, only show the root switch, this
+ * one is safe to toggle while other permission-based ones could
+ * certainly cause system-wide problems
+ */
+ if (isPlatformSigned && tpl != AppOpsState.SU_TEMPLATE) {
+ continue;
+ }
List<AppOpsState.AppOpEntry> entries = mState.buildState(tpl,
mPackageInfo.applicationInfo.uid, mPackageInfo.packageName);
for (final AppOpsState.AppOpEntry entry : entries) {
@@ -127,20 +172,57 @@ public class AppOpsDetails extends InstrumentedFragment {
}
((TextView)view.findViewById(R.id.op_name)).setText(
entry.getSwitchText(mState));
+ ((TextView)view.findViewById(R.id.op_counts)).setText(
+ entry.getCountsText(res));
((TextView)view.findViewById(R.id.op_time)).setText(
entry.getTimeText(res, true));
- Switch sw = (Switch)view.findViewById(R.id.switchWidget);
+
+ Spinner sp = (Spinner) view.findViewById(R.id.spinnerWidget);
+ sp.setVisibility(View.INVISIBLE);
+ Switch sw = (Switch) view.findViewById(R.id.switchWidget);
+ sw.setVisibility(View.INVISIBLE);
+
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() {
+ int mode = mAppOps.checkOp(switchOp, entry.getPackageOps().getUid(),
+ entry.getPackageOps().getPackageName());
+ sp.setSelection(modeToPosition(mode));
+ sp.setOnItemSelectedListener(new Spinner.OnItemSelectedListener() {
+ boolean firstMode = true;
+
@Override
- public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
+ public void onItemSelected(AdapterView<?> parentView, View selectedItemView,
+ int position, long id) {
+ if (firstMode) {
+ firstMode = false;
+ return;
+ }
mAppOps.setMode(switchOp, entry.getPackageOps().getUid(),
- entry.getPackageOps().getPackageName(), isChecked
- ? AppOpsManager.MODE_ALLOWED : AppOpsManager.MODE_IGNORED);
+ entry.getPackageOps().getPackageName(), positionToMode(position));
+ }
+
+ @Override
+ public void onNothingSelected(AdapterView<?> parentView) {
+ // Do nothing
}
});
+
+ sw.setChecked(mAppOps.checkOp(switchOp, entry.getPackageOps()
+ .getUid(), entry.getPackageOps().getPackageName()) == AppOpsManager.MODE_ALLOWED);
+ sw.setOnCheckedChangeListener(new Switch.OnCheckedChangeListener() {
+ public void onCheckedChanged(CompoundButton buttonView,
+ boolean isChecked) {
+ mAppOps.setMode(switchOp, entry.getPackageOps()
+ .getUid(), entry.getPackageOps()
+ .getPackageName(),
+ isChecked ? AppOpsManager.MODE_ALLOWED
+ : AppOpsManager.MODE_IGNORED);
+ }
+ });
+ if (AppOpsManager.isStrictOp(switchOp)) {
+ sp.setVisibility(View.VISIBLE);
+ } else {
+ sw.setVisibility(View.VISIBLE);
+ }
}
}