am f4d4440f
: am f7c184f0
: am 3f98c0ce
: Fix issue #21813831: Need API for asking to be added to power whitelist
* commit 'f4d4440fd4318a83ce83090a744171e336d6fd65': Fix issue #21813831: Need API for asking to be added to power whitelist
This commit is contained in:
@@ -956,6 +956,10 @@
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
<data android:scheme="package" />
|
||||
</intent-filter>
|
||||
<intent-filter android:priority="1">
|
||||
<action android:name="android.settings.IGNORE_BATTERY_OPTIMIZATION_SETTINGS" />
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
</intent-filter>
|
||||
<meta-data android:name="com.android.settings.FRAGMENT_CLASS"
|
||||
android:value="com.android.settings.applications.ManageApplications" />
|
||||
<meta-data android:name="com.android.settings.PRIMARY_PROFILE_CONTROLLED"
|
||||
|
@@ -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.
|
||||
|
@@ -20,6 +20,7 @@ import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
import android.app.Dialog;
|
||||
import android.app.DialogFragment;
|
||||
import android.app.Fragment;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.DialogInterface.OnClickListener;
|
||||
@@ -39,10 +40,13 @@ import com.android.settingslib.applications.ApplicationsState.AppEntry;
|
||||
|
||||
public class HighPowerDetail extends DialogFragment implements OnClickListener {
|
||||
|
||||
private static final String ARG_DEFAULT_ON = "default_on";
|
||||
|
||||
private final PowerWhitelistBackend mBackend = PowerWhitelistBackend.getInstance();
|
||||
|
||||
private String mPackageName;
|
||||
private CharSequence mLabel;
|
||||
private boolean mDefaultOn;
|
||||
private Adapter mAdapter;
|
||||
private int mSelectedIndex;
|
||||
|
||||
@@ -57,12 +61,13 @@ public class HighPowerDetail extends DialogFragment implements OnClickListener {
|
||||
} catch (NameNotFoundException e) {
|
||||
mLabel = mPackageName;
|
||||
}
|
||||
mDefaultOn = getArguments().getBoolean(ARG_DEFAULT_ON);
|
||||
mAdapter = new Adapter(getContext(), R.layout.radio_with_summary);
|
||||
mAdapter.add(new Pair<String, String>(getString(R.string.ignore_optimizations_on),
|
||||
getString(R.string.ignore_optimizations_on_desc)));
|
||||
mAdapter.add(new Pair<String, String>(getString(R.string.ignore_optimizations_off),
|
||||
getString(R.string.ignore_optimizations_off_desc)));
|
||||
mSelectedIndex = mBackend.isWhitelisted(mPackageName) ? 0 : 1;
|
||||
mSelectedIndex = mDefaultOn || mBackend.isWhitelisted(mPackageName) ? 0 : 1;
|
||||
if (mBackend.isSysWhitelisted(mPackageName)) {
|
||||
mAdapter.setEnabled(1, false);
|
||||
}
|
||||
@@ -97,6 +102,15 @@ public class HighPowerDetail extends DialogFragment implements OnClickListener {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDismiss(DialogInterface dialog) {
|
||||
super.onDismiss(dialog);
|
||||
Fragment target = getTargetFragment();
|
||||
if (target != null) {
|
||||
target.onActivityResult(getTargetRequestCode(), 0, null);
|
||||
}
|
||||
}
|
||||
|
||||
public static CharSequence getSummary(Context context, AppEntry entry) {
|
||||
return getSummary(context, entry.info.packageName);
|
||||
}
|
||||
@@ -106,12 +120,15 @@ public class HighPowerDetail extends DialogFragment implements OnClickListener {
|
||||
? R.string.high_power_on : R.string.high_power_off);
|
||||
}
|
||||
|
||||
public static void show(Activity activity, String packageName) {
|
||||
public static void show(Fragment caller, String packageName, int requestCode,
|
||||
boolean defaultToOn) {
|
||||
HighPowerDetail fragment = new HighPowerDetail();
|
||||
Bundle args = new Bundle();
|
||||
args.putString(AppInfoBase.ARG_PACKAGE_NAME, packageName);
|
||||
args.putBoolean(ARG_DEFAULT_ON, defaultToOn);
|
||||
fragment.setArguments(args);
|
||||
fragment.show(activity.getFragmentManager(), HighPowerDetail.class.getSimpleName());
|
||||
fragment.setTargetFragment(caller, requestCode);
|
||||
fragment.show(caller.getFragmentManager(), HighPowerDetail.class.getSimpleName());
|
||||
}
|
||||
|
||||
private class Adapter extends ArrayAdapter<Pair<String, String>> {
|
||||
|
Reference in New Issue
Block a user