summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Wenyu Zhang <zhangwenyu@google.com> 2025-01-30 20:02:05 -0800
committer Android (Google) Code Review <android-gerrit@google.com> 2025-01-30 20:02:05 -0800
commitc792d50b8e74bcee545a3d576500601bc18fc65c (patch)
tree1e53cb88a5e8f2a96cdbf0ded284f2787dc4583d
parent9a93e19522de4ffca4a7726ea985e03820218495 (diff)
parent2cd2119527c8816b8849e62893502de4083ddbde (diff)
Merge "a11y: Add AutoclickTypePanelView" into main
-rw-r--r--core/res/res/drawable/accessibility_autoclick_button_rounded_background.xml20
-rw-r--r--core/res/res/drawable/accessibility_autoclick_left_click.xml25
-rw-r--r--core/res/res/drawable/accessibility_autoclick_pause.xml26
-rw-r--r--core/res/res/drawable/accessibility_autoclick_position.xml26
-rw-r--r--core/res/res/drawable/accessibility_autoclick_type_panel_rounded_background.xml20
-rw-r--r--core/res/res/layout/accessibility_autoclick_type_panel.xml78
-rw-r--r--core/res/res/values/dimens.xml12
-rw-r--r--core/res/res/values/strings.xml10
-rw-r--r--core/res/res/values/styles.xml16
-rw-r--r--core/res/res/values/symbols.xml18
-rw-r--r--services/accessibility/java/com/android/server/accessibility/autoclick/AutoclickController.java5
-rw-r--r--services/accessibility/java/com/android/server/accessibility/autoclick/AutoclickTypePanel.java84
-rw-r--r--services/tests/servicestests/src/com/android/server/accessibility/autoclick/AutoclickControllerTest.java74
13 files changed, 392 insertions, 22 deletions
diff --git a/core/res/res/drawable/accessibility_autoclick_button_rounded_background.xml b/core/res/res/drawable/accessibility_autoclick_button_rounded_background.xml
new file mode 100644
index 000000000000..6d0c2653e5f2
--- /dev/null
+++ b/core/res/res/drawable/accessibility_autoclick_button_rounded_background.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright 2025 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<shape xmlns:android="http://schemas.android.com/apk/res/android">
+ <solid android:color="@color/materialColorSurfaceContainer" />
+ <corners android:radius="24dp" />
+</shape>
diff --git a/core/res/res/drawable/accessibility_autoclick_left_click.xml b/core/res/res/drawable/accessibility_autoclick_left_click.xml
new file mode 100644
index 000000000000..64c8efbe24b3
--- /dev/null
+++ b/core/res/res/drawable/accessibility_autoclick_left_click.xml
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright 2025 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="18dp"
+ android:height="18dp"
+ android:viewportWidth="18"
+ android:viewportHeight="18">
+ <path
+ android:pathData="M5.7 12C4.1 11.9167 2.75 11.3 1.65 10.15C0.55 9 0 7.61667 0 6C0 4.33333 0.583333 2.91667 1.75 1.75C2.91667 0.583332 4.33333 -0.00000143051 6 -0.00000143051C7.61667 -0.00000143051 9 0.549999 10.15 1.65C11.3 2.75 11.9167 4.1 12 5.7L9.9 5.075C9.68333 4.175 9.21667 3.44167 8.5 2.875C7.78333 2.29167 6.95 2 6 2C4.9 2 3.95833 2.39167 3.175 3.175C2.39167 3.95833 2 4.9 2 6C2 6.95 2.28333 7.78333 2.85 8.5C3.43333 9.21667 4.175 9.68333 5.075 9.9L5.7 12ZM14.525 16.5L10.25 12.225L9 16L6 6L16 9L12.225 10.25L16.5 14.525L14.525 16.5Z"
+ android:fillColor="@color/materialColorPrimary" />
+</vector>
diff --git a/core/res/res/drawable/accessibility_autoclick_pause.xml b/core/res/res/drawable/accessibility_autoclick_pause.xml
new file mode 100644
index 000000000000..5251b2afed0d
--- /dev/null
+++ b/core/res/res/drawable/accessibility_autoclick_pause.xml
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright 2025 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="24dp"
+ android:height="24dp"
+ android:viewportWidth="24"
+ android:viewportHeight="24">
+
+ <path
+ android:fillColor="@color/materialColorPrimary"
+ android:pathData="M6,19h4V5H6v14zm8,-14v14h4V5h-4z" />
+</vector>
diff --git a/core/res/res/drawable/accessibility_autoclick_position.xml b/core/res/res/drawable/accessibility_autoclick_position.xml
new file mode 100644
index 000000000000..8c98235e7d99
--- /dev/null
+++ b/core/res/res/drawable/accessibility_autoclick_position.xml
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright 2025 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="21dp"
+ android:height="17dp"
+ android:viewportWidth="21"
+ android:viewportHeight="17">
+ <path
+ android:pathData="M0.400024 2.99961C0.400024 1.67413 1.47454 0.599609 2.80002 0.599609H17.2C18.5255 0.599609 19.6 1.67413 19.6 2.99961V14.9996C19.6 16.3251 18.5255 17.3996 17.2 17.3996H2.80002C1.47454 17.3996 0.400024 16.3251 0.400024 14.9996V2.99961ZM2.80002 2.99961H17.2V14.9996H2.80002V2.99961ZM10.6 10.1996C9.60591 10.1996 8.80002 11.0055 8.80002 11.9996C8.80002 12.9937 9.60591 13.7996 10.6 13.7996H14.2C15.1941 13.7996 16 12.9937 16 11.9996C16 11.0055 15.1941 10.1996 14.2 10.1996H10.6Z"
+ android:fillType="evenOdd"
+ android:fillColor="@color/materialColorPrimary" />
+</vector>
diff --git a/core/res/res/drawable/accessibility_autoclick_type_panel_rounded_background.xml b/core/res/res/drawable/accessibility_autoclick_type_panel_rounded_background.xml
new file mode 100644
index 000000000000..e367ba55ae7d
--- /dev/null
+++ b/core/res/res/drawable/accessibility_autoclick_type_panel_rounded_background.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright 2025 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<shape xmlns:android="http://schemas.android.com/apk/res/android">
+ <solid android:color="@color/materialColorSurface" />
+ <corners android:radius="40dp" />
+</shape>
diff --git a/core/res/res/layout/accessibility_autoclick_type_panel.xml b/core/res/res/layout/accessibility_autoclick_type_panel.xml
new file mode 100644
index 000000000000..9aa47cc8d68b
--- /dev/null
+++ b/core/res/res/layout/accessibility_autoclick_type_panel.xml
@@ -0,0 +1,78 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+/*
+** Copyright 2025, The Android Open Source Project
+**
+** Licensed under the Apache License, Version 2.0 (the "License");
+** you may not use this file except in compliance with the License.
+** You may obtain a copy of the License at
+**
+** http://www.apache.org/licenses/LICENSE-2.0
+**
+** Unless required by applicable law or agreed to in writing, software
+** distributed under the License is distributed on an "AS IS" BASIS,
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+** See the License for the specific language governing permissions and
+** limitations under the License.
+*/
+-->
+
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@+id/accessibility_autoclick_type_panel"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center_horizontal"
+ android:background="@drawable/accessibility_autoclick_type_panel_rounded_background"
+ android:orientation="vertical"
+ android:padding="16dp">
+
+ <LinearLayout
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:gravity="center"
+ android:orientation="horizontal">
+
+ <LinearLayout
+ android:id="@+id/accessibility_autoclick_left_click_layout"
+ style="@style/AccessibilityAutoclickPanelButtonLayoutStyle"
+ android:layout_marginEnd="@dimen/accessibility_autoclick_type_panel_button_spacing">
+
+ <ImageButton
+ android:id="@+id/accessibility_autoclick_left_click_button"
+ style="@style/AccessibilityAutoclickPanelImageButtonStyle"
+ android:contentDescription="@string/accessibility_autoclick_left_click"
+ android:src="@drawable/accessibility_autoclick_left_click" />
+ </LinearLayout>
+
+ <View
+ android:layout_width="@dimen/accessibility_autoclick_type_panel_divider_width"
+ android:layout_height="@dimen/accessibility_autoclick_type_panel_divider_height"
+ android:layout_marginEnd="@dimen/accessibility_autoclick_type_panel_button_spacing"
+ android:background="@color/materialColorSurfaceContainer" />
+
+ <LinearLayout
+ android:id="@+id/accessibility_autoclick_pause_layout"
+ style="@style/AccessibilityAutoclickPanelButtonLayoutStyle"
+ android:layout_marginEnd="@dimen/accessibility_autoclick_type_panel_button_spacing">
+
+ <ImageButton
+ android:id="@+id/accessibility_autoclick_pause_button"
+ style="@style/AccessibilityAutoclickPanelImageButtonStyle"
+ android:contentDescription="@string/accessibility_autoclick_pause"
+ android:src="@drawable/accessibility_autoclick_pause" />
+ </LinearLayout>
+
+ <LinearLayout
+ android:id="@+id/accessibility_autoclick_position_layout"
+ style="@style/AccessibilityAutoclickPanelButtonLayoutStyle">
+
+ <ImageButton
+ android:id="@+id/accessibility_autoclick_position_button"
+ style="@style/AccessibilityAutoclickPanelImageButtonStyle"
+ android:contentDescription="@string/accessibility_autoclick_position"
+ android:src="@drawable/accessibility_autoclick_position" />
+ </LinearLayout>
+
+ </LinearLayout>
+
+</LinearLayout>
diff --git a/core/res/res/values/dimens.xml b/core/res/res/values/dimens.xml
index 5644cf9dd61d..484e8ef1e049 100644
--- a/core/res/res/values/dimens.xml
+++ b/core/res/res/values/dimens.xml
@@ -714,6 +714,18 @@
<!-- The minimum window size of the accessibility window magnifier -->
<dimen name="accessibility_window_magnifier_min_size">122dp</dimen>
+ <!-- The accessibility autoclick panel button spacing -->
+ <dimen name="accessibility_autoclick_type_panel_button_spacing">12dp</dimen>
+
+ <!-- The accessibility autoclick panel button width and height -->
+ <dimen name="accessibility_autoclick_type_panel_button_size">36dp</dimen>
+
+ <!-- The accessibility autoclick panel divider width -->
+ <dimen name="accessibility_autoclick_type_panel_divider_width">1dp</dimen>
+
+ <!-- The accessibility autoclick panel divider height -->
+ <dimen name="accessibility_autoclick_type_panel_divider_height">24dp</dimen>
+
<!-- Margin around the various security views -->
<dimen name="keyguard_muliuser_selector_margin">8dp</dimen>
diff --git a/core/res/res/values/strings.xml b/core/res/res/values/strings.xml
index fa4c21de682e..9399e2b9824e 100644
--- a/core/res/res/values/strings.xml
+++ b/core/res/res/values/strings.xml
@@ -6149,6 +6149,16 @@
<!-- Label for Dpad center action [CHAR LIMIT=NONE] -->
<string name="accessibility_system_action_dpad_center_label">Dpad Center</string>
+ <!-- Accessibility autoclick related strings -->
+ <!-- Label for autoclick type settings panel [CHAR LIMIT=NONE] -->
+ <string name="accessibility_autoclick_type_settings_panel_title">Autoclick type settings panel</string>
+ <!-- Label for autoclick left click button [CHAR LIMIT=NONE] -->
+ <string name="accessibility_autoclick_left_click">Left click</string>
+ <!-- Label for autoclick pause button [CHAR LIMIT=NONE] -->
+ <string name="accessibility_autoclick_pause">Pause</string>
+ <!-- Label for autoclick position button [CHAR LIMIT=NONE] -->
+ <string name="accessibility_autoclick_position">Position</string>
+
<!-- Text to tell the user that a package has been forced by themselves in the RESTRICTED bucket. [CHAR LIMIT=NONE] -->
<string name="as_app_forced_to_restricted_bucket">
<xliff:g id="package_name" example="com.android.example">%1$s</xliff:g> has been put into the RESTRICTED bucket</string>
diff --git a/core/res/res/values/styles.xml b/core/res/res/values/styles.xml
index 579dc91d2ca1..ee1edda838fd 100644
--- a/core/res/res/values/styles.xml
+++ b/core/res/res/values/styles.xml
@@ -1745,6 +1745,22 @@ please see styles_device_defaults.xml.
<item name="android:windowOptOutEdgeToEdgeEnforcement">true</item>
</style>
+ <style name="AccessibilityAutoclickPanelButtonLayoutStyle">
+ <item name="android:gravity">center</item>
+ <item name="android:background">@drawable/accessibility_autoclick_button_rounded_background</item>
+ <item name="android:layout_width">@dimen/accessibility_autoclick_type_panel_button_size</item>
+ <item name="android:layout_height">@dimen/accessibility_autoclick_type_panel_button_size</item>
+ </style>
+
+ <style name="AccessibilityAutoclickPanelImageButtonStyle">
+ <item name="android:gravity">center</item>
+ <item name="android:layout_width">wrap_content</item>
+ <item name="android:layout_height">wrap_content</item>
+ <item name="android:scaleType">center</item>
+ <item name="android:background">@android:color/transparent</item>
+ <item name="android:tint">@color/materialColorPrimary</item>
+ </style>
+
<!--
TODO(b/309578419): Make activities go edge-to-edge properly and then remove this.
-->
diff --git a/core/res/res/values/symbols.xml b/core/res/res/values/symbols.xml
index 8bb3c995cf9f..43ad7e2d75df 100644
--- a/core/res/res/values/symbols.xml
+++ b/core/res/res/values/symbols.xml
@@ -5605,6 +5605,24 @@
<java-symbol type="bool" name="config_enable_a11y_fullscreen_magnification_overscroll_handler" />
<java-symbol type="dimen" name="accessibility_fullscreen_magnification_gesture_edge_slop" />
+ <!-- Accessibility autoclick related -->
+ <java-symbol type="layout" name="accessibility_autoclick_type_panel" />
+ <java-symbol type="string" name="accessibility_autoclick_type_settings_panel_title" />
+ <java-symbol type="string" name="accessibility_autoclick_left_click" />
+ <java-symbol type="string" name="accessibility_autoclick_pause" />
+ <java-symbol type="string" name="accessibility_autoclick_position" />
+ <java-symbol type="dimen" name="accessibility_autoclick_type_panel_button_spacing" />
+ <java-symbol type="dimen" name="accessibility_autoclick_type_panel_button_size" />
+ <java-symbol type="dimen" name="accessibility_autoclick_type_panel_divider_height" />
+ <java-symbol type="dimen" name="accessibility_autoclick_type_panel_divider_width" />
+ <java-symbol type="id" name="accessibility_autoclick_type_panel" />
+ <java-symbol type="id" name="accessibility_autoclick_left_click_layout" />
+ <java-symbol type="id" name="accessibility_autoclick_left_click_button" />
+ <java-symbol type="id" name="accessibility_autoclick_pause_layout" />
+ <java-symbol type="id" name="accessibility_autoclick_pause_button" />
+ <java-symbol type="id" name="accessibility_autoclick_position_layout" />
+ <java-symbol type="id" name="accessibility_autoclick_position_button" />
+
<!-- For HapticFeedbackConstants configurability defined at HapticFeedbackCustomization -->
<java-symbol type="string" name="config_hapticFeedbackCustomizationFile" />
<java-symbol type="xml" name="haptic_feedback_customization" />
diff --git a/services/accessibility/java/com/android/server/accessibility/autoclick/AutoclickController.java b/services/accessibility/java/com/android/server/accessibility/autoclick/AutoclickController.java
index 1fe674890a99..8e448676c214 100644
--- a/services/accessibility/java/com/android/server/accessibility/autoclick/AutoclickController.java
+++ b/services/accessibility/java/com/android/server/accessibility/autoclick/AutoclickController.java
@@ -81,6 +81,7 @@ public class AutoclickController extends BaseEventStreamTransformation {
@VisibleForTesting AutoclickSettingsObserver mAutoclickSettingsObserver;
@VisibleForTesting AutoclickIndicatorScheduler mAutoclickIndicatorScheduler;
@VisibleForTesting AutoclickIndicatorView mAutoclickIndicatorView;
+ @VisibleForTesting AutoclickTypePanel mAutoclickTypePanel;
private WindowManager mWindowManager;
public AutoclickController(Context context, int userId, AccessibilityTraceManager trace) {
@@ -123,6 +124,9 @@ public class AutoclickController extends BaseEventStreamTransformation {
mAutoclickIndicatorView = new AutoclickIndicatorView(mContext);
mWindowManager = mContext.getSystemService(WindowManager.class);
+ mAutoclickTypePanel = new AutoclickTypePanel(mContext, mWindowManager);
+
+ mAutoclickTypePanel.show();
mWindowManager.addView(mAutoclickIndicatorView, mAutoclickIndicatorView.getLayoutParams());
}
@@ -167,6 +171,7 @@ public class AutoclickController extends BaseEventStreamTransformation {
mAutoclickIndicatorScheduler.cancel();
mAutoclickIndicatorScheduler = null;
mWindowManager.removeView(mAutoclickIndicatorView);
+ mAutoclickTypePanel.hide();
}
}
diff --git a/services/accessibility/java/com/android/server/accessibility/autoclick/AutoclickTypePanel.java b/services/accessibility/java/com/android/server/accessibility/autoclick/AutoclickTypePanel.java
new file mode 100644
index 000000000000..1ba574559918
--- /dev/null
+++ b/services/accessibility/java/com/android/server/accessibility/autoclick/AutoclickTypePanel.java
@@ -0,0 +1,84 @@
+/*
+ * Copyright 2025 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.server.accessibility.autoclick;
+
+import static android.view.WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS;
+
+import android.content.Context;
+import android.graphics.PixelFormat;
+import android.view.Gravity;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.WindowInsets;
+import android.view.WindowManager;
+
+import androidx.annotation.NonNull;
+
+import com.android.internal.R;
+
+public class AutoclickTypePanel {
+
+ private final String TAG = AutoclickTypePanel.class.getSimpleName();
+
+ private final Context mContext;
+
+ private final View mContentView;
+
+ private final WindowManager mWindowManager;
+
+ public AutoclickTypePanel(Context context, WindowManager windowManager) {
+ mContext = context;
+ mWindowManager = windowManager;
+
+ mContentView = LayoutInflater.from(context).inflate(
+ R.layout.accessibility_autoclick_type_panel, null);
+ }
+
+ public void show() {
+ mWindowManager.addView(mContentView, getLayoutParams());
+ }
+
+ public void hide() {
+ mWindowManager.removeView(mContentView);
+ }
+
+ /**
+ * Retrieves the layout params for AutoclickIndicatorView, used when it's added to the Window
+ * Manager.
+ */
+ @NonNull
+ private WindowManager.LayoutParams getLayoutParams() {
+ final WindowManager.LayoutParams layoutParams = new WindowManager.LayoutParams();
+ layoutParams.type = WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY;
+ layoutParams.flags = WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL;
+ layoutParams.privateFlags |= WindowManager.LayoutParams.SYSTEM_FLAG_SHOW_FOR_ALL_USERS;
+ layoutParams.setFitInsetsTypes(WindowInsets.Type.statusBars());
+ layoutParams.layoutInDisplayCutoutMode = LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS;
+ layoutParams.format = PixelFormat.TRANSLUCENT;
+ layoutParams.setTitle(AutoclickTypePanel.class.getSimpleName());
+ layoutParams.accessibilityTitle =
+ mContext.getString(R.string.accessibility_autoclick_type_settings_panel_title);
+ layoutParams.width = WindowManager.LayoutParams.WRAP_CONTENT;
+ layoutParams.height = WindowManager.LayoutParams.WRAP_CONTENT;
+ // TODO(b/388847771): Compute position based on user interaction.
+ layoutParams.x = 15;
+ layoutParams.y = 90;
+ layoutParams.gravity = Gravity.END | Gravity.BOTTOM;
+
+ return layoutParams;
+ }
+}
diff --git a/services/tests/servicestests/src/com/android/server/accessibility/autoclick/AutoclickControllerTest.java b/services/tests/servicestests/src/com/android/server/accessibility/autoclick/AutoclickControllerTest.java
index 5d476ec95e2e..457fde8d74d0 100644
--- a/services/tests/servicestests/src/com/android/server/accessibility/autoclick/AutoclickControllerTest.java
+++ b/services/tests/servicestests/src/com/android/server/accessibility/autoclick/AutoclickControllerTest.java
@@ -23,10 +23,8 @@ 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.Mockito.mock;
import static org.mockito.Mockito.verify;
-import static org.testng.AssertJUnit.assertEquals;
-import static org.testng.AssertJUnit.assertNotNull;
-import static org.testng.AssertJUnit.assertNull;
import android.content.Context;
import android.platform.test.annotations.DisableFlags;
@@ -85,69 +83,89 @@ public class AutoclickControllerTest {
@Test
public void onMotionEvent_lazyInitClickScheduler() {
- assertNull(mController.mClickScheduler);
+ assertThat(mController.mClickScheduler).isNull();
injectFakeMouseActionDownEvent();
- assertNotNull(mController.mClickScheduler);
+ assertThat(mController.mClickScheduler).isNotNull();
}
@Test
public void onMotionEvent_nonMouseSource_notInitClickScheduler() {
- assertNull(mController.mClickScheduler);
+ assertThat(mController.mClickScheduler).isNull();
injectFakeNonMouseActionDownEvent();
- assertNull(mController.mClickScheduler);
+ assertThat(mController.mClickScheduler).isNull();
}
@Test
public void onMotionEvent_lazyInitAutoclickSettingsObserver() {
- assertNull(mController.mAutoclickSettingsObserver);
+ assertThat(mController.mAutoclickSettingsObserver).isNull();
injectFakeMouseActionDownEvent();
- assertNotNull(mController.mAutoclickSettingsObserver);
+ assertThat(mController.mAutoclickSettingsObserver).isNotNull();
}
@Test
@EnableFlags(com.android.server.accessibility.Flags.FLAG_ENABLE_AUTOCLICK_INDICATOR)
public void onMotionEvent_flagOn_lazyInitAutoclickIndicatorScheduler() {
- assertNull(mController.mAutoclickIndicatorScheduler);
+ assertThat(mController.mAutoclickIndicatorScheduler).isNull();
injectFakeMouseActionDownEvent();
- assertNotNull(mController.mAutoclickIndicatorScheduler);
+ assertThat(mController.mAutoclickIndicatorScheduler).isNotNull();
}
@Test
@DisableFlags(com.android.server.accessibility.Flags.FLAG_ENABLE_AUTOCLICK_INDICATOR)
public void onMotionEvent_flagOff_notInitAutoclickIndicatorScheduler() {
- assertNull(mController.mAutoclickIndicatorScheduler);
+ assertThat(mController.mAutoclickIndicatorScheduler).isNull();
injectFakeMouseActionDownEvent();
- assertNull(mController.mAutoclickIndicatorScheduler);
+ assertThat(mController.mAutoclickIndicatorScheduler).isNull();
}
@Test
@EnableFlags(com.android.server.accessibility.Flags.FLAG_ENABLE_AUTOCLICK_INDICATOR)
public void onMotionEvent_flagOn_lazyInitAutoclickIndicatorView() {
- assertNull(mController.mAutoclickIndicatorView);
+ assertThat(mController.mAutoclickIndicatorView).isNull();
injectFakeMouseActionDownEvent();
- assertNotNull(mController.mAutoclickIndicatorView);
+ assertThat(mController.mAutoclickIndicatorView).isNotNull();
}
@Test
@DisableFlags(com.android.server.accessibility.Flags.FLAG_ENABLE_AUTOCLICK_INDICATOR)
public void onMotionEvent_flagOff_notInitAutoclickIndicatorView() {
- assertNull(mController.mAutoclickIndicatorView);
+ assertThat(mController.mAutoclickIndicatorView).isNull();
injectFakeMouseActionDownEvent();
- assertNull(mController.mAutoclickIndicatorView);
+ assertThat(mController.mAutoclickIndicatorView).isNull();
+ }
+
+ @Test
+ @EnableFlags(com.android.server.accessibility.Flags.FLAG_ENABLE_AUTOCLICK_INDICATOR)
+ public void onMotionEvent_flagOn_lazyInitAutoclickTypePanelView() {
+ assertThat(mController.mAutoclickTypePanel).isNull();
+
+ injectFakeMouseActionDownEvent();
+
+ assertThat(mController.mAutoclickTypePanel).isNotNull();
+ }
+
+ @Test
+ @DisableFlags(com.android.server.accessibility.Flags.FLAG_ENABLE_AUTOCLICK_INDICATOR)
+ public void onMotionEvent_flagOff_notInitAutoclickTypePanelView() {
+ assertThat(mController.mAutoclickTypePanel).isNull();
+
+ injectFakeMouseActionDownEvent();
+
+ assertThat(mController.mAutoclickTypePanel).isNull();
}
@Test
@@ -169,6 +187,18 @@ public class AutoclickControllerTest {
}
@Test
+ @EnableFlags(com.android.server.accessibility.Flags.FLAG_ENABLE_AUTOCLICK_INDICATOR)
+ public void onDestroy_flagOn_removeAutoclickTypePanelViewToWindowManager() {
+ injectFakeMouseActionDownEvent();
+ AutoclickTypePanel mockAutoclickTypePanel = mock(AutoclickTypePanel.class);
+ mController.mAutoclickTypePanel = mockAutoclickTypePanel;
+
+ mController.onDestroy();
+
+ verify(mockAutoclickTypePanel).hide();
+ }
+
+ @Test
public void onMotionEvent_initClickSchedulerDelayFromSetting() {
injectFakeMouseActionDownEvent();
@@ -178,7 +208,7 @@ public class AutoclickControllerTest {
Settings.Secure.ACCESSIBILITY_AUTOCLICK_DELAY,
AccessibilityManager.AUTOCLICK_DELAY_DEFAULT,
mTestableContext.getUserId());
- assertEquals(delay, mController.mClickScheduler.getDelayForTesting());
+ assertThat(mController.mClickScheduler.getDelayForTesting()).isEqualTo(delay);
}
@Test
@@ -192,7 +222,7 @@ public class AutoclickControllerTest {
Settings.Secure.ACCESSIBILITY_AUTOCLICK_CURSOR_AREA_SIZE,
AccessibilityManager.AUTOCLICK_CURSOR_AREA_SIZE_DEFAULT,
mTestableContext.getUserId());
- assertEquals(size, mController.mAutoclickIndicatorView.getRadiusForTesting());
+ assertThat(mController.mAutoclickIndicatorView.getRadiusForTesting()).isEqualTo(size);
}
@Test
@@ -234,7 +264,7 @@ public class AutoclickControllerTest {
mController.onDestroy();
- assertNull(mController.mClickScheduler);
+ assertThat(mController.mClickScheduler).isNull();
}
@Test
@@ -243,7 +273,7 @@ public class AutoclickControllerTest {
mController.onDestroy();
- assertNull(mController.mAutoclickSettingsObserver);
+ assertThat(mController.mAutoclickSettingsObserver).isNull();
}
@Test
@@ -253,7 +283,7 @@ public class AutoclickControllerTest {
mController.onDestroy();
- assertNull(mController.mAutoclickIndicatorScheduler);
+ assertThat(mController.mAutoclickIndicatorScheduler).isNull();
}
private void injectFakeMouseActionDownEvent() {