Loading services/accessibility/java/com/android/server/accessibility/autoclick/AutoclickController.java +1 −1 Original line number Diff line number Diff line Loading @@ -1094,7 +1094,7 @@ public class AutoclickController extends BaseEventStreamTransformation { private void resetSelectedClickTypeIfNecessary() { if ((mRevertToLeftClick && mActiveClickType != AUTOCLICK_TYPE_LEFT_CLICK) || mActiveClickType == AUTOCLICK_TYPE_LONG_PRESS) { mAutoclickTypePanel.resetSelectedClickType(); mAutoclickTypePanel.collapsePanelWithClickType(AUTOCLICK_TYPE_LEFT_CLICK); } } Loading services/accessibility/java/com/android/server/accessibility/autoclick/AutoclickTypePanel.java +26 −19 Original line number Diff line number Diff line Loading @@ -145,6 +145,7 @@ public class AutoclickTypePanel { private final LinearLayout mLongPressButton; private LinearLayout mSelectedButton; private int mSelectedClickType = AUTOCLICK_TYPE_LEFT_CLICK; private final Drawable mPauseButtonDrawable; private final Drawable mResumeButtonDrawable; Loading Loading @@ -248,6 +249,11 @@ public class AutoclickTypePanel { } mIsDragging = false; return true; case MotionEvent.ACTION_OUTSIDE: if (mExpanded) { collapsePanelWithClickType(mSelectedClickType); } return true; } return false; } Loading Loading @@ -306,17 +312,25 @@ public class AutoclickTypePanel { // The pause button calls `togglePause()` directly so it does not need extra logic. mPauseButton.setOnClickListener(v -> togglePause()); resetSelectedClickType(); collapsePanelWithClickType(AUTOCLICK_TYPE_LEFT_CLICK); // Remove spacing between buttons when initialized. adjustPanelSpacing(/* isExpanded= */ false); } /** Reset panel as collapsed state and only displays the left click button. */ public void resetSelectedClickType() { /** Reset panel as collapsed state and only displays selelcted button. */ public void collapsePanelWithClickType(@AutoclickType int clickType) { hideAllClickTypeButtons(); mLeftClickButton.setVisibility(View.VISIBLE); setSelectedClickType(AUTOCLICK_TYPE_LEFT_CLICK); final LinearLayout selectedButton = getButtonFromClickType(clickType); selectedButton.setVisibility(View.VISIBLE); // Sets the newly selected button. setSelectedClickType(clickType); // Remove spacing between buttons when collapsed. adjustPanelSpacing(/* isExpanded= */ false); mExpanded = false; } /** Sets the selected button and updates the newly and previously selected button styling. */ Loading @@ -329,6 +343,7 @@ public class AutoclickTypePanel { } mSelectedButton = selectedButton; mSelectedClickType = clickType; mClickPanelController.handleAutoclickTypeChange(clickType); // Updates the newly selected button styling. Loading Loading @@ -389,29 +404,20 @@ public class AutoclickTypePanel { /** Toggles the panel expanded or collapsed state. */ private void togglePanelExpansion(@AutoclickType int clickType) { final LinearLayout button = getButtonFromClickType(clickType); if (mExpanded) { // If the panel is already in expanded state, we should collapse it by hiding all // buttons except the one user selected. hideAllClickTypeButtons(); button.setVisibility(View.VISIBLE); // Sets the newly selected button. setSelectedClickType(clickType); // Remove spacing between buttons when collapsed. adjustPanelSpacing(/* isExpanded= */ false); collapsePanelWithClickType(clickType); } else { // If the panel is already collapsed, we just need to expand it. showAllClickTypeButtons(); // Add spacing when panel is expanded. adjustPanelSpacing(/* isExpanded= */ true); } // Toggle the state. mExpanded = !mExpanded; mExpanded = true; } } private void togglePause() { Loading Loading @@ -707,7 +713,8 @@ public class AutoclickTypePanel { private WindowManager.LayoutParams getDefaultLayoutParams() { final WindowManager.LayoutParams layoutParams = new WindowManager.LayoutParams(); layoutParams.type = WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY; layoutParams.flags = WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE; layoutParams.flags = WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH; layoutParams.privateFlags |= WindowManager.LayoutParams.SYSTEM_FLAG_SHOW_FOR_ALL_USERS; layoutParams.setFitInsetsTypes(WindowInsets.Type.statusBars()); layoutParams.layoutInDisplayCutoutMode = LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS; Loading services/tests/servicestests/src/com/android/server/accessibility/autoclick/AutoclickControllerTest.java +8 −3 Original line number Diff line number Diff line Loading @@ -25,6 +25,7 @@ import static com.android.server.testutils.MockitoUtilsKt.eq; import static com.google.common.truth.Truth.assertThat; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyInt; import static org.mockito.ArgumentMatchers.anyFloat; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.spy; Loading Loading @@ -1209,7 +1210,9 @@ public class AutoclickControllerTest { mTestableLooper.processAllMessages(); // Even after the click, the click type should not be reset. verify(mockAutoclickTypePanel, Mockito.never()).resetSelectedClickType(); assertThat(mController.getActiveClickTypeForTest()) .isEqualTo(AutoclickTypePanel.AUTOCLICK_TYPE_DRAG); verify(mockAutoclickTypePanel, Mockito.never()).collapsePanelWithClickType(anyInt()); } @Test Loading Loading @@ -1241,7 +1244,8 @@ public class AutoclickControllerTest { mController.exitScrollMode(); // Verify click type is reset when exiting scroll mode. verify(mockAutoclickTypePanel).resetSelectedClickType(); verify(mockAutoclickTypePanel).collapsePanelWithClickType( AutoclickTypePanel.AUTOCLICK_TYPE_LEFT_CLICK); } @Test Loading Loading @@ -1349,7 +1353,8 @@ public class AutoclickControllerTest { MotionEvent.ACTION_DOWN, MotionEvent.ACTION_BUTTON_PRESS, MotionEvent.ACTION_BUTTON_RELEASE, MotionEvent.ACTION_UP); verify(mockAutoclickTypePanel).resetSelectedClickType(); verify(mockAutoclickTypePanel).collapsePanelWithClickType( AutoclickTypePanel.AUTOCLICK_TYPE_LEFT_CLICK); } @Test Loading Loading
services/accessibility/java/com/android/server/accessibility/autoclick/AutoclickController.java +1 −1 Original line number Diff line number Diff line Loading @@ -1094,7 +1094,7 @@ public class AutoclickController extends BaseEventStreamTransformation { private void resetSelectedClickTypeIfNecessary() { if ((mRevertToLeftClick && mActiveClickType != AUTOCLICK_TYPE_LEFT_CLICK) || mActiveClickType == AUTOCLICK_TYPE_LONG_PRESS) { mAutoclickTypePanel.resetSelectedClickType(); mAutoclickTypePanel.collapsePanelWithClickType(AUTOCLICK_TYPE_LEFT_CLICK); } } Loading
services/accessibility/java/com/android/server/accessibility/autoclick/AutoclickTypePanel.java +26 −19 Original line number Diff line number Diff line Loading @@ -145,6 +145,7 @@ public class AutoclickTypePanel { private final LinearLayout mLongPressButton; private LinearLayout mSelectedButton; private int mSelectedClickType = AUTOCLICK_TYPE_LEFT_CLICK; private final Drawable mPauseButtonDrawable; private final Drawable mResumeButtonDrawable; Loading Loading @@ -248,6 +249,11 @@ public class AutoclickTypePanel { } mIsDragging = false; return true; case MotionEvent.ACTION_OUTSIDE: if (mExpanded) { collapsePanelWithClickType(mSelectedClickType); } return true; } return false; } Loading Loading @@ -306,17 +312,25 @@ public class AutoclickTypePanel { // The pause button calls `togglePause()` directly so it does not need extra logic. mPauseButton.setOnClickListener(v -> togglePause()); resetSelectedClickType(); collapsePanelWithClickType(AUTOCLICK_TYPE_LEFT_CLICK); // Remove spacing between buttons when initialized. adjustPanelSpacing(/* isExpanded= */ false); } /** Reset panel as collapsed state and only displays the left click button. */ public void resetSelectedClickType() { /** Reset panel as collapsed state and only displays selelcted button. */ public void collapsePanelWithClickType(@AutoclickType int clickType) { hideAllClickTypeButtons(); mLeftClickButton.setVisibility(View.VISIBLE); setSelectedClickType(AUTOCLICK_TYPE_LEFT_CLICK); final LinearLayout selectedButton = getButtonFromClickType(clickType); selectedButton.setVisibility(View.VISIBLE); // Sets the newly selected button. setSelectedClickType(clickType); // Remove spacing between buttons when collapsed. adjustPanelSpacing(/* isExpanded= */ false); mExpanded = false; } /** Sets the selected button and updates the newly and previously selected button styling. */ Loading @@ -329,6 +343,7 @@ public class AutoclickTypePanel { } mSelectedButton = selectedButton; mSelectedClickType = clickType; mClickPanelController.handleAutoclickTypeChange(clickType); // Updates the newly selected button styling. Loading Loading @@ -389,29 +404,20 @@ public class AutoclickTypePanel { /** Toggles the panel expanded or collapsed state. */ private void togglePanelExpansion(@AutoclickType int clickType) { final LinearLayout button = getButtonFromClickType(clickType); if (mExpanded) { // If the panel is already in expanded state, we should collapse it by hiding all // buttons except the one user selected. hideAllClickTypeButtons(); button.setVisibility(View.VISIBLE); // Sets the newly selected button. setSelectedClickType(clickType); // Remove spacing between buttons when collapsed. adjustPanelSpacing(/* isExpanded= */ false); collapsePanelWithClickType(clickType); } else { // If the panel is already collapsed, we just need to expand it. showAllClickTypeButtons(); // Add spacing when panel is expanded. adjustPanelSpacing(/* isExpanded= */ true); } // Toggle the state. mExpanded = !mExpanded; mExpanded = true; } } private void togglePause() { Loading Loading @@ -707,7 +713,8 @@ public class AutoclickTypePanel { private WindowManager.LayoutParams getDefaultLayoutParams() { final WindowManager.LayoutParams layoutParams = new WindowManager.LayoutParams(); layoutParams.type = WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY; layoutParams.flags = WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE; layoutParams.flags = WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH; layoutParams.privateFlags |= WindowManager.LayoutParams.SYSTEM_FLAG_SHOW_FOR_ALL_USERS; layoutParams.setFitInsetsTypes(WindowInsets.Type.statusBars()); layoutParams.layoutInDisplayCutoutMode = LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS; Loading
services/tests/servicestests/src/com/android/server/accessibility/autoclick/AutoclickControllerTest.java +8 −3 Original line number Diff line number Diff line Loading @@ -25,6 +25,7 @@ import static com.android.server.testutils.MockitoUtilsKt.eq; import static com.google.common.truth.Truth.assertThat; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyInt; import static org.mockito.ArgumentMatchers.anyFloat; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.spy; Loading Loading @@ -1209,7 +1210,9 @@ public class AutoclickControllerTest { mTestableLooper.processAllMessages(); // Even after the click, the click type should not be reset. verify(mockAutoclickTypePanel, Mockito.never()).resetSelectedClickType(); assertThat(mController.getActiveClickTypeForTest()) .isEqualTo(AutoclickTypePanel.AUTOCLICK_TYPE_DRAG); verify(mockAutoclickTypePanel, Mockito.never()).collapsePanelWithClickType(anyInt()); } @Test Loading Loading @@ -1241,7 +1244,8 @@ public class AutoclickControllerTest { mController.exitScrollMode(); // Verify click type is reset when exiting scroll mode. verify(mockAutoclickTypePanel).resetSelectedClickType(); verify(mockAutoclickTypePanel).collapsePanelWithClickType( AutoclickTypePanel.AUTOCLICK_TYPE_LEFT_CLICK); } @Test Loading Loading @@ -1349,7 +1353,8 @@ public class AutoclickControllerTest { MotionEvent.ACTION_DOWN, MotionEvent.ACTION_BUTTON_PRESS, MotionEvent.ACTION_BUTTON_RELEASE, MotionEvent.ACTION_UP); verify(mockAutoclickTypePanel).resetSelectedClickType(); verify(mockAutoclickTypePanel).collapsePanelWithClickType( AutoclickTypePanel.AUTOCLICK_TYPE_LEFT_CLICK); } @Test Loading