From 25be6577c30870a5bfb6bc614486886baf10035d Mon Sep 17 00:00:00 2001 From: Beverly Date: Wed, 7 Apr 2021 15:04:15 -0400 Subject: Update DisabledUdfpsCtrl to LockIconViewController Remove the old icon below the status bar on keyguard. Instead, a lock icon will show beneath the notification shade for devices with either udfps or face auth enrolled. All other devices will no longer have a lock icon. Test: manual, atest SystemUITests Bug: 183910378 Change-Id: I7eebc363150641b4d63ee0f35b379d163e3a71d5 --- .../SystemUI/res/layout/status_bar_expanded.xml | 5 + .../res/layout/super_notification_shade.xml | 16 +- packages/SystemUI/res/values/config.xml | 7 + .../android/keyguard/DisabledUdfpsController.java | 228 --------- .../com/android/keyguard/DisabledUdfpsView.java | 88 ---- .../android/keyguard/KeyguardUpdateMonitor.java | 28 +- .../android/keyguard/KeyguardViewController.java | 3 +- .../src/com/android/keyguard/LockIconView.java | 93 ++++ .../android/keyguard/LockIconViewController.java | 301 +++++++++++ .../systemui/biometrics/AuthController.java | 11 + .../systemui/keyguard/KeyguardViewMediator.java | 6 +- .../statusbar/KeyguardIndicationController.java | 23 +- .../phone/KeyguardClockPositionAlgorithm.java | 23 +- .../phone/LockscreenLockIconController.java | 565 --------------------- .../phone/NotificationPanelViewController.java | 82 +-- .../systemui/statusbar/phone/StatusBar.java | 25 +- .../phone/StatusBarKeyguardViewManager.java | 98 +--- .../statusbar/phone/dagger/StatusBarComponent.java | 8 +- .../phone/dagger/StatusBarViewModule.java | 7 +- .../phone/KeyguardClockPositionAlgorithmTest.java | 2 +- .../phone/LockscreenIconControllerTest.java | 151 ------ .../statusbar/phone/NotificationPanelViewTest.java | 20 +- .../phone/StatusBarKeyguardViewManagerTest.java | 12 +- .../systemui/statusbar/phone/StatusBarTest.java | 10 +- 24 files changed, 482 insertions(+), 1330 deletions(-) delete mode 100644 packages/SystemUI/src/com/android/keyguard/DisabledUdfpsController.java delete mode 100644 packages/SystemUI/src/com/android/keyguard/DisabledUdfpsView.java create mode 100644 packages/SystemUI/src/com/android/keyguard/LockIconView.java create mode 100644 packages/SystemUI/src/com/android/keyguard/LockIconViewController.java delete mode 100644 packages/SystemUI/src/com/android/systemui/statusbar/phone/LockscreenLockIconController.java delete mode 100644 packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/LockscreenIconControllerTest.java diff --git a/packages/SystemUI/res/layout/status_bar_expanded.xml b/packages/SystemUI/res/layout/status_bar_expanded.xml index 6b9b36586f92..46a698a092e3 100644 --- a/packages/SystemUI/res/layout/status_bar_expanded.xml +++ b/packages/SystemUI/res/layout/status_bar_expanded.xml @@ -112,4 +112,9 @@ android:layout_width="match_parent" /> + + diff --git a/packages/SystemUI/res/layout/super_notification_shade.xml b/packages/SystemUI/res/layout/super_notification_shade.xml index e46c6701684f..2e8b2991bb23 100644 --- a/packages/SystemUI/res/layout/super_notification_shade.xml +++ b/packages/SystemUI/res/layout/super_notification_shade.xml @@ -72,23 +72,13 @@ sysui:ignoreRightInset="true" /> - + - - + + + + + + + + diff --git a/packages/SystemUI/src/com/android/keyguard/DisabledUdfpsController.java b/packages/SystemUI/src/com/android/keyguard/DisabledUdfpsController.java deleted file mode 100644 index c9dea46c2f95..000000000000 --- a/packages/SystemUI/src/com/android/keyguard/DisabledUdfpsController.java +++ /dev/null @@ -1,228 +0,0 @@ -/* - * Copyright (C) 2020 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.keyguard; - -import static android.hardware.biometrics.BiometricSourceType.FINGERPRINT; - -import static com.android.systemui.classifier.Classifier.DISABLED_UDFPS_AFFORDANCE; - -import android.content.Context; -import android.graphics.drawable.Drawable; -import android.graphics.drawable.InsetDrawable; -import android.hardware.biometrics.BiometricSourceType; -import android.view.View; -import android.view.ViewGroup; - -import androidx.annotation.NonNull; - -import com.android.settingslib.Utils; -import com.android.systemui.Dumpable; -import com.android.systemui.R; -import com.android.systemui.biometrics.AuthController; -import com.android.systemui.dagger.SysUISingleton; -import com.android.systemui.plugins.FalsingManager; -import com.android.systemui.plugins.statusbar.StatusBarStateController; -import com.android.systemui.statusbar.StatusBarState; -import com.android.systemui.statusbar.policy.KeyguardStateController; -import com.android.systemui.util.ViewController; - -import java.io.FileDescriptor; -import java.io.PrintWriter; - -/** - * Controls when to show the DisabledUdfpsView affordance (unlock icon or circle) on lock screen. - * - * This view only exists when: - * - User has UDFPS enrolled - * - UDFPS is currently unavailable see {@link KeyguardUpdateMonitor#shouldListenForUdfps} - */ -@SysUISingleton -public class DisabledUdfpsController extends ViewController implements Dumpable { - @NonNull private final KeyguardUpdateMonitor mKeyguardUpdateMonitor; - @NonNull private final KeyguardViewController mKeyguardViewController; - @NonNull private final StatusBarStateController mStatusBarStateController; - @NonNull private final KeyguardStateController mKeyguardStateController; - @NonNull private final FalsingManager mFalsingManager; - @NonNull private final Drawable mButton; - @NonNull private final Drawable mUnlockIcon; - - private boolean mIsDozing; - private boolean mIsBouncerShowing; - private boolean mRunningFPS; - private boolean mCanDismissLockScreen; - private boolean mQsExpanded; - private int mStatusBarState; - - private boolean mShowButton; - private boolean mShowUnlockIcon; - - public DisabledUdfpsController( - @NonNull DisabledUdfpsView view, - @NonNull StatusBarStateController statusBarStateController, - @NonNull KeyguardUpdateMonitor keyguardUpdateMonitor, - @NonNull AuthController authController, - @NonNull KeyguardViewController keyguardViewController, - @NonNull KeyguardStateController keyguardStateController, - @NonNull FalsingManager falsingManager - ) { - super(view); - mView.setOnClickListener(v -> onAffordanceClick()); - mView.setOnLongClickListener(v -> onAffordanceClick()); - mView.setSensorProperties(authController.getUdfpsProps().get(0)); - - mStatusBarStateController = statusBarStateController; - mKeyguardUpdateMonitor = keyguardUpdateMonitor; - mKeyguardViewController = keyguardViewController; - mKeyguardStateController = keyguardStateController; - mFalsingManager = falsingManager; - - final Context context = view.getContext(); - mButton = context.getResources().getDrawable( - com.android.systemui.R.drawable.circle_white, context.getTheme()); - mUnlockIcon = new InsetDrawable(context.getResources().getDrawable( - com.android.internal.R.drawable.ic_lock_open, context.getTheme()), - context.getResources().getDimensionPixelSize( - com.android.systemui.R.dimen.udfps_unlock_icon_inset)); - } - - @Override - protected void onViewAttached() { - mIsBouncerShowing = mKeyguardViewController.isBouncerShowing(); - mIsDozing = mStatusBarStateController.isDozing(); - mRunningFPS = mKeyguardUpdateMonitor.isFingerprintDetectionRunning(); - mCanDismissLockScreen = mKeyguardStateController.canDismissLockScreen(); - mStatusBarState = mStatusBarStateController.getState(); - mUnlockIcon.setTint(Utils.getColorAttrDefaultColor(mView.getContext(), - R.attr.wallpaperTextColorAccent)); - updateVisibility(); - - mKeyguardUpdateMonitor.registerCallback(mKeyguardUpdateMonitorCallback); - mStatusBarStateController.addCallback(mStatusBarStateListener); - mKeyguardStateController.addCallback(mKeyguardStateCallback); - } - - @Override - protected void onViewDetached() { - mKeyguardUpdateMonitor.removeCallback(mKeyguardUpdateMonitorCallback); - mStatusBarStateController.removeCallback(mStatusBarStateListener); - mKeyguardStateController.removeCallback(mKeyguardStateCallback); - } - - private boolean onAffordanceClick() { - if (mFalsingManager.isFalseTouch(DISABLED_UDFPS_AFFORDANCE)) { - return false; - } - mView.setVisibility(View.INVISIBLE); - mKeyguardViewController.showBouncer(/* scrim */ true); - return true; - } - - /** - * Call when this controller is no longer needed. This will remove the view from its parent. - */ - public void destroy() { - if (mView != null && mView.getParent() != null) { - ((ViewGroup) mView.getParent()).removeView(mView); - } - } - - /** - * Set whether qs is expanded. When QS is expanded, don't show a DisabledUdfps affordance. - */ - public void setQsExpanded(boolean expanded) { - mQsExpanded = expanded; - updateVisibility(); - } - - private void updateVisibility() { - mShowButton = !mCanDismissLockScreen && !mRunningFPS && isLockScreen(); - mShowUnlockIcon = mCanDismissLockScreen && isLockScreen(); - - if (mShowButton) { - mView.setImageDrawable(mButton); - mView.setVisibility(View.VISIBLE); - } else if (mShowUnlockIcon) { - mView.setImageDrawable(mUnlockIcon); - mView.setVisibility(View.VISIBLE); - } else { - mView.setVisibility(View.INVISIBLE); - } - } - - private boolean isLockScreen() { - return !mIsDozing - && !mIsBouncerShowing - && !mQsExpanded - && mStatusBarState == StatusBarState.KEYGUARD; - } - - @Override - public void dump(@NonNull FileDescriptor fd, @NonNull PrintWriter pw, @NonNull String[] args) { - pw.println("DisabledUdfpsController state:"); - pw.println(" mShowBouncerButton: " + mShowButton); - pw.println(" mShowUnlockIcon: " + mShowUnlockIcon); - pw.println(" mIsDozing: " + mIsDozing); - pw.println(" mIsBouncerShowing: " + mIsBouncerShowing); - pw.println(" mRunningFPS: " + mRunningFPS); - pw.println(" mCanDismissLockScreen: " + mCanDismissLockScreen); - pw.println(" mStatusBarState: " + StatusBarState.toShortString(mStatusBarState)); - pw.println(" mQsExpanded: " + mQsExpanded); - } - - private StatusBarStateController.StateListener mStatusBarStateListener = - new StatusBarStateController.StateListener() { - @Override - public void onDozingChanged(boolean isDozing) { - mIsDozing = isDozing; - updateVisibility(); - } - - @Override - public void onStateChanged(int statusBarState) { - mStatusBarState = statusBarState; - updateVisibility(); - } - }; - - private final KeyguardUpdateMonitorCallback mKeyguardUpdateMonitorCallback = - new KeyguardUpdateMonitorCallback() { - @Override - public void onKeyguardBouncerChanged(boolean bouncer) { - mIsBouncerShowing = bouncer; - updateVisibility(); - } - - @Override - public void onBiometricRunningStateChanged(boolean running, - BiometricSourceType biometricSourceType) { - if (biometricSourceType == FINGERPRINT) { - mRunningFPS = running; - } - - updateVisibility(); - } - }; - - private final KeyguardStateController.Callback mKeyguardStateCallback = - new KeyguardStateController.Callback() { - @Override - public void onUnlockedChanged() { - mCanDismissLockScreen = mKeyguardStateController.canDismissLockScreen(); - updateVisibility(); - } - }; -} diff --git a/packages/SystemUI/src/com/android/keyguard/DisabledUdfpsView.java b/packages/SystemUI/src/com/android/keyguard/DisabledUdfpsView.java deleted file mode 100644 index 8ae753e7f3f7..000000000000 --- a/packages/SystemUI/src/com/android/keyguard/DisabledUdfpsView.java +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Copyright (C) 2020 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.keyguard; - -import android.annotation.NonNull; -import android.content.Context; -import android.graphics.RectF; -import android.hardware.fingerprint.FingerprintSensorPropertiesInternal; -import android.util.AttributeSet; -import android.view.Surface; -import android.widget.FrameLayout; -import android.widget.ImageView; - -/** - * A view positioned in the area of the UDPFS sensor. - */ -public class DisabledUdfpsView extends ImageView { - @NonNull private final RectF mSensorRect; - @NonNull private final Context mContext; - - // Used to obtain the sensor location. - @NonNull private FingerprintSensorPropertiesInternal mSensorProps; - - public DisabledUdfpsView(Context context, AttributeSet attrs) { - super(context, attrs); - mContext = context; - mSensorRect = new RectF(); - } - - public void setSensorProperties(@NonNull FingerprintSensorPropertiesInternal properties) { - mSensorProps = properties; - } - - // The "h" and "w" are the display's height and width relative to its current rotation. - private void updateSensorRect(int h, int w) { - // mSensorProps coordinates assume portrait mode. - mSensorRect.set(mSensorProps.sensorLocationX - mSensorProps.sensorRadius, - mSensorProps.sensorLocationY - mSensorProps.sensorRadius, - mSensorProps.sensorLocationX + mSensorProps.sensorRadius, - mSensorProps.sensorLocationY + mSensorProps.sensorRadius); - - // Transform mSensorRect if the device is in landscape mode. - switch (mContext.getDisplay().getRotation()) { - case Surface.ROTATION_90: - mSensorRect.set(mSensorRect.top, h - mSensorRect.right, mSensorRect.bottom, - h - mSensorRect.left); - break; - case Surface.ROTATION_270: - mSensorRect.set(w - mSensorRect.bottom, mSensorRect.left, w - mSensorRect.top, - mSensorRect.right); - break; - default: - // Do nothing to stay in portrait mode. - } - - setX(mSensorRect.left); - setY(mSensorRect.top); - setLayoutParams(new FrameLayout.LayoutParams( - (int) (mSensorRect.right - mSensorRect.left), - (int) (mSensorRect.bottom - mSensorRect.top))); - } - - @Override - protected void onLayout(boolean changed, int left, int top, int right, int bottom) { - super.onLayout(changed, left, top, right, bottom); - // Always re-compute the layout regardless of whether "changed" is true. It is usually false - // when the device goes from landscape to seascape and vice versa, but mSensorRect and - // its dependencies need to be recalculated to stay at the same physical location on the - // screen. - final int w = getLayoutParams().width; - final int h = getLayoutParams().height; - updateSensorRect(h, w); - } -} diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitor.java b/packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitor.java index 2219cf427498..3d6815c8e48f 100644 --- a/packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitor.java +++ b/packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitor.java @@ -315,6 +315,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab private boolean mLogoutEnabled; // cached value to avoid IPCs private boolean mIsUdfpsEnrolled; + private boolean mIsFaceEnrolled; // If the user long pressed the lock icon, disabling face auth for the current session. private boolean mLockIconPressed; private int mActiveMobileDataSubscription = SubscriptionManager.INVALID_SUBSCRIPTION_ID; @@ -1944,15 +1945,11 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab mIsUdfpsEnrolled = mAuthController.isUdfpsEnrolled(userId); } - /** - * Whether to show the lock icon on lock screen and bouncer. - */ - public boolean canShowLockIcon() { - if (mLockScreenMode == LOCK_SCREEN_MODE_LAYOUT_1) { - return isFaceAuthEnabledForUser(KeyguardUpdateMonitor.getCurrentUser()) - && !isUdfpsEnrolled(); - } - return true; + private void updateFaceEnrolled(int userId) { + mIsFaceEnrolled = whitelistIpcs( + () -> mFaceManager != null && mFaceManager.isHardwareDetected() + && mFaceManager.hasEnrolledTemplates(userId) + && mFaceSettingEnabledForUser.get(userId)); } /** @@ -1962,6 +1959,13 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab return mIsUdfpsEnrolled; } + /** + * @return true if there's at least one face enrolled + */ + public boolean isFaceEnrolled() { + return mIsFaceEnrolled; + } + private final UserSwitchObserver mUserSwitchObserver = new UserSwitchObserver() { @Override public void onUserSwitching(int newUserId, IRemoteCallback reply) { @@ -2279,10 +2283,8 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab * If face hardware is available, user has enrolled and enabled auth via setting. */ public boolean isFaceAuthEnabledForUser(int userId) { - // TODO(b/140034352) - return whitelistIpcs(() -> mFaceManager != null && mFaceManager.isHardwareDetected() - && mFaceManager.hasEnrolledTemplates(userId) - && mFaceSettingEnabledForUser.get(userId)); + updateFaceEnrolled(userId); + return mIsFaceEnrolled; } private void stopListeningForFingerprint() { diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardViewController.java b/packages/SystemUI/src/com/android/keyguard/KeyguardViewController.java index 9766ee128f7c..015c4e44185b 100644 --- a/packages/SystemUI/src/com/android/keyguard/KeyguardViewController.java +++ b/packages/SystemUI/src/com/android/keyguard/KeyguardViewController.java @@ -182,7 +182,6 @@ public interface KeyguardViewController { * @param container * @param notificationPanelViewController * @param biometricUnlockController - * @param lockIconContainer * @param notificationContainer * @param bypassController */ @@ -190,6 +189,6 @@ public interface KeyguardViewController { ViewGroup container, NotificationPanelViewController notificationPanelViewController, BiometricUnlockController biometricUnlockController, - ViewGroup lockIconContainer, View notificationContainer, + View notificationContainer, KeyguardBypassController bypassController); } diff --git a/packages/SystemUI/src/com/android/keyguard/LockIconView.java b/packages/SystemUI/src/com/android/keyguard/LockIconView.java new file mode 100644 index 000000000000..2167876d9cb6 --- /dev/null +++ b/packages/SystemUI/src/com/android/keyguard/LockIconView.java @@ -0,0 +1,93 @@ +/* + * Copyright (C) 2020 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.keyguard; + +import android.annotation.NonNull; +import android.content.Context; +import android.graphics.PointF; +import android.graphics.RectF; +import android.util.AttributeSet; +import android.view.Surface; +import android.widget.FrameLayout; +import android.widget.ImageView; + +/** + * A view positioned under the notification shade. + */ +public class LockIconView extends ImageView { + @NonNull private final RectF mSensorRect; + @NonNull private final Context mContext; + + @NonNull private PointF mLockIconCenter = new PointF(0f, 0f); + private int mRadius; + + public LockIconView(Context context, AttributeSet attrs) { + super(context, attrs); + mContext = context; + mSensorRect = new RectF(); + } + + void setLocation(@NonNull PointF center, int radius) { + mLockIconCenter = center; + mRadius = radius; + } + + // The "h" and "w" are the display's height and width relative to its current rotation. + private void updateSensorRect(int h, int w) { + // mSensorProps coordinates assume portrait mode. + mSensorRect.set(mLockIconCenter.x - mRadius, + mLockIconCenter.y - mRadius, + mLockIconCenter.x + mRadius, + mLockIconCenter.y + mRadius); + + // Transform mSensorRect if the device is in landscape mode. + switch (mContext.getDisplay().getRotation()) { + case Surface.ROTATION_90: + mSensorRect.set(mSensorRect.top, h - mSensorRect.right, mSensorRect.bottom, + h - mSensorRect.left); + break; + case Surface.ROTATION_270: + mSensorRect.set(w - mSensorRect.bottom, mSensorRect.left, w - mSensorRect.top, + mSensorRect.right); + break; + default: + // Do nothing to stay in portrait mode. + } + + setX(mSensorRect.left); + setY(mSensorRect.top); + setLayoutParams(new FrameLayout.LayoutParams( + (int) (mSensorRect.right - mSensorRect.left), + (int) (mSensorRect.bottom - mSensorRect.top))); + } + + @Override + protected void onLayout(boolean changed, int left, int top, int right, int bottom) { + super.onLayout(changed, left, top, right, bottom); + // Always re-compute the layout regardless of whether "changed" is true. It is usually false + // when the device goes from landscape to seascape and vice versa, but mSensorRect and + // its dependencies need to be recalculated to stay at the same physical location on the + // screen. + final int w = getLayoutParams().width; + final int h = getLayoutParams().height; + updateSensorRect(h, w); + } + + float getLocationTop() { + return mLockIconCenter.y - mRadius; + } +} diff --git a/packages/SystemUI/src/com/android/keyguard/LockIconViewController.java b/packages/SystemUI/src/com/android/keyguard/LockIconViewController.java new file mode 100644 index 000000000000..7329071169cc --- /dev/null +++ b/packages/SystemUI/src/com/android/keyguard/LockIconViewController.java @@ -0,0 +1,301 @@ +/* + * Copyright (C) 2020 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.keyguard; + +import static android.hardware.biometrics.BiometricSourceType.FINGERPRINT; + +import static com.android.systemui.classifier.Classifier.DISABLED_UDFPS_AFFORDANCE; + +import android.content.Context; +import android.graphics.PointF; +import android.graphics.drawable.Drawable; +import android.graphics.drawable.InsetDrawable; +import android.hardware.biometrics.BiometricSourceType; +import android.hardware.fingerprint.FingerprintSensorPropertiesInternal; +import android.util.Log; +import android.view.View; +import android.view.ViewGroup; + +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; + +import com.android.settingslib.Utils; +import com.android.systemui.Dumpable; +import com.android.systemui.R; +import com.android.systemui.biometrics.AuthController; +import com.android.systemui.dump.DumpManager; +import com.android.systemui.plugins.FalsingManager; +import com.android.systemui.plugins.statusbar.StatusBarStateController; +import com.android.systemui.statusbar.StatusBarState; +import com.android.systemui.statusbar.phone.dagger.StatusBarComponent; +import com.android.systemui.statusbar.policy.KeyguardStateController; +import com.android.systemui.util.ViewController; + +import java.io.FileDescriptor; +import java.io.PrintWriter; + +import javax.inject.Inject; + +/** + * Controls when to show the LockIcon affordance (lock/unlocked icon or circle) on lock screen. + * + * This view will only be shown if the user has UDFPS or FaceAuth enrolled + */ +@StatusBarComponent.StatusBarScope +public class LockIconViewController extends ViewController implements Dumpable { + @NonNull private final KeyguardUpdateMonitor mKeyguardUpdateMonitor; + @NonNull private final KeyguardViewController mKeyguardViewController; + @NonNull private final StatusBarStateController mStatusBarStateController; + @NonNull private final KeyguardStateController mKeyguardStateController; + @NonNull private final FalsingManager mFalsingManager; + @NonNull private final AuthController mAuthController; + + private boolean mHasUdfpsOrFaceAuthFeatures; + private boolean mUdfpsEnrolled; + private boolean mFaceAuthEnrolled; + + @NonNull private final Drawable mButton; + @NonNull private final Drawable mUnlockIcon; + @NonNull private final Drawable mLockIcon; + + private boolean mIsDozing; + private boolean mIsBouncerShowing; + private boolean mRunningFPS; + private boolean mCanDismissLockScreen; + private boolean mQsExpanded; + private int mStatusBarState; + private boolean mIsKeyguardShowing; + + private boolean mShowButton; + private boolean mShowUnlockIcon; + private boolean mShowLockIcon; + + @Inject + public LockIconViewController( + @Nullable LockIconView view, + @NonNull StatusBarStateController statusBarStateController, + @NonNull KeyguardUpdateMonitor keyguardUpdateMonitor, + @NonNull KeyguardViewController keyguardViewController, + @NonNull KeyguardStateController keyguardStateController, + @NonNull FalsingManager falsingManager, + @NonNull AuthController authController, + @NonNull DumpManager dumpManager + ) { + super(view); + if (mView != null) { + mView.setOnClickListener(v -> onAffordanceClick()); + mView.setOnLongClickListener(v -> onAffordanceClick()); + } + mStatusBarStateController = statusBarStateController; + mKeyguardUpdateMonitor = keyguardUpdateMonitor; + mAuthController = authController; + mKeyguardViewController = keyguardViewController; + mKeyguardStateController = keyguardStateController; + mFalsingManager = falsingManager; + + final Context context = view.getContext(); + mButton = context.getResources().getDrawable( + com.android.systemui.R.drawable.circle_white, context.getTheme()); + mUnlockIcon = new InsetDrawable(context.getResources().getDrawable( + com.android.internal.R.drawable.ic_lock_open, context.getTheme()), + context.getResources().getDimensionPixelSize( + com.android.systemui.R.dimen.udfps_unlock_icon_inset)); + mLockIcon = new InsetDrawable(context.getResources().getDrawable( + com.android.internal.R.drawable.ic_lock, context.getTheme()), + context.getResources().getDimensionPixelSize( + com.android.systemui.R.dimen.udfps_unlock_icon_inset)); + dumpManager.registerDumpable("LockIconViewController", this); + } + + @Override + protected void onViewAttached() { + // we check this here instead of onInit since the FingeprintManager + FaceManager may not + // have started up yet onInit + final boolean hasFaceAuth = mAuthController.getFaceAuthSensorLocation() != null; + final boolean hasUdfps = mAuthController.getUdfpsSensorLocation() != null; + mHasUdfpsOrFaceAuthFeatures = hasFaceAuth || hasUdfps; + if (!mHasUdfpsOrFaceAuthFeatures) { + ((ViewGroup) mView.getParent()).removeView(mView); + return; + } + + if (hasUdfps) { + FingerprintSensorPropertiesInternal props = mAuthController.getUdfpsProps().get(0); + mView.setLocation(new PointF(props.sensorLocationX, props.sensorLocationY), + props.sensorRadius); + } else { + int[] props = mView.getContext().getResources().getIntArray( + com.android.systemui.R.array.config_lock_icon_props); + if (props == null || props.length < 3) { + Log.e("LockIconViewController", "lock icon position should be " + + "setup in config under config_lock_icon_props"); + props = new int[]{0, 0, 0}; + } + mView.setLocation(new PointF(props[0], props[1]), props[2]); + } + + mIsKeyguardShowing = mKeyguardViewController.isShowing(); + mIsBouncerShowing = mKeyguardViewController.isBouncerShowing(); + mIsDozing = mStatusBarStateController.isDozing(); + mRunningFPS = mKeyguardUpdateMonitor.isFingerprintDetectionRunning(); + mCanDismissLockScreen = mKeyguardStateController.canDismissLockScreen(); + mStatusBarState = mStatusBarStateController.getState(); + + mUnlockIcon.setTint(Utils.getColorAttrDefaultColor(mView.getContext(), + R.attr.wallpaperTextColorAccent)); + mLockIcon.setTint(Utils.getColorAttrDefaultColor(mView.getContext(), + R.attr.wallpaperTextColorAccent)); + + mKeyguardUpdateMonitor.registerCallback(mKeyguardUpdateMonitorCallback); + mStatusBarStateController.addCallback(mStatusBarStateListener); + mKeyguardStateController.addCallback(mKeyguardStateCallback); + + updateVisibility(); + } + + @Override + protected void onViewDetached() { + mKeyguardUpdateMonitor.removeCallback(mKeyguardUpdateMonitorCallback); + mStatusBarStateController.removeCallback(mStatusBarStateListener); + mKeyguardStateController.removeCallback(mKeyguardStateCallback); + } + + public float getTop() { + return mView.getLocationTop(); + } + + private boolean onAffordanceClick() { + if (mFalsingManager.isFalseTouch(DISABLED_UDFPS_AFFORDANCE)) { + return false; + } + + // pre-emptively set to false to hide view + mIsKeyguardShowing = false; + updateVisibility(); + mKeyguardViewController.showBouncer(/* scrim */ true); + return true; + } + + /** + * Set whether qs is expanded. When QS is expanded, don't show a DisabledUdfps affordance. + */ + public void setQsExpanded(boolean expanded) { + mQsExpanded = expanded; + updateVisibility(); + } + + private void updateVisibility() { + if (!mIsKeyguardShowing) { + mView.setVisibility(View.INVISIBLE); + return; + } + + // these three states are mutually exclusive: + mShowButton = mUdfpsEnrolled && !mCanDismissLockScreen && !mRunningFPS && isLockScreen(); + mShowUnlockIcon = mCanDismissLockScreen && isLockScreen(); + mShowLockIcon = !mUdfpsEnrolled && !mCanDismissLockScreen && isLockScreen() + && mFaceAuthEnrolled; + + if (mShowButton) { + mView.setImageDrawable(mButton); + mView.setVisibility(View.VISIBLE); + } else if (mShowUnlockIcon) { + mView.setImageDrawable(mUnlockIcon); + mView.setVisibility(View.VISIBLE); + } else if (mShowLockIcon) { + mView.setImageDrawable(mLockIcon); + mView.setVisibility(View.VISIBLE); + } else { + mView.setVisibility(View.INVISIBLE); + } + } + + private boolean isLockScreen() { + return !mIsDozing + && !mIsBouncerShowing + && !mQsExpanded + && mStatusBarState == StatusBarState.KEYGUARD; + } + + @Override + public void dump(@NonNull FileDescriptor fd, @NonNull PrintWriter pw, @NonNull String[] args) { + pw.println(" mShowBouncerButton: " + mShowButton); + pw.println(" mShowUnlockIcon: " + mShowUnlockIcon); + pw.println(" mShowLockIcon: " + mShowLockIcon); + pw.println(" mHasUdfpsOrFaceAuthFeatures: " + mHasUdfpsOrFaceAuthFeatures); + pw.println(" mUdfpsEnrolled: " + mUdfpsEnrolled); + pw.println(" mFaceAuthEnrolled: " + mFaceAuthEnrolled); + pw.println(" mIsKeyguardShowing: " + mIsKeyguardShowing); + pw.println(" mIsDozing: " + mIsDozing); + pw.println(" mIsBouncerShowing: " + mIsBouncerShowing); + pw.println(" mRunningFPS: " + mRunningFPS); + pw.println(" mCanDismissLockScreen: " + mCanDismissLockScreen); + pw.println(" mStatusBarState: " + StatusBarState.toShortString(mStatusBarState)); + pw.println(" mQsExpanded: " + mQsExpanded); + } + + private StatusBarStateController.StateListener mStatusBarStateListener = + new StatusBarStateController.StateListener() { + @Override + public void onDozingChanged(boolean isDozing) { + mIsDozing = isDozing; + updateVisibility(); + } + + @Override + public void onStateChanged(int statusBarState) { + mStatusBarState = statusBarState; + updateVisibility(); + } + }; + + private final KeyguardUpdateMonitorCallback mKeyguardUpdateMonitorCallback = + new KeyguardUpdateMonitorCallback() { + @Override + public void onKeyguardBouncerChanged(boolean bouncer) { + mIsBouncerShowing = bouncer; + mIsKeyguardShowing = mKeyguardStateController.isShowing(); + updateVisibility(); + } + + @Override + public void onBiometricRunningStateChanged(boolean running, + BiometricSourceType biometricSourceType) { + if (biometricSourceType == FINGERPRINT) { + mRunningFPS = running; + } + + updateVisibility(); + } + }; + + private final KeyguardStateController.Callback mKeyguardStateCallback = + new KeyguardStateController.Callback() { + @Override + public void onUnlockedChanged() { + mCanDismissLockScreen = mKeyguardStateController.canDismissLockScreen(); + updateVisibility(); + } + @Override + public void onKeyguardShowingChanged() { + mIsKeyguardShowing = mKeyguardStateController.isShowing(); + mUdfpsEnrolled = mKeyguardUpdateMonitor.isUdfpsEnrolled(); + mFaceAuthEnrolled = mKeyguardUpdateMonitor.isFaceEnrolled(); + updateVisibility(); + } + }; +} diff --git a/packages/SystemUI/src/com/android/systemui/biometrics/AuthController.java b/packages/SystemUI/src/com/android/systemui/biometrics/AuthController.java index 28027427e245..ed8f32f31035 100644 --- a/packages/SystemUI/src/com/android/systemui/biometrics/AuthController.java +++ b/packages/SystemUI/src/com/android/systemui/biometrics/AuthController.java @@ -518,6 +518,17 @@ public class AuthController extends SystemUI implements CommandQueue.Callbacks, mCurrentDialog = null; } + /** + * Whether the passed userId has enrolled face auth. + */ + public boolean isFaceAuthEnrolled(int userId) { + if (mFaceProps == null) { + return false; + } + + return mFaceManager.hasEnrolledTemplates(userId); + } + /** * Whether the passed userId has enrolled UDFPS. */ diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java index eef41e045948..b227c7dd131c 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java +++ b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java @@ -2280,18 +2280,16 @@ public class KeyguardViewMediator extends SystemUI implements Dumpable, * @param container * @param panelView * @param biometricUnlockController - * @param lockIconContainer * @param notificationContainer * @param bypassController * @return the View Controller for the Keyguard View this class is mediating. */ public KeyguardViewController registerStatusBar(StatusBar statusBar, ViewGroup container, NotificationPanelViewController panelView, - BiometricUnlockController biometricUnlockController, ViewGroup lockIconContainer, + BiometricUnlockController biometricUnlockController, View notificationContainer, KeyguardBypassController bypassController) { mKeyguardViewControllerLazy.get().registerStatusBar(statusBar, container, panelView, - biometricUnlockController, lockIconContainer, - notificationContainer, bypassController); + biometricUnlockController, notificationContainer, bypassController); return mKeyguardViewControllerLazy.get(); } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/KeyguardIndicationController.java b/packages/SystemUI/src/com/android/systemui/statusbar/KeyguardIndicationController.java index a4e97a1dc6d5..9804b32376eb 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/KeyguardIndicationController.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/KeyguardIndicationController.java @@ -79,7 +79,6 @@ import com.android.systemui.keyguard.KeyguardIndication; import com.android.systemui.keyguard.KeyguardIndicationRotateTextViewController; import com.android.systemui.plugins.statusbar.StatusBarStateController; import com.android.systemui.statusbar.phone.KeyguardIndicationTextView; -import com.android.systemui.statusbar.phone.LockscreenLockIconController; import com.android.systemui.statusbar.phone.StatusBarKeyguardViewManager; import com.android.systemui.statusbar.policy.KeyguardStateController; import com.android.systemui.util.concurrency.DelayableExecutor; @@ -102,8 +101,7 @@ public class KeyguardIndicationController implements KeyguardStateController.Cal private static final boolean DEBUG_CHARGING_SPEED = false; private static final int MSG_HIDE_TRANSIENT = 1; - private static final int MSG_CLEAR_BIOMETRIC_MSG = 2; - private static final int MSG_SWIPE_UP_TO_UNLOCK = 3; + private static final int MSG_SWIPE_UP_TO_UNLOCK = 2; private static final long TRANSIENT_BIOMETRIC_ERROR_TIMEOUT = 1300; private static final float BOUNCE_ANIMATION_FINAL_Y = 0f; @@ -125,7 +123,6 @@ public class KeyguardIndicationController implements KeyguardStateController.Cal protected KeyguardIndicationRotateTextViewController mRotateTextViewController; private BroadcastReceiver mBroadcastReceiver; - private LockscreenLockIconController mLockIconController; private StatusBarKeyguardViewManager mStatusBarKeyguardViewManager; private String mRestingIndication; @@ -225,10 +222,6 @@ public class KeyguardIndicationController implements KeyguardStateController.Cal } } - public void setLockIconController(LockscreenLockIconController lockIconController) { - mLockIconController = lockIconController; - } - private void handleAlignStateChanged(int alignState) { String alignmentIndication = ""; if (alignState == DockManager.ALIGN_STATE_POOR) { @@ -848,10 +841,6 @@ public class KeyguardIndicationController implements KeyguardStateController.Cal public void handleMessage(Message msg) { if (msg.what == MSG_HIDE_TRANSIENT) { hideTransientIndication(); - } else if (msg.what == MSG_CLEAR_BIOMETRIC_MSG) { - if (mLockIconController != null) { - mLockIconController.setTransientBiometricsError(false); - } } else if (msg.what == MSG_SWIPE_UP_TO_UNLOCK) { showSwipeUpToUnlock(); } @@ -972,7 +961,6 @@ public class KeyguardIndicationController implements KeyguardStateController.Cal if (shouldSuppressBiometricError(msgId, biometricSourceType, mKeyguardUpdateMonitor)) { return; } - animatePadlockError(); if (msgId == FaceManager.FACE_ERROR_TIMEOUT) { // The face timeout message is not very actionable, let's ask the user to // manually retry. @@ -988,15 +976,6 @@ public class KeyguardIndicationController implements KeyguardStateController.Cal } } - private void animatePadlockError() { - if (mLockIconController != null) { - mLockIconController.setTransientBiometricsError(true); - } - mHandler.removeMessages(MSG_CLEAR_BIOMETRIC_MSG); - mHandler.sendMessageDelayed(mHandler.obtainMessage(MSG_CLEAR_BIOMETRIC_MSG), - TRANSIENT_BIOMETRIC_ERROR_TIMEOUT); - } - private boolean shouldSuppressBiometricError(int msgId, BiometricSourceType biometricSourceType, KeyguardUpdateMonitor updateMonitor) { if (biometricSourceType == BiometricSourceType.FINGERPRINT) diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardClockPositionAlgorithm.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardClockPositionAlgorithm.java index d6380199e844..f12bf7b53a0a 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardClockPositionAlgorithm.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardClockPositionAlgorithm.java @@ -106,14 +106,9 @@ public class KeyguardClockPositionAlgorithm { private int mMaxShadeBottom; /** - * Recommended distance from the status bar without the lock icon. + * Recommended distance from the status bar. */ - private int mContainerTopPaddingWithoutLockIcon; - - /** - * Recommended distance from the status bar with the lock icon. - */ - private int mContainerTopPaddingWithLockIcon; + private int mContainerTopPadding; /** * @see NotificationPanelViewController#getExpandedFraction() @@ -167,15 +162,8 @@ public class KeyguardClockPositionAlgorithm { mClockNotificationsMargin = res.getDimensionPixelSize( R.dimen.keyguard_clock_notifications_margin); - mContainerTopPaddingWithoutLockIcon = + mContainerTopPadding = res.getDimensionPixelSize(R.dimen.keyguard_clock_top_margin) / 2; - // Consider the lock icon when determining the minimum top padding between the status bar - // and top of the clock. - mContainerTopPaddingWithLockIcon = - Math.max(res.getDimensionPixelSize(R.dimen.keyguard_clock_top_margin), - res.getDimensionPixelSize(R.dimen.keyguard_lock_height) - + res.getDimensionPixelSize(R.dimen.keyguard_lock_padding) - + res.getDimensionPixelSize(R.dimen.keyguard_clock_lock_margin)); mBurnInPreventionOffsetX = res.getDimensionPixelSize( R.dimen.burn_in_prevention_offset_x); mBurnInPreventionOffsetY = res.getDimensionPixelSize( @@ -192,9 +180,8 @@ public class KeyguardClockPositionAlgorithm { int keyguardStatusHeight, int userSwitchHeight, int clockPreferredY, int userSwitchPreferredY, boolean hasCustomClock, boolean hasVisibleNotifs, float dark, float emptyDragAmount, boolean bypassEnabled, int unlockedStackScrollerPadding, - boolean showLockIcon, float qsExpansion, int cutoutTopInset) { - mMinTopMargin = keyguardStatusBarHeaderHeight + Math.max(showLockIcon - ? mContainerTopPaddingWithLockIcon : mContainerTopPaddingWithoutLockIcon, + float qsExpansion, int cutoutTopInset) { + mMinTopMargin = keyguardStatusBarHeaderHeight + Math.max(mContainerTopPadding, userSwitchHeight); mMaxShadeBottom = maxShadeBottom; mNotificationStackHeight = notificationStackHeight; diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/LockscreenLockIconController.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/LockscreenLockIconController.java deleted file mode 100644 index 7011eee054bc..000000000000 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/LockscreenLockIconController.java +++ /dev/null @@ -1,565 +0,0 @@ -/* - * Copyright (C) 2019 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.phone; - -import static android.view.View.GONE; - -import static com.android.systemui.statusbar.phone.LockIcon.STATE_BIOMETRICS_ERROR; -import static com.android.systemui.statusbar.phone.LockIcon.STATE_LOCKED; -import static com.android.systemui.statusbar.phone.LockIcon.STATE_LOCK_OPEN; -import static com.android.systemui.statusbar.phone.LockIcon.STATE_SCANNING_FACE; - -import android.animation.ArgbEvaluator; -import android.content.res.Configuration; -import android.content.res.Resources; -import android.content.res.TypedArray; -import android.graphics.Color; -import android.hardware.biometrics.BiometricSourceType; -import android.view.View; -import android.view.ViewGroup; -import android.view.accessibility.AccessibilityNodeInfo; - -import androidx.annotation.Nullable; - -import com.android.internal.logging.nano.MetricsProto; -import com.android.internal.widget.LockPatternUtils; -import com.android.keyguard.KeyguardUpdateMonitor; -import com.android.keyguard.KeyguardUpdateMonitorCallback; -import com.android.settingslib.Utils; -import com.android.systemui.R; -import com.android.systemui.dagger.qualifiers.Main; -import com.android.systemui.dock.DockManager; -import com.android.systemui.plugins.statusbar.StatusBarStateController; -import com.android.systemui.statusbar.CommandQueue; -import com.android.systemui.statusbar.KeyguardIndicationController; -import com.android.systemui.statusbar.StatusBarState; -import com.android.systemui.statusbar.notification.NotificationWakeUpCoordinator; -import com.android.systemui.statusbar.notification.NotificationWakeUpCoordinator.WakeUpListener; -import com.android.systemui.statusbar.phone.LockscreenGestureLogger.LockscreenUiEvent; -import com.android.systemui.statusbar.phone.dagger.StatusBarComponent; -import com.android.systemui.statusbar.policy.AccessibilityController; -import com.android.systemui.statusbar.policy.ConfigurationController; -import com.android.systemui.statusbar.policy.ConfigurationController.ConfigurationListener; -import com.android.systemui.statusbar.policy.KeyguardStateController; -import com.android.systemui.util.ViewController; - -import java.util.Optional; - -import javax.inject.Inject; - -/** Controls the {@link LockIcon} on the lockscreen. */ -@StatusBarComponent.StatusBarScope -public class LockscreenLockIconController extends ViewController { - - private final LockscreenGestureLogger mLockscreenGestureLogger; - private final KeyguardUpdateMonitor mKeyguardUpdateMonitor; - private final LockPatternUtils mLockPatternUtils; - private final ShadeController mShadeController; - private final AccessibilityController mAccessibilityController; - private final KeyguardIndicationController mKeyguardIndicationController; - private final StatusBarStateController mStatusBarStateController; - private final ConfigurationController mConfigurationController; - private final NotificationWakeUpCoordinator mNotificationWakeUpCoordinator; - private final KeyguardBypassController mKeyguardBypassController; - private final Optional mDockManager; - private final KeyguardStateController mKeyguardStateController; - private final Resources mResources; - private final HeadsUpManagerPhone mHeadsUpManagerPhone; - private boolean mKeyguardShowing; - private boolean mKeyguardJustShown; - private boolean mBlockUpdates; - private boolean mSimLocked; - private boolean mTransientBiometricsError; - private boolean mDocked; - private boolean mWakeAndUnlockRunning; - private boolean mShowingLaunchAffordance; - private float mBouncerHiddenAmount = KeyguardBouncer.EXPANSION_HIDDEN; - private boolean mBouncerShowingScrimmed; - private boolean mFingerprintUnlock; - private int mStatusBarState = StatusBarState.SHADE; - private int mLastState; - private boolean mDozing; - - @Inject - public LockscreenLockIconController( - @Nullable LockIcon view, - LockscreenGestureLogger lockscreenGestureLogger, - KeyguardUpdateMonitor keyguardUpdateMonitor, - LockPatternUtils lockPatternUtils, - ShadeController shadeController, - AccessibilityController accessibilityController, - KeyguardIndicationController keyguardIndicationController, - StatusBarStateController statusBarStateController, - ConfigurationController configurationController, - NotificationWakeUpCoordinator notificationWakeUpCoordinator, - KeyguardBypassController keyguardBypassController, - @Nullable DockManager dockManager, - KeyguardStateController keyguardStateController, - @Main Resources resources, - HeadsUpManagerPhone headsUpManagerPhone) { - super(view); - mLockscreenGestureLogger = lockscreenGestureLogger; - mKeyguardUpdateMonitor = keyguardUpdateMonitor; - mLockPatternUtils = lockPatternUtils; - mShadeController = shadeController; - mAccessibilityController = accessibilityController; - mKeyguardIndicationController = keyguardIndicationController; - mStatusBarStateController = statusBarStateController; - mConfigurationController = configurationController; - mNotificationWakeUpCoordinator = notificationWakeUpCoordinator; - mKeyguardBypassController = keyguardBypassController; - mDockManager = dockManager == null ? Optional.empty() : Optional.of(dockManager); - mKeyguardStateController = keyguardStateController; - mResources = resources; - mHeadsUpManagerPhone = headsUpManagerPhone; - - if (view != null) { - mKeyguardIndicationController.setLockIconController(this); - } - } - - @Override - protected void onInit() { - if (mView == null) { - return; - } - mView.setOnClickListener(this::handleClick); - mView.setOnLongClickListener(this::handleLongClick); - mView.setAccessibilityDelegate(mAccessibilityDelegate); - } - - @Override - protected void onViewAttached() { - setStatusBarState(mStatusBarStateController.getState()); - mDozing = mStatusBarStateController.isDozing(); - mStatusBarStateController.addCallback(mSBStateListener); - mConfigurationController.addCallback(mConfigurationListener); - mNotificationWakeUpCoordinator.addListener(mWakeUpListener); - mKeyguardUpdateMonitor.registerCallback(mUpdateMonitorCallback); - mKeyguardStateController.addCallback(mKeyguardMonitorCallback); - - mDockManager.ifPresent(dockManager -> dockManager.addListener(mDockEventListener)); - - mSimLocked = mKeyguardUpdateMonitor.isSimPinSecure(); - mConfigurationListener.onThemeChanged(); - - updateColor(); - update(); - } - - @Override - protected void onViewDetached() { - mStatusBarStateController.removeCallback(mSBStateListener); - mConfigurationController.removeCallback(mConfigurationListener); - mNotificationWakeUpCoordinator.removeListener(mWakeUpListener); - mKeyguardUpdateMonitor.removeCallback(mUpdateMonitorCallback); - mKeyguardStateController.removeCallback(mKeyguardMonitorCallback); - - mDockManager.ifPresent(dockManager -> dockManager.removeListener(mDockEventListener)); - } - - /** - * Called whenever the scrims become opaque, transparent or semi-transparent. - */ - public void onScrimVisibilityChanged(Integer scrimsVisible) { - if (mWakeAndUnlockRunning - && scrimsVisible == ScrimController.TRANSPARENT) { - mWakeAndUnlockRunning = false; - update(); - } - } - - /** - * We need to hide the lock whenever there's a fingerprint unlock, otherwise you'll see the - * icon on top of the black front scrim. - * We also want to halt padlock the animation when we're in face bypass mode or dismissing the - * keyguard with fingerprint. - * @param wakeAndUnlock are we wake and unlocking - * @param isUnlock are we currently unlocking - */ - public void onBiometricAuthModeChanged(boolean wakeAndUnlock, boolean isUnlock, - BiometricSourceType type) { - if (wakeAndUnlock) { - mWakeAndUnlockRunning = true; - } - mFingerprintUnlock = type == BiometricSourceType.FINGERPRINT; - if (isUnlock && (mFingerprintUnlock || mKeyguardBypassController.getBypassEnabled()) - && canBlockUpdates()) { - // We don't want the icon to change while we are unlocking - mBlockUpdates = true; - } - update(); - } - - /** - * When we're launching an affordance, like double pressing power to open camera. - */ - public void onShowingLaunchAffordanceChanged(Boolean showing) { - mShowingLaunchAffordance = showing; - update(); - } - - /** Sets whether the bouncer is showing. */ - public void setBouncerShowingScrimmed(boolean showing, boolean scrimmed) { - mBouncerShowingScrimmed = scrimmed; - update(); - } - - /** - * Sets how hidden the bouncer is, where 0f is fully visible and 1f is fully hidden - * See {@link KeyguardBouncer#EXPANSION_VISIBLE} and {@link KeyguardBouncer#EXPANSION_HIDDEN}. - */ - public void setBouncerHideAmount(float hideAmount) { - mBouncerHiddenAmount = hideAmount; - updateColor(); - } - - private void updateColor() { - if (mView == null) { - return; - } - int iconColor = -1; - if (mBouncerHiddenAmount == KeyguardBouncer.EXPANSION_VISIBLE) { - TypedArray typedArray = mView.getContext().getTheme().obtainStyledAttributes( - null, new int[]{ android.R.attr.textColorPrimary }, 0, 0); - iconColor = typedArray.getColor(0, Color.WHITE); - typedArray.recycle(); - } else if (mBouncerHiddenAmount == KeyguardBouncer.EXPANSION_HIDDEN) { - iconColor = Utils.getColorAttrDefaultColor( - mView.getContext(), com.android.systemui.R.attr.wallpaperTextColor); - } else { - // bouncer is transitioning - TypedArray typedArray = mView.getContext().getTheme().obtainStyledAttributes( - null, new int[]{ android.R.attr.textColorPrimary }, 0, 0); - int bouncerIconColor = typedArray.getColor(0, Color.WHITE); - typedArray.recycle(); - int keyguardIconColor = Utils.getColorAttrDefaultColor( - mView.getContext(), com.android.systemui.R.attr.wallpaperTextColor); - iconColor = (int) new ArgbEvaluator().evaluate( - mBouncerHiddenAmount, bouncerIconColor, keyguardIconColor); - } - mView.updateColor(iconColor); - } - - /** - * Animate padlock opening when bouncer challenge is solved. - */ - public void onBouncerPreHideAnimation() { - update(); - } - - /** - * If we're currently presenting an authentication error message. - */ - public void setTransientBiometricsError(boolean transientBiometricsError) { - mTransientBiometricsError = transientBiometricsError; - update(); - } - - private boolean handleLongClick(View view) { - mLockscreenGestureLogger.write(MetricsProto.MetricsEvent.ACTION_LS_LOCK, - 0 /* lengthDp - N/A */, 0 /* velocityDp - N/A */); - mLockscreenGestureLogger.log(LockscreenUiEvent.LOCKSCREEN_LOCK_TAP); - mKeyguardIndicationController.showTransientIndication( - R.string.keyguard_indication_trust_disabled); - mKeyguardUpdateMonitor.onLockIconPressed(); - mLockPatternUtils.requireCredentialEntry(KeyguardUpdateMonitor.getCurrentUser()); - - return true; - } - - - private void handleClick(View view) { - if (!mAccessibilityController.isAccessibilityEnabled()) { - return; - } - mShadeController.animateCollapsePanels(CommandQueue.FLAG_EXCLUDE_NONE, true /* force */); - } - - private void update() { - update(false /* force */); - } - - private void update(boolean force) { - if (mView == null) { - return; - } - int state = getState(); - boolean shouldUpdate = mLastState != state || force; - if (mBlockUpdates && canBlockUpdates()) { - shouldUpdate = false; - } - if (shouldUpdate && mView.getVisibility() != GONE) { - mView.update(state, mDozing, mKeyguardJustShown); - } - mLastState = state; - mKeyguardJustShown = false; - updateIconVisibility(); - updateClickability(); - } - - private int getState() { - if ((mKeyguardStateController.canDismissLockScreen() - || !mKeyguardStateController.isShowing() - || mKeyguardStateController.isKeyguardGoingAway() - || mKeyguardStateController.isKeyguardFadingAway()) && !mSimLocked) { - return STATE_LOCK_OPEN; - } else if (mTransientBiometricsError) { - return STATE_BIOMETRICS_ERROR; - } else if (mKeyguardUpdateMonitor.isFaceDetectionRunning()) { - return STATE_SCANNING_FACE; - } else { - return STATE_LOCKED; - } - } - - private boolean canBlockUpdates() { - return mKeyguardShowing || mKeyguardStateController.isKeyguardFadingAway(); - } - - /** Set the StatusBarState. */ - private void setStatusBarState(int statusBarState) { - mStatusBarState = statusBarState; - updateIconVisibility(); - } - - /** - * Update the icon visibility - * @return true if the visibility changed - */ - private boolean updateIconVisibility() { - if (mView == null) { - return false; - } - if (!mKeyguardUpdateMonitor.canShowLockIcon()) { - boolean changed = mView.getVisibility() != GONE; - mView.setVisibility(GONE); - return changed; - } - - boolean onAodOrDocked = mDozing || mDocked; - boolean invisible = onAodOrDocked || mWakeAndUnlockRunning || mShowingLaunchAffordance; - boolean fingerprintOrBypass = mFingerprintUnlock - || mKeyguardBypassController.getBypassEnabled(); - if (fingerprintOrBypass && !mBouncerShowingScrimmed) { - if ((mHeadsUpManagerPhone.isHeadsUpGoingAway() - || mHeadsUpManagerPhone.hasPinnedHeadsUp() - || mStatusBarState == StatusBarState.KEYGUARD - || mStatusBarState == StatusBarState.SHADE) - && !mNotificationWakeUpCoordinator.getNotificationsFullyHidden()) { - invisible = true; - } - } - return mView.updateIconVisibility(!invisible); - } - - private void updateClickability() { - if (mView == null) { - return; - } - boolean canLock = mKeyguardStateController.isMethodSecure() - && mKeyguardStateController.canDismissLockScreen(); - boolean clickToUnlock = mAccessibilityController.isAccessibilityEnabled(); - mView.setClickable(clickToUnlock); - mView.setLongClickable(canLock && !clickToUnlock); - mView.setFocusable(mAccessibilityController.isAccessibilityEnabled()); - } - - private final StatusBarStateController.StateListener mSBStateListener = - new StatusBarStateController.StateListener() { - @Override - public void onDozingChanged(boolean isDozing) { - if (mDozing != isDozing) { - mDozing = isDozing; - update(); - } - } - - @Override - public void onDozeAmountChanged(float linear, float eased) { - if (mView != null) { - mView.setDozeAmount(eased); - } - } - - @Override - public void onStateChanged(int newState) { - setStatusBarState(newState); - } - }; - - private final ConfigurationListener mConfigurationListener = new ConfigurationListener() { - private int mDensity; - - @Override - public void onUiModeChanged() { - updateColor(); - } - - @Override - public void onOverlayChanged() { - updateColor(); - } - - @Override - public void onDensityOrFontScaleChanged() { - ViewGroup.LayoutParams lp = mView.getLayoutParams(); - if (lp == null) { - return; - } - lp.width = mView.getResources().getDimensionPixelSize(R.dimen.keyguard_lock_width); - lp.height = mView.getResources().getDimensionPixelSize( - R.dimen.keyguard_lock_height); - mView.setLayoutParams(lp); - update(true /* force */); - } - - @Override - public void onLocaleListChanged() { - mView.setContentDescription( - mView.getResources().getText(R.string.accessibility_unlock_button)); - update(true /* force */); - } - - @Override - public void onConfigChanged(Configuration newConfig) { - final int density = newConfig.densityDpi; - if (density != mDensity) { - mDensity = density; - update(); - } - } - }; - - private final WakeUpListener mWakeUpListener = new WakeUpListener() { - @Override - public void onPulseExpansionChanged(boolean expandingChanged) { - } - - @Override - public void onFullyHiddenChanged(boolean isFullyHidden) { - if (mKeyguardBypassController.getBypassEnabled()) { - boolean changed = updateIconVisibility(); - if (changed) { - update(); - } - } - } - }; - - private final KeyguardUpdateMonitorCallback mUpdateMonitorCallback = - new KeyguardUpdateMonitorCallback() { - @Override - public void onSimStateChanged(int subId, int slotId, int simState) { - mSimLocked = mKeyguardUpdateMonitor.isSimPinSecure(); - update(); - } - - @Override - public void onKeyguardVisibilityChanged(boolean showing) { - update(); - } - - @Override - public void onBiometricRunningStateChanged(boolean running, - BiometricSourceType biometricSourceType) { - update(); - } - - @Override - public void onStrongAuthStateChanged(int userId) { - update(); - } - }; - - private final DockManager.DockEventListener mDockEventListener = - event -> { - boolean docked = - event == DockManager.STATE_DOCKED || event == DockManager.STATE_DOCKED_HIDE; - if (docked != mDocked) { - mDocked = docked; - update(); - } - }; - - private final KeyguardStateController.Callback mKeyguardMonitorCallback = - new KeyguardStateController.Callback() { - @Override - public void onKeyguardShowingChanged() { - boolean force = false; - boolean wasShowing = mKeyguardShowing; - mKeyguardShowing = mKeyguardStateController.isShowing(); - if (!wasShowing && mKeyguardShowing && mBlockUpdates) { - mBlockUpdates = false; - force = true; - } - if (!wasShowing && mKeyguardShowing) { - setBouncerHideAmount(KeyguardBouncer.EXPANSION_HIDDEN); - mKeyguardJustShown = true; - } - update(force); - } - - @Override - public void onKeyguardFadingAwayChanged() { - if (!mKeyguardStateController.isKeyguardFadingAway()) { - if (mBlockUpdates) { - mBlockUpdates = false; - update(true /* force */); - } - } - } - - @Override - public void onUnlockedChanged() { - update(); - } - }; - - private final View.AccessibilityDelegate mAccessibilityDelegate = - new View.AccessibilityDelegate() { - @Override - public void onInitializeAccessibilityNodeInfo(View host, - AccessibilityNodeInfo info) { - super.onInitializeAccessibilityNodeInfo(host, info); - boolean fingerprintRunning = - mKeyguardUpdateMonitor.isFingerprintDetectionRunning(); - // Only checking if unlocking with Biometric is allowed (no matter strong or - // non-strong as long as primary auth, i.e. PIN/pattern/password, is not - // required), so it's ok to pass true for isStrongBiometric to - // isUnlockingWithBiometricAllowed() to bypass the check of whether non-strong - // biometric is allowed - boolean unlockingAllowed = mKeyguardUpdateMonitor - .isUnlockingWithBiometricAllowed(true /* isStrongBiometric */); - if (fingerprintRunning && unlockingAllowed) { - AccessibilityNodeInfo.AccessibilityAction unlock = - new AccessibilityNodeInfo.AccessibilityAction( - AccessibilityNodeInfo.ACTION_CLICK, - mResources.getString( - R.string.accessibility_unlock_without_fingerprint)); - info.addAction(unlock); - info.setHintText(mResources.getString( - R.string.accessibility_waiting_for_fingerprint)); - } else if (getState() == STATE_SCANNING_FACE) { - //Avoid 'button' to be spoken for scanning face - info.setClassName(LockIcon.class.getName()); - info.setContentDescription(mResources.getString( - R.string.accessibility_scanning_face)); - } - } - }; -} diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelViewController.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelViewController.java index 606658910232..d29a1aebe5cd 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelViewController.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelViewController.java @@ -75,12 +75,12 @@ import com.android.internal.jank.InteractionJankMonitor; import com.android.internal.logging.MetricsLogger; import com.android.internal.logging.nano.MetricsProto.MetricsEvent; import com.android.internal.util.LatencyTracker; -import com.android.keyguard.DisabledUdfpsController; import com.android.keyguard.KeyguardClockSwitchController; import com.android.keyguard.KeyguardStatusView; import com.android.keyguard.KeyguardStatusViewController; import com.android.keyguard.KeyguardUpdateMonitor; import com.android.keyguard.KeyguardUpdateMonitorCallback; +import com.android.keyguard.LockIconViewController; import com.android.keyguard.dagger.KeyguardQsUserSwitchComponent; import com.android.keyguard.dagger.KeyguardStatusBarViewComponent; import com.android.keyguard.dagger.KeyguardStatusViewComponent; @@ -281,13 +281,6 @@ public class NotificationPanelViewController extends PanelViewController { mFirstBypassAttempt = mKeyguardBypassController.getBypassEnabled(); mDelayShowingKeyguardStatusBar = false; } - - @Override - public void onKeyguardVisibilityChanged(boolean showing) { - if (showing) { - updateDisabledUdfpsController(); - } - } }; private final LayoutInflater mLayoutInflater; @@ -325,7 +318,7 @@ public class NotificationPanelViewController extends PanelViewController { private QS mQs; private FrameLayout mQsFrame; private KeyguardStatusViewController mKeyguardStatusViewController; - private DisabledUdfpsController mDisabledUdfpsController; + private LockIconViewController mLockIconViewController; private NotificationsQuickSettingsContainer mNotificationContainerParent; private boolean mAnimateNextPositionUpdate; @@ -493,7 +486,6 @@ public class NotificationPanelViewController extends PanelViewController { */ private int mThemeResId; private KeyguardIndicationController mKeyguardIndicationController; - private Consumer mAffordanceLaunchListener; private int mShelfHeight; private int mDarkIconSize; private int mHeadsUpInset; @@ -584,6 +576,7 @@ public class NotificationPanelViewController extends PanelViewController { MediaDataManager mediaDataManager, NotificationShadeDepthController notificationShadeDepthController, AmbientState ambientState, + LockIconViewController lockIconViewController, FeatureFlags featureFlags) { super(view, falsingManager, dozeLog, keyguardStateController, (SysuiStatusBarStateController) statusBarStateController, vibratorHelper, @@ -668,6 +661,7 @@ public class NotificationPanelViewController extends PanelViewController { mEntryManager = notificationEntryManager; mConversationNotificationManager = conversationNotificationManager; mAuthController = authController; + mLockIconViewController = lockIconViewController; mView.setBackgroundColor(Color.TRANSPARENT); OnAttachStateChangeListener onAttachStateChangeListener = new OnAttachStateChangeListener(); @@ -704,7 +698,8 @@ public class NotificationPanelViewController extends PanelViewController { } } - updateViewControllers(mView.findViewById(R.id.keyguard_status_view), + updateViewControllers( + mView.findViewById(R.id.keyguard_status_view), userAvatarView, mKeyguardStatusBar, keyguardUserSwitcherView); @@ -849,13 +844,6 @@ public class NotificationPanelViewController extends PanelViewController { mStatusBar = bar; mKeyguardBottomArea.setStatusBar(mStatusBar); } - /** - * @see #launchCamera(boolean, int) - * @see #setLaunchingAffordance(boolean) - */ - public void setLaunchAffordanceListener(Consumer listener) { - mAffordanceLaunchListener = listener; - } public void updateResources() { int qsWidth = mResources.getDimensionPixelSize(R.dimen.qs_panel_width); @@ -1091,7 +1079,6 @@ public class NotificationPanelViewController extends PanelViewController { clockPreferredY, userSwitcherPreferredY, hasCustomClock(), hasVisibleNotifications, mInterpolatedDarkAmount, mEmptyDragAmount, bypassEnabled, getUnlockedStackScrollerPadding(), - mUpdateMonitor.canShowLockIcon(), getQsExpansionFraction(), mDisplayCutoutTopInset); mClockPositionAlgorithm.run(mClockPositionResult); @@ -1142,19 +1129,23 @@ public class NotificationPanelViewController extends PanelViewController { mNotificationShelfController.getVisibility() == View.GONE ? 0 : mNotificationShelfController.getIntrinsicHeight() + notificationPadding; - float availableSpace = - mNotificationStackScrollLayoutController.getHeight() - minPadding - shelfSize - - Math.max(mIndicationBottomPadding, mAmbientIndicationBottomPadding) - - mKeyguardStatusViewController.getLogoutButtonHeight(); - if (mUpdateMonitor.isUdfpsEnrolled()) { - availableSpace = mNotificationStackScrollLayoutController.getHeight() - - minPadding - shelfSize - - mKeyguardStatusViewController.getOwnerInfoHeight() - - mKeyguardStatusViewController.getLogoutButtonHeight() - - (mStatusBar.getDisplayHeight() - mAuthController.getUdfpsRegion().top); + float lockIconPadding = 0; + if (mLockIconViewController.getTop() != 0 + && (mUpdateMonitor.isUdfpsEnrolled() || mUpdateMonitor.isFaceEnrolled())) { + lockIconPadding = mStatusBar.getDisplayHeight() - mLockIconViewController.getTop(); } + float bottomPadding = Math.max(mIndicationBottomPadding, mAmbientIndicationBottomPadding); + bottomPadding = Math.max(lockIconPadding, bottomPadding); + + float availableSpace = + mNotificationStackScrollLayoutController.getHeight() + - minPadding + - shelfSize + - bottomPadding + - mKeyguardStatusViewController.getLogoutButtonHeight(); + int count = 0; ExpandableView previousView = null; for (int i = 0; i < mNotificationStackScrollLayoutController.getChildCount(); i++) { @@ -1851,10 +1842,7 @@ public class NotificationPanelViewController extends PanelViewController { mPulseExpansionHandler.setQsExpanded(expanded); mKeyguardBypassController.setQSExpanded(expanded); mStatusBarKeyguardViewManager.setQsExpanded(expanded); - - if (mDisabledUdfpsController != null) { - mDisabledUdfpsController.setQsExpanded(expanded); - } + mLockIconViewController.setQsExpanded(expanded); } } @@ -3045,9 +3033,6 @@ public class NotificationPanelViewController extends PanelViewController { mKeyguardAffordanceHelperCallback.getRightIcon().setLaunchingAffordance( launchingAffordance); mKeyguardBypassController.setLaunchingAffordance(launchingAffordance); - if (mAffordanceLaunchListener != null) { - mAffordanceLaunchListener.accept(launchingAffordance); - } } /** @@ -3287,9 +3272,6 @@ public class NotificationPanelViewController extends PanelViewController { if (mKeyguardStatusBar != null) { mKeyguardStatusBar.dump(fd, pw, args); } - if (mDisabledUdfpsController != null) { - mDisabledUdfpsController.dump(fd, pw, args); - } } public boolean hasActiveClearableNotifications() { @@ -3543,27 +3525,6 @@ public class NotificationPanelViewController extends PanelViewController { return false; } - private void updateDisabledUdfpsController() { - final boolean udfpsEnrolled = mAuthController.getUdfpsRegion() != null - && mAuthController.isUdfpsEnrolled( - KeyguardUpdateMonitor.getCurrentUser()); - if (mDisabledUdfpsController == null && udfpsEnrolled) { - mLayoutInflater.inflate(R.layout.disabled_udfps_view, mView); - mDisabledUdfpsController = new DisabledUdfpsController( - mView.findViewById(R.id.disabled_udfps_view), - mStatusBarStateController, - mUpdateMonitor, - mAuthController, - mStatusBarKeyguardViewManager, - mKeyguardStateController, - mFalsingManager); - mDisabledUdfpsController.init(); - } else if (mDisabledUdfpsController != null && !udfpsEnrolled) { - mDisabledUdfpsController.destroy(); - mDisabledUdfpsController = null; - } - } - private class OnHeightChangedListener implements ExpandableView.OnHeightChangedListener { @Override public void onHeightChanged(ExpandableView view, boolean needsAnimation) { @@ -3983,7 +3944,6 @@ public class NotificationPanelViewController extends PanelViewController { FragmentHostManager.get(mView).addTagListener(QS.TAG, mFragmentListener); mStatusBarStateController.addCallback(mStatusBarStateListener); mConfigurationController.addCallback(mConfigurationListener); - updateDisabledUdfpsController(); mUpdateMonitor.registerCallback(mKeyguardUpdateCallback); // Theme might have changed between inflating this view and attaching it to the // window, so diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java index f66b7a898950..7a2d4bde3787 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java @@ -430,7 +430,6 @@ public class StatusBar extends SystemUI implements DemoMode, // expanded notifications // the sliding/resizing panel within the notification window protected NotificationPanelViewController mNotificationPanelViewController; - protected LockscreenLockIconController mLockscreenLockIconController; // settings private QSPanelController mQSPanelController; @@ -1221,7 +1220,6 @@ public class StatusBar extends SystemUI implements DemoMode, mScrimController.setScrimVisibleListener(scrimsVisible -> { mNotificationShadeWindowController.setScrimsVisibility(scrimsVisible); - mLockscreenLockIconController.onScrimVisibilityChanged(scrimsVisible); }); mScrimController.attachViews(scrimBehind, scrimInFront, scrimForBubble); @@ -1519,12 +1517,8 @@ public class StatusBar extends SystemUI implements DemoMode, mStatusBarWindowController = statusBarComponent.getStatusBarWindowController(); mPhoneStatusBarWindow = mSuperStatusBarViewFactory.getStatusBarWindowView(); mNotificationPanelViewController = statusBarComponent.getNotificationPanelViewController(); - mLockscreenLockIconController = statusBarComponent.getLockscreenLockIconController(); - mLockscreenLockIconController.init(); + statusBarComponent.getLockIconViewController().init(); statusBarComponent.getAuthRippleController().init(); - - mNotificationPanelViewController.setLaunchAffordanceListener( - mLockscreenLockIconController::onShowingLaunchAffordanceChanged); } protected void startKeyguard() { @@ -1561,7 +1555,6 @@ public class StatusBar extends SystemUI implements DemoMode, mStatusBarKeyguardViewManager.registerStatusBar( /* statusBar= */ this, getBouncerContainer(), mNotificationPanelViewController, mBiometricUnlockController, - mNotificationShadeWindowView.findViewById(R.id.lock_icon_container), mStackScroller, mKeyguardBypassController); mKeyguardIndicationController .setStatusBarKeyguardViewManager(mStatusBarKeyguardViewManager); @@ -3877,8 +3870,6 @@ public class StatusBar extends SystemUI implements DemoMode, mBouncerShowing = bouncerShowing; mKeyguardBypassController.setBouncerShowing(bouncerShowing); mPulseExpansionHandler.setBouncerShowing(bouncerShowing); - mLockscreenLockIconController.setBouncerShowingScrimmed(bouncerShowing, - isBouncerShowingScrimmed()); if (mStatusBarView != null) mStatusBarView.setBouncerShowing(bouncerShowing); updateHideIconsForBouncer(true /* animate */); mCommandQueue.recomputeDisableFlags(mDisplayId, true /* animate */); @@ -3888,14 +3879,6 @@ public class StatusBar extends SystemUI implements DemoMode, } } - /** - * Sets how hidden the bouncer is, where 0f is fully visible and 1f is fully hidden - * See {@link KeyguardBouncer#EXPANSION_VISIBLE} and {@link KeyguardBouncer#EXPANSION_HIDDEN}. - */ - public void setBouncerHideAmount(float hideAmount) { - mLockscreenLockIconController.setBouncerHideAmount(hideAmount); - } - /** * Collapses the notification shade if it is tracking or expanded. */ @@ -4248,10 +4231,6 @@ public class StatusBar extends SystemUI implements DemoMode, public void notifyBiometricAuthModeChanged() { mDozeServiceHost.updateDozing(); updateScrimController(); - mLockscreenLockIconController.onBiometricAuthModeChanged( - mBiometricUnlockController.isWakeAndUnlock(), - mBiometricUnlockController.isBiometricUnlock(), - mBiometricUnlockController.getBiometricType()); } /** @@ -4679,7 +4658,7 @@ public class StatusBar extends SystemUI implements DemoMode, */ public void onBouncerPreHideAnimation() { mNotificationPanelViewController.onBouncerPreHideAnimation(); - mLockscreenLockIconController.onBouncerPreHideAnimation(); + } /** diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManager.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManager.java index 2815ce7002d0..18644a224fb5 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManager.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManager.java @@ -26,17 +26,13 @@ import static com.android.systemui.statusbar.phone.BiometricUnlockController.MOD import android.content.ComponentCallbacks2; import android.content.Context; import android.content.res.ColorStateList; -import android.content.res.Configuration; import android.os.Bundle; import android.os.SystemClock; -import android.util.TypedValue; -import android.view.Gravity; import android.view.KeyEvent; import android.view.View; import android.view.ViewGroup; import android.view.ViewRootImpl; import android.view.WindowManagerGlobal; -import android.widget.FrameLayout; import androidx.annotation.Nullable; import androidx.annotation.VisibleForTesting; @@ -47,7 +43,6 @@ import com.android.keyguard.KeyguardUpdateMonitor; import com.android.keyguard.KeyguardUpdateMonitorCallback; import com.android.keyguard.KeyguardViewController; import com.android.keyguard.ViewMediatorCallback; -import com.android.settingslib.animation.AppearAnimationUtils; import com.android.systemui.DejankUtils; import com.android.systemui.dagger.SysUISingleton; import com.android.systemui.dock.DockManager; @@ -56,11 +51,9 @@ import com.android.systemui.navigationbar.NavigationModeController; import com.android.systemui.plugins.statusbar.StatusBarStateController; import com.android.systemui.shared.system.QuickStepContract; import com.android.systemui.shared.system.SysUiStatsLog; -import com.android.systemui.statusbar.CrossFadeHelper; import com.android.systemui.statusbar.NotificationMediaManager; import com.android.systemui.statusbar.NotificationShadeWindowController; import com.android.systemui.statusbar.RemoteInputController; -import com.android.systemui.statusbar.StatusBarState; import com.android.systemui.statusbar.SysuiStatusBarStateController; import com.android.systemui.statusbar.notification.ViewGroupFadeHelper; import com.android.systemui.statusbar.phone.KeyguardBouncer.BouncerExpansionCallback; @@ -112,7 +105,6 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb public void onFullyShown() { updateStates(); mStatusBar.wakeUpIfDozing(SystemClock.uptimeMillis(), mContainer, "BOUNCER_VISIBLE"); - updateLockIcon(); } @Override @@ -123,18 +115,11 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb @Override public void onStartingToShow() { updateStates(); - updateLockIcon(); } @Override public void onFullyHidden() { updateStates(); - updateLockIcon(); - } - - @Override - public void onExpansionChanged(float hideAmount) { - mStatusBar.setBouncerHideAmount(hideAmount); } }; private final DockManager.DockEventListener mDockEventListener = @@ -157,7 +142,6 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb private BiometricUnlockController mBiometricUnlockController; private ViewGroup mContainer; - private ViewGroup mLockIconContainer; private View mNotificationContainer; protected KeyguardBouncer mBouncer; @@ -170,8 +154,6 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb private boolean mPulsing; private boolean mGesturalNav; private boolean mIsDocked; - private boolean mIsPortraitMode; - private int mScreenWidthDp; protected boolean mFirstUpdate = true; protected boolean mLastShowing; @@ -185,8 +167,6 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb private boolean mLastIsDocked; private boolean mLastPulsing; private int mLastBiometricMode; - private boolean mLastLockVisible; - private boolean mLastLockOrientationIsPortrait; private boolean mQsExpanded; private OnDismissAction mAfterKeyguardGoneAction; @@ -251,14 +231,10 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb ViewGroup container, NotificationPanelViewController notificationPanelViewController, BiometricUnlockController biometricUnlockController, - ViewGroup lockIconContainer, View notificationContainer, + View notificationContainer, KeyguardBypassController bypassController) { mStatusBar = statusBar; mContainer = container; - mLockIconContainer = lockIconContainer; - if (mLockIconContainer != null) { - mLastLockVisible = mLockIconContainer.getVisibility() == View.VISIBLE; - } mBiometricUnlockController = biometricUnlockController; mBouncer = mKeyguardBouncerFactory.create(container, mExpansionCallback); mNotificationPanelViewController = notificationPanelViewController; @@ -282,9 +258,6 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb mKeyguardUpdateManager.registerCallback(mUpdateMonitorCallback); mStatusBarStateController.addCallback(this); mConfigurationController.addCallback(this); - mIsPortraitMode = mContext.getResources().getConfiguration().orientation - == Configuration.ORIENTATION_PORTRAIT; - mScreenWidthDp = mContext.getResources().getConfiguration().screenWidthDp; mGesturalNav = QuickStepContract.isGesturalMode( mNavigationModeController.addListener(this)); if (mDockManager != null) { @@ -298,13 +271,6 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb hideBouncer(true /* destroyView */); } - @Override - public void onConfigChanged(Configuration newConfig) { - mIsPortraitMode = newConfig.orientation == Configuration.ORIENTATION_PORTRAIT; - mScreenWidthDp = newConfig.screenWidthDp; - updateLockIcon(); - } - @Override public void onPanelExpansionChanged(float expansion, boolean tracking) { // We don't want to translate the bounce when: @@ -333,11 +299,6 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb } } - @Override - public void onQsExpansionChanged(float expansion) { - updateLockIcon(); - } - /** * Update the global actions visibility state in order to show the navBar when active. */ @@ -346,55 +307,6 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb updateStates(); } - private void updateLockIcon() { - // Not all form factors have a lock icon - if (mLockIconContainer == null) { - return; - } - - boolean keyguardWithoutQs = mStatusBarStateController.getState() == StatusBarState.KEYGUARD - && !mNotificationPanelViewController.isQsExpanded(); - boolean lockVisible = (mBouncer.isShowing() || keyguardWithoutQs) - && !mBouncer.isAnimatingAway() && !mKeyguardStateController.isKeyguardFadingAway(); - boolean orientationChange = - lockVisible && (mLastLockOrientationIsPortrait != mIsPortraitMode); - - if (mLastLockVisible != lockVisible || orientationChange) { - mLastLockVisible = lockVisible; - mLastLockOrientationIsPortrait = mIsPortraitMode; - if (lockVisible) { - FrameLayout.LayoutParams lp = - (FrameLayout.LayoutParams) mLockIconContainer.getLayoutParams(); - if (mIsPortraitMode) { - lp.gravity = Gravity.TOP | Gravity.CENTER_HORIZONTAL; - } else { - final int width = (int) TypedValue.applyDimension( - TypedValue.COMPLEX_UNIT_DIP, - mScreenWidthDp, - mContext.getResources().getDisplayMetrics()) / 3; - mLockIconContainer.setMinimumWidth(width); - lp.gravity = Gravity.TOP | Gravity.LEFT; - } - mLockIconContainer.setLayoutParams(lp); - - CrossFadeHelper.fadeIn(mLockIconContainer, - AppearAnimationUtils.DEFAULT_APPEAR_DURATION /* duration */, - 0 /* delay */); - } else { - final long duration; - final int delay; - if (needsBypassFading()) { - duration = KeyguardBypassController.BYPASS_PANEL_FADE_DURATION; - delay = 0; - } else { - duration = AppearAnimationUtils.DEFAULT_APPEAR_DURATION / 2; - delay = 120; - } - CrossFadeHelper.fadeOut(mLockIconContainer, duration, delay, null /* runnable */); - } - } - } - /** * Show the keyguard. Will handle creating and attaching to the view manager * lazily. @@ -646,7 +558,6 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb finishRunnable.run(); } mNotificationPanelViewController.blockExpansionForCurrentTouch(); - updateLockIcon(); } @Override @@ -736,7 +647,6 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb mBiometricUnlockController.finishKeyguardFadingAway(); } } - updateLockIcon(); updateStates(); mNotificationShadeWindowController.setKeyguardShowing(false); mViewMediatorCallback.keyguardGone(); @@ -918,7 +828,6 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb if (bouncerShowing != mLastBouncerShowing || mFirstUpdate) { mNotificationShadeWindowController.setBouncerShowing(bouncerShowing); mStatusBar.setBouncerShowing(bouncerShowing); - updateLockIcon(); } if ((showing && !occluded) != (mLastShowing && !mLastOccluded) || mFirstUpdate) { @@ -1118,11 +1027,6 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb } } - @Override - public void onStateChanged(int newState) { - updateLockIcon(); - } - @Override public void onDozingChanged(boolean isDozing) { setDozing(isDozing); diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/dagger/StatusBarComponent.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/dagger/StatusBarComponent.java index e0cbbf0e0824..fb25ae37ea74 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/dagger/StatusBarComponent.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/dagger/StatusBarComponent.java @@ -18,8 +18,8 @@ package com.android.systemui.statusbar.phone.dagger; import static java.lang.annotation.RetentionPolicy.RUNTIME; +import com.android.keyguard.LockIconViewController; import com.android.systemui.biometrics.AuthRippleController; -import com.android.systemui.statusbar.phone.LockscreenLockIconController; import com.android.systemui.statusbar.phone.NotificationPanelViewController; import com.android.systemui.statusbar.phone.NotificationShadeWindowView; import com.android.systemui.statusbar.phone.NotificationShadeWindowViewController; @@ -76,13 +76,13 @@ public interface StatusBarComponent { NotificationPanelViewController getNotificationPanelViewController(); /** - * Creates a LockscreenLockIconController. + * Creates a LockIconViewController. Must be init after creation. */ @StatusBarScope - LockscreenLockIconController getLockscreenLockIconController(); + LockIconViewController getLockIconViewController(); /** - * Creates an AuthRippleController + * Creates an AuthRippleViewController. Must be init after creation. */ @StatusBarScope AuthRippleController getAuthRippleController(); diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/dagger/StatusBarViewModule.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/dagger/StatusBarViewModule.java index 0ce7538a6566..008c0aea7ce9 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/dagger/StatusBarViewModule.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/dagger/StatusBarViewModule.java @@ -18,9 +18,9 @@ package com.android.systemui.statusbar.phone.dagger; import android.annotation.Nullable; +import com.android.keyguard.LockIconView; import com.android.systemui.R; import com.android.systemui.biometrics.AuthRippleView; -import com.android.systemui.statusbar.phone.LockIcon; import com.android.systemui.statusbar.phone.NotificationPanelView; import com.android.systemui.statusbar.phone.NotificationShadeWindowView; @@ -40,10 +40,9 @@ public abstract class StatusBarViewModule { /** */ @Provides @StatusBarComponent.StatusBarScope - @Nullable - public static LockIcon getLockIcon( + public static LockIconView getLockIconView( NotificationShadeWindowView notificationShadeWindowView) { - return notificationShadeWindowView.findViewById(R.id.lock_icon); + return notificationShadeWindowView.findViewById(R.id.lock_icon_view); } /** */ diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/KeyguardClockPositionAlgorithmTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/KeyguardClockPositionAlgorithmTest.java index 9b623f950505..02e2e4c793bc 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/KeyguardClockPositionAlgorithmTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/KeyguardClockPositionAlgorithmTest.java @@ -396,7 +396,7 @@ public class KeyguardClockPositionAlgorithmTest extends SysuiTestCase { mPanelExpansion, SCREEN_HEIGHT, mKeyguardStatusHeight, 0 /* userSwitchHeight */, mPreferredClockY, 0 /* userSwitchPreferredY */, mHasCustomClock, mHasVisibleNotifs, mDark, ZERO_DRAG, false /* bypassEnabled */, - 0 /* unlockedStackScrollerPadding */, false /* udfpsEnrolled */, mQsExpansion, + 0 /* unlockedStackScrollerPadding */, mQsExpansion, mCutoutTopInset); mClockPositionAlgorithm.run(mClockPosition); } diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/LockscreenIconControllerTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/LockscreenIconControllerTest.java deleted file mode 100644 index 60af16acbb7e..000000000000 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/LockscreenIconControllerTest.java +++ /dev/null @@ -1,151 +0,0 @@ -/* - * Copyright (C) 2020 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.phone; - -import static org.mockito.ArgumentMatchers.anyInt; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - -import android.content.res.Resources; -import android.view.View; -import android.view.View.OnAttachStateChangeListener; - -import androidx.test.filters.SmallTest; -import androidx.test.runner.AndroidJUnit4; - -import com.android.internal.widget.LockPatternUtils; -import com.android.keyguard.KeyguardUpdateMonitor; -import com.android.systemui.SysuiTestCase; -import com.android.systemui.dock.DockManager; -import com.android.systemui.plugins.statusbar.StatusBarStateController; -import com.android.systemui.statusbar.KeyguardIndicationController; -import com.android.systemui.statusbar.StatusBarState; -import com.android.systemui.statusbar.notification.NotificationWakeUpCoordinator; -import com.android.systemui.statusbar.policy.AccessibilityController; -import com.android.systemui.statusbar.policy.ConfigurationController; -import com.android.systemui.statusbar.policy.KeyguardStateController; - -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.ArgumentCaptor; -import org.mockito.Captor; -import org.mockito.Mock; -import org.mockito.MockitoAnnotations; - -@SmallTest -@RunWith(AndroidJUnit4.class) -public class LockscreenIconControllerTest extends SysuiTestCase { - @Mock - private LockscreenGestureLogger mLockscreenGestureLogger; - @Mock - private KeyguardUpdateMonitor mKeyguardUpdateMonitor; - @Mock - private LockPatternUtils mLockPatternUtils; - @Mock - private ShadeController mShadeController; - @Mock - private AccessibilityController mAccessibilityController; - @Mock - private KeyguardIndicationController mKeyguardIndicationController; - @Mock - private LockIcon mLockIcon; - @Mock - private StatusBarStateController mStatusBarStateController; - @Mock - private ConfigurationController mConfigurationController; - @Mock - private NotificationWakeUpCoordinator mNotificationWakeUpCoordinator; - @Mock - private KeyguardBypassController mKeyguardBypassController; - @Mock - private DockManager mDockManager; - @Mock - private KeyguardStateController mKeyguardStateController; - @Mock - private Resources mResources; - @Mock - private HeadsUpManagerPhone mHeadsUpManagerPhone; - - private LockscreenLockIconController mLockIconController; - - @Captor ArgumentCaptor mOnAttachStateChangeCaptor; - @Captor ArgumentCaptor mStateListenerCaptor; - - private OnAttachStateChangeListener mOnAttachStateChangeListener; - private StatusBarStateController.StateListener mStatusBarStateListener; - - @Before - public void setUp() { - MockitoAnnotations.initMocks(this); - - when(mKeyguardUpdateMonitor.canShowLockIcon()).thenReturn(true); - when(mLockIcon.getContext()).thenReturn(mContext); - mLockIconController = new LockscreenLockIconController(mLockIcon, - mLockscreenGestureLogger, mKeyguardUpdateMonitor, mLockPatternUtils, - mShadeController, mAccessibilityController, mKeyguardIndicationController, - mStatusBarStateController, mConfigurationController, mNotificationWakeUpCoordinator, - mKeyguardBypassController, mDockManager, mKeyguardStateController, mResources, - mHeadsUpManagerPhone); - - when(mLockIcon.isAttachedToWindow()).thenReturn(true); - mLockIconController.init(); - - verify(mLockIcon).addOnAttachStateChangeListener( - mOnAttachStateChangeCaptor.capture()); - mOnAttachStateChangeListener = mOnAttachStateChangeCaptor.getValue(); - verify(mStatusBarStateController).addCallback(mStateListenerCaptor.capture()); - mStatusBarStateListener = mStateListenerCaptor.getValue(); - } - - @Test - public void lockIcon_click() { - ArgumentCaptor longClickCaptor = ArgumentCaptor.forClass( - View.OnLongClickListener.class); - ArgumentCaptor clickCaptor = ArgumentCaptor.forClass( - View.OnClickListener.class); - - // TODO: once we use a real LockIcon instead of a mock, remove all this. - verify(mLockIcon).setOnLongClickListener(longClickCaptor.capture()); - verify(mLockIcon).setOnClickListener(clickCaptor.capture()); - - when(mAccessibilityController.isAccessibilityEnabled()).thenReturn(true); - clickCaptor.getValue().onClick(new View(mContext)); - verify(mShadeController).animateCollapsePanels(anyInt(), eq(true)); - - longClickCaptor.getValue().onLongClick(new View(mContext)); - verify(mLockPatternUtils).requireCredentialEntry(anyInt()); - verify(mKeyguardUpdateMonitor).onLockIconPressed(); - } - - @Test - public void testVisibility_Dozing() { - when(mStatusBarStateController.isDozing()).thenReturn(true); - mStatusBarStateListener.onDozingChanged(true); - - verify(mLockIcon).updateIconVisibility(false); - } - - @Test - public void testVisibility_doNotShowLockIcon() { - when(mKeyguardUpdateMonitor.canShowLockIcon()).thenReturn(false); - mStatusBarStateListener.onStateChanged(StatusBarState.KEYGUARD); - - verify(mLockIcon).setVisibility(View.GONE); - } -} diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NotificationPanelViewTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NotificationPanelViewTest.java index 04ac1549e374..7d052b910cc6 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NotificationPanelViewTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NotificationPanelViewTest.java @@ -29,13 +29,11 @@ import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.doAnswer; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.never; -import static org.mockito.Mockito.spy; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; import android.annotation.IdRes; import android.app.ActivityManager; -import android.app.StatusBarManager; import android.content.res.Configuration; import android.content.res.Resources; import android.hardware.biometrics.BiometricSourceType; @@ -65,6 +63,7 @@ import com.android.keyguard.KeyguardClockSwitchController; import com.android.keyguard.KeyguardStatusView; import com.android.keyguard.KeyguardStatusViewController; import com.android.keyguard.KeyguardUpdateMonitor; +import com.android.keyguard.LockIconViewController; import com.android.keyguard.dagger.KeyguardQsUserSwitchComponent; import com.android.keyguard.dagger.KeyguardStatusBarViewComponent; import com.android.keyguard.dagger.KeyguardStatusViewComponent; @@ -110,7 +109,6 @@ import org.mockito.MockitoAnnotations; import org.mockito.stubbing.Answer; import java.util.List; -import java.util.function.Consumer; @SmallTest @RunWith(AndroidTestingRunner.class) @@ -235,6 +233,8 @@ public class NotificationPanelViewTest extends SysuiTestCase { private UserManager mUserManager; @Mock private UiEventLogger mUiEventLogger; + @Mock + private LockIconViewController mLockIconViewController; private SysuiStatusBarStateController mStatusBarStateController; private NotificationPanelViewController mNotificationPanelViewController; @@ -338,6 +338,7 @@ public class NotificationPanelViewTest extends SysuiTestCase { mMediaDataManager, mNotificationShadeDepthController, mAmbientState, + mLockIconViewController, mFeatureFlags); mNotificationPanelViewController.initDependencies( mStatusBar, @@ -370,19 +371,6 @@ public class NotificationPanelViewTest extends SysuiTestCase { assertThat((int) mNotificationPanelViewController.getExpandedHeight()).isEqualTo(200); } - @Test - public void testAffordanceLaunchingListener() { - Consumer listener = spy((showing) -> { }); - mNotificationPanelViewController.setExpandedFraction(1f); - mNotificationPanelViewController.setLaunchAffordanceListener(listener); - mNotificationPanelViewController.launchCamera(false /* animate */, - StatusBarManager.CAMERA_LAUNCH_SOURCE_POWER_DOUBLE_TAP); - verify(listener).accept(eq(true)); - - mNotificationPanelViewController.onAffordanceLaunchEnded(); - verify(listener).accept(eq(false)); - } - @Test public void testOnTouchEvent_expansionCanBeBlocked() { onTouchEvent(MotionEvent.obtain(0L /* downTime */, diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManagerTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManagerTest.java index 20261e060601..1d4cbdc959c1 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManagerTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManagerTest.java @@ -20,7 +20,6 @@ import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyBoolean; import static org.mockito.ArgumentMatchers.anyFloat; import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.RETURNS_DEEP_STUBS; import static org.mockito.Mockito.clearInvocations; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.never; @@ -32,8 +31,6 @@ import android.testing.AndroidTestingRunner; import android.testing.TestableLooper; import android.view.View; import android.view.ViewGroup; -import android.view.ViewPropertyAnimator; -import android.widget.FrameLayout; import androidx.test.filters.SmallTest; @@ -82,8 +79,6 @@ public class StatusBarKeyguardViewManagerTest extends SysuiTestCase { @Mock private DismissCallbackRegistry mDismissCallbackRegistry; @Mock - private ViewGroup mLockIconContainer; - @Mock private SysuiStatusBarStateController mStatusBarStateController; @Mock private View mNotificationContainer; @@ -101,11 +96,6 @@ public class StatusBarKeyguardViewManagerTest extends SysuiTestCase { @Before public void setUp() { MockitoAnnotations.initMocks(this); - when(mLockIconContainer.getParent()).thenReturn(mock(ViewGroup.class)); - when(mLockIconContainer.animate()).thenReturn(mock(ViewPropertyAnimator.class, - RETURNS_DEEP_STUBS)); - when(mLockIconContainer.getLayoutParams()).thenReturn(mock(FrameLayout.LayoutParams.class)); - when(mKeyguardBouncerFactory.create( any(ViewGroup.class), any(KeyguardBouncer.BouncerExpansionCallback.class))) @@ -127,7 +117,7 @@ public class StatusBarKeyguardViewManagerTest extends SysuiTestCase { mKeyguardBouncerFactory); mStatusBarKeyguardViewManager.registerStatusBar(mStatusBar, mContainer, mNotificationPanelView, mBiometrucUnlockController, - mLockIconContainer, mNotificationContainer, mBypassController); + mNotificationContainer, mBypassController); mStatusBarKeyguardViewManager.show(null); } diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/StatusBarTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/StatusBarTest.java index 98a44875fbd7..08d6d2d7c72d 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/StatusBarTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/StatusBarTest.java @@ -65,7 +65,6 @@ import android.util.SparseArray; import android.view.ViewGroup; import android.view.ViewGroup.LayoutParams; import android.view.WindowManager; -import android.widget.LinearLayout; import androidx.test.filters.SmallTest; @@ -236,7 +235,6 @@ public class StatusBarTest extends SysuiTestCase { @Mock private Lazy mLockscreenWallpaperLazy; @Mock private LockscreenWallpaper mLockscreenWallpaper; @Mock private DozeServiceHost mDozeServiceHost; - @Mock private LinearLayout mLockIconContainer; @Mock private ViewMediatorCallback mKeyguardVieMediatorCallback; @Mock private KeyguardLiftController mKeyguardLiftController; @Mock private VolumeComponent mVolumeComponent; @@ -252,7 +250,6 @@ public class StatusBarTest extends SysuiTestCase { @Mock private DismissCallbackRegistry mDismissCallbackRegistry; @Mock private StatusBarTouchableRegionManager mStatusBarTouchableRegionManager; @Mock private ScreenPinningRequest mScreenPinningRequest; - @Mock private LockscreenLockIconController mLockscreenLockIconController; @Mock private StatusBarNotificationActivityStarter.Builder mStatusBarNotificationActivityStarterBuilder; @Mock private DarkIconDispatcher mDarkIconDispatcher; @@ -434,13 +431,9 @@ public class StatusBarTest extends SysuiTestCase { mOngoingCallController, mTunerService, mFeatureFlags); - - when(mNotificationShadeWindowView.findViewById(R.id.lock_icon_container)).thenReturn( - mLockIconContainer); - when(mKeyguardViewMediator.registerStatusBar(any(StatusBar.class), any(ViewGroup.class), any(NotificationPanelViewController.class), any(BiometricUnlockController.class), - any(ViewGroup.class), any(ViewGroup.class), any(KeyguardBypassController.class))) + any(ViewGroup.class), any(KeyguardBypassController.class))) .thenReturn(mStatusBarKeyguardViewManager); when(mKeyguardViewMediator.getViewMediatorCallback()).thenReturn( @@ -450,7 +443,6 @@ public class StatusBarTest extends SysuiTestCase { // initialized automatically. mStatusBar.mNotificationShadeWindowView = mNotificationShadeWindowView; mStatusBar.mNotificationPanelViewController = mNotificationPanelViewController; - mStatusBar.mLockscreenLockIconController = mLockscreenLockIconController; mStatusBar.mDozeScrimController = mDozeScrimController; mStatusBar.mPresenter = mNotificationPresenter; mStatusBar.mKeyguardIndicationController = mKeyguardIndicationController; -- cgit v1.2.3-59-g8ed1b