Adding switch for Forced App Standby
Reusing the 'Background activity' switch found in App Info. The switch now needs to be shown for all apps and will toggle another app op RUN_ANY_IN_BACKGROUND which controls whether jobs or alarms are run for background apps. Also fixed handling of multiple packages with shared uid. The controller was picking the first package for uid but the order of packages can change on a reboot which would cause wrong app ops settings across packages of the same uid. Test: make -j32 RunSettingsRoboTests Bug: 65176793 Change-Id: I2a9b96bc02730776172c3ae317cb7f7f890bec30
This commit is contained in:
@@ -68,7 +68,8 @@ import java.util.List;
|
||||
public class AdvancedPowerUsageDetail extends DashboardFragment implements
|
||||
ButtonActionDialogFragment.AppButtonsDialogListener,
|
||||
AnomalyDialogFragment.AnomalyDialogListener,
|
||||
LoaderManager.LoaderCallbacks<List<Anomaly>> {
|
||||
LoaderManager.LoaderCallbacks<List<Anomaly>>,
|
||||
BackgroundActivityPreferenceController.WarningConfirmationListener {
|
||||
|
||||
public static final String TAG = "AdvancedPowerUsageDetail";
|
||||
public static final String EXTRA_UID = "extra_uid";
|
||||
@@ -109,6 +110,7 @@ public class AdvancedPowerUsageDetail extends DashboardFragment implements
|
||||
@VisibleForTesting
|
||||
AnomalySummaryPreferenceController mAnomalySummaryPreferenceController;
|
||||
private AppButtonsPreferenceController mAppButtonsPreferenceController;
|
||||
private BackgroundActivityPreferenceController mBackgroundActivityPreferenceController;
|
||||
|
||||
private DevicePolicyManagerWrapper mDpm;
|
||||
private UserManager mUserManager;
|
||||
@@ -319,7 +321,9 @@ public class AdvancedPowerUsageDetail extends DashboardFragment implements
|
||||
final int uid = bundle.getInt(EXTRA_UID, 0);
|
||||
final String packageName = bundle.getString(EXTRA_PACKAGE_NAME);
|
||||
|
||||
controllers.add(new BackgroundActivityPreferenceController(context, uid));
|
||||
mBackgroundActivityPreferenceController = new BackgroundActivityPreferenceController(
|
||||
context, this, uid, packageName);
|
||||
controllers.add(mBackgroundActivityPreferenceController);
|
||||
controllers.add(new BatteryOptimizationPreferenceController(
|
||||
(SettingsActivity) getActivity(), this, packageName));
|
||||
mAppButtonsPreferenceController = new AppButtonsPreferenceController(
|
||||
@@ -364,4 +368,10 @@ public class AdvancedPowerUsageDetail extends DashboardFragment implements
|
||||
public void onLoaderReset(Loader<List<Anomaly>> loader) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLimitBackgroundActivity() {
|
||||
mBackgroundActivityPreferenceController.setUnchecked(
|
||||
findPreference(mBackgroundActivityPreferenceController.getPreferenceKey()));
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user