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

Commit ba1f45c8 authored by Bryce Lee's avatar Bryce Lee Committed by Android (Google) Code Review
Browse files

Merge changes Ic0fbe837,I488f5152,Ib76ec1ec

* changes:
  Publish when communal view is occluded.
  Do not show keyguard clock when communal mode is active.
  Do not show notifications on keyguard with communal.
parents 2cb04ea6 1a487d35
Loading
Loading
Loading
Loading
+5 −2
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@ import android.graphics.Rect;
import android.util.Slog;

import com.android.keyguard.KeyguardClockSwitch.ClockSize;
import com.android.systemui.communal.CommunalStateController;
import com.android.systemui.keyguard.KeyguardUnlockAnimationController;
import com.android.systemui.shared.system.smartspace.SmartspaceTransitionController;
import com.android.systemui.statusbar.notification.AnimatableProperty;
@@ -64,6 +65,7 @@ public class KeyguardStatusViewController extends ViewController<KeyguardStatusV
            KeyguardClockSwitchController keyguardClockSwitchController,
            KeyguardStateController keyguardStateController,
            KeyguardUpdateMonitor keyguardUpdateMonitor,
            CommunalStateController communalStateController,
            ConfigurationController configurationController,
            DozeParameters dozeParameters,
            KeyguardUnlockAnimationController keyguardUnlockAnimationController,
@@ -76,8 +78,9 @@ public class KeyguardStatusViewController extends ViewController<KeyguardStatusV
        mConfigurationController = configurationController;
        mDozeParameters = dozeParameters;
        mKeyguardStateController = keyguardStateController;
        mKeyguardVisibilityHelper = new KeyguardVisibilityHelper(mView, keyguardStateController,
                dozeParameters, unlockedScreenOffAnimationController, /* animateYPos= */ true);
        mKeyguardVisibilityHelper = new KeyguardVisibilityHelper(mView, communalStateController,
                keyguardStateController, dozeParameters, unlockedScreenOffAnimationController,
                /* animateYPos= */ true);
        mKeyguardUnlockAnimationController = keyguardUnlockAnimationController;
        mSmartspaceTransitionController = smartspaceTransitionController;
    }
+12 −0
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@ import android.view.View;
import android.view.ViewPropertyAnimator;

import com.android.systemui.animation.Interpolators;
import com.android.systemui.communal.CommunalStateController;
import com.android.systemui.statusbar.StatusBarState;
import com.android.systemui.statusbar.notification.AnimatableProperty;
import com.android.systemui.statusbar.notification.PropertyAnimator;
@@ -38,6 +39,7 @@ import com.android.systemui.statusbar.policy.KeyguardStateController;
public class KeyguardVisibilityHelper {

