[Bouncer] Have initial message id for sim pin.
Seems like we can get into a state where the sim pin view does not have an initial message and is getting an exception because 0 is not a valid resource id. Moving the getInitialMessageResId to the parent of the sim pin view controller. Fixes: 261941458 Test: Add unit test. Open sim pin view. Change-Id: Ia2782c7c8acd0775bd2fb1cf9774f477264cf899
This commit is contained in:
@@ -142,7 +142,8 @@ public abstract class KeyguardInputViewController<T extends KeyguardInputView>
|
||||
}
|
||||
|
||||
public void startAppearAnimation() {
|
||||
if (TextUtils.isEmpty(mMessageAreaController.getMessage())) {
|
||||
if (TextUtils.isEmpty(mMessageAreaController.getMessage())
|
||||
&& getInitialMessageResId() != 0) {
|
||||
mMessageAreaController.setMessage(getInitialMessageResId());
|
||||
}
|
||||
mView.startAppearAnimation();
|
||||
@@ -163,9 +164,7 @@ public abstract class KeyguardInputViewController<T extends KeyguardInputView>
|
||||
}
|
||||
|
||||
/** Determines the message to show in the bouncer when it first appears. */
|
||||
protected int getInitialMessageResId() {
|
||||
return 0;
|
||||
}
|
||||
protected abstract int getInitialMessageResId();
|
||||
|
||||
/** Factory for a {@link KeyguardInputViewController}. */
|
||||
public static class Factory {
|
||||
|
||||
@@ -139,4 +139,9 @@ public abstract class KeyguardPinBasedInputViewController<T extends KeyguardPinB
|
||||
super.startErrorAnimation();
|
||||
mView.startErrorAnimation();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getInitialMessageResId() {
|
||||
return R.string.keyguard_enter_your_pin;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -74,9 +74,4 @@ public class KeyguardPinViewController
|
||||
return mView.startDisappearAnimation(
|
||||
mKeyguardUpdateMonitor.needsSlowUnlockTransition(), finishRunnable);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getInitialMessageResId() {
|
||||
return R.string.keyguard_enter_your_pin;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -156,5 +156,10 @@ public class KeyguardSecurityViewFlipperController
|
||||
@Override
|
||||
public void onStartingToHide() {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getInitialMessageResId() {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -99,6 +99,11 @@ public class KeyguardAbsKeyInputViewControllerTest extends SysuiTestCase {
|
||||
public void onResume(int reason) {
|
||||
super.onResume(reason);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getInitialMessageResId() {
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
mKeyguardAbsKeyInputViewController.init();
|
||||
reset(mKeyguardMessageAreaController); // Clear out implicit call to init.
|
||||
|
||||
@@ -16,6 +16,8 @@
|
||||
|
||||
package com.android.keyguard;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
@@ -113,4 +115,9 @@ public class KeyguardPinBasedInputViewControllerTest extends SysuiTestCase {
|
||||
mKeyguardPinViewController.onResume(KeyguardSecurityView.SCREEN_ON);
|
||||
verify(mPasswordEntry).requestFocus();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetInitialMessageResId() {
|
||||
assertThat(mKeyguardPinViewController.getInitialMessageResId()).isNotEqualTo(0);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user