Merge changes I71eb6e23,I6cd669ee into tm-qpr-dev
* changes:
Fix lint warnings in KeyguardUpdateMonitor
Fix lint errors in KeyguardUpdateMonitor.
diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitor.java b/packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitor.java
index 6eef3b3..2a7b62f 100644
--- a/packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitor.java
+++ b/packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitor.java
@@ -69,8 +69,7 @@
import android.annotation.AnyThread;
import android.annotation.MainThread;
-import android.annotation.NonNull;
-import android.annotation.Nullable;
+import android.annotation.SuppressLint;
import android.app.ActivityManager;
import android.app.ActivityTaskManager;
import android.app.ActivityTaskManager.RootTaskInfo;
@@ -126,6 +125,9 @@
import android.util.SparseArray;
import android.util.SparseBooleanArray;
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+
import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.jank.InteractionJankMonitor;
import com.android.internal.logging.InstanceId;
@@ -281,7 +283,6 @@
private final KeyguardUpdateMonitorLogger mLogger;
private final boolean mIsPrimaryUser;
private final AuthController mAuthController;
- private final StatusBarStateController mStatusBarStateController;
private final UiEventLogger mUiEventLogger;
private final Set<Integer> mFaceAcquiredInfoIgnoreList;
private int mStatusBarState;
@@ -304,7 +305,7 @@
};
HashMap<Integer, SimData> mSimDatas = new HashMap<>();
- HashMap<Integer, ServiceState> mServiceStates = new HashMap<Integer, ServiceState>();
+ HashMap<Integer, ServiceState> mServiceStates = new HashMap<>();
private int mPhoneState;
private boolean mKeyguardIsVisible;
@@ -336,34 +337,41 @@
private final ArrayList<WeakReference<KeyguardUpdateMonitorCallback>>
mCallbacks = Lists.newArrayList();
private ContentObserver mDeviceProvisionedObserver;
- private ContentObserver mTimeFormatChangeObserver;
+ private final ContentObserver mTimeFormatChangeObserver;
private boolean mSwitchingUser;
private boolean mDeviceInteractive;
- private SubscriptionManager mSubscriptionManager;
+ private final SubscriptionManager mSubscriptionManager;
private final TelephonyListenerManager mTelephonyListenerManager;
- private List<SubscriptionInfo> mSubscriptionInfo;
- private TrustManager mTrustManager;
- private UserManager mUserManager;
- private KeyguardBypassController mKeyguardBypassController;
- private int mFingerprintRunningState = BIOMETRIC_STATE_STOPPED;
- private int mFaceRunningState = BIOMETRIC_STATE_STOPPED;
- private LockPatternUtils mLockPatternUtils;
- private final IDreamManager mDreamManager;
- private boolean mIsDreaming;
+ private final TrustManager mTrustManager;
+ private final UserManager mUserManager;
private final DevicePolicyManager mDevicePolicyManager;
private final BroadcastDispatcher mBroadcastDispatcher;
private final InteractionJankMonitor mInteractionJankMonitor;
private final LatencyTracker mLatencyTracker;
+ private final StatusBarStateController mStatusBarStateController;
+ private final Executor mBackgroundExecutor;
+ private final SensorPrivacyManager mSensorPrivacyManager;
+ private final ActiveUnlockConfig mActiveUnlockConfig;
+ private final PowerManager mPowerManager;
+ private final IDreamManager mDreamManager;
+ private final TelephonyManager mTelephonyManager;
+ @Nullable
+ private FingerprintManager mFpm;
+ @Nullable
+ private FaceManager mFaceManager;
+ private final LockPatternUtils mLockPatternUtils;
+ private final boolean mWakeOnFingerprintAcquiredStart;
+
+ private KeyguardBypassController mKeyguardBypassController;
+ private List<SubscriptionInfo> mSubscriptionInfo;
+ private int mFingerprintRunningState = BIOMETRIC_STATE_STOPPED;
+ private int mFaceRunningState = BIOMETRIC_STATE_STOPPED;
+ private boolean mIsDreaming;
private boolean mLogoutEnabled;
private boolean mIsFaceEnrolled;
private int mActiveMobileDataSubscription = SubscriptionManager.INVALID_SUBSCRIPTION_ID;
- private final Executor mBackgroundExecutor;
- private SensorPrivacyManager mSensorPrivacyManager;
- private final ActiveUnlockConfig mActiveUnlockConfig;
- private final PowerManager mPowerManager;
- private final boolean mWakeOnFingerprintAcquiredStart;
/**
* Short delay before restarting fingerprint authentication after a successful try. This should
@@ -390,12 +398,10 @@
}
private final Handler mHandler;
- private SparseBooleanArray mBiometricEnabledForUser = new SparseBooleanArray();
- private BiometricManager mBiometricManager;
- private IBiometricEnabledOnKeyguardCallback mBiometricEnabledCallback =
+ private final IBiometricEnabledOnKeyguardCallback mBiometricEnabledCallback =
new IBiometricEnabledOnKeyguardCallback.Stub() {
@Override
- public void onChanged(boolean enabled, int userId) throws RemoteException {
+ public void onChanged(boolean enabled, int userId) {
mHandler.post(() -> {
mBiometricEnabledForUser.put(userId, enabled);
updateBiometricListeningState(BIOMETRIC_ACTION_UPDATE,
@@ -414,7 +420,7 @@
}
};
- private OnSubscriptionsChangedListener mSubscriptionListener =
+ private final OnSubscriptionsChangedListener mSubscriptionListener =
new OnSubscriptionsChangedListener() {
@Override
public void onSubscriptionsChanged() {
@@ -433,11 +439,12 @@
}
}
- private SparseBooleanArray mUserIsUnlocked = new SparseBooleanArray();
- private SparseBooleanArray mUserHasTrust = new SparseBooleanArray();
- private SparseBooleanArray mUserTrustIsManaged = new SparseBooleanArray();
- private SparseBooleanArray mUserTrustIsUsuallyManaged = new SparseBooleanArray();
- private Map<Integer, Intent> mSecondaryLockscreenRequirement = new HashMap<Integer, Intent>();
+ private final SparseBooleanArray mUserIsUnlocked = new SparseBooleanArray();
+ private final SparseBooleanArray mUserHasTrust = new SparseBooleanArray();
+ private final SparseBooleanArray mUserTrustIsManaged = new SparseBooleanArray();
+ private final SparseBooleanArray mUserTrustIsUsuallyManaged = new SparseBooleanArray();
+ private final SparseBooleanArray mBiometricEnabledForUser = new SparseBooleanArray();
+ private final Map<Integer, Intent> mSecondaryLockscreenRequirement = new HashMap<>();
@VisibleForTesting
SparseArray<BiometricAuthenticated> mUserFingerprintAuthenticated = new SparseArray<>();
@@ -598,7 +605,7 @@
}
if (sil == null) {
// getCompleteActiveSubscriptionInfoList was null callers expect an empty list.
- mSubscriptionInfo = new ArrayList<SubscriptionInfo>();
+ mSubscriptionInfo = new ArrayList<>();
} else {
mSubscriptionInfo = sil;
}
@@ -778,12 +785,8 @@
}
private void reportSuccessfulBiometricUnlock(boolean isStrongBiometric, int userId) {
- mBackgroundExecutor.execute(new Runnable() {
- @Override
- public void run() {
- mLockPatternUtils.reportSuccessfulBiometricUnlock(isStrongBiometric, userId);
- }
- });
+ mBackgroundExecutor.execute(
+ () -> mLockPatternUtils.reportSuccessfulBiometricUnlock(isStrongBiometric, userId));
}
private void handleFingerprintAuthFailed() {
@@ -866,7 +869,8 @@
}
}
- private Runnable mRetryFingerprintAuthentication = new Runnable() {
+ private final Runnable mRetryFingerprintAuthentication = new Runnable() {
+ @SuppressLint("MissingPermission")
@Override
public void run() {
mLogger.logRetryAfterFpHwUnavailable(mHardwareFingerprintUnavailableRetryCount);
@@ -910,7 +914,7 @@
boolean lockedOutStateChanged = false;
if (msgId == FingerprintManager.FINGERPRINT_ERROR_LOCKOUT_PERMANENT) {
- lockedOutStateChanged |= !mFingerprintLockedOutPermanent;
+ lockedOutStateChanged = !mFingerprintLockedOutPermanent;
mFingerprintLockedOutPermanent = true;
mLogger.d("Fingerprint locked out - requiring strong auth");
mLockPatternUtils.requireStrongAuth(
@@ -955,9 +959,9 @@
// that the events will arrive in a particular order. Add a delay here in case
// an unlock is in progress. In this is a normal unlock the extra delay won't
// be noticeable.
- mHandler.postDelayed(() -> {
- updateFingerprintListeningState(BIOMETRIC_ACTION_UPDATE);
- }, getBiometricLockoutDelay());
+ mHandler.postDelayed(
+ () -> updateFingerprintListeningState(BIOMETRIC_ACTION_UPDATE),
+ getBiometricLockoutDelay());
} else {
updateFingerprintListeningState(BIOMETRIC_ACTION_UPDATE);
}
@@ -1091,7 +1095,7 @@
}
}
- private Runnable mRetryFaceAuthentication = new Runnable() {
+ private final Runnable mRetryFaceAuthentication = new Runnable() {
@Override
public void run() {
mLogger.logRetryingAfterFaceHwUnavailable(mHardwareFaceUnavailableRetryCount);
@@ -1173,10 +1177,8 @@
mFaceLockedOutPermanent = (mode == BIOMETRIC_LOCKOUT_PERMANENT);
final boolean changed = (mFaceLockedOutPermanent != wasLockoutPermanent);
- mHandler.postDelayed(() -> {
- updateFaceListeningState(BIOMETRIC_ACTION_UPDATE,
- FACE_AUTH_TRIGGERED_FACE_LOCKOUT_RESET);
- }, getBiometricLockoutDelay());
+ mHandler.postDelayed(() -> updateFaceListeningState(BIOMETRIC_ACTION_UPDATE,
+ FACE_AUTH_TRIGGERED_FACE_LOCKOUT_RESET), getBiometricLockoutDelay());
if (changed) {
notifyLockedOutStateChanged(BiometricSourceType.FACE);
@@ -1215,12 +1217,11 @@
return mFaceRunningState == BIOMETRIC_STATE_RUNNING;
}
- private boolean isTrustDisabled(int userId) {
+ private boolean isTrustDisabled() {
// Don't allow trust agent if device is secured with a SIM PIN. This is here
// mainly because there's no other way to prompt the user to enter their SIM PIN
// once they get past the keyguard screen.
- final boolean disabledBySimPin = isSimPinSecure();
- return disabledBySimPin;
+ return isSimPinSecure(); // Disabled by SIM PIN
}
private boolean isFingerprintDisabled(int userId) {
@@ -1258,7 +1259,7 @@
}
public boolean getUserHasTrust(int userId) {
- return !isTrustDisabled(userId) && mUserHasTrust.get(userId);
+ return !isTrustDisabled() && mUserHasTrust.get(userId);
}
/**
@@ -1290,7 +1291,7 @@
}
public boolean getUserTrustIsManaged(int userId) {
- return mUserTrustIsManaged.get(userId) && !isTrustDisabled(userId);
+ return mUserTrustIsManaged.get(userId) && !isTrustDisabled();
}
private void updateSecondaryLockscreenRequirement(int userId) {
@@ -1677,22 +1678,19 @@
CancellationSignal mFingerprintCancelSignal;
@VisibleForTesting
CancellationSignal mFaceCancelSignal;
- private FingerprintManager mFpm;
- private FaceManager mFaceManager;
private List<FingerprintSensorPropertiesInternal> mFingerprintSensorProperties;
private List<FaceSensorPropertiesInternal> mFaceSensorProperties;
private boolean mFingerprintLockedOut;
private boolean mFingerprintLockedOutPermanent;
private boolean mFaceLockedOutPermanent;
- private HashMap<Integer, Boolean> mIsUnlockWithFingerprintPossible = new HashMap<>();
- private TelephonyManager mTelephonyManager;
+ private final HashMap<Integer, Boolean> mIsUnlockWithFingerprintPossible = new HashMap<>();
/**
* When we receive a
* {@link com.android.internal.telephony.TelephonyIntents#ACTION_SIM_STATE_CHANGED} broadcast,
* and then pass a result via our handler to {@link KeyguardUpdateMonitor#handleSimStateChange},
* we need a single object to pass to the handler. This class helps decode
- * the intent and provide a {@link SimCard.State} result.
+ * the intent and provide a {@link SimData} result.
*/
private static class SimData {
public int simState;
@@ -2120,8 +2118,8 @@
}
if (mFpm != null || mFaceManager != null) {
- mBiometricManager = context.getSystemService(BiometricManager.class);
- mBiometricManager.registerEnabledOnKeyguardCallback(mBiometricEnabledCallback);
+ BiometricManager biometricManager = context.getSystemService(BiometricManager.class);
+ biometricManager.registerEnabledOnKeyguardCallback(mBiometricEnabledCallback);
}
// in case authenticators aren't registered yet at this point:
@@ -2235,7 +2233,7 @@
}
@Override
- public void onUserSwitchComplete(int newUserId) throws RemoteException {
+ public void onUserSwitchComplete(int newUserId) {
mHandler.sendMessage(mHandler.obtainMessage(MSG_USER_SWITCH_COMPLETE,
newUserId, 0));
}
@@ -2794,6 +2792,7 @@
return isUnlockWithFacePossible(userId) || isUnlockWithFingerprintPossible(userId);
}
+ @SuppressLint("MissingPermission")
@VisibleForTesting
boolean isUnlockWithFingerprintPossible(int userId) {
// TODO (b/242022358), make this rely on onEnrollmentChanged event and update it only once.
@@ -2924,6 +2923,7 @@
try {
reply.sendResult(null);
} catch (RemoteException e) {
+ mLogger.logException(e, "Ignored exception while userSwitching");
}
}
@@ -3320,11 +3320,7 @@
}
// change in battery overheat
- if (current.health != old.health) {
- return true;
- }
-
- return false;
+ return current.health != old.health;
}
/**
@@ -3375,10 +3371,8 @@
public void setSwitchingUser(boolean switching) {
mSwitchingUser = switching;
// Since this comes in on a binder thread, we need to post if first
- mHandler.post(() -> {
- updateBiometricListeningState(BIOMETRIC_ACTION_UPDATE,
- FACE_AUTH_UPDATED_USER_SWITCHING);
- });
+ mHandler.post(() -> updateBiometricListeningState(BIOMETRIC_ACTION_UPDATE,
+ FACE_AUTH_UPDATED_USER_SWITCHING));
}
private void sendUpdates(KeyguardUpdateMonitorCallback callback) {
@@ -3487,7 +3481,7 @@
/**
* If any SIM cards are currently secure.
*
- * @see #isSimPinSecure(State)
+ * @see #isSimPinSecure(int)
*/
public boolean isSimPinSecure() {
// True if any SIM is pin secure
@@ -3716,8 +3710,9 @@
mHandler.removeCallbacksAndMessages(null);
}
+ @SuppressLint("MissingPermission")
@Override
- public void dump(PrintWriter pw, String[] args) {
+ public void dump(@NonNull PrintWriter pw, @NonNull String[] args) {
pw.println("KeyguardUpdateMonitor state:");
pw.println(" getUserHasTrust()=" + getUserHasTrust(getCurrentUser()));
pw.println(" getUserUnlockedWithBiometric()="