Merge "Inject system services instead of using context.getSystemService" into tm-qpr-dev am: 580e951458
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/19990924 Change-Id: I21eca215b857c5389950611d0c8e931b7d6b015e Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -112,7 +112,6 @@ import android.os.Trace;
|
|||||||
import android.os.UserHandle;
|
import android.os.UserHandle;
|
||||||
import android.os.UserManager;
|
import android.os.UserManager;
|
||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
import android.service.dreams.DreamService;
|
|
||||||
import android.service.dreams.IDreamManager;
|
import android.service.dreams.IDreamManager;
|
||||||
import android.telephony.CarrierConfigManager;
|
import android.telephony.CarrierConfigManager;
|
||||||
import android.telephony.ServiceState;
|
import android.telephony.ServiceState;
|
||||||
@@ -285,6 +284,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
|
|||||||
private final AuthController mAuthController;
|
private final AuthController mAuthController;
|
||||||
private final UiEventLogger mUiEventLogger;
|
private final UiEventLogger mUiEventLogger;
|
||||||
private final Set<Integer> mFaceAcquiredInfoIgnoreList;
|
private final Set<Integer> mFaceAcquiredInfoIgnoreList;
|
||||||
|
private final PackageManager mPackageManager;
|
||||||
private int mStatusBarState;
|
private int mStatusBarState;
|
||||||
private final StatusBarStateController.StateListener mStatusBarStateControllerListener =
|
private final StatusBarStateController.StateListener mStatusBarStateControllerListener =
|
||||||
new StatusBarStateController.StateListener() {
|
new StatusBarStateController.StateListener() {
|
||||||
@@ -358,9 +358,9 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
|
|||||||
private final IDreamManager mDreamManager;
|
private final IDreamManager mDreamManager;
|
||||||
private final TelephonyManager mTelephonyManager;
|
private final TelephonyManager mTelephonyManager;
|
||||||
@Nullable
|
@Nullable
|
||||||
private FingerprintManager mFpm;
|
private final FingerprintManager mFpm;
|
||||||
@Nullable
|
@Nullable
|
||||||
private FaceManager mFaceManager;
|
private final FaceManager mFaceManager;
|
||||||
private final LockPatternUtils mLockPatternUtils;
|
private final LockPatternUtils mLockPatternUtils;
|
||||||
private final boolean mWakeOnFingerprintAcquiredStart;
|
private final boolean mWakeOnFingerprintAcquiredStart;
|
||||||
|
|
||||||
@@ -740,7 +740,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
|
|||||||
* If the device is dreaming, awakens the device
|
* If the device is dreaming, awakens the device
|
||||||
*/
|
*/
|
||||||
public void awakenFromDream() {
|
public void awakenFromDream() {
|
||||||
if (mIsDreaming && mDreamManager != null) {
|
if (mIsDreaming) {
|
||||||
try {
|
try {
|
||||||
mDreamManager.awaken();
|
mDreamManager.awaken();
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
@@ -1121,12 +1121,8 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
|
|||||||
|
|
||||||
// Error is always the end of authentication lifecycle
|
// Error is always the end of authentication lifecycle
|
||||||
mFaceCancelSignal = null;
|
mFaceCancelSignal = null;
|
||||||
boolean cameraPrivacyEnabled = false;
|
boolean cameraPrivacyEnabled = mSensorPrivacyManager.isSensorPrivacyEnabled(
|
||||||
if (mSensorPrivacyManager != null) {
|
SensorPrivacyManager.TOGGLE_TYPE_SOFTWARE, SensorPrivacyManager.Sensors.CAMERA);
|
||||||
cameraPrivacyEnabled = mSensorPrivacyManager
|
|
||||||
.isSensorPrivacyEnabled(SensorPrivacyManager.TOGGLE_TYPE_SOFTWARE,
|
|
||||||
SensorPrivacyManager.Sensors.CAMERA);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (msgId == FaceManager.FACE_ERROR_CANCELED
|
if (msgId == FaceManager.FACE_ERROR_CANCELED
|
||||||
&& mFaceRunningState == BIOMETRIC_STATE_CANCELLING_RESTARTING) {
|
&& mFaceRunningState == BIOMETRIC_STATE_CANCELLING_RESTARTING) {
|
||||||
@@ -1225,18 +1221,15 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean isFingerprintDisabled(int userId) {
|
private boolean isFingerprintDisabled(int userId) {
|
||||||
final DevicePolicyManager dpm =
|
return (mDevicePolicyManager.getKeyguardDisabledFeatures(null, userId)
|
||||||
(DevicePolicyManager) mContext.getSystemService(Context.DEVICE_POLICY_SERVICE);
|
|
||||||
return dpm != null && (dpm.getKeyguardDisabledFeatures(null, userId)
|
|
||||||
& DevicePolicyManager.KEYGUARD_DISABLE_FINGERPRINT) != 0
|
& DevicePolicyManager.KEYGUARD_DISABLE_FINGERPRINT) != 0
|
||||||
|| isSimPinSecure();
|
|| isSimPinSecure();
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isFaceDisabled(int userId) {
|
private boolean isFaceDisabled(int userId) {
|
||||||
final DevicePolicyManager dpm =
|
|
||||||
(DevicePolicyManager) mContext.getSystemService(Context.DEVICE_POLICY_SERVICE);
|
|
||||||
// TODO(b/140035044)
|
// TODO(b/140035044)
|
||||||
return whitelistIpcs(() -> dpm != null && (dpm.getKeyguardDisabledFeatures(null, userId)
|
return whitelistIpcs(() ->
|
||||||
|
(mDevicePolicyManager.getKeyguardDisabledFeatures(null, userId)
|
||||||
& DevicePolicyManager.KEYGUARD_DISABLE_FACE) != 0
|
& DevicePolicyManager.KEYGUARD_DISABLE_FACE) != 0
|
||||||
|| isSimPinSecure());
|
|| isSimPinSecure());
|
||||||
}
|
}
|
||||||
@@ -1309,7 +1302,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
|
|||||||
Intent intent =
|
Intent intent =
|
||||||
new Intent(DevicePolicyManager.ACTION_BIND_SECONDARY_LOCKSCREEN_SERVICE)
|
new Intent(DevicePolicyManager.ACTION_BIND_SECONDARY_LOCKSCREEN_SERVICE)
|
||||||
.setPackage(supervisorComponent.getPackageName());
|
.setPackage(supervisorComponent.getPackageName());
|
||||||
ResolveInfo resolveInfo = mContext.getPackageManager().resolveService(intent, 0);
|
ResolveInfo resolveInfo = mPackageManager.resolveService(intent, 0);
|
||||||
if (resolveInfo != null && resolveInfo.serviceInfo != null) {
|
if (resolveInfo != null && resolveInfo.serviceInfo != null) {
|
||||||
Intent launchIntent =
|
Intent launchIntent =
|
||||||
new Intent().setComponent(resolveInfo.serviceInfo.getComponentName());
|
new Intent().setComponent(resolveInfo.serviceInfo.getComponentName());
|
||||||
@@ -1911,9 +1904,20 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
|
|||||||
UiEventLogger uiEventLogger,
|
UiEventLogger uiEventLogger,
|
||||||
// This has to be a provider because SessionTracker depends on KeyguardUpdateMonitor :(
|
// This has to be a provider because SessionTracker depends on KeyguardUpdateMonitor :(
|
||||||
Provider<SessionTracker> sessionTrackerProvider,
|
Provider<SessionTracker> sessionTrackerProvider,
|
||||||
PowerManager powerManager) {
|
PowerManager powerManager,
|
||||||
|
TrustManager trustManager,
|
||||||
|
SubscriptionManager subscriptionManager,
|
||||||
|
UserManager userManager,
|
||||||
|
IDreamManager dreamManager,
|
||||||
|
DevicePolicyManager devicePolicyManager,
|
||||||
|
SensorPrivacyManager sensorPrivacyManager,
|
||||||
|
TelephonyManager telephonyManager,
|
||||||
|
PackageManager packageManager,
|
||||||
|
@Nullable FaceManager faceManager,
|
||||||
|
@Nullable FingerprintManager fingerprintManager,
|
||||||
|
@Nullable BiometricManager biometricManager) {
|
||||||
mContext = context;
|
mContext = context;
|
||||||
mSubscriptionManager = SubscriptionManager.from(context);
|
mSubscriptionManager = subscriptionManager;
|
||||||
mTelephonyListenerManager = telephonyListenerManager;
|
mTelephonyListenerManager = telephonyListenerManager;
|
||||||
mDeviceProvisioned = isDeviceProvisionedInSettingsDb();
|
mDeviceProvisioned = isDeviceProvisionedInSettingsDb();
|
||||||
mStrongAuthTracker = new StrongAuthTracker(context, this::notifyStrongAuthStateChanged);
|
mStrongAuthTracker = new StrongAuthTracker(context, this::notifyStrongAuthStateChanged);
|
||||||
@@ -1927,12 +1931,20 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
|
|||||||
mLockPatternUtils = lockPatternUtils;
|
mLockPatternUtils = lockPatternUtils;
|
||||||
mAuthController = authController;
|
mAuthController = authController;
|
||||||
dumpManager.registerDumpable(getClass().getName(), this);
|
dumpManager.registerDumpable(getClass().getName(), this);
|
||||||
mSensorPrivacyManager = context.getSystemService(SensorPrivacyManager.class);
|
mSensorPrivacyManager = sensorPrivacyManager;
|
||||||
mActiveUnlockConfig = activeUnlockConfiguration;
|
mActiveUnlockConfig = activeUnlockConfiguration;
|
||||||
mLogger = logger;
|
mLogger = logger;
|
||||||
mUiEventLogger = uiEventLogger;
|
mUiEventLogger = uiEventLogger;
|
||||||
mSessionTrackerProvider = sessionTrackerProvider;
|
mSessionTrackerProvider = sessionTrackerProvider;
|
||||||
mPowerManager = powerManager;
|
mPowerManager = powerManager;
|
||||||
|
mTrustManager = trustManager;
|
||||||
|
mUserManager = userManager;
|
||||||
|
mDreamManager = dreamManager;
|
||||||
|
mTelephonyManager = telephonyManager;
|
||||||
|
mDevicePolicyManager = devicePolicyManager;
|
||||||
|
mPackageManager = packageManager;
|
||||||
|
mFpm = fingerprintManager;
|
||||||
|
mFaceManager = faceManager;
|
||||||
mActiveUnlockConfig.setKeyguardUpdateMonitor(this);
|
mActiveUnlockConfig.setKeyguardUpdateMonitor(this);
|
||||||
mWakeOnFingerprintAcquiredStart = context.getResources()
|
mWakeOnFingerprintAcquiredStart = context.getResources()
|
||||||
.getBoolean(com.android.internal.R.bool.kg_wake_on_acquire_start);
|
.getBoolean(com.android.internal.R.bool.kg_wake_on_acquire_start);
|
||||||
@@ -2077,8 +2089,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
|
|||||||
// listener now with the service state from the default sub.
|
// listener now with the service state from the default sub.
|
||||||
mBackgroundExecutor.execute(() -> {
|
mBackgroundExecutor.execute(() -> {
|
||||||
int subId = SubscriptionManager.getDefaultSubscriptionId();
|
int subId = SubscriptionManager.getDefaultSubscriptionId();
|
||||||
ServiceState serviceState = mContext.getSystemService(TelephonyManager.class)
|
ServiceState serviceState = mTelephonyManager.getServiceStateForSubscriber(subId);
|
||||||
.getServiceStateForSubscriber(subId);
|
|
||||||
mHandler.sendMessage(
|
mHandler.sendMessage(
|
||||||
mHandler.obtainMessage(MSG_SERVICE_STATE_CHANGE, subId, 0, serviceState));
|
mHandler.obtainMessage(MSG_SERVICE_STATE_CHANGE, subId, 0, serviceState));
|
||||||
});
|
});
|
||||||
@@ -2100,25 +2111,20 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
|
|||||||
e.rethrowAsRuntimeException();
|
e.rethrowAsRuntimeException();
|
||||||
}
|
}
|
||||||
|
|
||||||
mTrustManager = context.getSystemService(TrustManager.class);
|
|
||||||
mTrustManager.registerTrustListener(this);
|
mTrustManager.registerTrustListener(this);
|
||||||
|
|
||||||
setStrongAuthTracker(mStrongAuthTracker);
|
setStrongAuthTracker(mStrongAuthTracker);
|
||||||
|
|
||||||
mDreamManager = IDreamManager.Stub.asInterface(
|
if (mFpm != null) {
|
||||||
ServiceManager.getService(DreamService.DREAM_SERVICE));
|
|
||||||
|
|
||||||
if (mContext.getPackageManager().hasSystemFeature(PackageManager.FEATURE_FINGERPRINT)) {
|
|
||||||
mFpm = (FingerprintManager) context.getSystemService(Context.FINGERPRINT_SERVICE);
|
|
||||||
mFingerprintSensorProperties = mFpm.getSensorPropertiesInternal();
|
mFingerprintSensorProperties = mFpm.getSensorPropertiesInternal();
|
||||||
|
mFpm.addLockoutResetCallback(mFingerprintLockoutResetCallback);
|
||||||
}
|
}
|
||||||
if (mContext.getPackageManager().hasSystemFeature(PackageManager.FEATURE_FACE)) {
|
if (mFaceManager != null) {
|
||||||
mFaceManager = (FaceManager) context.getSystemService(Context.FACE_SERVICE);
|
|
||||||
mFaceSensorProperties = mFaceManager.getSensorPropertiesInternal();
|
mFaceSensorProperties = mFaceManager.getSensorPropertiesInternal();
|
||||||
|
mFaceManager.addLockoutResetCallback(mFaceLockoutResetCallback);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mFpm != null || mFaceManager != null) {
|
if (biometricManager != null) {
|
||||||
BiometricManager biometricManager = context.getSystemService(BiometricManager.class);
|
|
||||||
biometricManager.registerEnabledOnKeyguardCallback(mBiometricEnabledCallback);
|
biometricManager.registerEnabledOnKeyguardCallback(mBiometricEnabledCallback);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2137,19 +2143,11 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
updateBiometricListeningState(BIOMETRIC_ACTION_UPDATE, FACE_AUTH_UPDATED_ON_KEYGUARD_INIT);
|
updateBiometricListeningState(BIOMETRIC_ACTION_UPDATE, FACE_AUTH_UPDATED_ON_KEYGUARD_INIT);
|
||||||
if (mFpm != null) {
|
|
||||||
mFpm.addLockoutResetCallback(mFingerprintLockoutResetCallback);
|
|
||||||
}
|
|
||||||
if (mFaceManager != null) {
|
|
||||||
mFaceManager.addLockoutResetCallback(mFaceLockoutResetCallback);
|
|
||||||
}
|
|
||||||
|
|
||||||
TaskStackChangeListeners.getInstance().registerTaskStackListener(mTaskStackListener);
|
TaskStackChangeListeners.getInstance().registerTaskStackListener(mTaskStackListener);
|
||||||
mUserManager = context.getSystemService(UserManager.class);
|
|
||||||
mIsPrimaryUser = mUserManager.isPrimaryUser();
|
mIsPrimaryUser = mUserManager.isPrimaryUser();
|
||||||
int user = ActivityManager.getCurrentUser();
|
int user = ActivityManager.getCurrentUser();
|
||||||
mUserIsUnlocked.put(user, mUserManager.isUserUnlocked(user));
|
mUserIsUnlocked.put(user, mUserManager.isUserUnlocked(user));
|
||||||
mDevicePolicyManager = context.getSystemService(DevicePolicyManager.class);
|
|
||||||
mLogoutEnabled = mDevicePolicyManager.isLogoutEnabled();
|
mLogoutEnabled = mDevicePolicyManager.isLogoutEnabled();
|
||||||
updateSecondaryLockscreenRequirement(user);
|
updateSecondaryLockscreenRequirement(user);
|
||||||
List<UserInfo> allUsers = mUserManager.getUsers();
|
List<UserInfo> allUsers = mUserManager.getUsers();
|
||||||
@@ -2159,22 +2157,8 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
|
|||||||
}
|
}
|
||||||
updateAirplaneModeState();
|
updateAirplaneModeState();
|
||||||
|
|
||||||
mTelephonyManager =
|
|
||||||
(TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
|
|
||||||
if (mTelephonyManager != null) {
|
|
||||||
mTelephonyListenerManager.addActiveDataSubscriptionIdListener(mPhoneStateListener);
|
mTelephonyListenerManager.addActiveDataSubscriptionIdListener(mPhoneStateListener);
|
||||||
// Set initial sim states values.
|
initializeSimState();
|
||||||
for (int slot = 0; slot < mTelephonyManager.getActiveModemCount(); slot++) {
|
|
||||||
int state = mTelephonyManager.getSimState(slot);
|
|
||||||
int[] subIds = mSubscriptionManager.getSubscriptionIds(slot);
|
|
||||||
if (subIds != null) {
|
|
||||||
for (int subId : subIds) {
|
|
||||||
mHandler.obtainMessage(MSG_SIM_STATE_CHANGE, subId, slot, state)
|
|
||||||
.sendToTarget();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
mTimeFormatChangeObserver = new ContentObserver(mHandler) {
|
mTimeFormatChangeObserver = new ContentObserver(mHandler) {
|
||||||
@Override
|
@Override
|
||||||
@@ -2191,6 +2175,20 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
|
|||||||
false, mTimeFormatChangeObserver, UserHandle.USER_ALL);
|
false, mTimeFormatChangeObserver, UserHandle.USER_ALL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void initializeSimState() {
|
||||||
|
// Set initial sim states values.
|
||||||
|
for (int slot = 0; slot < mTelephonyManager.getActiveModemCount(); slot++) {
|
||||||
|
int state = mTelephonyManager.getSimState(slot);
|
||||||
|
int[] subIds = mSubscriptionManager.getSubscriptionIds(slot);
|
||||||
|
if (subIds != null) {
|
||||||
|
for (int subId : subIds) {
|
||||||
|
mHandler.obtainMessage(MSG_SIM_STATE_CHANGE, subId, slot, state)
|
||||||
|
.sendToTarget();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void updateFaceEnrolled(int userId) {
|
private void updateFaceEnrolled(int userId) {
|
||||||
mIsFaceEnrolled = whitelistIpcs(
|
mIsFaceEnrolled = whitelistIpcs(
|
||||||
() -> mFaceManager != null && mFaceManager.isHardwareDetected()
|
() -> mFaceManager != null && mFaceManager.isHardwareDetected()
|
||||||
@@ -3190,7 +3188,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
Intent homeIntent = new Intent(Intent.ACTION_MAIN).addCategory(Intent.CATEGORY_HOME);
|
Intent homeIntent = new Intent(Intent.ACTION_MAIN).addCategory(Intent.CATEGORY_HOME);
|
||||||
ResolveInfo resolveInfo = mContext.getPackageManager().resolveActivityAsUser(homeIntent,
|
ResolveInfo resolveInfo = mPackageManager.resolveActivityAsUser(homeIntent,
|
||||||
0 /* flags */, getCurrentUser());
|
0 /* flags */, getCurrentUser());
|
||||||
|
|
||||||
if (resolveInfo == null) {
|
if (resolveInfo == null) {
|
||||||
@@ -3528,10 +3526,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
|
|||||||
* @return true if and only if the state has changed for the specified {@code slotId}
|
* @return true if and only if the state has changed for the specified {@code slotId}
|
||||||
*/
|
*/
|
||||||
private boolean refreshSimState(int subId, int slotId) {
|
private boolean refreshSimState(int subId, int slotId) {
|
||||||
final TelephonyManager tele =
|
int state = mTelephonyManager.getSimState(slotId);
|
||||||
(TelephonyManager) mContext.getSystemService(Context.TELEPHONY_SERVICE);
|
|
||||||
int state = (tele != null) ?
|
|
||||||
tele.getSimState(slotId) : TelephonyManager.SIM_STATE_UNKNOWN;
|
|
||||||
SimData data = mSimDatas.get(subId);
|
SimData data = mSimDatas.get(subId);
|
||||||
final boolean changed;
|
final boolean changed;
|
||||||
if (data == null) {
|
if (data == null) {
|
||||||
@@ -3674,13 +3669,8 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
|
|||||||
* Unregister all listeners.
|
* Unregister all listeners.
|
||||||
*/
|
*/
|
||||||
public void destroy() {
|
public void destroy() {
|
||||||
// TODO: inject these dependencies:
|
mStatusBarStateController.removeCallback(mStatusBarStateControllerListener);
|
||||||
TelephonyManager telephony =
|
|
||||||
(TelephonyManager) mContext.getSystemService(Context.TELEPHONY_SERVICE);
|
|
||||||
if (telephony != null) {
|
|
||||||
mTelephonyListenerManager.removeActiveDataSubscriptionIdListener(mPhoneStateListener);
|
mTelephonyListenerManager.removeActiveDataSubscriptionIdListener(mPhoneStateListener);
|
||||||
}
|
|
||||||
|
|
||||||
mSubscriptionManager.removeOnSubscriptionsChangedListener(mSubscriptionListener);
|
mSubscriptionManager.removeOnSubscriptionsChangedListener(mSubscriptionListener);
|
||||||
|
|
||||||
if (mDeviceProvisionedObserver != null) {
|
if (mDeviceProvisionedObserver != null) {
|
||||||
|
|||||||
@@ -46,6 +46,7 @@ import android.content.res.AssetManager;
|
|||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
import android.hardware.SensorManager;
|
import android.hardware.SensorManager;
|
||||||
import android.hardware.SensorPrivacyManager;
|
import android.hardware.SensorPrivacyManager;
|
||||||
|
import android.hardware.biometrics.BiometricManager;
|
||||||
import android.hardware.camera2.CameraManager;
|
import android.hardware.camera2.CameraManager;
|
||||||
import android.hardware.devicestate.DeviceStateManager;
|
import android.hardware.devicestate.DeviceStateManager;
|
||||||
import android.hardware.display.AmbientDisplayConfiguration;
|
import android.hardware.display.AmbientDisplayConfiguration;
|
||||||
@@ -237,23 +238,40 @@ public class FrameworkServicesModule {
|
|||||||
@Singleton
|
@Singleton
|
||||||
static IDreamManager provideIDreamManager() {
|
static IDreamManager provideIDreamManager() {
|
||||||
return IDreamManager.Stub.asInterface(
|
return IDreamManager.Stub.asInterface(
|
||||||
ServiceManager.checkService(DreamService.DREAM_SERVICE));
|
ServiceManager.getService(DreamService.DREAM_SERVICE));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
@Singleton
|
@Singleton
|
||||||
@Nullable
|
@Nullable
|
||||||
static FaceManager provideFaceManager(Context context) {
|
static FaceManager provideFaceManager(Context context) {
|
||||||
|
if (context.getPackageManager().hasSystemFeature(PackageManager.FEATURE_FACE)) {
|
||||||
return context.getSystemService(FaceManager.class);
|
return context.getSystemService(FaceManager.class);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
@Singleton
|
@Singleton
|
||||||
@Nullable
|
@Nullable
|
||||||
static FingerprintManager providesFingerprintManager(Context context) {
|
static FingerprintManager providesFingerprintManager(Context context) {
|
||||||
|
if (context.getPackageManager().hasSystemFeature(PackageManager.FEATURE_FINGERPRINT)) {
|
||||||
return context.getSystemService(FingerprintManager.class);
|
return context.getSystemService(FingerprintManager.class);
|
||||||
}
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return null if both faceManager and fingerprintManager are null.
|
||||||
|
*/
|
||||||
|
@Provides
|
||||||
|
@Singleton
|
||||||
|
@Nullable
|
||||||
|
static BiometricManager providesBiometricManager(Context context,
|
||||||
|
@Nullable FaceManager faceManager, @Nullable FingerprintManager fingerprintManager) {
|
||||||
|
return faceManager == null && fingerprintManager == null ? null :
|
||||||
|
context.getSystemService(BiometricManager.class);
|
||||||
|
}
|
||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
@Singleton
|
@Singleton
|
||||||
|
|||||||
@@ -59,6 +59,7 @@ import android.content.pm.PackageManager;
|
|||||||
import android.content.pm.ResolveInfo;
|
import android.content.pm.ResolveInfo;
|
||||||
import android.content.pm.ServiceInfo;
|
import android.content.pm.ServiceInfo;
|
||||||
import android.content.pm.UserInfo;
|
import android.content.pm.UserInfo;
|
||||||
|
import android.hardware.SensorPrivacyManager;
|
||||||
import android.hardware.biometrics.BiometricConstants;
|
import android.hardware.biometrics.BiometricConstants;
|
||||||
import android.hardware.biometrics.BiometricManager;
|
import android.hardware.biometrics.BiometricManager;
|
||||||
import android.hardware.biometrics.BiometricSourceType;
|
import android.hardware.biometrics.BiometricSourceType;
|
||||||
@@ -79,13 +80,13 @@ import android.os.PowerManager;
|
|||||||
import android.os.RemoteException;
|
import android.os.RemoteException;
|
||||||
import android.os.UserHandle;
|
import android.os.UserHandle;
|
||||||
import android.os.UserManager;
|
import android.os.UserManager;
|
||||||
|
import android.service.dreams.IDreamManager;
|
||||||
import android.telephony.ServiceState;
|
import android.telephony.ServiceState;
|
||||||
import android.telephony.SubscriptionInfo;
|
import android.telephony.SubscriptionInfo;
|
||||||
import android.telephony.SubscriptionManager;
|
import android.telephony.SubscriptionManager;
|
||||||
import android.telephony.TelephonyManager;
|
import android.telephony.TelephonyManager;
|
||||||
import android.test.suitebuilder.annotation.SmallTest;
|
import android.test.suitebuilder.annotation.SmallTest;
|
||||||
import android.testing.AndroidTestingRunner;
|
import android.testing.AndroidTestingRunner;
|
||||||
import android.testing.TestableContext;
|
|
||||||
import android.testing.TestableLooper;
|
import android.testing.TestableLooper;
|
||||||
|
|
||||||
import com.android.dx.mockito.inline.extended.ExtendedMockito;
|
import com.android.dx.mockito.inline.extended.ExtendedMockito;
|
||||||
@@ -170,6 +171,8 @@ public class KeyguardUpdateMonitorTest extends SysuiTestCase {
|
|||||||
@Mock
|
@Mock
|
||||||
private DevicePolicyManager mDevicePolicyManager;
|
private DevicePolicyManager mDevicePolicyManager;
|
||||||
@Mock
|
@Mock
|
||||||
|
private IDreamManager mDreamManager;
|
||||||
|
@Mock
|
||||||
private KeyguardBypassController mKeyguardBypassController;
|
private KeyguardBypassController mKeyguardBypassController;
|
||||||
@Mock
|
@Mock
|
||||||
private SubscriptionManager mSubscriptionManager;
|
private SubscriptionManager mSubscriptionManager;
|
||||||
@@ -178,6 +181,8 @@ public class KeyguardUpdateMonitorTest extends SysuiTestCase {
|
|||||||
@Mock
|
@Mock
|
||||||
private TelephonyManager mTelephonyManager;
|
private TelephonyManager mTelephonyManager;
|
||||||
@Mock
|
@Mock
|
||||||
|
private SensorPrivacyManager mSensorPrivacyManager;
|
||||||
|
@Mock
|
||||||
private StatusBarStateController mStatusBarStateController;
|
private StatusBarStateController mStatusBarStateController;
|
||||||
@Mock
|
@Mock
|
||||||
private AuthController mAuthController;
|
private AuthController mAuthController;
|
||||||
@@ -219,7 +224,6 @@ public class KeyguardUpdateMonitorTest extends SysuiTestCase {
|
|||||||
private TestableLooper mTestableLooper;
|
private TestableLooper mTestableLooper;
|
||||||
private Handler mHandler;
|
private Handler mHandler;
|
||||||
private TestableKeyguardUpdateMonitor mKeyguardUpdateMonitor;
|
private TestableKeyguardUpdateMonitor mKeyguardUpdateMonitor;
|
||||||
private TestableContext mSpiedContext;
|
|
||||||
private MockitoSession mMockitoSession;
|
private MockitoSession mMockitoSession;
|
||||||
private StatusBarStateController.StateListener mStatusBarStateListener;
|
private StatusBarStateController.StateListener mStatusBarStateListener;
|
||||||
private IBiometricEnabledOnKeyguardCallback mBiometricEnabledOnKeyguardCallback;
|
private IBiometricEnabledOnKeyguardCallback mBiometricEnabledOnKeyguardCallback;
|
||||||
@@ -228,9 +232,6 @@ public class KeyguardUpdateMonitorTest extends SysuiTestCase {
|
|||||||
@Before
|
@Before
|
||||||
public void setup() throws RemoteException {
|
public void setup() throws RemoteException {
|
||||||
MockitoAnnotations.initMocks(this);
|
MockitoAnnotations.initMocks(this);
|
||||||
mSpiedContext = spy(mContext);
|
|
||||||
when(mPackageManager.hasSystemFeature(anyString())).thenReturn(true);
|
|
||||||
when(mSpiedContext.getPackageManager()).thenReturn(mPackageManager);
|
|
||||||
when(mActivityService.getCurrentUser()).thenReturn(mCurrentUserInfo);
|
when(mActivityService.getCurrentUser()).thenReturn(mCurrentUserInfo);
|
||||||
when(mActivityService.getCurrentUserId()).thenReturn(mCurrentUserId);
|
when(mActivityService.getCurrentUserId()).thenReturn(mCurrentUserId);
|
||||||
when(mFaceManager.isHardwareDetected()).thenReturn(true);
|
when(mFaceManager.isHardwareDetected()).thenReturn(true);
|
||||||
@@ -279,14 +280,6 @@ public class KeyguardUpdateMonitorTest extends SysuiTestCase {
|
|||||||
.thenReturn(new ServiceState());
|
.thenReturn(new ServiceState());
|
||||||
when(mLockPatternUtils.getLockSettings()).thenReturn(mLockSettings);
|
when(mLockPatternUtils.getLockSettings()).thenReturn(mLockSettings);
|
||||||
when(mAuthController.isUdfpsEnrolled(anyInt())).thenReturn(false);
|
when(mAuthController.isUdfpsEnrolled(anyInt())).thenReturn(false);
|
||||||
mSpiedContext.addMockSystemService(TrustManager.class, mTrustManager);
|
|
||||||
mSpiedContext.addMockSystemService(FingerprintManager.class, mFingerprintManager);
|
|
||||||
mSpiedContext.addMockSystemService(BiometricManager.class, mBiometricManager);
|
|
||||||
mSpiedContext.addMockSystemService(FaceManager.class, mFaceManager);
|
|
||||||
mSpiedContext.addMockSystemService(UserManager.class, mUserManager);
|
|
||||||
mSpiedContext.addMockSystemService(DevicePolicyManager.class, mDevicePolicyManager);
|
|
||||||
mSpiedContext.addMockSystemService(SubscriptionManager.class, mSubscriptionManager);
|
|
||||||
mSpiedContext.addMockSystemService(TelephonyManager.class, mTelephonyManager);
|
|
||||||
|
|
||||||
mMockitoSession = ExtendedMockito.mockitoSession()
|
mMockitoSession = ExtendedMockito.mockitoSession()
|
||||||
.spyStatic(SubscriptionManager.class)
|
.spyStatic(SubscriptionManager.class)
|
||||||
@@ -301,7 +294,7 @@ public class KeyguardUpdateMonitorTest extends SysuiTestCase {
|
|||||||
|
|
||||||
mTestableLooper = TestableLooper.get(this);
|
mTestableLooper = TestableLooper.get(this);
|
||||||
allowTestableLooperAsMainThread();
|
allowTestableLooperAsMainThread();
|
||||||
mKeyguardUpdateMonitor = new TestableKeyguardUpdateMonitor(mSpiedContext);
|
mKeyguardUpdateMonitor = new TestableKeyguardUpdateMonitor(mContext);
|
||||||
|
|
||||||
verify(mBiometricManager)
|
verify(mBiometricManager)
|
||||||
.registerEnabledOnKeyguardCallback(mBiometricEnabledCallbackArgCaptor.capture());
|
.registerEnabledOnKeyguardCallback(mBiometricEnabledCallbackArgCaptor.capture());
|
||||||
@@ -356,7 +349,7 @@ public class KeyguardUpdateMonitorTest extends SysuiTestCase {
|
|||||||
when(mTelephonyManager.getSimState(anyInt())).thenReturn(state);
|
when(mTelephonyManager.getSimState(anyInt())).thenReturn(state);
|
||||||
when(mSubscriptionManager.getSubscriptionIds(anyInt())).thenReturn(new int[]{subId});
|
when(mSubscriptionManager.getSubscriptionIds(anyInt())).thenReturn(new int[]{subId});
|
||||||
|
|
||||||
KeyguardUpdateMonitor testKUM = new TestableKeyguardUpdateMonitor(mSpiedContext);
|
KeyguardUpdateMonitor testKUM = new TestableKeyguardUpdateMonitor(mContext);
|
||||||
|
|
||||||
mTestableLooper.processAllMessages();
|
mTestableLooper.processAllMessages();
|
||||||
|
|
||||||
@@ -1202,9 +1195,9 @@ public class KeyguardUpdateMonitorTest extends SysuiTestCase {
|
|||||||
@Test
|
@Test
|
||||||
public void testShouldListenForFace_whenFaceManagerNotAvailable_returnsFalse() {
|
public void testShouldListenForFace_whenFaceManagerNotAvailable_returnsFalse() {
|
||||||
cleanupKeyguardUpdateMonitor();
|
cleanupKeyguardUpdateMonitor();
|
||||||
mSpiedContext.addMockSystemService(FaceManager.class, null);
|
mFaceManager = null;
|
||||||
when(mPackageManager.hasSystemFeature(PackageManager.FEATURE_FACE)).thenReturn(false);
|
|
||||||
mKeyguardUpdateMonitor = new TestableKeyguardUpdateMonitor(mSpiedContext);
|
mKeyguardUpdateMonitor = new TestableKeyguardUpdateMonitor(mContext);
|
||||||
|
|
||||||
assertThat(mKeyguardUpdateMonitor.shouldListenForFace()).isFalse();
|
assertThat(mKeyguardUpdateMonitor.shouldListenForFace()).isFalse();
|
||||||
}
|
}
|
||||||
@@ -1258,7 +1251,7 @@ public class KeyguardUpdateMonitorTest extends SysuiTestCase {
|
|||||||
// This disables face auth
|
// This disables face auth
|
||||||
when(mUserManager.isPrimaryUser()).thenReturn(false);
|
when(mUserManager.isPrimaryUser()).thenReturn(false);
|
||||||
mKeyguardUpdateMonitor =
|
mKeyguardUpdateMonitor =
|
||||||
new TestableKeyguardUpdateMonitor(mSpiedContext);
|
new TestableKeyguardUpdateMonitor(mContext);
|
||||||
|
|
||||||
// Face auth should run when the following is true.
|
// Face auth should run when the following is true.
|
||||||
keyguardNotGoingAway();
|
keyguardNotGoingAway();
|
||||||
@@ -1527,15 +1520,16 @@ public class KeyguardUpdateMonitorTest extends SysuiTestCase {
|
|||||||
verify(mHandler, times(1)).removeCallbacks(mKeyguardUpdateMonitor.mFpCancelNotReceived);
|
verify(mHandler, times(1)).removeCallbacks(mKeyguardUpdateMonitor.mFpCancelNotReceived);
|
||||||
mKeyguardUpdateMonitor.dispatchStartedGoingToSleep(0 /* why */);
|
mKeyguardUpdateMonitor.dispatchStartedGoingToSleep(0 /* why */);
|
||||||
mTestableLooper.processAllMessages();
|
mTestableLooper.processAllMessages();
|
||||||
assertThat(mKeyguardUpdateMonitor.shouldListenForFingerprint(anyBoolean())).isEqualTo(true);
|
assertThat(mKeyguardUpdateMonitor.shouldListenForFingerprint(false)).isEqualTo(true);
|
||||||
|
assertThat(mKeyguardUpdateMonitor.shouldListenForFingerprint(true)).isEqualTo(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFingerAcquired_wakesUpPowerManager() {
|
public void testFingerAcquired_wakesUpPowerManager() {
|
||||||
cleanupKeyguardUpdateMonitor();
|
cleanupKeyguardUpdateMonitor();
|
||||||
mSpiedContext.getOrCreateTestableResources().addOverride(
|
mContext.getOrCreateTestableResources().addOverride(
|
||||||
com.android.internal.R.bool.kg_wake_on_acquire_start, true);
|
com.android.internal.R.bool.kg_wake_on_acquire_start, true);
|
||||||
mKeyguardUpdateMonitor = new TestableKeyguardUpdateMonitor(mSpiedContext);
|
mKeyguardUpdateMonitor = new TestableKeyguardUpdateMonitor(mContext);
|
||||||
fingerprintAcquireStart();
|
fingerprintAcquireStart();
|
||||||
|
|
||||||
verify(mPowerManager).wakeUp(anyLong(), anyInt(), anyString());
|
verify(mPowerManager).wakeUp(anyLong(), anyInt(), anyString());
|
||||||
@@ -1544,9 +1538,9 @@ public class KeyguardUpdateMonitorTest extends SysuiTestCase {
|
|||||||
@Test
|
@Test
|
||||||
public void testFingerAcquired_doesNotWakeUpPowerManager() {
|
public void testFingerAcquired_doesNotWakeUpPowerManager() {
|
||||||
cleanupKeyguardUpdateMonitor();
|
cleanupKeyguardUpdateMonitor();
|
||||||
mSpiedContext.getOrCreateTestableResources().addOverride(
|
mContext.getOrCreateTestableResources().addOverride(
|
||||||
com.android.internal.R.bool.kg_wake_on_acquire_start, false);
|
com.android.internal.R.bool.kg_wake_on_acquire_start, false);
|
||||||
mKeyguardUpdateMonitor = new TestableKeyguardUpdateMonitor(mSpiedContext);
|
mKeyguardUpdateMonitor = new TestableKeyguardUpdateMonitor(mContext);
|
||||||
fingerprintAcquireStart();
|
fingerprintAcquireStart();
|
||||||
|
|
||||||
verify(mPowerManager, never()).wakeUp(anyLong(), anyInt(), anyString());
|
verify(mPowerManager, never()).wakeUp(anyLong(), anyInt(), anyString());
|
||||||
@@ -1716,7 +1710,9 @@ public class KeyguardUpdateMonitorTest extends SysuiTestCase {
|
|||||||
mAuthController, mTelephonyListenerManager,
|
mAuthController, mTelephonyListenerManager,
|
||||||
mInteractionJankMonitor, mLatencyTracker, mActiveUnlockConfig,
|
mInteractionJankMonitor, mLatencyTracker, mActiveUnlockConfig,
|
||||||
mKeyguardUpdateMonitorLogger, mUiEventLogger, () -> mSessionTracker,
|
mKeyguardUpdateMonitorLogger, mUiEventLogger, () -> mSessionTracker,
|
||||||
mPowerManager);
|
mPowerManager, mTrustManager, mSubscriptionManager, mUserManager,
|
||||||
|
mDreamManager, mDevicePolicyManager, mSensorPrivacyManager, mTelephonyManager,
|
||||||
|
mPackageManager, mFaceManager, mFingerprintManager, mBiometricManager);
|
||||||
setStrongAuthTracker(KeyguardUpdateMonitorTest.this.mStrongAuthTracker);
|
setStrongAuthTracker(KeyguardUpdateMonitorTest.this.mStrongAuthTracker);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user