Merge changes I71eb6e23,I6cd669ee into tm-qpr-dev

* changes:
  Fix lint warnings in KeyguardUpdateMonitor
  Fix lint errors in KeyguardUpdateMonitor.
This commit is contained in:
Chandru S
2022-10-05 09:15:10 +00:00
committed by Android (Google) Code Review

View File

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