summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDiogo Ferreira <defer@cyngn.com>2015-01-05 18:19:12 +0000
committerMichael Bestas <mikeioannina@gmail.com>2016-01-03 14:45:07 -0800
commit10bac9137eb2c7fe6f2a56c2f29bd2e6464e33b2 (patch)
tree35179f3c712234025dd25bbd4ff0ed3929475169
parent7822cf9f28703bc48ab257ffe31ef2e22ae11149 (diff)
downloadpackages_apps_Settings-10bac9137eb2c7fe6f2a56c2f29bd2e6464e33b2.zip
packages_apps_Settings-10bac9137eb2c7fe6f2a56c2f29bd2e6464e33b2.tar.gz
packages_apps_Settings-10bac9137eb2c7fe6f2a56c2f29bd2e6464e33b2.tar.bz2
privacyguard: Add Superuser summary
Adds superuser summary to the privacy guard "Advanced" menu, this is useful for auditing purposes. The tab is only visible when root for apps is enabled. Change-Id: I0b71c51d10e44e69102c311e526cdb1fde9bda26
-rw-r--r--src/com/android/settings/applications/AppOpsSummary.java35
1 files changed, 23 insertions, 12 deletions
diff --git a/src/com/android/settings/applications/AppOpsSummary.java b/src/com/android/settings/applications/AppOpsSummary.java
index 71af7f4..5d071cc 100644
--- a/src/com/android/settings/applications/AppOpsSummary.java
+++ b/src/com/android/settings/applications/AppOpsSummary.java
@@ -24,7 +24,6 @@ import android.app.FragmentManager;
import android.content.Context;
import android.content.DialogInterface;
import android.content.res.Resources;
-import android.content.res.TypedArray;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.PreferenceFrameLayout;
@@ -39,7 +38,11 @@ import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
+import java.util.ArrayList;
+import java.util.List;
+
import com.android.internal.logging.MetricsLogger;
+import com.android.settings.DevelopmentSettings;
import com.android.settings.InstrumentedFragment;
import com.android.settings.R;
@@ -57,13 +60,6 @@ public class AppOpsSummary extends InstrumentedFragment {
private SharedPreferences mPreferences;
CharSequence[] mPageNames;
- static AppOpsState.OpsTemplate[] sPageTemplates = new AppOpsState.OpsTemplate[] {
- AppOpsState.LOCATION_TEMPLATE,
- AppOpsState.PERSONAL_TEMPLATE,
- AppOpsState.MESSAGING_TEMPLATE,
- AppOpsState.MEDIA_TEMPLATE,
- AppOpsState.DEVICE_TEMPLATE
- };
int mCurPos;
@@ -73,19 +69,21 @@ public class AppOpsSummary extends InstrumentedFragment {
}
class MyPagerAdapter extends FragmentPagerAdapter implements ViewPager.OnPageChangeListener {
+ private AppOpsState.OpsTemplate[] mPageTemplates;
- public MyPagerAdapter(FragmentManager fm) {
+ public MyPagerAdapter(FragmentManager fm, AppOpsState.OpsTemplate[] templates) {
super(fm);
+ mPageTemplates = templates;
}
@Override
public Fragment getItem(int position) {
- return new AppOpsCategory(sPageTemplates[position]);
+ return new AppOpsCategory(mPageTemplates[position]);
}
@Override
public int getCount() {
- return sPageTemplates.length;
+ return mPageTemplates.length;
}
@Override
@@ -135,7 +133,8 @@ public class AppOpsSummary extends InstrumentedFragment {
mPageNames = getResources().getTextArray(R.array.app_ops_categories_cm);
mViewPager = (ViewPager) rootView.findViewById(R.id.pager);
- mAdapter = new MyPagerAdapter(getChildFragmentManager());
+ mAdapter = new MyPagerAdapter(getChildFragmentManager(),
+ filterTemplates(AppOpsState.ALL_TEMPLATES));
mViewPager.setAdapter(mAdapter);
mViewPager.setOnPageChangeListener(mAdapter);
PagerTabStrip tabs = (PagerTabStrip) rootView.findViewById(R.id.tabs);
@@ -157,6 +156,18 @@ public class AppOpsSummary extends InstrumentedFragment {
return rootView;
}
+ private AppOpsState.OpsTemplate[] filterTemplates(AppOpsState.OpsTemplate[] templates) {
+ List<AppOpsState.OpsTemplate> validTemplates = new ArrayList(templates.length);
+ for (AppOpsState.OpsTemplate template : templates) {
+ if (template == AppOpsState.SU_TEMPLATE
+ && !DevelopmentSettings.isRootForAppsEnabled()) {
+ continue;
+ }
+ validTemplates.add(template);
+ }
+ return validTemplates.toArray(new AppOpsState.OpsTemplate[0]);
+ }
+
private boolean shouldShowUserApps() {
return mPreferences.getBoolean("show_user_apps", true);
}