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

Commit 1809be44 authored by Android Build Coastguard Worker's avatar Android Build Coastguard Worker
Browse files

Merge cherrypicks of ['googleplex-android-review.googlesource.com/27918597',...

Merge cherrypicks of ['googleplex-android-review.googlesource.com/27918597', 'googleplex-android-review.googlesource.com/27881315'] into 24Q3-release.

Change-Id: I1ae1881b033915062901fa6b6148a9c4a02fce7b
parents 902f6c5b 60037348
Loading
Loading
Loading
Loading
+4 −5
Original line number Diff line number Diff line
@@ -21,16 +21,16 @@ import com.android.systemui.shared.settings.data.repository.SecureSettingsReposi
import kotlinx.coroutines.CoroutineDispatcher
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.SharingStarted
import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.flow.distinctUntilChanged
import kotlinx.coroutines.flow.flowOn
import kotlinx.coroutines.flow.map
import kotlinx.coroutines.flow.stateIn
import kotlinx.coroutines.withContext

/** Provides access to state related to notification settings. */
class NotificationSettingsRepository(
    scope: CoroutineScope,
    private val scope: CoroutineScope,
    private val backgroundDispatcher: CoroutineDispatcher,
    private val secureSettingsRepository: SecureSettingsRepository,
) {
@@ -41,16 +41,15 @@ class NotificationSettingsRepository(
            .distinctUntilChanged()

    /** The current state of the notification setting. */
    val isShowNotificationsOnLockScreenEnabled: StateFlow<Boolean> =
    suspend fun isShowNotificationsOnLockScreenEnabled(): StateFlow<Boolean> =
        secureSettingsRepository
            .intSetting(
                name = Settings.Secure.LOCK_SCREEN_SHOW_NOTIFICATIONS,
            )
            .map { it == 1 }
            .flowOn(backgroundDispatcher)
            .stateIn(
                scope = scope,
                started = SharingStarted.WhileSubscribed(),
                initialValue = false,
            )

    suspend fun setShowNotificationsOnLockscreenEnabled(enabled: Boolean) {
+3 −3
Original line number Diff line number Diff line
@@ -26,8 +26,8 @@ class NotificationSettingsInteractor(
    val isNotificationHistoryEnabled = repository.isNotificationHistoryEnabled

    /** Should notifications be visible on the lockscreen? */
    val isShowNotificationsOnLockScreenEnabled: StateFlow<Boolean> =
        repository.isShowNotificationsOnLockScreenEnabled
    suspend fun isShowNotificationsOnLockScreenEnabled(): StateFlow<Boolean> =
        repository.isShowNotificationsOnLockScreenEnabled()

    suspend fun setShowNotificationsOnLockscreenEnabled(enabled: Boolean) {
        repository.setShowNotificationsOnLockscreenEnabled(enabled)
@@ -35,7 +35,7 @@ class NotificationSettingsInteractor(

    /** Toggles the setting to show or hide notifications on the lock screen. */
    suspend fun toggleShowNotificationsOnLockscreenEnabled() {
        val current = repository.isShowNotificationsOnLockScreenEnabled.value
        val current = repository.isShowNotificationsOnLockScreenEnabled().value
        repository.setShowNotificationsOnLockscreenEnabled(!current)
    }
}
+2 −2
Original line number Diff line number Diff line
@@ -56,7 +56,7 @@ class NotificationSettingsRepositoryTest : SysuiTestCase() {
    @Test
    fun testGetIsShowNotificationsOnLockscreenEnabled() =
        testScope.runTest {
            val showNotifs by collectLastValue(underTest.isShowNotificationsOnLockScreenEnabled)
            val showNotifs by collectLastValue(underTest.isShowNotificationsOnLockScreenEnabled())

            secureSettingsRepository.setInt(
                name = Settings.Secure.LOCK_SCREEN_SHOW_NOTIFICATIONS,
@@ -74,7 +74,7 @@ class NotificationSettingsRepositoryTest : SysuiTestCase() {
    @Test
    fun testSetIsShowNotificationsOnLockscreenEnabled() =
        testScope.runTest {
            val showNotifs by collectLastValue(underTest.isShowNotificationsOnLockScreenEnabled)
            val showNotifs by collectLastValue(underTest.isShowNotificationsOnLockScreenEnabled())

            underTest.setShowNotificationsOnLockscreenEnabled(true)
            assertThat(showNotifs).isEqualTo(true)
+13 −1
Original line number Diff line number Diff line
@@ -252,7 +252,8 @@ class BackNavigationController {
                // skip if one of participant activity is translucent
                backType = BackNavigationInfo.TYPE_CALLBACK;
            } else if (prevActivities.size() > 0) {
                if (!isOccluded || isAllActivitiesCanShowWhenLocked(prevActivities)) {
                if ((!isOccluded || isAllActivitiesCanShowWhenLocked(prevActivities))
                        && isAllActivitiesCreated(prevActivities)) {
                    // We have another Activity in the same currentTask to go to
                    final WindowContainer parent = currentActivity.getParent();
                    final boolean canCustomize = parent != null
@@ -549,6 +550,17 @@ class BackNavigationController {
        return !prevActivities.isEmpty();
    }

    private static boolean isAllActivitiesCreated(
            @NonNull ArrayList<ActivityRecord> prevActivities) {
        for (int i = prevActivities.size() - 1; i >= 0; --i) {
            final ActivityRecord check = prevActivities.get(i);
            if (check.isState(ActivityRecord.State.INITIALIZING)) {
                return false;
            }
        }
        return !prevActivities.isEmpty();
    }

    boolean isMonitoringTransition() {
        return mAnimationHandler.mComposed || mNavigationMonitor.isMonitorForRemote();
    }
+3 −0
Original line number Diff line number Diff line
@@ -30,6 +30,7 @@ import static com.android.dx.mockito.inline.extended.ExtendedMockito.doReturn;
import static com.android.dx.mockito.inline.extended.ExtendedMockito.mockitoSession;
import static com.android.dx.mockito.inline.extended.ExtendedMockito.spyOn;
import static com.android.dx.mockito.inline.extended.ExtendedMockito.verify;
import static com.android.server.wm.ActivityRecord.State.STOPPED;

import static com.google.common.truth.Truth.assertThat;
import static com.google.common.truth.Truth.assertWithMessage;
@@ -245,6 +246,7 @@ public class BackNavigationControllerTests extends WindowTestsBase {
        assertTrue("Animation scheduled", backNavigationInfo.isPrepareRemoteAnimation());

        // reset drawing status
        testCase.recordBack.setState(STOPPED, "stopped");
        backNavigationInfo.onBackNavigationFinished(false);
        mBackNavigationController.clearBackAnimations();
        makeWindowVisibleAndDrawn(testCase.recordFront.findMainWindow());
@@ -937,6 +939,7 @@ public class BackNavigationControllerTests extends WindowTestsBase {
        testCase.recordFront = record2;
        testCase.windowBack = window1;
        testCase.windowFront = window2;
        record1.setState(STOPPED, "stopped");
        return testCase;
    }