Loading core/java/android/app/ActivityView.java +37 −0 Original line number Diff line number Diff line Loading @@ -34,6 +34,7 @@ import android.view.SurfaceHolder; import android.view.SurfaceView; import android.view.ViewGroup; import android.view.WindowManager; import android.view.WindowManagerGlobal; import dalvik.system.CloseGuard; Loading @@ -58,6 +59,8 @@ public class ActivityView extends ViewGroup { private StateCallback mActivityViewCallback; private IInputForwarder mInputForwarder; // Temp container to store view coordinates on screen. private final int[] mLocationOnScreen = new int[2]; private final CloseGuard mGuard = CloseGuard.get(); private boolean mOpened; // Protected by mGuard. Loading Loading @@ -198,11 +201,30 @@ public class ActivityView extends ViewGroup { performRelease(); } /** * Triggers an update of {@link ActivityView}'s location on screen to properly set touch exclude * regions and avoid focus switches by touches on this view. */ public void onLocationChanged() { updateLocation(); } @Override public void onLayout(boolean changed, int l, int t, int r, int b) { mSurfaceView.layout(0 /* left */, 0 /* top */, r - l /* right */, b - t /* bottom */); } /** Send current location and size to the WM to set tap exclude region for this view. */ private void updateLocation() { try { getLocationOnScreen(mLocationOnScreen); WindowManagerGlobal.getWindowSession().updateTapExcludeRegion(getWindow(), hashCode(), mLocationOnScreen[0], mLocationOnScreen[1], getWidth(), getHeight()); } catch (RemoteException e) { e.rethrowAsRuntimeException(); } } @Override public boolean onTouchEvent(MotionEvent event) { return injectInputEvent(event) || super.onTouchEvent(event); Loading Loading @@ -241,6 +263,7 @@ public class ActivityView extends ViewGroup { } else { mVirtualDisplay.setSurface(surfaceHolder.getSurface()); } updateLocation(); } @Override Loading @@ -248,6 +271,7 @@ public class ActivityView extends ViewGroup { if (mVirtualDisplay != null) { mVirtualDisplay.resize(width, height, getBaseDisplayDensity()); } updateLocation(); } @Override Loading @@ -257,6 +281,7 @@ public class ActivityView extends ViewGroup { if (mVirtualDisplay != null) { mVirtualDisplay.setSurface(null); } cleanTapExcludeRegion(); } } Loading Loading @@ -290,6 +315,7 @@ public class ActivityView extends ViewGroup { if (mInputForwarder != null) { mInputForwarder = null; } cleanTapExcludeRegion(); final boolean displayReleased; if (mVirtualDisplay != null) { Loading @@ -313,6 +339,17 @@ public class ActivityView extends ViewGroup { mOpened = false; } /** Report to server that tap exclude region on hosting display should be cleared. */ private void cleanTapExcludeRegion() { // Update tap exclude region with an empty rect to clean the state on server. try { WindowManagerGlobal.getWindowSession().updateTapExcludeRegion(getWindow(), hashCode(), 0 /* left */, 0 /* top */, 0 /* width */, 0 /* height */); } catch (RemoteException e) { e.rethrowAsRuntimeException(); } } /** Get density of the hosting display. */ private int getBaseDisplayDensity() { final WindowManager wm = mContext.getSystemService(WindowManager.class); Loading core/java/android/view/IWindowSession.aidl +8 −0 Original line number Diff line number Diff line Loading @@ -236,4 +236,12 @@ interface IWindowSession { boolean startMovingTask(IWindow window, float startX, float startY); void updatePointerIcon(IWindow window); /** * Update a tap exclude region with a rectangular area identified by provided id in the window. * Touches on this region will not switch focus to this window. Passing an empty rect will * remove the area from the exclude region of this window. */ void updateTapExcludeRegion(IWindow window, int regionId, int left, int top, int width, int height); } core/java/android/view/View.java +9 −0 Original line number Diff line number Diff line Loading @@ -17885,6 +17885,15 @@ public class View implements Drawable.Callback, KeyEvent.Callback, return mAttachInfo != null ? mAttachInfo.mSession : null; } /** * Return the window this view is currently attached to. Used in * {@link android.app.ActivityView} to communicate with WM. * @hide */ protected IWindow getWindow() { return mAttachInfo != null ? mAttachInfo.mWindow : null; } /** * Return the visibility value of the least visible component passed. */ services/core/java/com/android/server/wm/DisplayContent.java +8 −1 Original line number Diff line number Diff line Loading @@ -134,6 +134,7 @@ import android.os.IBinder; import android.os.RemoteException; import android.os.SystemClock; import android.os.Trace; import android.util.ArraySet; import android.util.DisplayMetrics; import android.util.MutableBoolean; import android.util.Slog; Loading Loading @@ -330,6 +331,8 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo final PinnedStackController mPinnedStackControllerLocked; final ArrayList<WindowState> mTapExcludedWindows = new ArrayList<>(); /** A collection of windows that provide tap exclude regions inside of them. */ final ArraySet<WindowState> mTapExcludeProvidingWindows = new ArraySet<>(); private boolean mHaveBootMsg = false; private boolean mHaveApp = false; Loading Loading @@ -1866,10 +1869,14 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo } } for (int i = mTapExcludedWindows.size() - 1; i >= 0; i--) { WindowState win = mTapExcludedWindows.get(i); final WindowState win = mTapExcludedWindows.get(i); win.getTouchableRegion(mTmpRegion); mTouchExcludeRegion.op(mTmpRegion, Region.Op.UNION); } for (int i = mTapExcludeProvidingWindows.size() - 1; i >= 0; i--) { final WindowState win = mTapExcludeProvidingWindows.valueAt(i); win.amendTapExcludeRegion(mTouchExcludeRegion); } // TODO(multi-display): Support docked stacks on secondary displays. if (mDisplayId == DEFAULT_DISPLAY && getSplitScreenPrimaryStack() != null) { mDividerControllerLocked.getTouchRegion(mTmpRect); Loading services/core/java/com/android/server/wm/Session.java +11 −0 Original line number Diff line number Diff line Loading @@ -467,6 +467,17 @@ class Session extends IWindowSession.Stub implements IBinder.DeathRecipient { } } @Override public void updateTapExcludeRegion(IWindow window, int regionId, int left, int top, int width, int height) { final long identity = Binder.clearCallingIdentity(); try { mService.updateTapExcludeRegion(window, regionId, left, top, width, height); } finally { Binder.restoreCallingIdentity(identity); } } void windowAddedLocked(String packageName) { mPackageName = packageName; mRelayoutTag = "relayoutWindow: " + mPackageName; Loading Loading
core/java/android/app/ActivityView.java +37 −0 Original line number Diff line number Diff line Loading @@ -34,6 +34,7 @@ import android.view.SurfaceHolder; import android.view.SurfaceView; import android.view.ViewGroup; import android.view.WindowManager; import android.view.WindowManagerGlobal; import dalvik.system.CloseGuard; Loading @@ -58,6 +59,8 @@ public class ActivityView extends ViewGroup { private StateCallback mActivityViewCallback; private IInputForwarder mInputForwarder; // Temp container to store view coordinates on screen. private final int[] mLocationOnScreen = new int[2]; private final CloseGuard mGuard = CloseGuard.get(); private boolean mOpened; // Protected by mGuard. Loading Loading @@ -198,11 +201,30 @@ public class ActivityView extends ViewGroup { performRelease(); } /** * Triggers an update of {@link ActivityView}'s location on screen to properly set touch exclude * regions and avoid focus switches by touches on this view. */ public void onLocationChanged() { updateLocation(); } @Override public void onLayout(boolean changed, int l, int t, int r, int b) { mSurfaceView.layout(0 /* left */, 0 /* top */, r - l /* right */, b - t /* bottom */); } /** Send current location and size to the WM to set tap exclude region for this view. */ private void updateLocation() { try { getLocationOnScreen(mLocationOnScreen); WindowManagerGlobal.getWindowSession().updateTapExcludeRegion(getWindow(), hashCode(), mLocationOnScreen[0], mLocationOnScreen[1], getWidth(), getHeight()); } catch (RemoteException e) { e.rethrowAsRuntimeException(); } } @Override public boolean onTouchEvent(MotionEvent event) { return injectInputEvent(event) || super.onTouchEvent(event); Loading Loading @@ -241,6 +263,7 @@ public class ActivityView extends ViewGroup { } else { mVirtualDisplay.setSurface(surfaceHolder.getSurface()); } updateLocation(); } @Override Loading @@ -248,6 +271,7 @@ public class ActivityView extends ViewGroup { if (mVirtualDisplay != null) { mVirtualDisplay.resize(width, height, getBaseDisplayDensity()); } updateLocation(); } @Override Loading @@ -257,6 +281,7 @@ public class ActivityView extends ViewGroup { if (mVirtualDisplay != null) { mVirtualDisplay.setSurface(null); } cleanTapExcludeRegion(); } } Loading Loading @@ -290,6 +315,7 @@ public class ActivityView extends ViewGroup { if (mInputForwarder != null) { mInputForwarder = null; } cleanTapExcludeRegion(); final boolean displayReleased; if (mVirtualDisplay != null) { Loading @@ -313,6 +339,17 @@ public class ActivityView extends ViewGroup { mOpened = false; } /** Report to server that tap exclude region on hosting display should be cleared. */ private void cleanTapExcludeRegion() { // Update tap exclude region with an empty rect to clean the state on server. try { WindowManagerGlobal.getWindowSession().updateTapExcludeRegion(getWindow(), hashCode(), 0 /* left */, 0 /* top */, 0 /* width */, 0 /* height */); } catch (RemoteException e) { e.rethrowAsRuntimeException(); } } /** Get density of the hosting display. */ private int getBaseDisplayDensity() { final WindowManager wm = mContext.getSystemService(WindowManager.class); Loading
core/java/android/view/IWindowSession.aidl +8 −0 Original line number Diff line number Diff line Loading @@ -236,4 +236,12 @@ interface IWindowSession { boolean startMovingTask(IWindow window, float startX, float startY); void updatePointerIcon(IWindow window); /** * Update a tap exclude region with a rectangular area identified by provided id in the window. * Touches on this region will not switch focus to this window. Passing an empty rect will * remove the area from the exclude region of this window. */ void updateTapExcludeRegion(IWindow window, int regionId, int left, int top, int width, int height); }
core/java/android/view/View.java +9 −0 Original line number Diff line number Diff line Loading @@ -17885,6 +17885,15 @@ public class View implements Drawable.Callback, KeyEvent.Callback, return mAttachInfo != null ? mAttachInfo.mSession : null; } /** * Return the window this view is currently attached to. Used in * {@link android.app.ActivityView} to communicate with WM. * @hide */ protected IWindow getWindow() { return mAttachInfo != null ? mAttachInfo.mWindow : null; } /** * Return the visibility value of the least visible component passed. */
services/core/java/com/android/server/wm/DisplayContent.java +8 −1 Original line number Diff line number Diff line Loading @@ -134,6 +134,7 @@ import android.os.IBinder; import android.os.RemoteException; import android.os.SystemClock; import android.os.Trace; import android.util.ArraySet; import android.util.DisplayMetrics; import android.util.MutableBoolean; import android.util.Slog; Loading Loading @@ -330,6 +331,8 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo final PinnedStackController mPinnedStackControllerLocked; final ArrayList<WindowState> mTapExcludedWindows = new ArrayList<>(); /** A collection of windows that provide tap exclude regions inside of them. */ final ArraySet<WindowState> mTapExcludeProvidingWindows = new ArraySet<>(); private boolean mHaveBootMsg = false; private boolean mHaveApp = false; Loading Loading @@ -1866,10 +1869,14 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo } } for (int i = mTapExcludedWindows.size() - 1; i >= 0; i--) { WindowState win = mTapExcludedWindows.get(i); final WindowState win = mTapExcludedWindows.get(i); win.getTouchableRegion(mTmpRegion); mTouchExcludeRegion.op(mTmpRegion, Region.Op.UNION); } for (int i = mTapExcludeProvidingWindows.size() - 1; i >= 0; i--) { final WindowState win = mTapExcludeProvidingWindows.valueAt(i); win.amendTapExcludeRegion(mTouchExcludeRegion); } // TODO(multi-display): Support docked stacks on secondary displays. if (mDisplayId == DEFAULT_DISPLAY && getSplitScreenPrimaryStack() != null) { mDividerControllerLocked.getTouchRegion(mTmpRect); Loading
services/core/java/com/android/server/wm/Session.java +11 −0 Original line number Diff line number Diff line Loading @@ -467,6 +467,17 @@ class Session extends IWindowSession.Stub implements IBinder.DeathRecipient { } } @Override public void updateTapExcludeRegion(IWindow window, int regionId, int left, int top, int width, int height) { final long identity = Binder.clearCallingIdentity(); try { mService.updateTapExcludeRegion(window, regionId, left, top, width, height); } finally { Binder.restoreCallingIdentity(identity); } } void windowAddedLocked(String packageName) { mPackageName = packageName; mRelayoutTag = "relayoutWindow: " + mPackageName; Loading