From 1538b7fda7608f40ee85020785504539a0f02e78 Mon Sep 17 00:00:00 2001 From: Bernardo Rufino Date: Wed, 15 Sep 2021 14:54:25 +0100 Subject: [PATCH] Remove sendCloseSystemDialogs() from PhoneFallbackEventHandler Today's flow of events is like this: key goes to focused app (ViewRootImpl::processKeyEvent), the view hierarchy does not handle the event, so ViewRootImpl uses FallbackEventHandler to invoke the fallback action for this key. The problem is that for many keys the app itself is closing system dialogs before taking the appropriate action (often launching an activity, eg. dialer for KEYCODE_CALL), but this is now prohibited in S due to abuse of said action. The long-term plan is to return to InputDispatcher the fact that the key wasn't handled by the app and have ID call out to the policy, which will launch the appropriate action and adjust the UI as it sees fit (close system dialogs). However, we need to prevent apps from crashing because of this, hence this change for S still. The unfortunate effect is that system dialogs won't be hidden in these cases, but this livable with until we properly implement the infrastructure. Bug: 199173862 Test: Simulate code-paths with affected keys and make sure apps don't crash: 1. adb shell input keyevent --longpress KEYCODE_CALL 2. adb shell input keyevent --longpress KEYCODE_CAMERA Change-Id: I44ad41ac1eac9acc8320298ceb4c1b21bde8af5d --- .../internal/policy/PhoneFallbackEventHandler.java | 8 -------- 1 file changed, 8 deletions(-) diff --git a/core/java/com/android/internal/policy/PhoneFallbackEventHandler.java b/core/java/com/android/internal/policy/PhoneFallbackEventHandler.java index b321ac08912b8..a09c8236b47d1 100644 --- a/core/java/com/android/internal/policy/PhoneFallbackEventHandler.java +++ b/core/java/com/android/internal/policy/PhoneFallbackEventHandler.java @@ -124,7 +124,6 @@ public class PhoneFallbackEventHandler implements FallbackEventHandler { Intent intent = new Intent(Intent.ACTION_VOICE_COMMAND); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); try { - sendCloseSystemWindows(); mContext.startActivity(intent); } catch (ActivityNotFoundException e) { startCallActivity(); @@ -147,7 +146,6 @@ public class PhoneFallbackEventHandler implements FallbackEventHandler { dispatcher.performedLongPress(event); if (isUserSetupComplete()) { mView.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS); - sendCloseSystemWindows(); // Broadcast an intent that the Camera button was longpressed Intent intent = new Intent(Intent.ACTION_CAMERA_BUTTON, null); intent.addFlags(Intent.FLAG_RECEIVER_FOREGROUND); @@ -178,7 +176,6 @@ public class PhoneFallbackEventHandler implements FallbackEventHandler { intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); try { mView.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS); - sendCloseSystemWindows(); getSearchManager().stopSearch(); mContext.startActivity(intent); // Only clear this if we successfully start the @@ -272,7 +269,6 @@ public class PhoneFallbackEventHandler implements FallbackEventHandler { @UnsupportedAppUsage void startCallActivity() { - sendCloseSystemWindows(); Intent intent = new Intent(Intent.ACTION_CALL_BUTTON); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); try { @@ -319,10 +315,6 @@ public class PhoneFallbackEventHandler implements FallbackEventHandler { return mMediaSessionManager; } - void sendCloseSystemWindows() { - PhoneWindow.sendCloseSystemWindows(mContext, null); - } - private void handleVolumeKeyEvent(KeyEvent keyEvent) { getMediaSessionManager().dispatchVolumeKeyEventAsSystemService(keyEvent, AudioManager.USE_DEFAULT_STREAM_TYPE);