diff options
| author | Yuncheol Heo <ycheo@google.com> | 2020-05-01 11:50:52 -0700 |
|---|---|---|
| committer | Yuncheol Heo <ycheo@google.com> | 2020-05-05 14:41:43 -0700 |
| commit | 8f5f53ca0fed52106ebddc84dd5e738e6facd566 (patch) | |
| tree | 38c9af1fb38062158782698e2ba29952320cbe61 /core/java/android/window/VirtualDisplayTaskEmbedder.java | |
| parent | 9d3317b8da7690c75ed799ab91df1e6b73b88aaa (diff) | |
Migrate Tap exclusion logic to TaskEmbedder.
We want to pass the touches on ActivityView to the Activity inside ActivityView, not to be consumed by Activity hosting ActivityView.
To do that, we need to set a tap exclude region, so touches can go through.
Bug: 155424730
Test: Make sure the Activity inside ActivityView gets touch.
Change-Id: Ia9b2c7eba0c48512a633c798b1012e5fbec8422f
Diffstat (limited to 'core/java/android/window/VirtualDisplayTaskEmbedder.java')
| -rw-r--r-- | core/java/android/window/VirtualDisplayTaskEmbedder.java | 58 |
1 files changed, 7 insertions, 51 deletions
diff --git a/core/java/android/window/VirtualDisplayTaskEmbedder.java b/core/java/android/window/VirtualDisplayTaskEmbedder.java index 6f85dc263a4d..2e6cbeee7d22 100644 --- a/core/java/android/window/VirtualDisplayTaskEmbedder.java +++ b/core/java/android/window/VirtualDisplayTaskEmbedder.java @@ -21,7 +21,6 @@ import static android.hardware.display.DisplayManager.VIRTUAL_DISPLAY_FLAG_OWN_C import static android.hardware.display.DisplayManager.VIRTUAL_DISPLAY_FLAG_PUBLIC; import static android.view.Display.INVALID_DISPLAY; -import android.annotation.Nullable; import android.app.ActivityManager; import android.app.ActivityOptions; import android.app.ActivityTaskManager; @@ -40,7 +39,6 @@ import android.os.RemoteException; import android.os.SystemClock; import android.util.DisplayMetrics; import android.util.Log; -import android.view.IWindow; import android.view.IWindowManager; import android.view.IWindowSession; import android.view.InputDevice; @@ -134,20 +132,15 @@ public class VirtualDisplayTaskEmbedder extends TaskEmbedder { e.rethrowAsRuntimeException(); } - if (mHost.getWindow() != null) { - updateLocationAndTapExcludeRegion(); - } - return true; + return super.onInitialize(); } @Override protected boolean onRelease() { + super.onRelease(); // Clear activity view geometry for IME on this display clearActivityViewGeometryForIme(); - // Clear tap-exclude region (if any) for this window. - clearTapExcludeRegion(); - if (mTaskStackListener != null) { try { mActivityTaskManager.unregisterTaskStackListener(mTaskStackListener); @@ -170,9 +163,9 @@ public class VirtualDisplayTaskEmbedder extends TaskEmbedder { */ @Override public void start() { + super.start(); if (isInitialized()) { mVirtualDisplay.setDisplayState(true); - updateLocationAndTapExcludeRegion(); } } @@ -181,23 +174,14 @@ public class VirtualDisplayTaskEmbedder extends TaskEmbedder { */ @Override public void stop() { + super.stop(); if (isInitialized()) { mVirtualDisplay.setDisplayState(false); clearActivityViewGeometryForIme(); - clearTapExcludeRegion(); } } /** - * This should be called whenever the position or size of the surface changes - * or if touchable areas above the surface are added or removed. - */ - @Override - public void notifyBoundsChanged() { - updateLocationAndTapExcludeRegion(); - } - - /** * Called to update the dimensions whenever the host size changes. * * @param width the new width of the surface @@ -298,12 +282,13 @@ public class VirtualDisplayTaskEmbedder extends TaskEmbedder { * This should be called whenever the position or size of the surface changes * or if touchable areas above the surface are added or removed. */ - private void updateLocationAndTapExcludeRegion() { + @Override + protected void updateLocationAndTapExcludeRegion() { + super.updateLocationAndTapExcludeRegion(); if (!isInitialized() || mHost.getWindow() == null) { return; } reportLocation(mHost.getScreenToTaskMatrix(), mHost.getPositionInWindow()); - applyTapExcludeRegion(mHost.getWindow(), mHost.getTapExcludeRegion()); } /** @@ -332,24 +317,6 @@ public class VirtualDisplayTaskEmbedder extends TaskEmbedder { } /** - * Call to update the tap exclude region for the window. - * <p> - * This should not normally be called directly, but through - * {@link #updateLocationAndTapExcludeRegion()}. This method - * is provided as an optimization when managing multiple TaskSurfaces within a view. - * - * @see IWindowSession#updateTapExcludeRegion(IWindow, Region) - */ - private void applyTapExcludeRegion(IWindow window, @Nullable Region tapExcludeRegion) { - try { - IWindowSession session = WindowManagerGlobal.getWindowSession(); - session.updateTapExcludeRegion(window, tapExcludeRegion); - } catch (RemoteException e) { - e.rethrowAsRuntimeException(); - } - } - - /** * @see InputMethodManager#reportActivityView(int, Matrix) */ private void clearActivityViewGeometryForIme() { @@ -357,17 +324,6 @@ public class VirtualDisplayTaskEmbedder extends TaskEmbedder { mContext.getSystemService(InputMethodManager.class).reportActivityView(displayId, null); } - /** - * Removes the tap exclude region set by {@link #updateLocationAndTapExcludeRegion()}. - */ - private void clearTapExcludeRegion() { - if (mHost.getWindow() == null) { - Log.w(TAG, "clearTapExcludeRegion: not attached to window!"); - return; - } - applyTapExcludeRegion(mHost.getWindow(), null); - } - private static KeyEvent createKeyEvent(int action, int code, int displayId) { long when = SystemClock.uptimeMillis(); final KeyEvent ev = new KeyEvent(when, when, action, code, 0 /* repeat */, |
