Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f6e2c19f authored by Lei Yu's avatar Lei Yu Committed by Android (Google) Code Review
Browse files

Merge "Fix bugs in auto restriction." into pi-dev

parents 10280a53 252d4e1f
Loading
Loading
Loading
Loading
+3 −6
Original line number Original line Diff line number Diff line
@@ -43,7 +43,6 @@ public class RestrictAppPreferenceController extends BasePreferenceController {
    @VisibleForTesting
    @VisibleForTesting
    List<AppInfo> mAppInfos;
    List<AppInfo> mAppInfos;
    private AppOpsManager mAppOpsManager;
    private AppOpsManager mAppOpsManager;
    private SettingsActivity mSettingsActivity;
    private InstrumentedPreferenceFragment mPreferenceFragment;
    private InstrumentedPreferenceFragment mPreferenceFragment;
    private UserManager mUserManager;
    private UserManager mUserManager;


@@ -53,10 +52,8 @@ public class RestrictAppPreferenceController extends BasePreferenceController {
        mUserManager = context.getSystemService(UserManager.class);
        mUserManager = context.getSystemService(UserManager.class);
    }
    }


    public RestrictAppPreferenceController(SettingsActivity settingsActivity,
    public RestrictAppPreferenceController(InstrumentedPreferenceFragment preferenceFragment) {
            InstrumentedPreferenceFragment preferenceFragment) {
        this(preferenceFragment.getContext());
        this(settingsActivity.getApplicationContext());
        mSettingsActivity = settingsActivity;
        mPreferenceFragment = preferenceFragment;
        mPreferenceFragment = preferenceFragment;
    }
    }


@@ -83,7 +80,7 @@ public class RestrictAppPreferenceController extends BasePreferenceController {
    public boolean handlePreferenceTreeClick(Preference preference) {
    public boolean handlePreferenceTreeClick(Preference preference) {
        if (getPreferenceKey().equals(preference.getKey())) {
        if (getPreferenceKey().equals(preference.getKey())) {
            // start fragment
            // start fragment
            RestrictedAppDetails.startRestrictedAppDetails(mSettingsActivity, mPreferenceFragment,
            RestrictedAppDetails.startRestrictedAppDetails(mPreferenceFragment,
                    mAppInfos);
                    mAppInfos);
            return true;
            return true;
        }
        }
+3 −3
Original line number Original line Diff line number Diff line
@@ -67,12 +67,12 @@ public class RestrictedAppDetails extends DashboardFragment {
    private final FooterPreferenceMixin mFooterPreferenceMixin =
    private final FooterPreferenceMixin mFooterPreferenceMixin =
            new FooterPreferenceMixin(this, getLifecycle());
            new FooterPreferenceMixin(this, getLifecycle());


    public static void startRestrictedAppDetails(SettingsActivity caller,
    public static void startRestrictedAppDetails(InstrumentedPreferenceFragment fragment,
            InstrumentedPreferenceFragment fragment, List<AppInfo> appInfos) {
            List<AppInfo> appInfos) {
        final Bundle args = new Bundle();
        final Bundle args = new Bundle();
        args.putParcelableList(EXTRA_APP_INFO_LIST, appInfos);
        args.putParcelableList(EXTRA_APP_INFO_LIST, appInfos);


        new SubSettingLauncher(caller)
        new SubSettingLauncher(fragment.getContext())
                .setDestination(RestrictedAppDetails.class.getName())
                .setDestination(RestrictedAppDetails.class.getName())
                .setArguments(args)
                .setArguments(args)
                .setTitle(R.string.restricted_app_title)
                .setTitle(R.string.restricted_app_title)
+1 −1
Original line number Original line Diff line number Diff line
@@ -71,7 +71,7 @@ public class SmartBatterySettings extends DashboardFragment {
        controllers.add(new SmartBatteryPreferenceController(context));
        controllers.add(new SmartBatteryPreferenceController(context));
        if (settingsActivity != null && fragment != null) {
        if (settingsActivity != null && fragment != null) {
            controllers.add(
            controllers.add(
                    new RestrictAppPreferenceController(settingsActivity, fragment));
                    new RestrictAppPreferenceController(fragment));
        } else {
        } else {
            controllers.add(new RestrictAppPreferenceController(context));
            controllers.add(new RestrictAppPreferenceController(context));
        }
        }
+1 −0
Original line number Original line Diff line number Diff line
@@ -100,6 +100,7 @@ public class AnomalyDetectionJobService extends JobService {
                    .getFactory(this).getPowerUsageFeatureProvider(this);
                    .getFactory(this).getPowerUsageFeatureProvider(this);
            final MetricsFeatureProvider metricsFeatureProvider = FeatureFactory
            final MetricsFeatureProvider metricsFeatureProvider = FeatureFactory
                    .getFactory(this).getMetricsFeatureProvider();
                    .getFactory(this).getMetricsFeatureProvider();
            batteryUtils.initBatteryStatsHelper(batteryStatsHelper, null /* bundle */, userManager);


            for (JobWorkItem item = params.dequeueWork(); item != null;
            for (JobWorkItem item = params.dequeueWork(); item != null;
                    item = params.dequeueWork()) {
                    item = params.dequeueWork()) {
+1 −2
Original line number Original line Diff line number Diff line
@@ -101,8 +101,7 @@ public class BatteryTipUtils {
                }
                }
            case BatteryTip.TipType.APP_RESTRICTION:
            case BatteryTip.TipType.APP_RESTRICTION:
                if (batteryTip.getState() == BatteryTip.StateType.HANDLED) {
                if (batteryTip.getState() == BatteryTip.StateType.HANDLED) {
                    return new OpenRestrictAppFragmentAction(settingsActivity, fragment,
                    return new OpenRestrictAppFragmentAction(fragment, (RestrictAppTip) batteryTip);
                            (RestrictAppTip) batteryTip);
                } else {
                } else {
                    return new RestrictAppAction(settingsActivity, (RestrictAppTip) batteryTip);
                    return new RestrictAppAction(settingsActivity, (RestrictAppTip) batteryTip);
                }
                }
Loading