    private View mView;
    private final CommunalStateController mCommunalStateController;
    private final KeyguardStateController mKeyguardStateController;
    private final DozeParameters mDozeParameters;
    private final UnlockedScreenOffAnimationController mUnlockedScreenOffAnimationController;
@@ -47,11 +49,13 @@ public class KeyguardVisibilityHelper {
    private final AnimationProperties mAnimationProperties = new AnimationProperties();

    public KeyguardVisibilityHelper(View view,
            CommunalStateController communalStateController,
            KeyguardStateController keyguardStateController,
            DozeParameters dozeParameters,
            UnlockedScreenOffAnimationController unlockedScreenOffAnimationController,
            boolean animateYPos) {
        mView = view;
        mCommunalStateController = communalStateController;
        mKeyguardStateController = keyguardStateController;
        mDozeParameters = dozeParameters;
        mUnlockedScreenOffAnimationController = unlockedScreenOffAnimationController;
@@ -73,6 +77,14 @@ public class KeyguardVisibilityHelper {
        mView.animate().cancel();
        boolean isOccluded = mKeyguardStateController.isOccluded();
        mKeyguardViewVisibilityAnimating = false;

        // If the communal view is showing, hide immediately
        if (mCommunalStateController.getCommunalViewShowing()) {
            mView.setVisibility(View.GONE);
            mView.setAlpha(1f);
            return;
        }

        if ((!keyguardFadingAway && oldStatusBarState == KEYGUARD
                && statusBarState != KEYGUARD) || goingToFullShade) {
            mKeyguardViewVisibilityAnimating = true;
+25 −0
Original line number Diff line number Diff line
@@ -53,6 +53,8 @@ public class CommunalHostViewController extends ViewController<CommunalHostView>
    private final StatusBarStateController mStatusBarStateController;
    private WeakReference<CommunalSource> mLastSource;
    private int mState;
    private float mQsExpansion;
    private float mShadeExpansion;

    @Retention(RetentionPolicy.RUNTIME)
    @IntDef({STATE_KEYGUARD_SHOWING, STATE_DOZING, STATE_BOUNCER_SHOWING, STATE_KEYGUARD_OCCLUDED})
@@ -264,4 +266,27 @@ public class CommunalHostViewController extends ViewController<CommunalHostView>
        mLastSource = source;
        showSource();
    }

    /**
     * Invoked when the quick settings is expanded.
     * @param expansionFraction the percentage the QS shade has been expanded.
     */
    public void updateQsExpansion(float expansionFraction) {
        mQsExpansion = expansionFraction;
        updateCommunalViewOccluded();
    }

    /**
     * Invoked when the main shade is expanded.
     * @param shadeExpansion the percentage the main shade has expanded.
     */
    public void updateShadeExpansion(float shadeExpansion) {
        mShadeExpansion = shadeExpansion;
        updateCommunalViewOccluded();
    }

    private void updateCommunalViewOccluded() {
        mCommunalStateController.setCommunalViewOccluded(
                mQsExpansion > 0.0f || mShadeExpansion > 0.0f);
    }
}
+40 −6
Original line number Diff line number Diff line
@@ -34,6 +34,7 @@ import javax.inject.Inject;
public class CommunalStateController implements
        CallbackController<CommunalStateController.Callback> {
    private final ArrayList<Callback> mCallbacks = new ArrayList<>();
    private boolean mCommunalViewOccluded;
    private boolean mCommunalViewShowing;

    /**
@@ -45,6 +46,12 @@ public class CommunalStateController implements
         */
        default void onCommunalViewShowingChanged() {
        }

        /**
         * Called when the occlusion of the communal view changes.
         */
        default void onCommunalViewOccludedChanged() {
        }
    }

    @VisibleForTesting
@@ -57,7 +64,10 @@ public class CommunalStateController implements
     * @param communalViewShowing {@code true} if the view is showing, {@code false} otherwise.
     */
    public void setCommunalViewShowing(boolean communalViewShowing) {
        if (mCommunalViewShowing != communalViewShowing) {
        if (mCommunalViewShowing == communalViewShowing) {
            return;
        }

        mCommunalViewShowing = communalViewShowing;

        final ArrayList<Callback> callbacks = new ArrayList<>(mCallbacks);
@@ -65,6 +75,22 @@ public class CommunalStateController implements
            callback.onCommunalViewShowingChanged();
        }
    }

    /**
     * Sets whether the communal view is occluded (but otherwise still showing).
     * @param communalViewOccluded {@code true} if the view is occluded, {@code false} otherwise.
     */
    public void setCommunalViewOccluded(boolean communalViewOccluded) {
        if (mCommunalViewOccluded == communalViewOccluded) {
            return;
        }

        mCommunalViewOccluded = communalViewOccluded;

        ArrayList<Callback> callbacks = new ArrayList<>(mCallbacks);
        for (int i = 0; i < callbacks.size(); i++) {
            callbacks.get(i).onCommunalViewOccludedChanged();
        }
    }

    /**
@@ -75,6 +101,14 @@ public class CommunalStateController implements
        return mCommunalViewShowing;
    }

    /**
     * Returns whether the communal view is occluded.
     * @return {@code true} if the view is occluded, {@code false} otherwise.
     */
    public boolean getCommunalViewOccluded() {
        return mCommunalViewOccluded;
    }

    @Override
    public void addCallback(@NonNull Callback callback) {
        Objects.requireNonNull(callback, "Callback must not be null. b/128895449");
+70 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2021 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.statusbar.notification.collection.coordinator;

import androidx.annotation.NonNull;

import com.android.systemui.communal.CommunalStateController;
import com.android.systemui.statusbar.NotificationLockscreenUserManager;
import com.android.systemui.statusbar.notification.NotificationEntryManager;
import com.android.systemui.statusbar.notification.collection.NotifPipeline;
import com.android.systemui.statusbar.notification.collection.NotificationEntry;
import com.android.systemui.statusbar.notification.collection.listbuilder.pluggable.NotifFilter;

import javax.inject.Inject;

/**
 * {@link CommunalCoordinator} prevents notifications from showing on the keyguard when the communal
 * view is present.
 */
public class CommunalCoordinator implements Coordinator {
    final CommunalStateController mCommunalStateController;
    final NotificationEntryManager mNotificationEntryManager;
    final NotificationLockscreenUserManager mNotificationLockscreenUserManager;

    @Inject
    public CommunalCoordinator(NotificationEntryManager notificationEntryManager,
            NotificationLockscreenUserManager notificationLockscreenUserManager,
            CommunalStateController communalStateController) {
        mNotificationEntryManager = notificationEntryManager;
        mNotificationLockscreenUserManager = notificationLockscreenUserManager;
        mCommunalStateController = communalStateController;
    }

    final NotifFilter mFilter = new NotifFilter("CommunalCoordinator") {
        @Override
        public boolean shouldFilterOut(@NonNull NotificationEntry entry, long now) {
            return mCommunalStateController.getCommunalViewShowing();
        }
    };

    final CommunalStateController.Callback mStateCallback = new CommunalStateController.Callback() {
        @Override
        public void onCommunalViewShowingChanged() {
            mFilter.invalidateList();
            mNotificationEntryManager.updateNotifications("Communal mode state changed");
        }
    };

    @Override
    public void attach(@NonNull NotifPipeline pipeline) {
        pipeline.addPreGroupFilter(mFilter);
        mCommunalStateController.addCallback(mStateCallback);
        mNotificationLockscreenUserManager.addKeyguardNotificationSuppressor(
                entry -> mCommunalStateController.getCommunalViewShowing());
    }
}
Loading