Fix issue #21813831: Need API for asking to be added to power whitelist

When launching the battery whitelist for a particular app, we now
default to the app being asked to enable adding to the whitelist, and
dismissing the dialog will dismiss the entire whitelist UI.

You can now launch the whitelist without specifying an app to just
get the regular UI.

Change-Id: Idf3840b8a30febe71fbd600969c257d72809643f
This commit is contained in:
Dianne Hackborn
2015-06-12 18:13:54 -07:00
parent f4d7bd4f49
commit 3f98c0ce51
3 changed files with 36 additions and 6 deletions

View File

@@ -184,6 +184,7 @@ public class ManageApplications extends InstrumentedFragment
private String mCurrentPkgName;
private int mCurrentUid;
private boolean mFinishAfterDialog;
private Menu mOptionsMenu;
@@ -240,12 +241,13 @@ public class ManageApplications extends InstrumentedFragment
mListType = LIST_TYPE_HIGH_POWER;
// Default to showing system.
mShowSystem = true;
if (intent != null && Settings.ACTION_IGNORE_BATTERY_OPTIMIZATION_SETTINGS
.equals(intent.getAction())) {
if (Settings.ACTION_IGNORE_BATTERY_OPTIMIZATION_SETTINGS.equals(intent.getAction())
&& intent.getData() != null) {
mCurrentPkgName = intent.getData().getSchemeSpecificPart();
if (mCurrentPkgName != null) {
mCurrentUid = mApplicationsState.getEntry(mCurrentPkgName,
UserHandle.myUserId()).info.uid;
mFinishAfterDialog = true;
startApplicationDetailsActivity();
}
}
@@ -427,6 +429,12 @@ public class ManageApplications extends InstrumentedFragment
if (requestCode == INSTALLED_APP_DETAILS && mCurrentPkgName != null) {
if (mListType == LIST_TYPE_NOTIFICATION) {
mApplications.mExtraInfoBridge.forceUpdate(mCurrentPkgName, mCurrentUid);
} else if (mListType == LIST_TYPE_HIGH_POWER) {
if (mFinishAfterDialog) {
getActivity().onBackPressed();
} else {
mApplications.mExtraInfoBridge.forceUpdate(mCurrentPkgName, mCurrentUid);
}
} else {
mApplicationsState.requestSize(mCurrentPkgName, UserHandle.getUserId(mCurrentUid));
}
@@ -450,7 +458,8 @@ public class ManageApplications extends InstrumentedFragment
startAppInfoFragment(AppStorageSettings.class, R.string.storage_settings);
break;
case LIST_TYPE_HIGH_POWER:
HighPowerDetail.show(getActivity(), mCurrentPkgName);
HighPowerDetail.show(this, mCurrentPkgName, INSTALLED_APP_DETAILS,
mFinishAfterDialog);
break;
// TODO: Figure out if there is a way where we can spin up the profile's settings
// process ahead of time, to avoid a long load of data when user clicks on a managed app.