Merge "Unrestricting app when put on power whitelist" into pi-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
e70e27ccea
@@ -545,7 +545,7 @@ public class ManageApplications extends InstrumentedFragment
|
||||
startAppInfoFragment(AppStorageSettings.class, R.string.storage_settings);
|
||||
break;
|
||||
case LIST_TYPE_HIGH_POWER:
|
||||
HighPowerDetail.show(this, mCurrentPkgName, INSTALLED_APP_DETAILS);
|
||||
HighPowerDetail.show(this, mCurrentUid, mCurrentPkgName, INSTALLED_APP_DETAILS);
|
||||
break;
|
||||
case LIST_TYPE_OVERLAY:
|
||||
startAppInfoFragment(DrawOverlayDetails.class, R.string.overlay_settings);
|
||||
|
@@ -17,6 +17,7 @@
|
||||
package com.android.settings.fuelgauge;
|
||||
|
||||
import android.app.AlertDialog;
|
||||
import android.app.AppOpsManager;
|
||||
import android.app.Dialog;
|
||||
import android.app.Fragment;
|
||||
import android.content.Context;
|
||||
@@ -43,12 +44,18 @@ public class HighPowerDetail extends InstrumentedDialogFragment implements OnCli
|
||||
|
||||
private static final String ARG_DEFAULT_ON = "default_on";
|
||||
|
||||
private final PowerWhitelistBackend mBackend = PowerWhitelistBackend.getInstance();
|
||||
|
||||
private String mPackageName;
|
||||
@VisibleForTesting
|
||||
PowerWhitelistBackend mBackend;
|
||||
@VisibleForTesting
|
||||
BatteryUtils mBatteryUtils;
|
||||
@VisibleForTesting
|
||||
String mPackageName;
|
||||
@VisibleForTesting
|
||||
int mPackageUid;
|
||||
private CharSequence mLabel;
|
||||
private boolean mDefaultOn;
|
||||
private boolean mIsEnabled;
|
||||
@VisibleForTesting
|
||||
boolean mIsEnabled;
|
||||
private Checkable mOptionOn;
|
||||
private Checkable mOptionOff;
|
||||
|
||||
@@ -60,8 +67,11 @@ public class HighPowerDetail extends InstrumentedDialogFragment implements OnCli
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
mBatteryUtils = BatteryUtils.getInstance(getContext());
|
||||
mBackend = PowerWhitelistBackend.getInstance();
|
||||
|
||||
mPackageName = getArguments().getString(AppInfoBase.ARG_PACKAGE_NAME);
|
||||
mPackageUid = getArguments().getInt(AppInfoBase.ARG_PACKAGE_UID);
|
||||
PackageManager pm = getContext().getPackageManager();
|
||||
try {
|
||||
mLabel = pm.getApplicationInfo(mPackageName, 0).loadLabel(pm);
|
||||
@@ -129,6 +139,8 @@ public class HighPowerDetail extends InstrumentedDialogFragment implements OnCli
|
||||
if (newValue != oldValue) {
|
||||
logSpecialPermissionChange(newValue, mPackageName, getContext());
|
||||
if (newValue) {
|
||||
mBatteryUtils.setForceAppStandby(mPackageUid, mPackageName,
|
||||
AppOpsManager.MODE_ALLOWED);
|
||||
mBackend.addApp(mPackageName);
|
||||
} else {
|
||||
mBackend.removeApp(mPackageName);
|
||||
@@ -165,10 +177,11 @@ public class HighPowerDetail extends InstrumentedDialogFragment implements OnCli
|
||||
: R.string.high_power_off);
|
||||
}
|
||||
|
||||
public static void show(Fragment caller, String packageName, int requestCode) {
|
||||
public static void show(Fragment caller, int uid, String packageName, int requestCode) {
|
||||
HighPowerDetail fragment = new HighPowerDetail();
|
||||
Bundle args = new Bundle();
|
||||
args.putString(AppInfoBase.ARG_PACKAGE_NAME, packageName);
|
||||
args.putInt(AppInfoBase.ARG_PACKAGE_UID, uid);
|
||||
fragment.setArguments(args);
|
||||
fragment.setTargetFragment(caller, requestCode);
|
||||
fragment.show(caller.getFragmentManager(), HighPowerDetail.class.getSimpleName());
|
||||
|
Reference in New Issue
Block a user