From 373aff0c7cc4d4ce4a57a725ab0defa5f1c5e171 Mon Sep 17 00:00:00 2001 From: Matt Pietal Date: Mon, 27 Sep 2021 16:43:32 -0400 Subject: [PATCH] Keyguard indication area - owner info fix There was discrepancy between how null values and empty strings were treated in KeyguardIndication and KeyguardIndicationController. This could lead to a crash in systemui. Modify the KeyguardIndicationController to match the logic in KeyguardIndication. Bug: 201339576 Test: KeyguardIndicationControllerTest Change-Id: I8b7b4d7b33b1ee809df17e64347c816f65a50727 --- .../statusbar/KeyguardIndicationController.java | 4 ++-- .../KeyguardIndicationControllerTest.java | 15 +++++++++++++++ 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/KeyguardIndicationController.java b/packages/SystemUI/src/com/android/systemui/statusbar/KeyguardIndicationController.java index 17bcfe73ccd99..8a397199dc84d 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/KeyguardIndicationController.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/KeyguardIndicationController.java @@ -335,7 +335,7 @@ public class KeyguardIndicationController { info = mLockPatternUtils.getOwnerInfo(KeyguardUpdateMonitor.getCurrentUser()); } } - if (info != null) { + if (!TextUtils.isEmpty(info)) { mRotateTextViewController.updateIndication( INDICATION_TYPE_OWNER_INFO, new KeyguardIndication.Builder() @@ -433,7 +433,7 @@ public class KeyguardIndicationController { } private void updateResting() { - if (mRestingIndication != null + if (!TextUtils.isEmpty(mRestingIndication) && !mRotateTextViewController.hasIndications()) { mRotateTextViewController.updateIndication( INDICATION_TYPE_RESTING, diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/KeyguardIndicationControllerTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/KeyguardIndicationControllerTest.java index 09a3d35d2d324..f5cab1df9fa29 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/KeyguardIndicationControllerTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/KeyguardIndicationControllerTest.java @@ -23,6 +23,7 @@ import static android.content.pm.UserInfo.FLAG_MANAGED_PROFILE; import static com.android.systemui.keyguard.KeyguardIndicationRotateTextViewController.INDICATION_TYPE_ALIGNMENT; import static com.android.systemui.keyguard.KeyguardIndicationRotateTextViewController.INDICATION_TYPE_BATTERY; import static com.android.systemui.keyguard.KeyguardIndicationRotateTextViewController.INDICATION_TYPE_DISCLOSURE; +import static com.android.systemui.keyguard.KeyguardIndicationRotateTextViewController.INDICATION_TYPE_OWNER_INFO; import static com.android.systemui.keyguard.KeyguardIndicationRotateTextViewController.INDICATION_TYPE_RESTING; import static com.android.systemui.keyguard.KeyguardIndicationRotateTextViewController.INDICATION_TYPE_TRANSIENT; import static com.android.systemui.keyguard.KeyguardIndicationRotateTextViewController.INDICATION_TYPE_TRUST; @@ -725,6 +726,20 @@ public class KeyguardIndicationControllerTest extends SysuiTestCase { verify(mIndicationAreaBottom).announceForAccessibility(eq(faceHelpMsg)); } + @Test + public void testEmptyOwnerInfoHidesIndicationArea() { + createController(); + + // GIVEN the owner info is set to an empty string + when(mLockPatternUtils.getDeviceOwnerInfo()).thenReturn(""); + + // WHEN asked to update the indication area + mController.setVisible(true); + + // THEN the owner info should be hidden + verifyHideIndication(INDICATION_TYPE_OWNER_INFO); + } + private void sendUpdateDisclosureBroadcast() { mBroadcastReceiver.onReceive(mContext, new Intent()); }