diff --git a/res/values/arrays.xml b/res/values/arrays.xml index 6c463bf46b6..24d9dd00317 100644 --- a/res/values/arrays.xml +++ b/res/values/arrays.xml @@ -574,6 +574,8 @@ Write calendar Wi-Fi scan Post notification + Cell tower scan + Call phone diff --git a/res/values/strings.xml b/res/values/strings.xml index 0f127f28428..0652bfe1288 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -2702,7 +2702,7 @@ - App ops + Privacy Running diff --git a/src/com/android/settings/applications/AppOpsCategory.java b/src/com/android/settings/applications/AppOpsCategory.java index fa164abfa5d..7247ad38942 100644 --- a/src/com/android/settings/applications/AppOpsCategory.java +++ b/src/com/android/settings/applications/AppOpsCategory.java @@ -304,10 +304,16 @@ public class AppOpsCategory extends ListFragment implements // Start out with a progress indicator. setListShown(false); + } - // Prepare the loader. Either re-connect with an existing one, - // or start a new one. - getLoaderManager().initLoader(0, null, this); + @Override + public void onStart() { + super.onStart(); + + // Prepare the loader. We don't monitor for changes while stopped, + // so want to re-start the loader (retrieving a new data set) each + // time we start. + getLoaderManager().restartLoader(0, null, this); } // utility method used to start sub activity diff --git a/src/com/android/settings/applications/AppOpsDetails.java b/src/com/android/settings/applications/AppOpsDetails.java index 85eba0c5f5f..6bdd3bfebea 100644 --- a/src/com/android/settings/applications/AppOpsDetails.java +++ b/src/com/android/settings/applications/AppOpsDetails.java @@ -117,39 +117,41 @@ public class AppOpsDetails extends Fragment { List entries = mState.buildState(tpl, mPackageInfo.applicationInfo.uid, mPackageInfo.packageName); for (final AppOpsState.AppOpEntry entry : entries) { - for (int i=0; i CREATOR = new Creator() { @@ -94,7 +98,13 @@ public class AppOpsState { new int[] { AppOpsManager.OP_COARSE_LOCATION, AppOpsManager.OP_FINE_LOCATION, AppOpsManager.OP_GPS, - AppOpsManager.OP_WIFI_SCAN } + AppOpsManager.OP_WIFI_SCAN, + AppOpsManager.OP_NEIGHBORING_CELLS }, + new boolean[] { true, + true, + false, + false, + false } ); public static final OpsTemplate PERSONAL_TEMPLATE = new OpsTemplate( @@ -103,12 +113,22 @@ public class AppOpsState { AppOpsManager.OP_READ_CALL_LOG, AppOpsManager.OP_WRITE_CALL_LOG, AppOpsManager.OP_READ_CALENDAR, - AppOpsManager.OP_WRITE_CALENDAR } + AppOpsManager.OP_WRITE_CALENDAR }, + new boolean[] { true, + true, + true, + true, + true, + true } ); public static final OpsTemplate DEVICE_TEMPLATE = new OpsTemplate( new int[] { AppOpsManager.OP_VIBRATE, - AppOpsManager.OP_POST_NOTIFICATION } + AppOpsManager.OP_POST_NOTIFICATION, + AppOpsManager.OP_CALL_PHONE }, + new boolean[] { false, + false, + true } ); public static final OpsTemplate[] ALL_TEMPLATES = new OpsTemplate[] { @@ -124,6 +144,8 @@ public class AppOpsState { private final File mApkFile; private final SparseArray mOps = new SparseArray(); + private final SparseArray mOpSwitches + = new SparseArray(); private String mLabel; private Drawable mIcon; private boolean mMounted; @@ -134,14 +156,19 @@ public class AppOpsState { mApkFile = new File(info.sourceDir); } - public void addOp(AppOpsManager.OpEntry op) { + public void addOp(AppOpEntry entry, AppOpsManager.OpEntry op) { mOps.put(op.getOp(), op); + mOpSwitches.put(AppOpsManager.opToSwitch(op.getOp()), entry); } public boolean hasOp(int op) { return mOps.indexOfKey(op) >= 0; } + public AppOpEntry getOpSwitch(int op) { + return mOpSwitches.get(AppOpsManager.opToSwitch(op)); + } + public ApplicationInfo getApplicationInfo() { return mInfo; } @@ -199,32 +226,45 @@ public class AppOpsState { private final AppOpsManager.PackageOps mPkgOps; private final ArrayList mOps = new ArrayList(); + private final ArrayList mBriefOps + = new ArrayList(); private final AppEntry mApp; - public AppOpEntry(AppOpsManager.PackageOps pkg, AppOpsManager.OpEntry op, AppEntry app) { + public AppOpEntry(AppOpsManager.PackageOps pkg, AppOpsManager.OpEntry op, AppEntry app, + boolean brief) { mPkgOps = pkg; mApp = app; - mApp.addOp(op); + mApp.addOp(this, op); mOps.add(op); + if (brief) { + mBriefOps.add(op); + } } - public void addOp(AppOpsManager.OpEntry op) { - mApp.addOp(op); - for (int i=0; i list, AppOpsManager.OpEntry op) { + for (int i=0; i ops, + AppOpsState state) { + if (ops.size() == 1) { + return state.mOpNames[ops.get(0).getOp()]; } else { StringBuilder builder = new StringBuilder(); - for (int i=0; i 0) { builder.append(", "); } - builder.append(state.mOpNames[getOpEntry(i).getOp()]); + builder.append(state.mOpNames[ops.get(i).getOp()]); } return builder.toString(); } } + public CharSequence getLabelText(AppOpsState state) { + return getLabelText(mOps, state); + } + + public CharSequence getBriefLabelText(AppOpsState state) { + if (mBriefOps.size() > 0) { + return getLabelText(mBriefOps, state); + } else { + return getLabelText(mOps, state); + } + } + public CharSequence getTimeText(Resources res) { if (isRunning()) { return res.getText(R.string.app_ops_running); @@ -305,8 +358,8 @@ public class AppOpsState { }; private void addOp(List entries, AppOpsManager.PackageOps pkgOps, - AppEntry appEntry, AppOpsManager.OpEntry opEntry) { - if (entries.size() > 0) { + AppEntry appEntry, AppOpsManager.OpEntry opEntry, boolean brief, boolean allowMerge) { + if (allowMerge && entries.size() > 0) { AppOpEntry last = entries.get(entries.size()-1); if (last.getAppEntry() == appEntry) { boolean lastExe = last.getTime() != 0; @@ -314,12 +367,17 @@ public class AppOpsState { if (lastExe == entryExe) { if (DEBUG) Log.d(TAG, "Add op " + opEntry.getOp() + " to package " + pkgOps.getPackageName() + ": append to " + last); - last.addOp(opEntry); + last.addOp(opEntry, brief); return; } } } - AppOpEntry entry = new AppOpEntry(pkgOps, opEntry, appEntry); + AppOpEntry entry = appEntry.getOpSwitch(opEntry.getOp()); + if (entry != null) { + entry.addOp(opEntry, brief); + return; + } + entry = new AppOpEntry(pkgOps, opEntry, appEntry, brief); if (DEBUG) Log.d(TAG, "Add op " + opEntry.getOp() + " to package " + pkgOps.getPackageName() + ": making new " + entry); entries.add(entry); @@ -354,15 +412,19 @@ public class AppOpsState { final Context context = mContext; final HashMap appEntries = new HashMap(); - List entries = new ArrayList(); + final List entries = new ArrayList(); - ArrayList perms = new ArrayList(); - ArrayList permOps = new ArrayList(); + final ArrayList perms = new ArrayList(); + final ArrayList permOps = new ArrayList(); + final boolean[] brief = new boolean[AppOpsManager._NUM_OP]; for (int i=0; i