Merge "Execute show overlay method immediatly." into sc-dev

This commit is contained in:
Joe Bolinger
2021-06-30 16:57:16 +00:00
committed by Android (Google) Code Review

View File

@@ -596,8 +596,10 @@ public class UdfpsController implements DozeReceiver {
} }
private void updateOverlay() { private void updateOverlay() {
mExecution.assertIsMainThread();
if (mServerRequest != null) { if (mServerRequest != null) {
showUdfpsOverlay(mServerRequest.mRequestReason); showUdfpsOverlay(mServerRequest);
} else { } else {
hideUdfpsOverlay(); hideUdfpsOverlay();
} }
@@ -658,36 +660,37 @@ public class UdfpsController implements DozeReceiver {
updateOverlay(); updateOverlay();
} }
private void showUdfpsOverlay(int reason) { private void showUdfpsOverlay(@NonNull ServerRequest request) {
mFgExecutor.execute(() -> { mExecution.assertIsMainThread();
if (mView == null) {
try {
Log.v(TAG, "showUdfpsOverlay | adding window reason=" + reason);
mView = (UdfpsView) mInflater.inflate(R.layout.udfps_view, null, false);
mView.setSensorProperties(mSensorProps);
mView.setHbmProvider(mHbmProvider);
UdfpsAnimationViewController animation = inflateUdfpsAnimation(reason);
animation.init();
mView.setAnimationViewController(animation);
// This view overlaps the sensor area, so prevent it from being selectable final int reason = request.mRequestReason;
// during a11y. if (mView == null) {
if (reason == IUdfpsOverlayController.REASON_ENROLL_FIND_SENSOR try {
|| reason == IUdfpsOverlayController.REASON_ENROLL_ENROLLING) { Log.v(TAG, "showUdfpsOverlay | adding window reason=" + reason);
mView.setImportantForAccessibility(View.IMPORTANT_FOR_ACCESSIBILITY_NO); mView = (UdfpsView) mInflater.inflate(R.layout.udfps_view, null, false);
} mView.setSensorProperties(mSensorProps);
mView.setHbmProvider(mHbmProvider);
UdfpsAnimationViewController animation = inflateUdfpsAnimation(reason);
animation.init();
mView.setAnimationViewController(animation);
mWindowManager.addView(mView, computeLayoutParams(animation)); // This view overlaps the sensor area, so prevent it from being selectable
mAccessibilityManager.addTouchExplorationStateChangeListener( // during a11y.
mTouchExplorationStateChangeListener); if (reason == IUdfpsOverlayController.REASON_ENROLL_FIND_SENSOR
updateTouchListener(); || reason == IUdfpsOverlayController.REASON_ENROLL_ENROLLING) {
} catch (RuntimeException e) { mView.setImportantForAccessibility(View.IMPORTANT_FOR_ACCESSIBILITY_NO);
Log.e(TAG, "showUdfpsOverlay | failed to add window", e);
} }
} else {
Log.v(TAG, "showUdfpsOverlay | the overlay is already showing"); mWindowManager.addView(mView, computeLayoutParams(animation));
mAccessibilityManager.addTouchExplorationStateChangeListener(
mTouchExplorationStateChangeListener);
updateTouchListener();
} catch (RuntimeException e) {
Log.e(TAG, "showUdfpsOverlay | failed to add window", e);
} }
}); } else {
Log.v(TAG, "showUdfpsOverlay | the overlay is already showing");
}
} }
private UdfpsAnimationViewController inflateUdfpsAnimation(int reason) { private UdfpsAnimationViewController inflateUdfpsAnimation(int reason) {