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

Commit 37ce78c5 authored by Hawkwood Glazier's avatar Hawkwood Glazier Committed by Android (Google) Code Review
Browse files

Merge "Remove main thread assertion from some parts of LockscreenSmartspaceController" into main

parents 72cd9a53 92127de6
Loading
Loading
Loading
Loading
+5 −6
Original line number Diff line number Diff line
@@ -197,8 +197,7 @@ constructor(
                initiallySelectedSlotId =
                    bundle.getString(
                        KeyguardPreviewConstants.KEY_INITIALLY_SELECTED_SLOT_ID,
                    )
                        ?: KeyguardQuickAffordanceSlots.SLOT_ID_BOTTOM_START,
                    ) ?: KeyguardQuickAffordanceSlots.SLOT_ID_BOTTOM_START,
                shouldHighlightSelectedAffordance = shouldHighlightSelectedAffordance,
            )
        } else {
@@ -230,8 +229,7 @@ constructor(
            val previewContext =
                display?.let {
                    ContextThemeWrapper(context.createDisplayContext(it), context.getTheme())
                }
                    ?: context
                } ?: context

            val rootView = FrameLayout(previewContext)

@@ -318,8 +316,8 @@ constructor(
     */
    private fun setUpSmartspace(previewContext: Context, parentView: ViewGroup) {
        if (
            !lockscreenSmartspaceController.isEnabled() ||
                !lockscreenSmartspaceController.isDateWeatherDecoupled()
            !lockscreenSmartspaceController.isEnabled ||
                !lockscreenSmartspaceController.isDateWeatherDecoupled
        ) {
            return
        }
@@ -654,6 +652,7 @@ constructor(
            clockController.clock = clock
        }
    }

    private fun onClockChanged() {
        if (MigrateClocksToBlueprint.isEnabled) {
            return
+3 −3
Original line number Diff line number Diff line
@@ -35,7 +35,7 @@ constructor(
) : KeyguardSection() {
    override fun addViews(constraintLayout: ConstraintLayout) {
        if (!MigrateClocksToBlueprint.isEnabled) return
        if (smartspaceController.isEnabled()) return
        if (smartspaceController.isEnabled) return

        constraintLayout.findViewById<View?>(R.id.keyguard_slice_view)?.let {
            (it.parent as ViewGroup).removeView(it)
@@ -47,7 +47,7 @@ constructor(

    override fun applyConstraints(constraintSet: ConstraintSet) {
        if (!MigrateClocksToBlueprint.isEnabled) return
        if (smartspaceController.isEnabled()) return
        if (smartspaceController.isEnabled) return

        constraintSet.apply {
            connect(
@@ -82,7 +82,7 @@ constructor(

    override fun removeViews(constraintLayout: ConstraintLayout) {
        if (!MigrateClocksToBlueprint.isEnabled) return
        if (smartspaceController.isEnabled()) return
        if (smartspaceController.isEnabled) return

        constraintLayout.removeView(R.id.keyguard_slice_view)
    }
+2 −2
Original line number Diff line number Diff line
@@ -40,12 +40,12 @@ constructor(
    smartspaceInteractor: KeyguardSmartspaceInteractor,
) {
    /** Whether the smartspace section is available in the build. */
    val isSmartspaceEnabled: Boolean = smartspaceController.isEnabled()
    val isSmartspaceEnabled: Boolean = smartspaceController.isEnabled
    /** Whether the weather area is available in the build. */
    private val isWeatherEnabled: StateFlow<Boolean> = smartspaceInteractor.isWeatherEnabled

    /** Whether the data and weather areas are decoupled in the build. */
    val isDateWeatherDecoupled: Boolean = smartspaceController.isDateWeatherDecoupled()
    val isDateWeatherDecoupled: Boolean = smartspaceController.isDateWeatherDecoupled

    /** Whether the date area should be visible. */
    val isDateVisible: StateFlow<Boolean> =
+18 −24
Original line number Diff line number Diff line
@@ -305,24 +305,18 @@ constructor(
        dumpManager.registerDumpable(this)
    }

    fun isEnabled(): Boolean {
        execution.assertIsMainThread()

        return plugin != null
    }

    fun isDateWeatherDecoupled(): Boolean {
        execution.assertIsMainThread()
    val isEnabled: Boolean = plugin != null

        return datePlugin != null && weatherPlugin != null
    }
    val isDateWeatherDecoupled: Boolean = datePlugin != null && weatherPlugin != null

    fun isWeatherEnabled(): Boolean {
       execution.assertIsMainThread()
       val showWeather = secureSettings.getIntForUser(
    val isWeatherEnabled: Boolean
        get() {
            val showWeather =
                secureSettings.getIntForUser(
                    LOCK_SCREEN_WEATHER_ENABLED,
                    1,
           userTracker.userId) == 1
                    userTracker.userId,
                ) == 1
            return showWeather
        }

@@ -337,10 +331,10 @@ constructor(
    fun buildAndConnectDateView(parent: ViewGroup): View? {
        execution.assertIsMainThread()

        if (!isEnabled()) {
        if (!isEnabled) {
            throw RuntimeException("Cannot build view when not enabled")
        }
        if (!isDateWeatherDecoupled()) {
        if (!isDateWeatherDecoupled) {
            throw RuntimeException("Cannot build date view when not decoupled")
        }

@@ -361,10 +355,10 @@ constructor(
    fun buildAndConnectWeatherView(parent: ViewGroup): View? {
        execution.assertIsMainThread()

        if (!isEnabled()) {
        if (!isEnabled) {
            throw RuntimeException("Cannot build view when not enabled")
        }
        if (!isDateWeatherDecoupled()) {
        if (!isDateWeatherDecoupled) {
            throw RuntimeException("Cannot build weather view when not decoupled")
        }

@@ -385,7 +379,7 @@ constructor(
    fun buildAndConnectView(parent: ViewGroup): View? {
        execution.assertIsMainThread()

        if (!isEnabled()) {
        if (!isEnabled) {
            throw RuntimeException("Cannot build view when not enabled")
        }

@@ -577,7 +571,7 @@ constructor(
    }

    private fun filterSmartspaceTarget(t: SmartspaceTarget): Boolean {
        if (isDateWeatherDecoupled() && t.featureType == SmartspaceTarget.FEATURE_WEATHER) {
        if (isDateWeatherDecoupled && t.featureType == SmartspaceTarget.FEATURE_WEATHER) {
            return false
        }
        if (!showNotifications) {
+1 −1
Original line number Diff line number Diff line
@@ -42,7 +42,7 @@ class KeyguardBottomAreaViewController
    }

    override fun onViewAttached() {
        if (!smartspaceRelocateToBottom() || !smartspaceController.isEnabled()) {
        if (!smartspaceRelocateToBottom() || !smartspaceController.isEnabled) {
            return
        }