Loading libs/input/SpriteController.cpp +6 −5 Original line number Diff line number Diff line Loading @@ -27,10 +27,12 @@ namespace android { // --- SpriteController --- SpriteController::SpriteController(const sp<Looper>& looper, int32_t overlayLayer) : mLooper(looper), mOverlayLayer(overlayLayer) { SpriteController::SpriteController(const sp<Looper>& looper, int32_t overlayLayer, ParentSurfaceProvider parentSurfaceProvider) : mLooper(looper), mOverlayLayer(overlayLayer), mParentSurfaceProvider(std::move(parentSurfaceProvider)) { mHandler = new WeakMessageHandler(this); mLocked.transactionNestingCount = 0; mLocked.deferredSpriteUpdate = false; } Loading Loading @@ -168,8 +170,7 @@ void SpriteController::doUpdateSprites() { // If surface is a new one, we have to set right layer stack. if (update.surfaceChanged || update.state.dirty & DIRTY_DISPLAY_ID) { t.setLayerStack(update.state.surfaceControl, ui::LayerStack::fromValue(update.state.displayId)); t.reparent(update.state.surfaceControl, mParentSurfaceProvider(update.state.displayId)); needApplyTransaction = true; } } Loading libs/input/SpriteController.h +3 −1 Original line number Diff line number Diff line Loading @@ -114,7 +114,8 @@ protected: virtual ~SpriteController(); public: SpriteController(const sp<Looper>& looper, int32_t overlayLayer); using ParentSurfaceProvider = std::function<sp<SurfaceControl>(int /*displayId*/)>; SpriteController(const sp<Looper>& looper, int32_t overlayLayer, ParentSurfaceProvider parent); /* Creates a new sprite, initially invisible. */ virtual sp<Sprite> createSprite(); Loading Loading @@ -245,6 +246,7 @@ private: sp<Looper> mLooper; const int32_t mOverlayLayer; sp<WeakMessageHandler> mHandler; ParentSurfaceProvider mParentSurfaceProvider; sp<SurfaceComposerClient> mSurfaceComposerClient; Loading libs/input/tests/mocks/MockSpriteController.h +2 −1 Original line number Diff line number Diff line Loading @@ -26,7 +26,8 @@ namespace android { class MockSpriteController : public SpriteController { public: MockSpriteController(sp<Looper> looper) : SpriteController(looper, 0) {} MockSpriteController(sp<Looper> looper) : SpriteController(looper, 0, [](int) { return nullptr; }) {} ~MockSpriteController() {} MOCK_METHOD(sp<Sprite>, createSprite, (), (override)); Loading services/core/java/com/android/server/input/InputManagerService.java +16 −0 Original line number Diff line number Diff line Loading @@ -98,6 +98,7 @@ import android.view.InputMonitor; import android.view.KeyEvent; import android.view.PointerIcon; import android.view.Surface; import android.view.SurfaceControl; import android.view.VerifiedInputEvent; import android.view.ViewConfiguration; import android.widget.Toast; Loading Loading @@ -2906,6 +2907,15 @@ public class InputManagerService extends IInputManager.Stub return PointerIcon.getDefaultIcon(getContextForPointerIcon(displayId)); } // Native callback. private long getParentSurfaceForPointers(int displayId) { final SurfaceControl sc = mWindowManagerCallbacks.getParentSurfaceForPointers(displayId); if (sc == null) { return 0; } return sc.mNativeObject; } @NonNull private Context getContextForPointerIcon(int displayId) { if (mPointerIconDisplayContext != null Loading Loading @@ -3105,6 +3115,12 @@ public class InputManagerService extends IInputManager.Stub * Called when the drag over window has changed. */ void notifyDropWindow(IBinder token, float x, float y); /** * Get the {@link SurfaceControl} that should be the parent for the surfaces created for * pointers such as the mouse cursor and touch spots for the given display. */ SurfaceControl getParentSurfaceForPointers(int displayId); } /** Loading services/core/java/com/android/server/wm/InputManagerCallback.java +14 −0 Original line number Diff line number Diff line Loading @@ -29,6 +29,7 @@ import android.os.IBinder; import android.util.Slog; import android.view.InputApplicationHandle; import android.view.KeyEvent; import android.view.SurfaceControl; import android.view.WindowManager; import android.view.WindowManagerPolicyConstants; Loading Loading @@ -234,6 +235,19 @@ final class InputManagerCallback implements InputManagerService.WindowManagerCal mService.mDragDropController::reportDropWindow, token, x, y)); } @Override public SurfaceControl getParentSurfaceForPointers(int displayId) { synchronized (mService.mGlobalLock) { final DisplayContent dc = mService.mRoot.getDisplayContent(displayId); if (dc == null) { Slog.e(TAG, "Failed to get parent surface for pointers on display " + displayId + " - DisplayContent not found."); return null; } return dc.getOverlayLayer(); } } /** Waits until the built-in input devices have been configured. */ public boolean waitForInputDevicesReady(long timeoutMillis) { synchronized (mInputDevicesReadyMonitor) { Loading Loading
libs/input/SpriteController.cpp +6 −5 Original line number Diff line number Diff line Loading @@ -27,10 +27,12 @@ namespace android { // --- SpriteController --- SpriteController::SpriteController(const sp<Looper>& looper, int32_t overlayLayer) : mLooper(looper), mOverlayLayer(overlayLayer) { SpriteController::SpriteController(const sp<Looper>& looper, int32_t overlayLayer, ParentSurfaceProvider parentSurfaceProvider) : mLooper(looper), mOverlayLayer(overlayLayer), mParentSurfaceProvider(std::move(parentSurfaceProvider)) { mHandler = new WeakMessageHandler(this); mLocked.transactionNestingCount = 0; mLocked.deferredSpriteUpdate = false; } Loading Loading @@ -168,8 +170,7 @@ void SpriteController::doUpdateSprites() { // If surface is a new one, we have to set right layer stack. if (update.surfaceChanged || update.state.dirty & DIRTY_DISPLAY_ID) { t.setLayerStack(update.state.surfaceControl, ui::LayerStack::fromValue(update.state.displayId)); t.reparent(update.state.surfaceControl, mParentSurfaceProvider(update.state.displayId)); needApplyTransaction = true; } } Loading
libs/input/SpriteController.h +3 −1 Original line number Diff line number Diff line Loading @@ -114,7 +114,8 @@ protected: virtual ~SpriteController(); public: SpriteController(const sp<Looper>& looper, int32_t overlayLayer); using ParentSurfaceProvider = std::function<sp<SurfaceControl>(int /*displayId*/)>; SpriteController(const sp<Looper>& looper, int32_t overlayLayer, ParentSurfaceProvider parent); /* Creates a new sprite, initially invisible. */ virtual sp<Sprite> createSprite(); Loading Loading @@ -245,6 +246,7 @@ private: sp<Looper> mLooper; const int32_t mOverlayLayer; sp<WeakMessageHandler> mHandler; ParentSurfaceProvider mParentSurfaceProvider; sp<SurfaceComposerClient> mSurfaceComposerClient; Loading
libs/input/tests/mocks/MockSpriteController.h +2 −1 Original line number Diff line number Diff line Loading @@ -26,7 +26,8 @@ namespace android { class MockSpriteController : public SpriteController { public: MockSpriteController(sp<Looper> looper) : SpriteController(looper, 0) {} MockSpriteController(sp<Looper> looper) : SpriteController(looper, 0, [](int) { return nullptr; }) {} ~MockSpriteController() {} MOCK_METHOD(sp<Sprite>, createSprite, (), (override)); Loading
services/core/java/com/android/server/input/InputManagerService.java +16 −0 Original line number Diff line number Diff line Loading @@ -98,6 +98,7 @@ import android.view.InputMonitor; import android.view.KeyEvent; import android.view.PointerIcon; import android.view.Surface; import android.view.SurfaceControl; import android.view.VerifiedInputEvent; import android.view.ViewConfiguration; import android.widget.Toast; Loading Loading @@ -2906,6 +2907,15 @@ public class InputManagerService extends IInputManager.Stub return PointerIcon.getDefaultIcon(getContextForPointerIcon(displayId)); } // Native callback. private long getParentSurfaceForPointers(int displayId) { final SurfaceControl sc = mWindowManagerCallbacks.getParentSurfaceForPointers(displayId); if (sc == null) { return 0; } return sc.mNativeObject; } @NonNull private Context getContextForPointerIcon(int displayId) { if (mPointerIconDisplayContext != null Loading Loading @@ -3105,6 +3115,12 @@ public class InputManagerService extends IInputManager.Stub * Called when the drag over window has changed. */ void notifyDropWindow(IBinder token, float x, float y); /** * Get the {@link SurfaceControl} that should be the parent for the surfaces created for * pointers such as the mouse cursor and touch spots for the given display. */ SurfaceControl getParentSurfaceForPointers(int displayId); } /** Loading
services/core/java/com/android/server/wm/InputManagerCallback.java +14 −0 Original line number Diff line number Diff line Loading @@ -29,6 +29,7 @@ import android.os.IBinder; import android.util.Slog; import android.view.InputApplicationHandle; import android.view.KeyEvent; import android.view.SurfaceControl; import android.view.WindowManager; import android.view.WindowManagerPolicyConstants; Loading Loading @@ -234,6 +235,19 @@ final class InputManagerCallback implements InputManagerService.WindowManagerCal mService.mDragDropController::reportDropWindow, token, x, y)); } @Override public SurfaceControl getParentSurfaceForPointers(int displayId) { synchronized (mService.mGlobalLock) { final DisplayContent dc = mService.mRoot.getDisplayContent(displayId); if (dc == null) { Slog.e(TAG, "Failed to get parent surface for pointers on display " + displayId + " - DisplayContent not found."); return null; } return dc.getOverlayLayer(); } } /** Waits until the built-in input devices have been configured. */ public boolean waitForInputDevicesReady(long timeoutMillis) { synchronized (mInputDevicesReadyMonitor) { Loading