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

Commit c41de7f0 authored by Treehugger Robot's avatar Treehugger Robot Committed by Automerger Merge Worker
Browse files

Merge "Query DeviceConfig flag for Notification WakeLocks" into udc-dev am: a8c33220

parents 3f0ebfcf a8c33220
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -118,6 +118,9 @@ public final class SystemUiDeviceConfigFlags {
     */
    public static final String NAS_DEFAULT_SERVICE = "nas_default_service";

    /** (boolean) Whether notify() calls to NMS should acquire and hold WakeLocks. */
    public static final String NOTIFY_WAKELOCK = "nms_notify_wakelock";

    // Flags related to media notifications

    /**
+4 −1
Original line number Diff line number Diff line
@@ -6597,7 +6597,10 @@ public class NotificationManagerService extends SystemService {
    }
    private PostNotificationTracker acquireWakeLockForPost(String pkg, int uid) {
        if (mFlagResolver.isEnabled(WAKE_LOCK_FOR_POSTING_NOTIFICATION)) {
        if (mFlagResolver.isEnabled(WAKE_LOCK_FOR_POSTING_NOTIFICATION)
                && Binder.withCleanCallingIdentity(
                    () -> DeviceConfig.getBoolean(DeviceConfig.NAMESPACE_SYSTEMUI,
                        SystemUiDeviceConfigFlags.NOTIFY_WAKELOCK, false))) {
            // The package probably doesn't have WAKE_LOCK permission and should not require it.
            return Binder.withCleanCallingIdentity(() -> {
                WakeLock wakeLock = mPowerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK,
+19 −1
Original line number Diff line number Diff line
@@ -587,6 +587,8 @@ public class NotificationManagerServiceTest extends UiServiceTestCase {
                    return wl;
                });
        mTestFlagResolver.setFlagOverride(WAKE_LOCK_FOR_POSTING_NOTIFICATION, true);
        DeviceConfig.setProperty(DeviceConfig.NAMESPACE_SYSTEMUI,
                SystemUiDeviceConfigFlags.NOTIFY_WAKELOCK, "true", false);
        // apps allowed as convos
        mService.setStringArrayResourceValue(PKG_O);
@@ -1929,8 +1931,24 @@ public class NotificationManagerServiceTest extends UiServiceTestCase {
    }
    @Test
    public void enqueueNotification_wakeLockFlagOff_noWakeLock() throws Exception {
    public void enqueueNotification_wakeLockSystemPropertyOff_noWakeLock() throws Exception {
        mTestFlagResolver.setFlagOverride(WAKE_LOCK_FOR_POSTING_NOTIFICATION, false);
        DeviceConfig.setProperty(DeviceConfig.NAMESPACE_SYSTEMUI,
                SystemUiDeviceConfigFlags.NOTIFY_WAKELOCK, "true", false);
        mBinderService.enqueueNotificationWithTag(PKG, PKG,
                "enqueueNotification_setsWakeLockWorkSource", 0,
                generateNotificationRecord(null).getNotification(), 0);
        waitForIdle();
        verifyZeroInteractions(mPowerManager);
    }
    @Test
    public void enqueueNotification_wakeLockDeviceConfigOff_noWakeLock() throws Exception {
        mTestFlagResolver.setFlagOverride(WAKE_LOCK_FOR_POSTING_NOTIFICATION, true);
        DeviceConfig.setProperty(DeviceConfig.NAMESPACE_SYSTEMUI,
                SystemUiDeviceConfigFlags.NOTIFY_WAKELOCK, "false", false);
        mBinderService.enqueueNotificationWithTag(PKG, PKG,
                "enqueueNotification_setsWakeLockWorkSource", 0,