summaryrefslogtreecommitdiffstats
path: root/src/com/android/settings/fuelgauge/PowerUsageDetail.java
diff options
context:
space:
mode:
authorDianne Hackborn <hackbod@google.com>2011-09-16 13:36:20 -0700
committerDianne Hackborn <hackbod@google.com>2011-09-16 13:36:20 -0700
commit5c2b48d4d52a2b6b3ae3c745e7016da390a4e1d7 (patch)
treed7d793514c8d931a66b9cfff39c6361b6ee746f4 /src/com/android/settings/fuelgauge/PowerUsageDetail.java
parentae226fffadc5029e8de73248cb58ea8baf3a228e (diff)
downloadpackages_apps_settings-5c2b48d4d52a2b6b3ae3c745e7016da390a4e1d7.zip
packages_apps_settings-5c2b48d4d52a2b6b3ae3c745e7016da390a4e1d7.tar.gz
packages_apps_settings-5c2b48d4d52a2b6b3ae3c745e7016da390a4e1d7.tar.bz2
Fix issue #5320747: Disabling an app that is an active device administrator...
...can lead to an unsecure device Now you can't disable device admins. Or clear their data. Or force stop them. Or uninstall them (though the package manager also prevents uninstalling, might as well disable this button along with everything else). Change-Id: I69eefc2342e6f932908e9f5b87d3a601752810a4
Diffstat (limited to 'src/com/android/settings/fuelgauge/PowerUsageDetail.java')
-rw-r--r--src/com/android/settings/fuelgauge/PowerUsageDetail.java22
1 files changed, 21 insertions, 1 deletions
diff --git a/src/com/android/settings/fuelgauge/PowerUsageDetail.java b/src/com/android/settings/fuelgauge/PowerUsageDetail.java
index e6552ce..79cbac6 100644
--- a/src/com/android/settings/fuelgauge/PowerUsageDetail.java
+++ b/src/com/android/settings/fuelgauge/PowerUsageDetail.java
@@ -20,6 +20,7 @@ import android.app.Activity;
import android.app.ActivityManager;
import android.app.ApplicationErrorReport;
import android.app.Fragment;
+import android.app.admin.DevicePolicyManager;
import android.content.BroadcastReceiver;
import android.content.ComponentName;
import android.content.Context;
@@ -102,7 +103,8 @@ public class PowerUsageDetail extends Fragment implements Button.OnClickListener
public static final String EXTRA_NO_COVERAGE = "noCoverage";
public static final String EXTRA_ICON_ID = "iconId"; // Int
- private static final boolean DEBUG = true;
+ private PackageManager mPm;
+ private DevicePolicyManager mDpm;
private String mTitle;
private int mUsageSince;
private int[] mTypes;
@@ -131,6 +133,8 @@ public class PowerUsageDetail extends Fragment implements Button.OnClickListener
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
+ mPm = getActivity().getPackageManager();
+ mDpm = (DevicePolicyManager)getActivity().getSystemService(Context.DEVICE_POLICY_SERVICE);
}
@Override
@@ -429,6 +433,22 @@ public class PowerUsageDetail extends Fragment implements Button.OnClickListener
mForceStopButton.setEnabled(false);
return;
}
+ for (int i = 0; i < mPackages.length; i++) {
+ if (mDpm.packageHasActiveAdmins(mPackages[i])) {
+ mForceStopButton.setEnabled(false);
+ return;
+ }
+ }
+ for (int i = 0; i < mPackages.length; i++) {
+ try {
+ ApplicationInfo info = mPm.getApplicationInfo(mPackages[i], 0);
+ if ((info.flags&ApplicationInfo.FLAG_STOPPED) == 0) {
+ mForceStopButton.setEnabled(true);
+ break;
+ }
+ } catch (PackageManager.NameNotFoundException e) {
+ }
+ }
Intent intent = new Intent(Intent.ACTION_QUERY_PACKAGE_RESTART,
Uri.fromParts("package", mPackages[0], null));
intent.putExtra(Intent.EXTRA_PACKAGES, mPackages);