Merge "Show charging status in addition to trust granted" into rvc-dev am: a5a270378d

Change-Id: Ib90a91ba2fc5fe610e432b61ec2a1c961fd63655
This commit is contained in:
Automerger Merge Worker
2020-03-04 21:25:55 +00:00
3 changed files with 52 additions and 7 deletions

View File

@@ -1425,6 +1425,9 @@
<!-- Indication on the keyguard that appears when the user disables trust agents until the next time they unlock manually. [CHAR LIMIT=NONE] --> <!-- Indication on the keyguard that appears when the user disables trust agents until the next time they unlock manually. [CHAR LIMIT=NONE] -->
<string name="keyguard_indication_trust_disabled">Device will stay locked until you manually unlock</string> <string name="keyguard_indication_trust_disabled">Device will stay locked until you manually unlock</string>
<!-- Indication on the keyguard that appears when trust agents unlocks the device and device is plugged in. [CHAR LIMIT=NONE] -->
<string name="keyguard_indication_trust_unlocked_plugged_in"><xliff:g id="keyguard_indication" example="Kept unlocked by TrustAgent">%1$s</xliff:g>\n<xliff:g id="power_indication" example="Charging Slowly">%2$s</xliff:g></string>
<!-- Title of notification educating the user about enabling notifications on the lockscreen. [CHAR LIMIT=40] --> <!-- Title of notification educating the user about enabling notifications on the lockscreen. [CHAR LIMIT=40] -->
<string name="hidden_notifications_title">Get notifications faster</string> <string name="hidden_notifications_title">Get notifications faster</string>

View File

@@ -224,6 +224,14 @@ public class KeyguardIndicationController implements StateListener,
return mContext.getString(R.string.keyguard_indication_trust_unlocked); return mContext.getString(R.string.keyguard_indication_trust_unlocked);
} }
/**
* Sets if the device is plugged in
*/
@VisibleForTesting
void setPowerPluggedIn(boolean plugged) {
mPowerPluggedIn = plugged;
}
/** /**
* Returns the indication text indicating that trust is currently being managed. * Returns the indication text indicating that trust is currently being managed.
* *
@@ -322,29 +330,48 @@ public class KeyguardIndicationController implements StateListener,
int userId = KeyguardUpdateMonitor.getCurrentUser(); int userId = KeyguardUpdateMonitor.getCurrentUser();
String trustGrantedIndication = getTrustGrantedIndication(); String trustGrantedIndication = getTrustGrantedIndication();
String trustManagedIndication = getTrustManagedIndication(); String trustManagedIndication = getTrustManagedIndication();
String powerIndication = null;
if (mPowerPluggedIn) {
powerIndication = computePowerIndication();
}
if (!mKeyguardUpdateMonitor.isUserUnlocked(userId)) { if (!mKeyguardUpdateMonitor.isUserUnlocked(userId)) {
mTextView.switchIndication(com.android.internal.R.string.lockscreen_storage_locked); mTextView.switchIndication(com.android.internal.R.string.lockscreen_storage_locked);
mTextView.setTextColor(mInitialTextColorState); mTextView.setTextColor(mInitialTextColorState);
} else if (!TextUtils.isEmpty(mTransientIndication)) { } else if (!TextUtils.isEmpty(mTransientIndication)) {
mTextView.switchIndication(mTransientIndication); if (powerIndication != null) {
String indication = mContext.getResources().getString(
R.string.keyguard_indication_trust_unlocked_plugged_in,
mTransientIndication, powerIndication);
mTextView.switchIndication(indication);
} else {
mTextView.switchIndication(mTransientIndication);
}
mTextView.setTextColor(mTransientTextColorState); mTextView.setTextColor(mTransientTextColorState);
} else if (!TextUtils.isEmpty(trustGrantedIndication) } else if (!TextUtils.isEmpty(trustGrantedIndication)
&& mKeyguardUpdateMonitor.getUserHasTrust(userId)) { && mKeyguardUpdateMonitor.getUserHasTrust(userId)) {
mTextView.switchIndication(trustGrantedIndication); if (powerIndication != null) {
String indication = mContext.getResources().getString(
R.string.keyguard_indication_trust_unlocked_plugged_in,
trustGrantedIndication, powerIndication);
mTextView.switchIndication(indication);
} else {
mTextView.switchIndication(trustGrantedIndication);
}
mTextView.setTextColor(mInitialTextColorState); mTextView.setTextColor(mInitialTextColorState);
} else if (!TextUtils.isEmpty(mAlignmentIndication)) { } else if (!TextUtils.isEmpty(mAlignmentIndication)) {
mTextView.switchIndication(mAlignmentIndication); mTextView.switchIndication(mAlignmentIndication);
mTextView.setTextColor(Utils.getColorError(mContext)); mTextView.setTextColor(Utils.getColorError(mContext));
} else if (mPowerPluggedIn) { } else if (mPowerPluggedIn) {
String indication = computePowerIndication();
if (DEBUG_CHARGING_SPEED) { if (DEBUG_CHARGING_SPEED) {
indication += ", " + (mChargingWattage / 1000) + " mW"; powerIndication += ", " + (mChargingWattage / 1000) + " mW";
} }
mTextView.setTextColor(mInitialTextColorState); mTextView.setTextColor(mInitialTextColorState);
if (animate) { if (animate) {
animateText(mTextView, indication); animateText(mTextView, powerIndication);
} else { } else {
mTextView.switchIndication(indication); mTextView.switchIndication(powerIndication);
} }
} else if (!TextUtils.isEmpty(trustManagedIndication) } else if (!TextUtils.isEmpty(trustManagedIndication)
&& mKeyguardUpdateMonitor.getUserTrustIsManaged(userId) && mKeyguardUpdateMonitor.getUserTrustIsManaged(userId)
@@ -409,7 +436,8 @@ public class KeyguardIndicationController implements StateListener,
}); });
} }
private String computePowerIndication() { @VisibleForTesting
String computePowerIndication() {
if (mPowerCharged) { if (mPowerCharged) {
return mContext.getResources().getString(R.string.keyguard_charged); return mContext.getResources().getString(R.string.keyguard_charged);
} }

View File

@@ -374,4 +374,18 @@ public class KeyguardIndicationControllerTest extends SysuiTestCase {
verify(mStatusBarStateController).addCallback(eq(mController)); verify(mStatusBarStateController).addCallback(eq(mController));
verify(mKeyguardUpdateMonitor, times(2)).registerCallback(any()); verify(mKeyguardUpdateMonitor, times(2)).registerCallback(any());
} }
@Test
public void unlockMethodCache_listenerUpdatesPluggedIndication() {
createController();
when(mKeyguardUpdateMonitor.getUserHasTrust(anyInt())).thenReturn(true);
mController.setPowerPluggedIn(true);
mController.setVisible(true);
String powerIndication = mController.computePowerIndication();
String pluggedIndication = mContext.getString(R.string.keyguard_indication_trust_unlocked);
pluggedIndication = mContext.getString(
R.string.keyguard_indication_trust_unlocked_plugged_in,
pluggedIndication, powerIndication);
assertThat(mTextView.getText()).isEqualTo(pluggedIndication);
}
} }