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

Commit 29d69ccf authored by Aaron Liu's avatar Aaron Liu Committed by Android (Google) Code Review
Browse files

Merge changes I7f8a0f11,Iea1d8b4a into main

* changes:
  Ensure that resetStateLocked is called
  Move binding back to constructor
parents 2e516479 d1575cbd
Loading
Loading
Loading
Loading
+28 −54
Original line number Diff line number Diff line
@@ -19,11 +19,6 @@ package com.android.systemui.keyguard.ui.composable.section
import android.content.Context
import android.view.ViewGroup
import androidx.compose.runtime.Composable
import androidx.compose.runtime.DisposableEffect
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
import com.android.compose.animation.scene.SceneScope
import com.android.systemui.dagger.SysUISingleton
@@ -45,7 +40,6 @@ import com.android.systemui.statusbar.notification.stack.ui.viewmodel.Notificati
import com.android.systemui.statusbar.notification.stack.ui.viewmodel.SharedNotificationContainerViewModel
import javax.inject.Inject
import kotlinx.coroutines.CoroutineDispatcher
import kotlinx.coroutines.DisposableHandle

@SysUISingleton
class NotificationSection
@@ -53,39 +47,31 @@ class NotificationSection
constructor(
    @Application private val context: Context,
    private val viewModel: NotificationsPlaceholderViewModel,
    private val controller: NotificationStackScrollLayoutController,
    private val sceneContainerFlags: SceneContainerFlags,
    private val sharedNotificationContainer: SharedNotificationContainer,
    private val sharedNotificationContainerViewModel: SharedNotificationContainerViewModel,
    private val stackScrollLayout: NotificationStackScrollLayout,
    private val notificationStackAppearanceViewModel: NotificationStackAppearanceViewModel,
    private val ambientState: AmbientState,
    private val notificationStackSizeCalculator: NotificationStackSizeCalculator,
    controller: NotificationStackScrollLayoutController,
    sceneContainerFlags: SceneContainerFlags,
    sharedNotificationContainer: SharedNotificationContainer,
    sharedNotificationContainerViewModel: SharedNotificationContainerViewModel,
    stackScrollLayout: NotificationStackScrollLayout,
    notificationStackAppearanceViewModel: NotificationStackAppearanceViewModel,
    ambientState: AmbientState,
    notificationStackSizeCalculator: NotificationStackSizeCalculator,
    @Main private val mainDispatcher: CoroutineDispatcher,
) {
    @Composable
    fun SceneScope.Notifications(modifier: Modifier = Modifier) {
        if (KeyguardShadeMigrationNssl.isUnexpectedlyInLegacyMode()) {

    init {
        if (!KeyguardShadeMigrationNssl.isUnexpectedlyInLegacyMode()) {
            // This scene container section moves the NSSL to the SharedNotificationContainer.
            // This also requires that SharedNotificationContainer gets moved to the
            // SceneWindowRootView by the SceneWindowRootViewBinder. Prior to Scene Container,
            // but when the KeyguardShadeMigrationNssl flag is enabled, NSSL is moved into this
            // container by the NotificationStackScrollLayoutSection.
            return
        }

        var isBound by remember { mutableStateOf(false) }

        DisposableEffect(Unit) {
            val disposableHandles: MutableList<DisposableHandle> = mutableListOf()

            // Ensure stackScrollLayout is a child of sharedNotificationContainer.

            if (stackScrollLayout.parent != sharedNotificationContainer) {
                (stackScrollLayout.parent as? ViewGroup)?.removeView(stackScrollLayout)
                sharedNotificationContainer.addNotificationStackScrollLayout(stackScrollLayout)
            }

            disposableHandles.add(
            SharedNotificationContainerBinder.bind(
                sharedNotificationContainer,
                sharedNotificationContainerViewModel,
@@ -94,10 +80,8 @@ constructor(
                notificationStackSizeCalculator,
                mainDispatcher,
            )
            )

            if (sceneContainerFlags.flexiNotifsEnabled()) {
                disposableHandles.add(
                NotificationStackAppearanceViewBinder.bind(
                    context,
                    sharedNotificationContainer,
@@ -105,22 +89,12 @@ constructor(
                    ambientState,
                    controller,
                )
                )
            }

            isBound = true

            onDispose {
                disposableHandles.forEach { it.dispose() }
                disposableHandles.clear()
                isBound = false
            }
        }

        if (!isBound) {
            return
    }

    @Composable
    fun SceneScope.Notifications(modifier: Modifier = Modifier) {
        NotificationStack(
            viewModel = viewModel,
            modifier = modifier,
+9 −8
Original line number Diff line number Diff line
@@ -689,17 +689,18 @@ public class KeyguardViewMediator implements CoreStartable, Dumpable,
                            } else {
                                resetStateLocked();
                            }
                        } else {
                            if (lastSimStateWasLocked && mShowing) {
                                if (DEBUG_SIM_STATES) {
                                    Log.d(TAG, "SIM moved to "
                                            + "NOT_READY/ABSENT/UNKNOWN when the previous state "
                                            + "was locked. Reset the state.");
                                }
                        if (simState == TelephonyManager.SIM_STATE_ABSENT) {
                            // MVNO SIMs can become transiently NOT_READY when switching networks,
                            // so we should only lock when they are ABSENT.
                            if (lastSimStateWasLocked) {
                                if (DEBUG_SIM_STATES) Log.d(TAG, "SIM moved to ABSENT when the "
                                        + "previous state was locked. Reset the state.");
                                resetStateLocked();
                            }
                            mSimWasLocked.append(slotId, false);
                        }

                        mSimWasLocked.append(slotId, false);
                    }
                    break;
                case TelephonyManager.SIM_STATE_PIN_REQUIRED: