Loading services/accessibility/java/com/android/server/accessibility/autoclick/AutoclickTypePanel.java +15 −1 Original line number Diff line number Diff line Loading @@ -40,6 +40,7 @@ import androidx.annotation.NonNull; import androidx.annotation.VisibleForTesting; import com.android.internal.R; import com.android.internal.policy.SystemBarUtils; public class AutoclickTypePanel { Loading Loading @@ -134,6 +135,8 @@ public class AutoclickTypePanel { // Whether autoclick is paused. private boolean mPaused = false; private int mStatusBarHeight = 0; // The current corner position of the panel, default to bottom right. private @Corner int mCurrentCorner = CORNER_BOTTOM_RIGHT; Loading Loading @@ -197,6 +200,8 @@ public class AutoclickTypePanel { mLongPressButton = mContentView.findViewById(R.id.accessibility_autoclick_long_press_layout); // Get status bar height. mStatusBarHeight = SystemBarUtils.getStatusBarHeight(context); // Initialize the cursor icons. mCurrentCursor = PointerIcon.getSystemIcon(context, PointerIcon.TYPE_ARROW); Loading Loading @@ -259,7 +264,12 @@ public class AutoclickTypePanel { // Update panel position, based on Top-Left absolute positioning. mParams.x = mPanelStartX + (int) deltaX; mParams.y = mPanelStartY + (int) deltaY; // Adjust Y by status bar height: // Note: mParams.y is relative to the content area (below the status bar), // but mPanelStartY uses absolute screen coordinates. Subtract status bar // height to align coordinates properly. mParams.y = Math.max(0, mPanelStartY + (int) deltaY - mStatusBarHeight); mWindowManager.updateViewLayout(mContentView, mParams); } return true; Loading Loading @@ -747,6 +757,10 @@ public class AutoclickTypePanel { } @VisibleForTesting int getStatusBarHeightForTesting() { return mStatusBarHeight; } PointerIcon getCurrentCursorForTesting() { return mCurrentCursor; } Loading services/tests/servicestests/src/com/android/server/accessibility/autoclick/AutoclickTypePanelTest.java +8 −3 Original line number Diff line number Diff line Loading @@ -351,7 +351,9 @@ public class AutoclickTypePanelTest { assertThat(mAutoclickTypePanel.getIsDraggingForTesting()).isTrue(); assertThat(params.gravity).isEqualTo(Gravity.LEFT | Gravity.TOP); assertThat(params.x).isEqualTo(panelLocation[0] + delta); assertThat(params.y).isEqualTo(panelLocation[1] + delta); assertThat(params.y).isEqualTo( Math.max(0, panelLocation[1] + delta - mAutoclickTypePanel.getStatusBarHeightForTesting())); } @Test Loading Loading @@ -475,7 +477,9 @@ public class AutoclickTypePanelTest { assertThat(parts).hasLength(4); assertThat(Integer.parseInt(parts[0])).isEqualTo(Gravity.START | Gravity.TOP); assertThat(Integer.parseInt(parts[1])).isEqualTo(15); assertThat(Integer.parseInt(parts[2])).isEqualTo(panelLocation[1] + 10); assertThat(Integer.parseInt(parts[2])).isEqualTo( Math.max(0, panelLocation[1] + 10 - mAutoclickTypePanel.getStatusBarHeightForTesting())); assertThat(Integer.parseInt(parts[3])).isEqualTo(CORNER_BOTTOM_LEFT); // Show panel to trigger position restoration. Loading @@ -485,7 +489,8 @@ public class AutoclickTypePanelTest { WindowManager.LayoutParams params = mAutoclickTypePanel.getLayoutParamsForTesting(); assertThat(params.gravity).isEqualTo(Gravity.START | Gravity.TOP); assertThat(params.x).isEqualTo(15); // PANEL_EDGE_MARGIN assertThat(params.y).isEqualTo(panelLocation[1] + 10); assertThat(params.y).isEqualTo(Math.max(0, panelLocation[1] + 10 - mAutoclickTypePanel.getStatusBarHeightForTesting())); assertThat(mAutoclickTypePanel.getCurrentCornerForTesting()).isEqualTo( CORNER_BOTTOM_LEFT); } Loading Loading
services/accessibility/java/com/android/server/accessibility/autoclick/AutoclickTypePanel.java +15 −1 Original line number Diff line number Diff line Loading @@ -40,6 +40,7 @@ import androidx.annotation.NonNull; import androidx.annotation.VisibleForTesting; import com.android.internal.R; import com.android.internal.policy.SystemBarUtils; public class AutoclickTypePanel { Loading Loading @@ -134,6 +135,8 @@ public class AutoclickTypePanel { // Whether autoclick is paused. private boolean mPaused = false; private int mStatusBarHeight = 0; // The current corner position of the panel, default to bottom right. private @Corner int mCurrentCorner = CORNER_BOTTOM_RIGHT; Loading Loading @@ -197,6 +200,8 @@ public class AutoclickTypePanel { mLongPressButton = mContentView.findViewById(R.id.accessibility_autoclick_long_press_layout); // Get status bar height. mStatusBarHeight = SystemBarUtils.getStatusBarHeight(context); // Initialize the cursor icons. mCurrentCursor = PointerIcon.getSystemIcon(context, PointerIcon.TYPE_ARROW); Loading Loading @@ -259,7 +264,12 @@ public class AutoclickTypePanel { // Update panel position, based on Top-Left absolute positioning. mParams.x = mPanelStartX + (int) deltaX; mParams.y = mPanelStartY + (int) deltaY; // Adjust Y by status bar height: // Note: mParams.y is relative to the content area (below the status bar), // but mPanelStartY uses absolute screen coordinates. Subtract status bar // height to align coordinates properly. mParams.y = Math.max(0, mPanelStartY + (int) deltaY - mStatusBarHeight); mWindowManager.updateViewLayout(mContentView, mParams); } return true; Loading Loading @@ -747,6 +757,10 @@ public class AutoclickTypePanel { } @VisibleForTesting int getStatusBarHeightForTesting() { return mStatusBarHeight; } PointerIcon getCurrentCursorForTesting() { return mCurrentCursor; } Loading
services/tests/servicestests/src/com/android/server/accessibility/autoclick/AutoclickTypePanelTest.java +8 −3 Original line number Diff line number Diff line Loading @@ -351,7 +351,9 @@ public class AutoclickTypePanelTest { assertThat(mAutoclickTypePanel.getIsDraggingForTesting()).isTrue(); assertThat(params.gravity).isEqualTo(Gravity.LEFT | Gravity.TOP); assertThat(params.x).isEqualTo(panelLocation[0] + delta); assertThat(params.y).isEqualTo(panelLocation[1] + delta); assertThat(params.y).isEqualTo( Math.max(0, panelLocation[1] + delta - mAutoclickTypePanel.getStatusBarHeightForTesting())); } @Test Loading Loading @@ -475,7 +477,9 @@ public class AutoclickTypePanelTest { assertThat(parts).hasLength(4); assertThat(Integer.parseInt(parts[0])).isEqualTo(Gravity.START | Gravity.TOP); assertThat(Integer.parseInt(parts[1])).isEqualTo(15); assertThat(Integer.parseInt(parts[2])).isEqualTo(panelLocation[1] + 10); assertThat(Integer.parseInt(parts[2])).isEqualTo( Math.max(0, panelLocation[1] + 10 - mAutoclickTypePanel.getStatusBarHeightForTesting())); assertThat(Integer.parseInt(parts[3])).isEqualTo(CORNER_BOTTOM_LEFT); // Show panel to trigger position restoration. Loading @@ -485,7 +489,8 @@ public class AutoclickTypePanelTest { WindowManager.LayoutParams params = mAutoclickTypePanel.getLayoutParamsForTesting(); assertThat(params.gravity).isEqualTo(Gravity.START | Gravity.TOP); assertThat(params.x).isEqualTo(15); // PANEL_EDGE_MARGIN assertThat(params.y).isEqualTo(panelLocation[1] + 10); assertThat(params.y).isEqualTo(Math.max(0, panelLocation[1] + 10 - mAutoclickTypePanel.getStatusBarHeightForTesting())); assertThat(mAutoclickTypePanel.getCurrentCornerForTesting()).isEqualTo( CORNER_BOTTOM_LEFT); } Loading