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

Commit 885da59d authored by Julia Reynolds's avatar Julia Reynolds Committed by Automerger Merge Worker
Browse files

Merge "Allow DND screens on low ram devices" into rvc-qpr-dev am: 74c6c21b

Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Settings/+/12294001

Change-Id: I1e318a02298759aa95d71459508273d7985a2696
parents 08e0f190 74c6c21b
Loading
Loading
Loading
Loading
+1 −8
Original line number Diff line number Diff line
@@ -40,20 +40,13 @@ public class ZenAccessController extends BasePreferenceController {

    private static final String TAG = "ZenAccessController";

    private final ActivityManager mActivityManager;

    public ZenAccessController(Context context, String preferenceKey) {
        super(context, preferenceKey);
        mActivityManager = (ActivityManager) mContext.getSystemService(Context.ACTIVITY_SERVICE);
    }

    @Override
    public int getAvailabilityStatus() {
        return isSupported(mActivityManager) ? AVAILABLE : UNSUPPORTED_ON_DEVICE;
    }

    public static boolean isSupported(ActivityManager activityManager) {
        return !activityManager.isLowRamDevice();
        return AVAILABLE;
    }

    public static Set<String> getPackagesRequestingNotificationPolicyAccess() {
+0 −3
Original line number Diff line number Diff line
@@ -50,9 +50,6 @@ public class ZenAccessDetails extends AppInfoWithHeader implements
    @Override
    protected boolean refreshUi() {
        final Context context = getContext();
        if (!ZenAccessController.isSupported(context.getSystemService(ActivityManager.class))) {
            return false;
        }
        // If this app didn't declare this permission in their manifest, don't bother showing UI.
        final Set<String> needAccessApps =
                ZenAccessController.getPackagesRequestingNotificationPolicyAccess();
+0 −6
Original line number Diff line number Diff line
@@ -53,9 +53,6 @@ public class ZenAccessSettingObserverMixin extends ContentObserver implements Li

    @Override
    public void onStart() {
        if (!ZenAccessController.isSupported(mContext.getSystemService(ActivityManager.class))) {
            return;
        }
        mContext.getContentResolver().registerContentObserver(
                Settings.Secure.getUriFor(
                        Settings.Secure.ENABLED_NOTIFICATION_POLICY_ACCESS_PACKAGES),
@@ -69,9 +66,6 @@ public class ZenAccessSettingObserverMixin extends ContentObserver implements Li

    @Override
    public void onStop() {
        if (!ZenAccessController.isSupported(mContext.getSystemService(ActivityManager.class))) {
            return;
        }
        mContext.getContentResolver().unregisterContentObserver(this /* observer */);
    }
}
+0 −6
Original line number Diff line number Diff line
@@ -62,12 +62,6 @@ public class ZenAccessControllerTest {
        assertThat(mController.isAvailable()).isTrue();
    }

    @Test
    public void isAvailable_lowMemory_false() {
        mActivityManager.setIsLowRamDevice(true);
        assertThat(mController.isAvailable()).isFalse();
    }

    @Test
    public void logSpecialPermissionChange() {
        ZenAccessController.logSpecialPermissionChange(true, "app", mContext);
+1 −19
Original line number Diff line number Diff line
@@ -65,27 +65,13 @@ public class ZenAccessSettingObserverMixinTest {
    }

    @Test
    public void onStart_lowMemory_shouldNotRegisterListener() {
    public void onStart_shouldRegisterListener() {
        final ShadowActivityManager sam = Shadow.extract(
                mContext.getSystemService(ActivityManager.class));
        sam.setIsLowRamDevice(true);

        mLifecycle.handleLifecycleEvent(ON_START);

        mContext.getContentResolver().notifyChange(Settings.Secure.getUriFor(
                Settings.Secure.ENABLED_NOTIFICATION_POLICY_ACCESS_PACKAGES), null);

        verify(mListener, never()).onZenAccessPolicyChanged();
    }

    @Test
    public void onStart_highMemory_shouldRegisterListener() {
        final ShadowActivityManager sam = Shadow.extract(
                mContext.getSystemService(ActivityManager.class));
        sam.setIsLowRamDevice(false);

        mLifecycle.handleLifecycleEvent(ON_START);

        mContext.getContentResolver().notifyChange(Settings.Secure.getUriFor(
                Settings.Secure.ENABLED_NOTIFICATION_POLICY_ACCESS_PACKAGES), null);

@@ -94,10 +80,6 @@ public class ZenAccessSettingObserverMixinTest {

    @Test
    public void onStop_shouldUnregisterListener() {
        final ShadowActivityManager sam = Shadow.extract(
                mContext.getSystemService(ActivityManager.class));
        sam.setIsLowRamDevice(false);

        mLifecycle.handleLifecycleEvent(ON_START);
        mLifecycle.handleLifecycleEvent(ON_STOP);