Merge "Fix binder error about non-oneway biometric calls" into sc-v2-dev am: 555023b9dd am: 3443278546
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/16165288 Change-Id: I3279350d9c178550bdef4a16b308f530f725e990
This commit is contained in:
@@ -22,6 +22,7 @@ import android.content.Context;
|
||||
import android.hardware.biometrics.face.IFace;
|
||||
import android.hardware.biometrics.face.ISession;
|
||||
import android.hardware.biometrics.face.ISessionCallback;
|
||||
import android.os.Binder;
|
||||
import android.os.IBinder;
|
||||
import android.os.RemoteException;
|
||||
import android.util.Slog;
|
||||
@@ -52,6 +53,7 @@ public class FaceStartUserClient extends StartUserClient<IFace, ISession> {
|
||||
try {
|
||||
final ISession newSession = getFreshDaemon().createSession(getSensorId(),
|
||||
getTargetUserId(), mSessionCallback);
|
||||
Binder.allowBlocking(newSession.asBinder());
|
||||
mUserStartedCallback.onUserStarted(getTargetUserId(), newSession);
|
||||
getCallback().onClientFinished(this, true /* success */);
|
||||
} catch (RemoteException e) {
|
||||
|
||||
@@ -22,6 +22,7 @@ import android.content.Context;
|
||||
import android.hardware.biometrics.fingerprint.IFingerprint;
|
||||
import android.hardware.biometrics.fingerprint.ISession;
|
||||
import android.hardware.biometrics.fingerprint.ISessionCallback;
|
||||
import android.os.Binder;
|
||||
import android.os.IBinder;
|
||||
import android.os.RemoteException;
|
||||
import android.util.Slog;
|
||||
@@ -53,6 +54,7 @@ public class FingerprintStartUserClient extends StartUserClient<IFingerprint, IS
|
||||
try {
|
||||
final ISession newSession = getFreshDaemon().createSession(getSensorId(),
|
||||
getTargetUserId(), mSessionCallback);
|
||||
Binder.allowBlocking(newSession.asBinder());
|
||||
mUserStartedCallback.onUserStarted(getTargetUserId(), newSession);
|
||||
getCallback().onClientFinished(this, true /* success */);
|
||||
} catch (RemoteException e) {
|
||||
|
||||
@@ -19,13 +19,17 @@ package com.android.server.biometrics.sensors.face.aidl;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.mockito.ArgumentMatchers.anyInt;
|
||||
import static org.mockito.Mockito.any;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import android.content.Context;
|
||||
import android.hardware.biometrics.common.CommonProps;
|
||||
import android.hardware.biometrics.face.IFace;
|
||||
import android.hardware.biometrics.face.ISession;
|
||||
import android.hardware.biometrics.face.SensorProps;
|
||||
import android.os.RemoteException;
|
||||
import android.os.UserManager;
|
||||
import android.platform.test.annotations.Presubmit;
|
||||
|
||||
@@ -33,7 +37,6 @@ import androidx.annotation.NonNull;
|
||||
import androidx.test.InstrumentationRegistry;
|
||||
import androidx.test.filters.SmallTest;
|
||||
|
||||
import com.android.server.biometrics.sensors.BaseClientMonitor;
|
||||
import com.android.server.biometrics.sensors.BiometricScheduler;
|
||||
import com.android.server.biometrics.sensors.HalClientMonitor;
|
||||
import com.android.server.biometrics.sensors.LockoutResetDispatcher;
|
||||
@@ -55,6 +58,8 @@ public class FaceProviderTest {
|
||||
private Context mContext;
|
||||
@Mock
|
||||
private UserManager mUserManager;
|
||||
@Mock
|
||||
private IFace mDaemon;
|
||||
|
||||
private SensorProps[] mSensorProps;
|
||||
private LockoutResetDispatcher mLockoutResetDispatcher;
|
||||
@@ -65,11 +70,12 @@ public class FaceProviderTest {
|
||||
}
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
public void setUp() throws RemoteException {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
|
||||
when(mContext.getSystemService(Context.USER_SERVICE)).thenReturn(mUserManager);
|
||||
when(mUserManager.getAliveUsers()).thenReturn(new ArrayList<>());
|
||||
when(mDaemon.createSession(anyInt(), anyInt(), any())).thenReturn(mock(ISession.class));
|
||||
|
||||
final SensorProps sensor1 = new SensorProps();
|
||||
sensor1.commonProps = new CommonProps();
|
||||
@@ -78,11 +84,11 @@ public class FaceProviderTest {
|
||||
sensor2.commonProps = new CommonProps();
|
||||
sensor2.commonProps.sensorId = 1;
|
||||
|
||||
mSensorProps = new SensorProps[] {sensor1, sensor2};
|
||||
mSensorProps = new SensorProps[]{sensor1, sensor2};
|
||||
|
||||
mLockoutResetDispatcher = new LockoutResetDispatcher(mContext);
|
||||
|
||||
mFaceProvider = new TestableFaceProvider(mContext, mSensorProps, TAG,
|
||||
mFaceProvider = new TestableFaceProvider(mDaemon, mContext, mSensorProps, TAG,
|
||||
mLockoutResetDispatcher);
|
||||
}
|
||||
|
||||
@@ -127,17 +133,20 @@ public class FaceProviderTest {
|
||||
}
|
||||
|
||||
private static class TestableFaceProvider extends FaceProvider {
|
||||
public TestableFaceProvider(@NonNull Context context,
|
||||
private final IFace mDaemon;
|
||||
|
||||
TestableFaceProvider(@NonNull IFace daemon,
|
||||
@NonNull Context context,
|
||||
@NonNull SensorProps[] props,
|
||||
@NonNull String halInstanceName,
|
||||
@NonNull LockoutResetDispatcher lockoutResetDispatcher) {
|
||||
super(context, props, halInstanceName, lockoutResetDispatcher);
|
||||
mDaemon = daemon;
|
||||
}
|
||||
|
||||
@Override
|
||||
synchronized IFace getHalInstance() {
|
||||
return mock(IFace.class);
|
||||
return mDaemon;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ package com.android.server.biometrics.sensors.fingerprint.aidl;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.mockito.Mockito.any;
|
||||
import static org.mockito.Mockito.anyInt;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
@@ -28,8 +29,10 @@ import android.content.res.Resources;
|
||||
import android.content.res.TypedArray;
|
||||
import android.hardware.biometrics.common.CommonProps;
|
||||
import android.hardware.biometrics.fingerprint.IFingerprint;
|
||||
import android.hardware.biometrics.fingerprint.ISession;
|
||||
import android.hardware.biometrics.fingerprint.SensorLocation;
|
||||
import android.hardware.biometrics.fingerprint.SensorProps;
|
||||
import android.os.RemoteException;
|
||||
import android.os.UserManager;
|
||||
import android.platform.test.annotations.Presubmit;
|
||||
|
||||
@@ -63,6 +66,8 @@ public class FingerprintProviderTest {
|
||||
@Mock
|
||||
private UserManager mUserManager;
|
||||
@Mock
|
||||
private IFingerprint mDaemon;
|
||||
@Mock
|
||||
private GestureAvailabilityDispatcher mGestureAvailabilityDispatcher;
|
||||
@Mock
|
||||
private FingerprintStateCallback mFingerprintStateCallback;
|
||||
@@ -76,13 +81,14 @@ public class FingerprintProviderTest {
|
||||
}
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
public void setUp() throws RemoteException {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
|
||||
when(mContext.getResources()).thenReturn(mResources);
|
||||
when(mResources.obtainTypedArray(anyInt())).thenReturn(mock(TypedArray.class));
|
||||
when(mContext.getSystemService(Context.USER_SERVICE)).thenReturn(mUserManager);
|
||||
when(mUserManager.getAliveUsers()).thenReturn(new ArrayList<>());
|
||||
when(mDaemon.createSession(anyInt(), anyInt(), any())).thenReturn(mock(ISession.class));
|
||||
|
||||
final SensorProps sensor1 = new SensorProps();
|
||||
sensor1.commonProps = new CommonProps();
|
||||
@@ -97,8 +103,9 @@ public class FingerprintProviderTest {
|
||||
|
||||
mLockoutResetDispatcher = new LockoutResetDispatcher(mContext);
|
||||
|
||||
mFingerprintProvider = new TestableFingerprintProvider(mContext, mFingerprintStateCallback,
|
||||
mSensorProps, TAG, mLockoutResetDispatcher, mGestureAvailabilityDispatcher);
|
||||
mFingerprintProvider = new TestableFingerprintProvider(mDaemon, mContext,
|
||||
mFingerprintStateCallback, mSensorProps, TAG, mLockoutResetDispatcher,
|
||||
mGestureAvailabilityDispatcher);
|
||||
}
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
@@ -142,7 +149,10 @@ public class FingerprintProviderTest {
|
||||
}
|
||||
|
||||
private static class TestableFingerprintProvider extends FingerprintProvider {
|
||||
public TestableFingerprintProvider(@NonNull Context context,
|
||||
private final IFingerprint mDaemon;
|
||||
|
||||
TestableFingerprintProvider(@NonNull IFingerprint daemon,
|
||||
@NonNull Context context,
|
||||
@NonNull FingerprintStateCallback fingerprintStateCallback,
|
||||
@NonNull SensorProps[] props,
|
||||
@NonNull String halInstanceName,
|
||||
@@ -150,11 +160,12 @@ public class FingerprintProviderTest {
|
||||
@NonNull GestureAvailabilityDispatcher gestureAvailabilityDispatcher) {
|
||||
super(context, fingerprintStateCallback, props, halInstanceName, lockoutResetDispatcher,
|
||||
gestureAvailabilityDispatcher);
|
||||
mDaemon = daemon;
|
||||
}
|
||||
|
||||
@Override
|
||||
synchronized IFingerprint getHalInstance() {
|
||||
return mock(IFingerprint.class);
|
||||
return mDaemon;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user