Loading packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitor.java +1 −1 Original line number Diff line number Diff line Loading @@ -2368,7 +2368,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab } // Take a guess at initial SIM state, battery status and PLMN until we get an update mBatteryStatus = new BatteryStatus(BATTERY_STATUS_UNKNOWN, /* level= */ 100, /* plugged= */ mBatteryStatus = new BatteryStatus(BATTERY_STATUS_UNKNOWN, /* level= */ -1, /* plugged= */ 0, CHARGING_POLICY_DEFAULT, /* maxChargingWattage= */0, /* present= */true); // Watch for interesting updates Loading packages/SystemUI/src/com/android/systemui/statusbar/KeyguardIndicationController.java +6 −2 Original line number Diff line number Diff line Loading @@ -214,7 +214,7 @@ public class KeyguardIndicationController { private boolean mEnableBatteryDefender; private boolean mIncompatibleCharger; private int mChargingWattage; private int mBatteryLevel; private int mBatteryLevel = -1; private boolean mBatteryPresent = true; protected long mChargingTimeRemaining; private Pair<String, BiometricSourceType> mBiometricErrorMessageToShowOnScreenOn; Loading Loading @@ -1032,12 +1032,16 @@ public class KeyguardIndicationController { } else if (!TextUtils.isEmpty(mTransientIndication)) { newIndication = mTransientIndication; } else if (!mBatteryPresent) { // If there is no battery detected, hide the indication and bail // If there is no battery detected, hide the indication area and bail mIndicationArea.setVisibility(GONE); return; } else if (!TextUtils.isEmpty(mAlignmentIndication)) { useMisalignmentColor = true; newIndication = mAlignmentIndication; } else if (mBatteryLevel == -1) { // If the battery level is not initialized, hide the indication area mIndicationArea.setVisibility(GONE); return; } else if (mPowerPluggedIn || mEnableBatteryDefender) { newIndication = computePowerIndication(); } else { Loading packages/SystemUI/tests/src/com/android/systemui/statusbar/KeyguardIndicationControllerTest.java +20 −0 Original line number Diff line number Diff line Loading @@ -21,6 +21,8 @@ import static android.content.pm.UserInfo.FLAG_MANAGED_PROFILE; import static android.hardware.biometrics.BiometricFaceConstants.FACE_ACQUIRED_TOO_DARK; import static android.hardware.biometrics.BiometricFaceConstants.FACE_ERROR_LOCKOUT_PERMANENT; import static android.hardware.biometrics.BiometricFaceConstants.FACE_ERROR_TIMEOUT; import static android.view.View.GONE; import static android.view.View.VISIBLE; import static com.android.keyguard.KeyguardUpdateMonitor.BIOMETRIC_HELP_FACE_NOT_AVAILABLE; import static com.android.keyguard.KeyguardUpdateMonitor.BIOMETRIC_HELP_FACE_NOT_RECOGNIZED; Loading Loading @@ -776,6 +778,24 @@ public class KeyguardIndicationControllerTest extends KeyguardIndicationControll mContext.getString(R.string.keyguard_suggest_fingerprint)); } @Test public void indicationAreaHidden_untilBatteryInfoArrives() { createController(); // level of -1 indicates missing info BatteryStatus status = new BatteryStatus(BatteryManager.BATTERY_STATUS_UNKNOWN, -1 /* level */, BatteryManager.BATTERY_PLUGGED_WIRELESS, 100 /* health */, 0 /* maxChargingWattage */, true /* present */); mController.setVisible(true); mStatusBarStateListener.onDozingChanged(true); reset(mIndicationArea); mController.getKeyguardCallback().onRefreshBatteryInfo(status); // VISIBLE is always called first verify(mIndicationArea).setVisibility(VISIBLE); verify(mIndicationArea).setVisibility(GONE); } @Test public void onRefreshBatteryInfo_computesChargingTime() throws RemoteException { createController(); Loading Loading
packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitor.java +1 −1 Original line number Diff line number Diff line Loading @@ -2368,7 +2368,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab } // Take a guess at initial SIM state, battery status and PLMN until we get an update mBatteryStatus = new BatteryStatus(BATTERY_STATUS_UNKNOWN, /* level= */ 100, /* plugged= */ mBatteryStatus = new BatteryStatus(BATTERY_STATUS_UNKNOWN, /* level= */ -1, /* plugged= */ 0, CHARGING_POLICY_DEFAULT, /* maxChargingWattage= */0, /* present= */true); // Watch for interesting updates Loading
packages/SystemUI/src/com/android/systemui/statusbar/KeyguardIndicationController.java +6 −2 Original line number Diff line number Diff line Loading @@ -214,7 +214,7 @@ public class KeyguardIndicationController { private boolean mEnableBatteryDefender; private boolean mIncompatibleCharger; private int mChargingWattage; private int mBatteryLevel; private int mBatteryLevel = -1; private boolean mBatteryPresent = true; protected long mChargingTimeRemaining; private Pair<String, BiometricSourceType> mBiometricErrorMessageToShowOnScreenOn; Loading Loading @@ -1032,12 +1032,16 @@ public class KeyguardIndicationController { } else if (!TextUtils.isEmpty(mTransientIndication)) { newIndication = mTransientIndication; } else if (!mBatteryPresent) { // If there is no battery detected, hide the indication and bail // If there is no battery detected, hide the indication area and bail mIndicationArea.setVisibility(GONE); return; } else if (!TextUtils.isEmpty(mAlignmentIndication)) { useMisalignmentColor = true; newIndication = mAlignmentIndication; } else if (mBatteryLevel == -1) { // If the battery level is not initialized, hide the indication area mIndicationArea.setVisibility(GONE); return; } else if (mPowerPluggedIn || mEnableBatteryDefender) { newIndication = computePowerIndication(); } else { Loading
packages/SystemUI/tests/src/com/android/systemui/statusbar/KeyguardIndicationControllerTest.java +20 −0 Original line number Diff line number Diff line Loading @@ -21,6 +21,8 @@ import static android.content.pm.UserInfo.FLAG_MANAGED_PROFILE; import static android.hardware.biometrics.BiometricFaceConstants.FACE_ACQUIRED_TOO_DARK; import static android.hardware.biometrics.BiometricFaceConstants.FACE_ERROR_LOCKOUT_PERMANENT; import static android.hardware.biometrics.BiometricFaceConstants.FACE_ERROR_TIMEOUT; import static android.view.View.GONE; import static android.view.View.VISIBLE; import static com.android.keyguard.KeyguardUpdateMonitor.BIOMETRIC_HELP_FACE_NOT_AVAILABLE; import static com.android.keyguard.KeyguardUpdateMonitor.BIOMETRIC_HELP_FACE_NOT_RECOGNIZED; Loading Loading @@ -776,6 +778,24 @@ public class KeyguardIndicationControllerTest extends KeyguardIndicationControll mContext.getString(R.string.keyguard_suggest_fingerprint)); } @Test public void indicationAreaHidden_untilBatteryInfoArrives() { createController(); // level of -1 indicates missing info BatteryStatus status = new BatteryStatus(BatteryManager.BATTERY_STATUS_UNKNOWN, -1 /* level */, BatteryManager.BATTERY_PLUGGED_WIRELESS, 100 /* health */, 0 /* maxChargingWattage */, true /* present */); mController.setVisible(true); mStatusBarStateListener.onDozingChanged(true); reset(mIndicationArea); mController.getKeyguardCallback().onRefreshBatteryInfo(status); // VISIBLE is always called first verify(mIndicationArea).setVisibility(VISIBLE); verify(mIndicationArea).setVisibility(GONE); } @Test public void onRefreshBatteryInfo_computesChargingTime() throws RemoteException { createController(); Loading