diff options
| author | 2024-09-17 15:14:40 +0000 | |
|---|---|---|
| committer | 2024-09-17 15:14:40 +0000 | |
| commit | 0b2828ce12c08ff138b30bdfb19f89b48c889778 (patch) | |
| tree | 56b8fb44a5c40368171e3b01b288396ad68a7538 | |
| parent | 350d40e992216a7ebf7acd0570ce45a158016a50 (diff) | |
| parent | 6e7b28d581c072c2fc93db90fe87d46e607abd3d (diff) | |
Merge "Made TouchpadDebugView edges rounded" into main
| -rw-r--r-- | services/core/java/com/android/server/input/debug/TouchpadDebugView.java | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/services/core/java/com/android/server/input/debug/TouchpadDebugView.java b/services/core/java/com/android/server/input/debug/TouchpadDebugView.java index 3f11e7836609..5ff8568f81b2 100644 --- a/services/core/java/com/android/server/input/debug/TouchpadDebugView.java +++ b/services/core/java/com/android/server/input/debug/TouchpadDebugView.java @@ -29,7 +29,9 @@ import android.util.Slog; import android.util.TypedValue; import android.view.Gravity; import android.view.MotionEvent; +import android.view.SurfaceControl; import android.view.ViewConfiguration; +import android.view.ViewRootImpl; import android.view.WindowManager; import android.widget.LinearLayout; import android.widget.TextView; @@ -49,6 +51,7 @@ public class TouchpadDebugView extends LinearLayout { private static final float DEFAULT_RES_X = 47f; private static final float DEFAULT_RES_Y = 45f; private static final int TEXT_PADDING_DP = 12; + private static final int ROUNDED_CORNER_RADIUS_DP = 24; /** * Input device ID for the touchpad that this debug view is displaying. @@ -152,6 +155,30 @@ public class TouchpadDebugView extends LinearLayout { } @Override + public void onAttachedToWindow() { + super.onAttachedToWindow(); + postDelayed(() -> { + final ViewRootImpl viewRootImpl = getRootView().getViewRootImpl(); + if (viewRootImpl == null) { + Slog.d("TouchpadDebugView", "ViewRootImpl is null."); + return; + } + + SurfaceControl surfaceControl = viewRootImpl.getSurfaceControl(); + if (surfaceControl != null && surfaceControl.isValid()) { + try (SurfaceControl.Transaction transaction = new SurfaceControl.Transaction()) { + transaction.setCornerRadius(surfaceControl, + TypedValue.applyDimension(COMPLEX_UNIT_DIP, + ROUNDED_CORNER_RADIUS_DP, + getResources().getDisplayMetrics())).apply(); + } + } else { + Slog.d("TouchpadDebugView", "SurfaceControl is invalid or has been released."); + } + }, 100); + } + + @Override public boolean onTouchEvent(MotionEvent event) { float deltaX; float deltaY; |