Execute show overlay method immediatly.

Prevents the server request from being reset in an interleaved operation.

Fix: 189289808
Test: manual (did not crash)
Change-Id: I0c5b197937ead40f87e9cd245b4483727fb720da
This commit is contained in:
Joe Bolinger
2021-06-29 10:54:08 -07:00
parent 0954cfe651
commit 2c40083758

View File

@@ -596,8 +596,10 @@ public class UdfpsController implements DozeReceiver {
}
private void updateOverlay() {
mExecution.assertIsMainThread();
if (mServerRequest != null) {
showUdfpsOverlay(mServerRequest.mRequestReason);
showUdfpsOverlay(mServerRequest);
} else {
hideUdfpsOverlay();
}
@@ -658,36 +660,37 @@ public class UdfpsController implements DozeReceiver {
updateOverlay();
}
private void showUdfpsOverlay(int reason) {
mFgExecutor.execute(() -> {
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);
private void showUdfpsOverlay(@NonNull ServerRequest request) {
mExecution.assertIsMainThread();
// This view overlaps the sensor area, so prevent it from being selectable
// during a11y.
if (reason == IUdfpsOverlayController.REASON_ENROLL_FIND_SENSOR
|| reason == IUdfpsOverlayController.REASON_ENROLL_ENROLLING) {
mView.setImportantForAccessibility(View.IMPORTANT_FOR_ACCESSIBILITY_NO);
}
final int reason = request.mRequestReason;
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);
mWindowManager.addView(mView, computeLayoutParams(animation));
mAccessibilityManager.addTouchExplorationStateChangeListener(
mTouchExplorationStateChangeListener);
updateTouchListener();
} catch (RuntimeException e) {
Log.e(TAG, "showUdfpsOverlay | failed to add window", e);
// This view overlaps the sensor area, so prevent it from being selectable
// during a11y.
if (reason == IUdfpsOverlayController.REASON_ENROLL_FIND_SENSOR
|| reason == IUdfpsOverlayController.REASON_ENROLL_ENROLLING) {
mView.setImportantForAccessibility(View.IMPORTANT_FOR_ACCESSIBILITY_NO);
}
} 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) {