Merge changes Ib61c9a4f,I308cd691 into sc-dev
* changes: Inflate a new UdfpsView for each new operation Add defaults to fix fake UDFPS
This commit is contained in:
@@ -85,8 +85,8 @@ public class FingerprintSensorPropertiesInternal extends SensorPropertiesInterna
|
|||||||
boolean resetLockoutRequiresHardwareAuthToken) {
|
boolean resetLockoutRequiresHardwareAuthToken) {
|
||||||
// TODO(b/179175438): Value should be provided from the HAL
|
// TODO(b/179175438): Value should be provided from the HAL
|
||||||
this(sensorId, strength, maxEnrollmentsPerUser, sensorType,
|
this(sensorId, strength, maxEnrollmentsPerUser, sensorType,
|
||||||
resetLockoutRequiresHardwareAuthToken, 0 /* sensorLocationX */,
|
resetLockoutRequiresHardwareAuthToken, 540 /* sensorLocationX */,
|
||||||
0 /* sensorLocationY */, 0 /* sensorRadius */);
|
1636 /* sensorLocationY */, 130 /* sensorRadius */);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -68,6 +68,7 @@ public class UdfpsController implements DozeReceiver, HbmCallback {
|
|||||||
|
|
||||||
private final Context mContext;
|
private final Context mContext;
|
||||||
private final FingerprintManager mFingerprintManager;
|
private final FingerprintManager mFingerprintManager;
|
||||||
|
@NonNull private final LayoutInflater mInflater;
|
||||||
private final WindowManager mWindowManager;
|
private final WindowManager mWindowManager;
|
||||||
private final DelayableExecutor mFgExecutor;
|
private final DelayableExecutor mFgExecutor;
|
||||||
private final StatusBarStateController mStatusBarStateController;
|
private final StatusBarStateController mStatusBarStateController;
|
||||||
@@ -75,10 +76,8 @@ public class UdfpsController implements DozeReceiver, HbmCallback {
|
|||||||
// sensors, this, in addition to a lot of the code here, will be updated.
|
// sensors, this, in addition to a lot of the code here, will be updated.
|
||||||
@VisibleForTesting final FingerprintSensorPropertiesInternal mSensorProps;
|
@VisibleForTesting final FingerprintSensorPropertiesInternal mSensorProps;
|
||||||
private final WindowManager.LayoutParams mCoreLayoutParams;
|
private final WindowManager.LayoutParams mCoreLayoutParams;
|
||||||
private final UdfpsView mView;
|
|
||||||
// Indicates whether the overlay is currently showing. Even if it has been requested, it might
|
@Nullable private UdfpsView mView;
|
||||||
// not be showing.
|
|
||||||
private boolean mIsOverlayShowing;
|
|
||||||
// Indicates whether the overlay has been requested.
|
// Indicates whether the overlay has been requested.
|
||||||
private boolean mIsOverlayRequested;
|
private boolean mIsOverlayRequested;
|
||||||
// Reason the overlay has been requested. See IUdfpsOverlayController for definitions.
|
// Reason the overlay has been requested. See IUdfpsOverlayController for definitions.
|
||||||
@@ -111,20 +110,48 @@ public class UdfpsController implements DozeReceiver, HbmCallback {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onEnrollmentProgress(int sensorId, int remaining) {
|
public void onEnrollmentProgress(int sensorId, int remaining) {
|
||||||
|
if (mView == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
mView.onEnrollmentProgress(remaining);
|
mView.onEnrollmentProgress(remaining);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onEnrollmentHelp(int sensorId) {
|
public void onEnrollmentHelp(int sensorId) {
|
||||||
|
if (mView == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
mView.onEnrollmentHelp();
|
mView.onEnrollmentHelp();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setDebugMessage(int sensorId, String message) {
|
public void setDebugMessage(int sensorId, String message) {
|
||||||
|
if (mView == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
mView.setDebugMessage(message);
|
mView.setDebugMessage(message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@VisibleForTesting
|
||||||
|
final StatusBar.ExpansionChangedListener mStatusBarExpansionListener =
|
||||||
|
(expansion, expanded) -> {
|
||||||
|
if (mView != null) {
|
||||||
|
mView.onExpansionChanged(expansion, expanded);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
@VisibleForTesting
|
||||||
|
final StatusBarStateController.StateListener mStatusBarStateListener =
|
||||||
|
new StatusBarStateController.StateListener() {
|
||||||
|
@Override
|
||||||
|
public void onStateChanged(int newState) {
|
||||||
|
if (mView != null) {
|
||||||
|
mView.onStateChanged(newState);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
@SuppressLint("ClickableViewAccessibility")
|
@SuppressLint("ClickableViewAccessibility")
|
||||||
private final UdfpsView.OnTouchListener mOnTouchListener = (v, event) -> {
|
private final UdfpsView.OnTouchListener mOnTouchListener = (v, event) -> {
|
||||||
UdfpsView view = (UdfpsView) v;
|
UdfpsView view = (UdfpsView) v;
|
||||||
@@ -157,13 +184,14 @@ public class UdfpsController implements DozeReceiver, HbmCallback {
|
|||||||
@Inject
|
@Inject
|
||||||
public UdfpsController(@NonNull Context context,
|
public UdfpsController(@NonNull Context context,
|
||||||
@Main Resources resources,
|
@Main Resources resources,
|
||||||
LayoutInflater inflater,
|
@NonNull LayoutInflater inflater,
|
||||||
@Nullable FingerprintManager fingerprintManager,
|
@Nullable FingerprintManager fingerprintManager,
|
||||||
WindowManager windowManager,
|
WindowManager windowManager,
|
||||||
@NonNull StatusBarStateController statusBarStateController,
|
@NonNull StatusBarStateController statusBarStateController,
|
||||||
@Main DelayableExecutor fgExecutor,
|
@Main DelayableExecutor fgExecutor,
|
||||||
@Nullable StatusBar statusBar) {
|
@Nullable StatusBar statusBar) {
|
||||||
mContext = context;
|
mContext = context;
|
||||||
|
mInflater = inflater;
|
||||||
// The fingerprint manager is queried for UDFPS before this class is constructed, so the
|
// The fingerprint manager is queried for UDFPS before this class is constructed, so the
|
||||||
// fingerprint manager should never be null.
|
// fingerprint manager should never be null.
|
||||||
mFingerprintManager = checkNotNull(fingerprintManager);
|
mFingerprintManager = checkNotNull(fingerprintManager);
|
||||||
@@ -189,15 +217,10 @@ public class UdfpsController implements DozeReceiver, HbmCallback {
|
|||||||
WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS;
|
WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS;
|
||||||
mCoreLayoutParams.privateFlags = WindowManager.LayoutParams.PRIVATE_FLAG_TRUSTED_OVERLAY;
|
mCoreLayoutParams.privateFlags = WindowManager.LayoutParams.PRIVATE_FLAG_TRUSTED_OVERLAY;
|
||||||
|
|
||||||
mView = (UdfpsView) inflater.inflate(R.layout.udfps_view, null, false);
|
statusBar.addExpansionChangedListener(mStatusBarExpansionListener);
|
||||||
mView.setSensorProperties(mSensorProps);
|
mStatusBarStateController.addCallback(mStatusBarStateListener);
|
||||||
mView.setHbmCallback(this);
|
|
||||||
|
|
||||||
statusBar.addExpansionChangedListener(mView);
|
|
||||||
statusBarStateController.addCallback(mView);
|
|
||||||
|
|
||||||
mFingerprintManager.setUdfpsOverlayController(new UdfpsOverlayController());
|
mFingerprintManager.setUdfpsOverlayController(new UdfpsOverlayController());
|
||||||
mIsOverlayShowing = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@@ -220,7 +243,13 @@ public class UdfpsController implements DozeReceiver, HbmCallback {
|
|||||||
* @return where the UDFPS exists on the screen in pixels.
|
* @return where the UDFPS exists on the screen in pixels.
|
||||||
*/
|
*/
|
||||||
public RectF getSensorLocation() {
|
public RectF getSensorLocation() {
|
||||||
return mView.getSensorRect();
|
// This is currently used to calculate the amount of space available for notifications
|
||||||
|
// on lockscreen. Keyguard is only shown in portrait mode for now, so this will need to
|
||||||
|
// be updated if that ever changes.
|
||||||
|
return new RectF(mSensorProps.sensorLocationX - mSensorProps.sensorRadius,
|
||||||
|
mSensorProps.sensorLocationY - mSensorProps.sensorRadius,
|
||||||
|
mSensorProps.sensorLocationX + mSensorProps.sensorRadius,
|
||||||
|
mSensorProps.sensorLocationY + mSensorProps.sensorRadius);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void showOverlay(int reason) {
|
private void showOverlay(int reason) {
|
||||||
@@ -298,14 +327,18 @@ public class UdfpsController implements DozeReceiver, HbmCallback {
|
|||||||
|
|
||||||
private void showUdfpsOverlay(int reason) {
|
private void showUdfpsOverlay(int reason) {
|
||||||
mFgExecutor.execute(() -> {
|
mFgExecutor.execute(() -> {
|
||||||
if (!mIsOverlayShowing) {
|
if (mView == null) {
|
||||||
try {
|
try {
|
||||||
Log.v(TAG, "showUdfpsOverlay | adding window");
|
Log.v(TAG, "showUdfpsOverlay | adding window");
|
||||||
|
|
||||||
|
mView = (UdfpsView) mInflater.inflate(R.layout.udfps_view, null, false);
|
||||||
|
mView.setSensorProperties(mSensorProps);
|
||||||
|
mView.setHbmCallback(this);
|
||||||
|
|
||||||
final UdfpsAnimation animation = getUdfpsAnimationForReason(reason);
|
final UdfpsAnimation animation = getUdfpsAnimationForReason(reason);
|
||||||
mView.setExtras(animation, mEnrollHelper);
|
mView.setExtras(animation, mEnrollHelper);
|
||||||
mWindowManager.addView(mView, computeLayoutParams(animation));
|
mWindowManager.addView(mView, computeLayoutParams(animation));
|
||||||
mView.setOnTouchListener(mOnTouchListener);
|
mView.setOnTouchListener(mOnTouchListener);
|
||||||
mIsOverlayShowing = true;
|
|
||||||
} catch (RuntimeException e) {
|
} catch (RuntimeException e) {
|
||||||
Log.e(TAG, "showUdfpsOverlay | failed to add window", e);
|
Log.e(TAG, "showUdfpsOverlay | failed to add window", e);
|
||||||
}
|
}
|
||||||
@@ -334,14 +367,12 @@ public class UdfpsController implements DozeReceiver, HbmCallback {
|
|||||||
|
|
||||||
private void hideUdfpsOverlay() {
|
private void hideUdfpsOverlay() {
|
||||||
mFgExecutor.execute(() -> {
|
mFgExecutor.execute(() -> {
|
||||||
if (mIsOverlayShowing) {
|
if (mView != null) {
|
||||||
Log.v(TAG, "hideUdfpsOverlay | removing window");
|
Log.v(TAG, "hideUdfpsOverlay | removing window");
|
||||||
mView.setExtras(null, null);
|
|
||||||
mView.setOnTouchListener(null);
|
|
||||||
// Reset the controller back to its starting state.
|
// Reset the controller back to its starting state.
|
||||||
onFingerUp();
|
onFingerUp();
|
||||||
mWindowManager.removeView(mView);
|
mWindowManager.removeView(mView);
|
||||||
mIsOverlayShowing = false;
|
mView = null;
|
||||||
} else {
|
} else {
|
||||||
Log.v(TAG, "hideUdfpsOverlay | the overlay is already hidden");
|
Log.v(TAG, "hideUdfpsOverlay | the overlay is already hidden");
|
||||||
}
|
}
|
||||||
@@ -388,12 +419,20 @@ public class UdfpsController implements DozeReceiver, HbmCallback {
|
|||||||
|
|
||||||
// This method can be called from the UI thread.
|
// This method can be called from the UI thread.
|
||||||
private void onFingerDown(int x, int y, float minor, float major) {
|
private void onFingerDown(int x, int y, float minor, float major) {
|
||||||
|
if (mView == null) {
|
||||||
|
Log.w(TAG, "Null view in onFingerDown");
|
||||||
|
return;
|
||||||
|
}
|
||||||
mView.startIllumination(() ->
|
mView.startIllumination(() ->
|
||||||
mFingerprintManager.onPointerDown(mSensorProps.sensorId, x, y, minor, major));
|
mFingerprintManager.onPointerDown(mSensorProps.sensorId, x, y, minor, major));
|
||||||
}
|
}
|
||||||
|
|
||||||
// This method can be called from the UI thread.
|
// This method can be called from the UI thread.
|
||||||
private void onFingerUp() {
|
private void onFingerUp() {
|
||||||
|
if (mView == null) {
|
||||||
|
Log.w(TAG, "Null view in onFingerUp");
|
||||||
|
return;
|
||||||
|
}
|
||||||
mFingerprintManager.onPointerUp(mSensorProps.sensorId);
|
mFingerprintManager.onPointerUp(mSensorProps.sensorId);
|
||||||
mView.stopIllumination();
|
mView.stopIllumination();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -135,11 +135,6 @@ public class UdfpsView extends FrameLayout implements DozeReceiver, UdfpsIllumin
|
|||||||
mAnimationView.dozeTimeTick();
|
mAnimationView.dozeTimeTick();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onExpandedChanged(boolean isExpanded) {
|
|
||||||
mNotificationShadeExpanded = isExpanded;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onStateChanged(int newState) {
|
public void onStateChanged(int newState) {
|
||||||
mStatusBarState = newState;
|
mStatusBarState = newState;
|
||||||
@@ -147,6 +142,7 @@ public class UdfpsView extends FrameLayout implements DozeReceiver, UdfpsIllumin
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onExpansionChanged(float expansion, boolean expanded) {
|
public void onExpansionChanged(float expansion, boolean expanded) {
|
||||||
|
mNotificationShadeExpanded = expanded;
|
||||||
mAnimationView.onExpansionChanged(expansion, expanded);
|
mAnimationView.onExpansionChanged(expansion, expanded);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -192,10 +188,6 @@ public class UdfpsView extends FrameLayout implements DozeReceiver, UdfpsIllumin
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
RectF getSensorRect() {
|
|
||||||
return new RectF(mSensorRect);
|
|
||||||
}
|
|
||||||
|
|
||||||
void setDebugMessage(String message) {
|
void setDebugMessage(String message) {
|
||||||
mDebugMessage = message;
|
mDebugMessage = message;
|
||||||
postInvalidate();
|
postInvalidate();
|
||||||
|
|||||||
@@ -150,7 +150,10 @@ public class UdfpsControllerTest extends SysuiTestCase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void dozeTimeTick() {
|
public void dozeTimeTick() throws RemoteException {
|
||||||
|
mOverlayController.showUdfpsOverlay(TEST_UDFPS_SENSOR_ID,
|
||||||
|
IUdfpsOverlayController.REASON_AUTH_FPM_KEYGUARD);
|
||||||
|
mFgExecutor.runAllReady();
|
||||||
mUdfpsController.dozeTimeTick();
|
mUdfpsController.dozeTimeTick();
|
||||||
verify(mUdfpsView).dozeTimeTick();
|
verify(mUdfpsView).dozeTimeTick();
|
||||||
}
|
}
|
||||||
@@ -240,7 +243,8 @@ public class UdfpsControllerTest extends SysuiTestCase {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void registersViewForCallbacks() throws RemoteException {
|
public void registersViewForCallbacks() throws RemoteException {
|
||||||
verify(mStatusBarStateController).addCallback(mUdfpsView);
|
verify(mStatusBarStateController).addCallback(mUdfpsController.mStatusBarStateListener);
|
||||||
verify(mStatusBar).addExpansionChangedListener(mUdfpsView);
|
verify(mStatusBar).addExpansionChangedListener(
|
||||||
|
mUdfpsController.mStatusBarExpansionListener);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user