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

Commit 30e2ea9c authored by Justin Weir's avatar Justin Weir
Browse files

Delete ShadeFullExpansionListener

I squashed ag/25058951 into this hoping that the further cleanups
to the lifecycle of StatusBarStateControllerImpl would resolve the
possible regression to OnlyShowNewNotificationsOnLockscreen. I can't
be sure that this resolved any issues, but the test passes on both
real and emulated devices with this change.

Fixes: 300243163
Test: updated existing tests
Test: manual
Test: verified OnlyShowNewNotificationsOnLockscreen locally on phone and tablet and remotely on cuttlefish https://android-build.corp.google.com/abtd/run/L14100000963602695
Change-Id: I4c24cc008f3bdaf622b72c4279c1ba37a9676e58
parent 8cb8a3ea
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -2629,7 +2629,6 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump
        if (isPanelExpanded() != isExpanded) {
            setExpandedOrAwaitingInputTransfer(isExpanded);
            updateSystemUiStateFlags();
            mShadeExpansionStateManager.onShadeExpansionFullyChanged(isExpanded);
            if (!isExpanded) {
                mQsController.closeQsCustomizer();
            }
+0 −22
Original line number Diff line number Diff line
@@ -36,7 +36,6 @@ import javax.inject.Inject
class ShadeExpansionStateManager @Inject constructor() : ShadeStateEvents {

    private val expansionListeners = CopyOnWriteArrayList<ShadeExpansionListener>()
    private val fullExpansionListeners = CopyOnWriteArrayList<ShadeFullExpansionListener>()
    private val qsExpansionListeners = CopyOnWriteArrayList<ShadeQsExpansionListener>()
    private val qsExpansionFractionListeners =
        CopyOnWriteArrayList<ShadeQsExpansionFractionListener>()
@@ -67,15 +66,6 @@ class ShadeExpansionStateManager @Inject constructor() : ShadeStateEvents {
        expansionListeners.remove(listener)
    }

    fun addFullExpansionListener(listener: ShadeFullExpansionListener) {
        fullExpansionListeners.add(listener)
        listener.onShadeExpansionFullyChanged(qsExpanded)
    }

    fun removeFullExpansionListener(listener: ShadeFullExpansionListener) {
        fullExpansionListeners.remove(listener)
    }

    fun addQsExpansionListener(listener: ShadeQsExpansionListener) {
        qsExpansionListeners.add(listener)
        listener.onQsExpansionChanged(qsExpanded)
@@ -99,11 +89,6 @@ class ShadeExpansionStateManager @Inject constructor() : ShadeStateEvents {
        stateListeners.add(listener)
    }

    /** Removes a state listener. */
    fun removeStateListener(listener: ShadeStateListener) {
        stateListeners.remove(listener)
    }

    override fun addShadeStateEventsListener(listener: ShadeStateEventsListener) {
        shadeStateEventsListeners.addIfAbsent(listener)
    }
@@ -196,13 +181,6 @@ class ShadeExpansionStateManager @Inject constructor() : ShadeStateEvents {
        }
    }

    fun onShadeExpansionFullyChanged(isExpanded: Boolean) {
        this.expanded = isExpanded

        debugLog("expanded=$isExpanded")
        fullExpansionListeners.forEach { it.onShadeExpansionFullyChanged(isExpanded) }
    }

    /** Updates the panel state if necessary. */
    fun updateState(@PanelState state: Int) {
        debugLog(
+0 −23
Original line number Diff line number Diff line
/*
 * Copyright (c) 2022 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.shade

/** A listener interface to be notified of expansion events for the notification shade. */
fun interface ShadeFullExpansionListener {
    /** Invoked whenever the shade expansion changes, when it is fully collapsed or expanded */
    fun onShadeExpansionFullyChanged(isExpanded: Boolean)
}
+7 −6
Original line number Diff line number Diff line
@@ -148,12 +148,13 @@ constructor(
     *
     * TODO(b/300258424) remove all but the first sentence of this comment
     */
    val isAnyExpanded: Flow<Boolean> =
    val isAnyExpanded: StateFlow<Boolean> =
        if (sceneContainerFlags.isEnabled()) {
                anyExpansion.map { it > 0f }.distinctUntilChanged()
            } else {
                repository.legacyExpandedOrAwaitingInputTransfer
            }
            .stateIn(scope, SharingStarted.Eagerly, false)

    /**
     * Whether the user is expanding or collapsing the shade with user input. This will be true even
@@ -184,7 +185,7 @@ constructor(
     * but a transition they initiated is still animating.
     */
    val isUserInteracting: Flow<Boolean> =
        combine(isUserInteractingWithShade, isUserInteractingWithShade) { shade, qs -> shade || qs }
        combine(isUserInteractingWithShade, isUserInteractingWithQs) { shade, qs -> shade || qs }
            .distinctUntilChanged()

    /** Are touches allowed on the notification panel? */
+28 −4
Original line number Diff line number Diff line
@@ -48,11 +48,12 @@ import androidx.annotation.Nullable;

import com.android.internal.statusbar.IStatusBarService;
import com.android.internal.statusbar.NotificationVisibility;
import com.android.systemui.CoreStartable;
import com.android.systemui.Dumpable;
import com.android.systemui.dump.DumpManager;
import com.android.systemui.plugins.statusbar.StatusBarStateController;
import com.android.systemui.power.domain.interactor.PowerInteractor;
import com.android.systemui.res.R;
import com.android.systemui.shade.domain.interactor.ShadeInteractor;
import com.android.systemui.statusbar.dagger.CentralSurfacesDependenciesModule;
import com.android.systemui.statusbar.notification.NotifPipelineFlags;
import com.android.systemui.statusbar.notification.RemoteInputControllerLogger;
@@ -65,6 +66,7 @@ import com.android.systemui.statusbar.policy.RemoteInputUriController;
import com.android.systemui.statusbar.policy.RemoteInputView;
import com.android.systemui.util.DumpUtilsKt;
import com.android.systemui.util.ListenerSet;
import com.android.systemui.util.kotlin.JavaAdapter;

import java.io.PrintWriter;
import java.util.ArrayList;
@@ -78,7 +80,7 @@ import java.util.function.Consumer;
 * interaction, keeping track of notifications to remove when NotificationPresenter is collapsed,
 * and handling clicks on remote views.
 */
public class NotificationRemoteInputManager implements Dumpable {
public class NotificationRemoteInputManager implements CoreStartable {
    public static final boolean ENABLE_REMOTE_INPUT =
            SystemProperties.getBoolean("debug.enable_remote_input", true);
    public static boolean FORCE_REMOTE_INPUT_HISTORY =
@@ -94,6 +96,8 @@ public class NotificationRemoteInputManager implements Dumpable {
    private final NotificationVisibilityProvider mVisibilityProvider;
    private final PowerInteractor mPowerInteractor;
    private final ActionClickLogger mLogger;
    private final JavaAdapter mJavaAdapter;
    private final ShadeInteractor mShadeInteractor;
    protected final Context mContext;
    protected final NotifPipelineFlags mNotifPipelineFlags;
    private final UserManager mUserManager;
@@ -261,7 +265,8 @@ public class NotificationRemoteInputManager implements Dumpable {
            RemoteInputControllerLogger remoteInputControllerLogger,
            NotificationClickNotifier clickNotifier,
            ActionClickLogger logger,
            DumpManager dumpManager) {
            JavaAdapter javaAdapter,
            ShadeInteractor shadeInteractor) {
        mContext = context;
        mNotifPipelineFlags = notifPipelineFlags;
        mLockscreenUserManager = lockscreenUserManager;
@@ -269,6 +274,8 @@ public class NotificationRemoteInputManager implements Dumpable {
        mVisibilityProvider = visibilityProvider;
        mPowerInteractor = powerInteractor;
        mLogger = logger;
        mJavaAdapter = javaAdapter;
        mShadeInteractor = shadeInteractor;
        mBarService = IStatusBarService.Stub.asInterface(
                ServiceManager.getService(Context.STATUS_BAR_SERVICE));
        mUserManager = (UserManager) mContext.getSystemService(Context.USER_SERVICE);
@@ -277,8 +284,25 @@ public class NotificationRemoteInputManager implements Dumpable {
        mRemoteInputUriController = remoteInputUriController;
        mRemoteInputControllerLogger = remoteInputControllerLogger;
        mClickNotifier = clickNotifier;
    }

        dumpManager.registerDumpable(this);
    @Override
    public void start() {
        mJavaAdapter.alwaysCollectFlow(mShadeInteractor.isAnyExpanded(),
                this::onShadeOrQsExpanded);
    }

    private void onShadeOrQsExpanded(boolean expanded) {
        if (expanded && mStatusBarStateController.getState() != StatusBarState.KEYGUARD) {
            try {
                mBarService.clearNotificationEffects();
            } catch (RemoteException e) {
                // Won't fail unless the world has ended.
            }
        }
        if (!expanded) {
            onPanelCollapsed();
        }
    }

    /** Add a listener for various remote input events.  Works with NEW pipeline only. */
Loading