summaryrefslogtreecommitdiff
path: root/packages/SystemUI/src/com/android/keyguard/LockIconViewController.java
diff options
context:
space:
mode:
authorBrian Orr <brianorr@google.com>2021-06-15 12:47:53 -0700
committerDaniel Norman <danielnorman@google.com>2021-06-17 13:37:54 -0700
commit71c831703ae59baf47e0afe611fecd714c481cdf (patch)
tree06731a987032723085b9e1a65951cf96abbc19cf /packages/SystemUI/src/com/android/keyguard/LockIconViewController.java
parent065c9e9a6e9d61d4383a91721eb56a3de253bdbe (diff)
parent81833820d54b9a6b27894f9f8dfd72222d416992 (diff)
Merge SP1A.210604.001
Change-Id: I5200ee05285ae422d5e9c1c00f45709a5d6188be
Diffstat (limited to 'packages/SystemUI/src/com/android/keyguard/LockIconViewController.java')
-rw-r--r--packages/SystemUI/src/com/android/keyguard/LockIconViewController.java140
1 files changed, 110 insertions, 30 deletions
diff --git a/packages/SystemUI/src/com/android/keyguard/LockIconViewController.java b/packages/SystemUI/src/com/android/keyguard/LockIconViewController.java
index b5f2ab213559..ccc487925fe4 100644
--- a/packages/SystemUI/src/com/android/keyguard/LockIconViewController.java
+++ b/packages/SystemUI/src/com/android/keyguard/LockIconViewController.java
@@ -40,16 +40,20 @@ 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.qualifiers.Main;
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.ConfigurationController;
import com.android.systemui.statusbar.policy.KeyguardStateController;
import com.android.systemui.util.ViewController;
+import com.android.systemui.util.concurrency.DelayableExecutor;
import java.io.FileDescriptor;
import java.io.PrintWriter;
+import java.util.Objects;
import javax.inject.Inject;
@@ -67,6 +71,8 @@ public class LockIconViewController extends ViewController<LockIconView> impleme
@NonNull private final FalsingManager mFalsingManager;
@NonNull private final AuthController mAuthController;
@NonNull private final AccessibilityManager mAccessibilityManager;
+ @NonNull private final ConfigurationController mConfigurationController;
+ @NonNull private final DelayableExecutor mExecutor;
private boolean mHasUdfpsOrFaceAuthFeatures;
private boolean mUdfpsEnrolled;
@@ -75,6 +81,9 @@ public class LockIconViewController extends ViewController<LockIconView> impleme
@NonNull private final Drawable mButton;
@NonNull private final Drawable mUnlockIcon;
@NonNull private final Drawable mLockIcon;
+ @NonNull private final CharSequence mDisabledLabel;
+ @NonNull private final CharSequence mUnlockedLabel;
+ @NonNull private final CharSequence mLockedLabel;
private boolean mIsDozing;
private boolean mIsBouncerShowing;
@@ -84,6 +93,7 @@ public class LockIconViewController extends ViewController<LockIconView> impleme
private int mStatusBarState;
private boolean mIsKeyguardShowing;
private boolean mUserUnlockedWithBiometric;
+ private Runnable mCancelDelayedUpdateVisibilityRunnable;
private boolean mShowButton;
private boolean mShowUnlockIcon;
@@ -99,7 +109,9 @@ public class LockIconViewController extends ViewController<LockIconView> impleme
@NonNull FalsingManager falsingManager,
@NonNull AuthController authController,
@NonNull DumpManager dumpManager,
- @NonNull AccessibilityManager accessibilityManager
+ @NonNull AccessibilityManager accessibilityManager,
+ @NonNull ConfigurationController configurationController,
+ @NonNull @Main DelayableExecutor executor
) {
super(view);
mStatusBarStateController = statusBarStateController;
@@ -109,6 +121,8 @@ public class LockIconViewController extends ViewController<LockIconView> impleme
mKeyguardStateController = keyguardStateController;
mFalsingManager = falsingManager;
mAccessibilityManager = accessibilityManager;
+ mConfigurationController = configurationController;
+ mExecutor = executor;
final Context context = view.getContext();
mButton = context.getResources().getDrawable(
@@ -121,6 +135,10 @@ public class LockIconViewController extends ViewController<LockIconView> impleme
com.android.internal.R.drawable.ic_lock, context.getTheme()),
context.getResources().getDimensionPixelSize(
com.android.systemui.R.dimen.udfps_unlock_icon_inset));
+ mDisabledLabel = context.getResources().getString(
+ R.string.accessibility_udfps_disabled_button);
+ mUnlockedLabel = context.getResources().getString(R.string.accessibility_unlock_button);
+ mLockedLabel = context.getResources().getString(R.string.accessibility_lock_icon);
dumpManager.registerDumpable("LockIconViewController", this);
}
@@ -137,7 +155,13 @@ public class LockIconViewController extends ViewController<LockIconView> impleme
final boolean hasUdfps = mAuthController.getUdfpsSensorLocation() != null;
mHasUdfpsOrFaceAuthFeatures = hasFaceAuth || hasUdfps;
if (!mHasUdfpsOrFaceAuthFeatures) {
- ((ViewGroup) mView.getParent()).removeView(mView);
+ // Posting since removing a view in the middle of onAttach can lead to a crash in the
+ // iteration loop when the view isn't last
+ mView.setVisibility(View.GONE);
+ mView.post(() -> {
+ mView.setVisibility(View.VISIBLE);
+ ((ViewGroup) mView.getParent()).removeView(mView);
+ });
return;
}
@@ -164,10 +188,8 @@ public class LockIconViewController extends ViewController<LockIconView> impleme
mCanDismissLockScreen = mKeyguardStateController.canDismissLockScreen();
mStatusBarState = mStatusBarStateController.getState();
- mUnlockIcon.setTint(Utils.getColorAttrDefaultColor(mView.getContext(),
- R.attr.wallpaperTextColorAccent));
- mLockIcon.setTint(Utils.getColorAttrDefaultColor(mView.getContext(),
- R.attr.wallpaperTextColorAccent));
+ updateColors();
+ mConfigurationController.addCallback(mConfigurationListener);
mKeyguardUpdateMonitor.registerCallback(mKeyguardUpdateMonitorCallback);
mStatusBarStateController.addCallback(mStatusBarStateListener);
@@ -180,11 +202,17 @@ public class LockIconViewController extends ViewController<LockIconView> impleme
@Override
protected void onViewDetached() {
+ mConfigurationController.removeCallback(mConfigurationListener);
mKeyguardUpdateMonitor.removeCallback(mKeyguardUpdateMonitorCallback);
mStatusBarStateController.removeCallback(mStatusBarStateListener);
mKeyguardStateController.removeCallback(mKeyguardStateCallback);
mAccessibilityManager.removeTouchExplorationStateChangeListener(
mTouchExplorationStateChangeListener);
+
+ if (mCancelDelayedUpdateVisibilityRunnable != null) {
+ mCancelDelayedUpdateVisibilityRunnable.run();
+ mCancelDelayedUpdateVisibilityRunnable = null;
+ }
}
public float getTop() {
@@ -196,8 +224,8 @@ public class LockIconViewController extends ViewController<LockIconView> impleme
return false;
}
- // pre-emptively set to false to hide view
- mIsKeyguardShowing = false;
+ // pre-emptively set to true to hide view
+ mIsBouncerShowing = true;
updateVisibility();
mKeyguardViewController.showBouncer(/* scrim */ true);
return true;
@@ -212,6 +240,11 @@ public class LockIconViewController extends ViewController<LockIconView> impleme
}
private void updateVisibility() {
+ if (mCancelDelayedUpdateVisibilityRunnable != null) {
+ mCancelDelayedUpdateVisibilityRunnable.run();
+ mCancelDelayedUpdateVisibilityRunnable = null;
+ }
+
if (!mIsKeyguardShowing || (!mUdfpsEnrolled && !mFaceAuthEnrolled)) {
mView.setVisibility(View.INVISIBLE);
return;
@@ -225,25 +258,27 @@ public class LockIconViewController extends ViewController<LockIconView> impleme
&& mFaceAuthEnrolled;
updateClickListener();
+ final CharSequence prevContentDescription = mView.getContentDescription();
if (mShowButton) {
mView.setImageDrawable(mButton);
mView.setVisibility(View.VISIBLE);
- mView.setContentDescription(getResources().getString(
- R.string.accessibility_udfps_disabled_button));
+ mView.setContentDescription(mDisabledLabel);
} else if (mShowUnlockIcon) {
mView.setImageDrawable(mUnlockIcon);
mView.setVisibility(View.VISIBLE);
- mView.setContentDescription(getResources().getString(
- R.string.accessibility_unlock_button));
+ mView.setContentDescription(mUnlockedLabel);
} else if (mShowLockIcon) {
mView.setImageDrawable(mLockIcon);
mView.setVisibility(View.VISIBLE);
- mView.setContentDescription(getResources().getString(
- R.string.accessibility_lock_icon));
+ mView.setContentDescription(mLockedLabel);
} else {
mView.setVisibility(View.INVISIBLE);
mView.setContentDescription(null);
}
+ if (!Objects.equals(prevContentDescription, mView.getContentDescription())
+ && mView.getContentDescription() != null) {
+ mView.announceForAccessibility(mView.getContentDescription());
+ }
}
private final View.AccessibilityDelegate mAccessibilityDelegate =
@@ -258,20 +293,12 @@ public class LockIconViewController extends ViewController<LockIconView> impleme
getResources().getString(R.string.accessibility_enter_hint));
public void onInitializeAccessibilityNodeInfo(View v, AccessibilityNodeInfo info) {
super.onInitializeAccessibilityNodeInfo(v, info);
- removeAllActions(info);
if (mShowButton || mShowLockIcon) {
info.addAction(mAccessibilityAuthenticateHint);
} else if (mShowUnlockIcon) {
info.addAction(mAccessibilityEnterHint);
}
}
-
- private void removeAllActions(AccessibilityNodeInfo info) {
- info.removeAction(mAccessibilityAuthenticateHint);
- info.removeAction(mAccessibilityEnterHint);
- info.removeAction(AccessibilityNodeInfo.AccessibilityAction.ACTION_LONG_CLICK);
- mView.setLongClickable(false);
- }
};
private boolean isLockScreen() {
@@ -286,6 +313,7 @@ public class LockIconViewController extends ViewController<LockIconView> impleme
mView.setOnClickListener(v -> onAffordanceClick());
if (mAccessibilityManager.isTouchExplorationEnabled()) {
mView.setOnLongClickListener(null);
+ mView.setLongClickable(false);
} else {
mView.setOnLongClickListener(v -> onAffordanceClick());
}
@@ -297,15 +325,22 @@ public class LockIconViewController extends ViewController<LockIconView> impleme
&& !mKeyguardStateController.isKeyguardGoingAway();
}
+ private void updateColors() {
+ final int color = Utils.getColorAttrDefaultColor(mView.getContext(),
+ R.attr.wallpaperTextColorAccent);
+ mUnlockIcon.setTint(color);
+ mLockIcon.setTint(color);
+ }
+
@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("mHasUdfpsOrFaceAuthFeatures: " + mHasUdfpsOrFaceAuthFeatures);
+ pw.println("mUdfpsEnrolled: " + mUdfpsEnrolled);
+ pw.println("mFaceAuthEnrolled: " + mFaceAuthEnrolled);
+ pw.println("mIsKeyguardShowing: " + mIsKeyguardShowing);
+ pw.println(" mShowBouncerButton: " + mShowButton);
+ pw.println(" mShowUnlockIcon: " + mShowUnlockIcon);
+ pw.println(" mShowLockIcon: " + mShowLockIcon);
pw.println(" mIsDozing: " + mIsDozing);
pw.println(" mIsBouncerShowing: " + mIsBouncerShowing);
pw.println(" mUserUnlockedWithBiometric: " + mUserUnlockedWithBiometric);
@@ -333,6 +368,14 @@ public class LockIconViewController extends ViewController<LockIconView> impleme
private final KeyguardUpdateMonitorCallback mKeyguardUpdateMonitorCallback =
new KeyguardUpdateMonitorCallback() {
@Override
+ public void onKeyguardVisibilityChanged(boolean showing) {
+ // reset mIsBouncerShowing state in case it was preemptively set
+ // onAffordanceClick
+ mIsBouncerShowing = mKeyguardViewController.isBouncerShowing();
+ updateVisibility();
+ }
+
+ @Override
public void onKeyguardBouncerChanged(boolean bouncer) {
mIsBouncerShowing = bouncer;
updateVisibility();
@@ -347,7 +390,19 @@ public class LockIconViewController extends ViewController<LockIconView> impleme
if (biometricSourceType == FINGERPRINT) {
mRunningFPS = running;
- updateVisibility();
+ if (!mRunningFPS) {
+ if (mCancelDelayedUpdateVisibilityRunnable != null) {
+ mCancelDelayedUpdateVisibilityRunnable.run();
+ }
+
+ // For some devices, auth is cancelled immediately on screen off but
+ // before dozing state is set. We want to avoid briefly showing the
+ // button in this case, so we delay updating the visibility by 50ms.
+ mCancelDelayedUpdateVisibilityRunnable =
+ mExecutor.executeDelayed(() -> updateVisibility(), 50);
+ } else {
+ updateVisibility();
+ }
}
}
};
@@ -376,6 +431,31 @@ public class LockIconViewController extends ViewController<LockIconView> impleme
}
};
+ private final ConfigurationController.ConfigurationListener mConfigurationListener =
+ new ConfigurationController.ConfigurationListener() {
+ @Override
+ public void onUiModeChanged() {
+ updateColors();
+ }
+
+ @Override
+ public void onThemeChanged() {
+ updateColors();
+ }
+
+ @Override
+ public void onOverlayChanged() {
+ updateColors();
+ }
+ };
+
private final AccessibilityManager.TouchExplorationStateChangeListener
mTouchExplorationStateChangeListener = enabled -> updateClickListener();
+
+ /**
+ * Set the alpha of this view.
+ */
+ public void setAlpha(float alpha) {
+ mView.setAlpha(alpha);
+ }
}