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

Commit 2fff589c authored by Caitlin Shkuratov's avatar Caitlin Shkuratov
Browse files

[SB][Flexi] Add status bar to lockscreen in flexiglass.

Importantly: Right now, NPVC passes a lot of different bits of
information to the keyguard status bar view. However in flexiglass, NPVC
does not exist. So, there's a lot of future work in having keyguard
status bar view fetch those bits of information without NPVC. This CL
is just a starting point :)

Notable bugs so far:
 - The status bar is visible on AOD when it should be hidden.
 - If you unplug then replug the device, the status bar on keyguard is
   no longer shown. (I think this is related to the battery charging
   animation.)

 Note on constraining the height:
 In flexiglass, KeyguardStatusBarView is detached & re-attached, so we
need to ensure the height is constrained in the constraint set so the
height is re-set each time it's re-attached. (In the old system, the
view was never detached, so the height didn't need to be re-set.)

Bug: 296122465
Test: enable flexiglass -> verify status bar with real icons appears on
lockscreen
Test: disable flexiglass -> verify status bar on lockscreen still works
Test: enable flexiglass. On lockscreen, open then close the shade ->
verify status bar is still visible after closing the shade
Test: atest KeyguardStatusBarViewControllerTest

Change-Id: Ie45f00834e9ff7fb8d2d3e8307ccb7818cac32e4
parent b34d07fa
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -29,6 +29,7 @@ import com.android.systemui.keyguard.ui.view.layout.sections.DefaultLockIconSect
import com.android.systemui.keyguard.ui.view.layout.sections.DefaultNotificationStackScrollLayoutSection
import com.android.systemui.keyguard.ui.view.layout.sections.DefaultSettingsPopupMenuSection
import com.android.systemui.keyguard.ui.view.layout.sections.DefaultShortcutsSection
import com.android.systemui.keyguard.ui.view.layout.sections.DefaultStatusBarSection
import com.android.systemui.keyguard.ui.view.layout.sections.DefaultStatusViewSection
import com.android.systemui.keyguard.ui.view.layout.sections.SplitShadeGuidelines
import javax.inject.Inject
@@ -49,6 +50,7 @@ constructor(
    defaultAmbientIndicationAreaSection: DefaultAmbientIndicationAreaSection,
    defaultSettingsPopupMenuSection: DefaultSettingsPopupMenuSection,
    defaultStatusViewSection: DefaultStatusViewSection,
    defaultStatusBarSection: DefaultStatusBarSection,
    defaultNotificationStackScrollLayoutSection: DefaultNotificationStackScrollLayoutSection,
    splitShadeGuidelines: SplitShadeGuidelines,
    aodNotificationIconsSection: AodNotificationIconsSection,
@@ -64,6 +66,7 @@ constructor(
            defaultAmbientIndicationAreaSection,
            defaultSettingsPopupMenuSection,
            defaultStatusViewSection,
            defaultStatusBarSection,
            defaultNotificationStackScrollLayoutSection,
            splitShadeGuidelines,
            aodNotificationIconsSection,
+3 −0
Original line number Diff line number Diff line
@@ -26,6 +26,7 @@ import com.android.systemui.keyguard.ui.view.layout.sections.DefaultIndicationAr
import com.android.systemui.keyguard.ui.view.layout.sections.DefaultLockIconSection
import com.android.systemui.keyguard.ui.view.layout.sections.DefaultNotificationStackScrollLayoutSection
import com.android.systemui.keyguard.ui.view.layout.sections.DefaultSettingsPopupMenuSection
import com.android.systemui.keyguard.ui.view.layout.sections.DefaultStatusBarSection
import com.android.systemui.keyguard.ui.view.layout.sections.DefaultStatusViewSection
import com.android.systemui.keyguard.ui.view.layout.sections.SplitShadeGuidelines
import javax.inject.Inject
@@ -41,6 +42,7 @@ constructor(
    defaultSettingsPopupMenuSection: DefaultSettingsPopupMenuSection,
    alignShortcutsToUdfpsSection: AlignShortcutsToUdfpsSection,
    defaultStatusViewSection: DefaultStatusViewSection,
    defaultStatusBarSection: DefaultStatusBarSection,
    splitShadeGuidelines: SplitShadeGuidelines,
    defaultNotificationStackScrollLayoutSection: DefaultNotificationStackScrollLayoutSection,
    aodNotificationIconsSection: AodNotificationIconsSection,
@@ -55,6 +57,7 @@ constructor(
            defaultSettingsPopupMenuSection,
            alignShortcutsToUdfpsSection,
            defaultStatusViewSection,
            defaultStatusBarSection,
            defaultNotificationStackScrollLayoutSection,
            splitShadeGuidelines,
            aodNotificationIconsSection,
+103 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2023 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.android.systemui.keyguard.ui.view.layout.sections

import android.content.Context
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.constraintlayout.widget.ConstraintLayout
import androidx.constraintlayout.widget.ConstraintSet
import androidx.constraintlayout.widget.ConstraintSet.END
import androidx.constraintlayout.widget.ConstraintSet.PARENT_ID
import androidx.constraintlayout.widget.ConstraintSet.START
import androidx.constraintlayout.widget.ConstraintSet.TOP
import com.android.keyguard.dagger.KeyguardStatusBarViewComponent
import com.android.systemui.R
import com.android.systemui.flags.FeatureFlags
import com.android.systemui.flags.Flags
import com.android.systemui.keyguard.shared.model.KeyguardSection
import com.android.systemui.shade.NotificationPanelView
import com.android.systemui.shade.ShadeViewStateProvider
import com.android.systemui.statusbar.phone.KeyguardStatusBarView
import com.android.systemui.util.Utils
import javax.inject.Inject

/** A section for the status bar displayed at the top of the lockscreen. */
class DefaultStatusBarSection
@Inject
constructor(
    private val context: Context,
    private val featureFlags: FeatureFlags,
    private val notificationPanelView: NotificationPanelView,
    private val keyguardStatusBarViewComponentFactory: KeyguardStatusBarViewComponent.Factory,
) : KeyguardSection() {

    private val statusBarViewId = R.id.keyguard_header

    override fun addViews(constraintLayout: ConstraintLayout) {
        if (!featureFlags.isEnabled(Flags.MIGRATE_KEYGUARD_STATUS_BAR_VIEW)) {
            return
        }

        notificationPanelView.findViewById<View>(statusBarViewId)?.let {
            (it.parent as ViewGroup).removeView(it)
        }

        val view =
            LayoutInflater.from(constraintLayout.context)
                .inflate(R.layout.keyguard_status_bar, constraintLayout, false)
                as KeyguardStatusBarView

        constraintLayout.addView(view)
    }

    override fun bindData(constraintLayout: ConstraintLayout) {
        if (!featureFlags.isEnabled(Flags.MIGRATE_KEYGUARD_STATUS_BAR_VIEW)) {
            return
        }

        val statusBarView =
            constraintLayout.findViewById<KeyguardStatusBarView>(statusBarViewId) ?: return

        val provider =
            object : ShadeViewStateProvider {
                override val lockscreenShadeDragProgress: Float = 0f
                override val panelViewExpandedHeight: Float = 0f
                override fun shouldHeadsUpBeVisible(): Boolean {
                    return false
                }
            }
        val statusBarViewComponent =
            keyguardStatusBarViewComponentFactory.build(statusBarView, provider)
        val controller = statusBarViewComponent.keyguardStatusBarViewController
        controller.init()
    }

    override fun applyConstraints(constraintSet: ConstraintSet) {
        constraintSet.apply {
            constrainHeight(statusBarViewId, Utils.getStatusBarHeaderHeightKeyguard(context))
            connect(statusBarViewId, TOP, PARENT_ID, TOP)
            connect(statusBarViewId, START, PARENT_ID, START)
            connect(statusBarViewId, END, PARENT_ID, END)
        }
    }

    override fun removeViews(constraintLayout: ConstraintLayout) {
        constraintLayout.removeView(statusBarViewId)
    }
}
+3 −1
Original line number Diff line number Diff line
@@ -91,7 +91,7 @@ constructor(
                    it.requireViewById<ViewGroup>(R.id.status_view_media_container)
                )
                keyguardViewConfigurator.get().keyguardStatusViewController = controller
                notificationPanelViewController.get().updateStatusBarViewController()
                notificationPanelViewController.get().updateStatusViewController()
            }
        }
    }
@@ -100,6 +100,8 @@ constructor(
        constraintSet.apply {
            constrainWidth(statusViewId, MATCH_CONSTRAINT)
            constrainHeight(statusViewId, WRAP_CONTENT)
            // TODO(b/296122465): Constrain to the top of [DefaultStatusBarSection] and remove the
            // extra margin below.
            connect(statusViewId, TOP, PARENT_ID, TOP)
            connect(statusViewId, START, PARENT_ID, START)
            connect(statusViewId, END, PARENT_ID, END)
+3 −6
Original line number Diff line number Diff line
@@ -205,7 +205,6 @@ import com.android.systemui.statusbar.phone.KeyguardBottomAreaView;
import com.android.systemui.statusbar.phone.KeyguardBottomAreaViewController;
import com.android.systemui.statusbar.phone.KeyguardBypassController;
import com.android.systemui.statusbar.phone.KeyguardClockPositionAlgorithm;
import com.android.systemui.statusbar.phone.KeyguardStatusBarView;
import com.android.systemui.statusbar.phone.KeyguardStatusBarViewController;
import com.android.systemui.statusbar.phone.LockscreenGestureLogger;
import com.android.systemui.statusbar.phone.LockscreenGestureLogger.LockscreenUiEvent;
@@ -383,7 +382,6 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump
    private int mMaxAllowedKeyguardNotifications;
    private KeyguardQsUserSwitchController mKeyguardQsUserSwitchController;
    private KeyguardUserSwitcherController mKeyguardUserSwitcherController;
    private KeyguardStatusBarView mKeyguardStatusBar;
    private KeyguardStatusBarViewController mKeyguardStatusBarViewController;
    private KeyguardStatusViewController mKeyguardStatusViewController;
    private final LockIconViewController mLockIconViewController;
@@ -1037,7 +1035,6 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump
    @VisibleForTesting
    void onFinishInflate() {
        loadDimens();
        mKeyguardStatusBar = mView.findViewById(R.id.keyguard_header);

        FrameLayout userAvatarContainer = null;
        KeyguardUserSwitcherView keyguardUserSwitcherView = null;
@@ -1055,7 +1052,7 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump

        mKeyguardStatusBarViewController =
                mKeyguardStatusBarViewComponentFactory.build(
                                mKeyguardStatusBar,
                                mView.findViewById(R.id.keyguard_header),
                                mShadeViewStateProvider)
                        .getKeyguardStatusBarViewController();
        mKeyguardStatusBarViewController.init();
@@ -1228,7 +1225,7 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump
    private void updateViewControllers(
            FrameLayout userAvatarView,
            KeyguardUserSwitcherView keyguardUserSwitcherView) {
        updateStatusBarViewController();
        updateStatusViewController();
        if (mKeyguardUserSwitcherController != null) {
            // Try to close the switcher so that callbacks are triggered if necessary.
            // Otherwise, NPV can get into a state where some of the views are still hidden
@@ -1259,7 +1256,7 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump
    }

    /** Updates the StatusBarViewController and updates any that depend on it. */
    public void updateStatusBarViewController() {
    public void updateStatusViewController() {
        // Re-associate the KeyguardStatusViewController
        if (mKeyguardStatusViewController != null) {
            mKeyguardStatusViewController.onDestroy();
Loading