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
This commit is contained in:
Matt Pietal
2021-09-27 16:43:32 -04:00
parent 3a8df63e40
commit 373aff0c7c
2 changed files with 17 additions and 2 deletions

View File

@@ -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,

View File

@@ -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());
}