diff options
author | Ricardo Cerqueira <ricardo@cyngn.com> | 2015-11-05 02:27:28 +0000 |
---|---|---|
committer | Ricardo Cerqueira <ricardo@cyngn.com> | 2015-11-05 15:13:26 +0000 |
commit | a89168479cb14f482268af6f1a650b28eba0b393 (patch) | |
tree | 8552b9d49ecfad6a453ee5f743571b700b4d3d3c /packages/SystemUI/src/com/android/systemui/statusbar/KeyguardIndicationController.java | |
parent | 8331d3e508498a19c296fed41b9d4b23ea960031 (diff) | |
parent | 25b5096f154721c8142d54f1b3af9e2998deffe9 (diff) | |
download | frameworks_base-a89168479cb14f482268af6f1a650b28eba0b393.zip frameworks_base-a89168479cb14f482268af6f1a650b28eba0b393.tar.gz frameworks_base-a89168479cb14f482268af6f1a650b28eba0b393.tar.bz2 |
Merge tag 'android-6.0.0_r26' into HEAD
Android 6.0.0 release 26
Conflicts:
cmds/bootanimation/BootAnimation.cpp
core/java/android/accounts/AccountManager.java
core/java/android/app/AppOpsManager.java
core/java/android/os/PowerManagerInternal.java
core/java/android/os/storage/IMountService.java
core/java/android/provider/Settings.java
core/java/com/android/internal/widget/ILockSettings.aidl
core/res/res/values-mcc204-mnc12/config.xml
core/res/res/values-mcc219-mnc02/config.xml
core/res/res/values-mcc730-mnc07/config.xml
core/res/res/values/config.xml
core/res/res/values/symbols.xml
packages/SystemUI/res/values/config.xml
packages/SystemUI/src/com/android/systemui/doze/DozeService.java
packages/SystemUI/src/com/android/systemui/statusbar/CommandQueue.java
packages/SystemUI/src/com/android/systemui/statusbar/ExpandableOutlineView.java
packages/SystemUI/src/com/android/systemui/statusbar/phone/DozeParameters.java
packages/SystemUI/src/com/android/systemui/statusbar/phone/DozeScrimController.java
packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java
packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java
packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarHeaderView.java
packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManager.java
packages/SystemUI/src/com/android/systemui/statusbar/stack/StackScrollAlgorithm.java
services/core/java/com/android/server/LocationManagerService.java
services/core/java/com/android/server/am/ActivityManagerService.java
services/core/java/com/android/server/pm/PackageManagerService.java
services/core/java/com/android/server/power/PowerManagerService.java
telecomm/java/android/telecom/Phone.java
telephony/java/android/telephony/CarrierConfigManager.java
telephony/java/android/telephony/RadioAccessFamily.java
telephony/java/android/telephony/ServiceState.java
telephony/java/android/telephony/SignalStrength.java
telephony/java/android/telephony/TelephonyManager.java
telephony/java/com/android/ims/ImsCallProfile.java
telephony/java/com/android/ims/ImsReasonInfo.java
telephony/java/com/android/ims/ImsSuppServiceNotification.aidl
telephony/java/com/android/ims/ImsSuppServiceNotification.java
telephony/java/com/android/ims/internal/IImsRegistrationListener.aidl
telephony/java/com/android/internal/telephony/RILConstants.java
Change-Id: I99c6edb8e25a77145b5adef97d0d55bfbe676959
Diffstat (limited to 'packages/SystemUI/src/com/android/systemui/statusbar/KeyguardIndicationController.java')
-rw-r--r-- | packages/SystemUI/src/com/android/systemui/statusbar/KeyguardIndicationController.java | 151 |
1 files changed, 133 insertions, 18 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/KeyguardIndicationController.java b/packages/SystemUI/src/com/android/systemui/statusbar/KeyguardIndicationController.java index 07a055c..50d274d 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/KeyguardIndicationController.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/KeyguardIndicationController.java @@ -16,17 +16,13 @@ package com.android.systemui.statusbar; -import com.android.internal.app.IBatteryStats; -import com.android.keyguard.KeyguardUpdateMonitor; -import com.android.keyguard.KeyguardUpdateMonitorCallback; -import com.android.systemui.R; -import com.android.systemui.statusbar.phone.KeyguardIndicationTextView; - import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.content.IntentFilter; +import android.content.res.Resources; import android.graphics.Color; +import android.hardware.fingerprint.FingerprintManager; import android.os.BatteryManager; import android.os.BatteryStats; import android.os.Handler; @@ -39,19 +35,35 @@ import android.text.format.Formatter; import android.util.Log; import android.view.View; +import com.android.internal.app.IBatteryStats; +import com.android.keyguard.KeyguardUpdateMonitor; +import com.android.keyguard.KeyguardUpdateMonitorCallback; +import com.android.systemui.R; +import com.android.systemui.statusbar.phone.KeyguardIndicationTextView; +import com.android.systemui.statusbar.phone.LockIcon; +import com.android.systemui.statusbar.phone.StatusBarKeyguardViewManager; + /** - * Controls the little text indicator on the keyguard. + * Controls the indications and error messages shown on the Keyguard */ public class KeyguardIndicationController { private static final String TAG = "KeyguardIndicationController"; + private static final boolean DEBUG_CHARGING_CURRENT = false; private static final int MSG_HIDE_TRANSIENT = 1; + private static final int MSG_CLEAR_FP_MSG = 2; + private static final long TRANSIENT_FP_ERROR_TIMEOUT = 1300; private final Context mContext; private final KeyguardIndicationTextView mTextView; private final IBatteryStats mBatteryInfo; + private final int mSlowThreshold; + private final int mFastThreshold; + private final LockIcon mLockIcon; + private StatusBarKeyguardViewManager mStatusBarKeyguardViewManager; + private String mRestingIndication; private String mTransientIndication; private int mTransientTextColor; @@ -59,10 +71,20 @@ public class KeyguardIndicationController { private boolean mPowerPluggedIn; private boolean mPowerCharged; + private int mChargingSpeed; + private int mChargingCurrent; + private String mMessageToShowOnScreenOn; - public KeyguardIndicationController(Context context, KeyguardIndicationTextView textView) { + public KeyguardIndicationController(Context context, KeyguardIndicationTextView textView, + LockIcon lockIcon) { mContext = context; mTextView = textView; + mLockIcon = lockIcon; + + Resources res = context.getResources(); + mSlowThreshold = res.getInteger(R.integer.config_chargingSlowlyThreshold); + mFastThreshold = res.getInteger(R.integer.config_chargingFastThreshold); + mBatteryInfo = IBatteryStats.Stub.asInterface( ServiceManager.getService(BatteryStats.SERVICE_NAME)); @@ -150,7 +172,11 @@ public class KeyguardIndicationController { return mTransientIndication; } if (mPowerPluggedIn) { - return computePowerIndication(); + String indication = computePowerIndication(); + if (DEBUG_CHARGING_CURRENT) { + indication += ", " + (mChargingCurrent / 1000) + " mA"; + } + return indication; } return mRestingIndication; } @@ -161,20 +187,41 @@ public class KeyguardIndicationController { } // Try fetching charging time from battery stats. + long chargingTimeRemaining = 0; try { - long chargingTimeRemaining = mBatteryInfo.computeChargeTimeRemaining(); - if (chargingTimeRemaining > 0) { - String chargingTimeFormatted = Formatter.formatShortElapsedTimeRoundingUpToMinutes( - mContext, chargingTimeRemaining); - return mContext.getResources().getString( - R.string.keyguard_indication_charging_time, chargingTimeFormatted); - } + chargingTimeRemaining = mBatteryInfo.computeChargeTimeRemaining(); + } catch (RemoteException e) { Log.e(TAG, "Error calling IBatteryStats: ", e); } + final boolean hasChargingTime = chargingTimeRemaining > 0; - // Fall back to simple charging label. - return mContext.getResources().getString(R.string.keyguard_plugged_in); + int chargingId; + switch (mChargingSpeed) { + case KeyguardUpdateMonitor.BatteryStatus.CHARGING_FAST: + chargingId = hasChargingTime + ? R.string.keyguard_indication_charging_time_fast_if_translated + : R.string.keyguard_plugged_in_charging_fast; + break; + case KeyguardUpdateMonitor.BatteryStatus.CHARGING_SLOWLY: + chargingId = hasChargingTime + ? R.string.keyguard_indication_charging_time_slowly_if_translated + : R.string.keyguard_plugged_in_charging_slowly; + break; + default: + chargingId = hasChargingTime + ? R.string.keyguard_indication_charging_time + : R.string.keyguard_plugged_in; + break; + } + + if (hasChargingTime) { + String chargingTimeFormatted = Formatter.formatShortElapsedTimeRoundingUpToMinutes( + mContext, chargingTimeRemaining); + return mContext.getResources().getString(chargingId, chargingTimeFormatted); + } else { + return mContext.getResources().getString(chargingId); + } } KeyguardUpdateMonitorCallback mUpdateMonitor = new KeyguardUpdateMonitorCallback() { @@ -184,8 +231,68 @@ public class KeyguardIndicationController { || status.status == BatteryManager.BATTERY_STATUS_FULL; mPowerPluggedIn = status.isPluggedIn() && isChargingOrFull; mPowerCharged = status.isCharged(); + mChargingCurrent = status.maxChargingCurrent; + mChargingSpeed = status.getChargingSpeed(mSlowThreshold, mFastThreshold); updateIndication(); } + + @Override + public void onFingerprintHelp(int msgId, String helpString) { + KeyguardUpdateMonitor updateMonitor = KeyguardUpdateMonitor.getInstance(mContext); + if (!updateMonitor.isUnlockingWithFingerprintAllowed()) { + return; + } + int errorColor = mContext.getResources().getColor(R.color.system_warning_color, null); + if (mStatusBarKeyguardViewManager.isBouncerShowing()) { + mStatusBarKeyguardViewManager.showBouncerMessage(helpString, errorColor); + } else if (updateMonitor.isDeviceInteractive()) { + mLockIcon.setTransientFpError(true); + showTransientIndication(helpString, errorColor); + mHandler.removeMessages(MSG_CLEAR_FP_MSG); + mHandler.sendMessageDelayed(mHandler.obtainMessage(MSG_CLEAR_FP_MSG), + TRANSIENT_FP_ERROR_TIMEOUT); + } + } + + @Override + public void onFingerprintError(int msgId, String errString) { + KeyguardUpdateMonitor updateMonitor = KeyguardUpdateMonitor.getInstance(mContext); + if (!updateMonitor.isUnlockingWithFingerprintAllowed() + || msgId == FingerprintManager.FINGERPRINT_ERROR_CANCELED) { + return; + } + int errorColor = mContext.getResources().getColor(R.color.system_warning_color, null); + if (mStatusBarKeyguardViewManager.isBouncerShowing()) { + mStatusBarKeyguardViewManager.showBouncerMessage(errString, errorColor); + } else if (updateMonitor.isDeviceInteractive()) { + showTransientIndication(errString, errorColor); + // We want to keep this message around in case the screen was off + mHandler.removeMessages(MSG_HIDE_TRANSIENT); + hideTransientIndicationDelayed(5000); + } else { + mMessageToShowOnScreenOn = errString; + } + } + + @Override + public void onScreenTurnedOn() { + if (mMessageToShowOnScreenOn != null) { + int errorColor = mContext.getResources().getColor(R.color.system_warning_color, + null); + showTransientIndication(mMessageToShowOnScreenOn, errorColor); + // We want to keep this message around in case the screen was off + mHandler.removeMessages(MSG_HIDE_TRANSIENT); + hideTransientIndicationDelayed(5000); + mMessageToShowOnScreenOn = null; + } + } + + @Override + public void onFingerprintRunningStateChanged(boolean running) { + if (running) { + mMessageToShowOnScreenOn = null; + } + } }; BroadcastReceiver mReceiver = new BroadcastReceiver() { @@ -203,7 +310,15 @@ public class KeyguardIndicationController { if (msg.what == MSG_HIDE_TRANSIENT && mTransientIndication != null) { mTransientIndication = null; updateIndication(); + } else if (msg.what == MSG_CLEAR_FP_MSG) { + mLockIcon.setTransientFpError(false); + hideTransientIndication(); } } }; + + public void setStatusBarKeyguardViewManager( + StatusBarKeyguardViewManager statusBarKeyguardViewManager) { + mStatusBarKeyguardViewManager = statusBarKeyguardViewManager; + } } |