diff options
author | Dianne Hackborn <hackbod@google.com> | 2013-01-16 18:49:48 -0800 |
---|---|---|
committer | Dianne Hackborn <hackbod@google.com> | 2013-01-16 18:49:48 -0800 |
commit | 228df665d4c98e267dce3f529ab953046cd03e5b (patch) | |
tree | 4cb30f37a4a925da6cab041cf0c28dd5b7f344a8 /src/com/android/settings/applications | |
parent | a522a8ef8233382bbd39308b7d5f2e26eed44d22 (diff) | |
download | packages_apps_Settings-228df665d4c98e267dce3f529ab953046cd03e5b.zip packages_apps_Settings-228df665d4c98e267dce3f529ab953046cd03e5b.tar.gz packages_apps_Settings-228df665d4c98e267dce3f529ab953046cd03e5b.tar.bz2 |
Show all apps that can perform an op.
Change-Id: Ic4c6fdbc5b345c890a2f41a00b4b5c11272702d7
Diffstat (limited to 'src/com/android/settings/applications')
-rw-r--r-- | src/com/android/settings/applications/AppOpsCategory.java | 50 | ||||
-rw-r--r-- | src/com/android/settings/applications/AppOpsSummary.java | 18 |
2 files changed, 59 insertions, 9 deletions
diff --git a/src/com/android/settings/applications/AppOpsCategory.java b/src/com/android/settings/applications/AppOpsCategory.java index e9254f9..940ba0b 100644 --- a/src/com/android/settings/applications/AppOpsCategory.java +++ b/src/com/android/settings/applications/AppOpsCategory.java @@ -3,6 +3,7 @@ package com.android.settings.applications; import android.app.AppOpsManager; import android.app.ListFragment; import android.app.LoaderManager; +import android.app.AppOpsManager.OpEntry; import android.content.AsyncTaskLoader; import android.content.BroadcastReceiver; import android.content.Context; @@ -11,6 +12,7 @@ import android.content.IntentFilter; import android.content.Loader; import android.content.pm.ActivityInfo; import android.content.pm.ApplicationInfo; +import android.content.pm.PackageInfo; import android.content.pm.PackageManager; import android.content.res.Configuration; import android.content.res.Resources; @@ -112,9 +114,10 @@ public class AppOpsCategory extends ListFragment implements public AppOpsCategory() { } - public AppOpsCategory(int[] ops) { + public AppOpsCategory(int[] ops, String[] perms) { Bundle args = new Bundle(); args.putIntArray("ops", ops); + args.putStringArray("perms", perms); setArguments(args); } @@ -228,17 +231,19 @@ public class AppOpsCategory extends ListFragment implements final AppOpsManager mAppOps; final PackageManager mPm; final int[] mOps; + final String[] mPerms; final HashMap<String, AppEntry> mAppEntries = new HashMap<String, AppEntry>(); List<AppOpEntry> mApps; PackageIntentReceiver mPackageObserver; - public AppListLoader(Context context, int[] ops) { + public AppListLoader(Context context, int[] ops, String[] perms) { super(context); mAppOps = (AppOpsManager)context.getSystemService(Context.APP_OPS_SERVICE); mPm = context.getPackageManager(); mOps = ops; + mPerms = perms; } @Override public List<AppOpEntry> loadInBackground() { @@ -268,6 +273,26 @@ public class AppOpsCategory extends ListFragment implements } } + if (mPerms != null) { + List<PackageInfo> apps = mPm.getPackagesHoldingPermissions(mPerms, 0); + for (int i=0; i<apps.size(); i++) { + PackageInfo appInfo = apps.get(i); + AppEntry appEntry = mAppEntries.get(appInfo.packageName); + if (appEntry == null) { + appEntry = new AppEntry(this, appInfo.applicationInfo); + appEntry.loadLabel(context); + mAppEntries.put(appInfo.packageName, appEntry); + List<AppOpsManager.OpEntry> dummyOps = new ArrayList<AppOpsManager.OpEntry>(); + AppOpsManager.OpEntry opEntry = new AppOpsManager.OpEntry(0, 0, 0); + dummyOps.add(opEntry); + AppOpsManager.PackageOps pkgOps = new AppOpsManager.PackageOps( + appInfo.packageName, appInfo.applicationInfo.uid, dummyOps); + AppOpEntry entry = new AppOpEntry(pkgOps, opEntry, appEntry); + entries.add(entry); + } + } + } + // Sort the list. Collections.sort(entries, APP_OP_COMPARATOR); @@ -404,7 +429,7 @@ public class AppOpsCategory extends ListFragment implements CharSequence opTimeToString(AppOpsManager.OpEntry op) { if (op.isRunning()) { - return "Running"; + return mRunningStr; } return DateUtils.getRelativeTimeSpanString(op.getTime(), System.currentTimeMillis(), @@ -428,9 +453,14 @@ public class AppOpsCategory extends ListFragment implements ((ImageView)view.findViewById(R.id.app_icon)).setImageDrawable( item.getAppEntry().getIcon()); ((TextView)view.findViewById(R.id.app_name)).setText(item.getAppEntry().getLabel()); - ((TextView)view.findViewById(R.id.op_name)).setText( - mOpNames[item.getOpEntry().getOp()]); - ((TextView)view.findViewById(R.id.op_time)).setText(opTimeToString(item.getOpEntry())); + if (item.getOpEntry().getTime() != 0) { + ((TextView)view.findViewById(R.id.op_name)).setText( + mOpNames[item.getOpEntry().getOp()]); + ((TextView)view.findViewById(R.id.op_time)).setText(opTimeToString(item.getOpEntry())); + } else { + ((TextView)view.findViewById(R.id.op_name)).setText(""); + ((TextView)view.findViewById(R.id.op_time)).setText(""); + } return view; } @@ -465,7 +495,13 @@ public class AppOpsCategory extends ListFragment implements @Override public Loader<List<AppOpEntry>> onCreateLoader(int id, Bundle args) { Bundle fargs = getArguments(); - return new AppListLoader(getActivity(), fargs != null ? fargs.getIntArray("ops") : null); + int[] ops = null; + String[] perms = null; + if (fargs != null) { + ops = fargs.getIntArray("ops"); + perms = fargs.getStringArray("perms"); + } + return new AppListLoader(getActivity(), ops, perms); } @Override public void onLoadFinished(Loader<List<AppOpEntry>> loader, List<AppOpEntry> data) { diff --git a/src/com/android/settings/applications/AppOpsSummary.java b/src/com/android/settings/applications/AppOpsSummary.java index dd34679..4872fa5 100644 --- a/src/com/android/settings/applications/AppOpsSummary.java +++ b/src/com/android/settings/applications/AppOpsSummary.java @@ -26,7 +26,7 @@ public class AppOpsSummary extends Fragment { static int[][] sPageOps = new int[][] { // "Location" page. new int[] { AppOpsManager.OP_COARSE_LOCATION, AppOpsManager.OP_FINE_LOCATION, - AppOpsManager.OP_GPS}, + AppOpsManager.OP_GPS }, // "Personal" page. new int[] { AppOpsManager.OP_READ_CONTACTS, AppOpsManager.OP_WRITE_CONTACTS, @@ -35,6 +35,20 @@ public class AppOpsSummary extends Fragment { // "Device" page. new int[] { AppOpsManager.OP_VIBRATE }, }; + static String[][] sPagePerms = new String[][] { + // "Location" page. + new String[] { android.Manifest.permission.ACCESS_COARSE_LOCATION, + android.Manifest.permission.ACCESS_FINE_LOCATION }, + + // "Personal" page. + new String[] { android.Manifest.permission.READ_CONTACTS, + android.Manifest.permission.WRITE_CONTACTS, + android.Manifest.permission.READ_CALL_LOG, + android.Manifest.permission.WRITE_CALL_LOG }, + + // "Device" page. + new String[] { android.Manifest.permission.VIBRATE }, + }; int mCurPos; @@ -46,7 +60,7 @@ public class AppOpsSummary extends Fragment { @Override public Fragment getItem(int position) { - return new AppOpsCategory(sPageOps[position]); + return new AppOpsCategory(sPageOps[position], sPagePerms[position]); } @Override |