Merge "Accessibility settings interaction controls category restructure, add system controls fragment for related accessibility services."
diff --git a/res/values/strings.xml b/res/values/strings.xml
index de4e811..7c03010 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -4952,6 +4952,8 @@
     <string name="interaction_control_category_title">Interaction controls</string>
     <!-- Title for the accessibility tap assistance page. [CHAR LIMIT=50] -->
     <string name="accessibility_tap_assistance_title">Tap assistance</string>
+    <!-- Title for the accessibility system controls page. [CHAR LIMIT=50] -->
+    <string name="accessibility_system_controls_title">System controls</string>
     <!-- Title for the accessibility preference category of services downloaded by the user. [CHAR LIMIT=50] -->
     <string name="user_installed_services_category_title">Downloaded apps</string>
     <!-- Title for the accessibility preference category of settings considered to be experimental, meaning they might be changed or removed in the future. [CHAR LIMIT=50] -->
diff --git a/res/xml/accessibility_settings.xml b/res/xml/accessibility_settings.xml
index 126865c..b7c28b4 100644
--- a/res/xml/accessibility_settings.xml
+++ b/res/xml/accessibility_settings.xml
@@ -65,25 +65,6 @@
         android:persistent="false"
         android:title="@string/interaction_control_category_title">
 
-        <SwitchPreference
-            android:key="toggle_power_button_ends_call_preference"
-            android:persistent="false"
-            android:title="@string/accessibility_power_button_ends_call_prerefence_title"
-            settings:controller="com.android.settings.accessibility.PowerButtonEndsCallPreferenceController"/>
-
-        <SwitchPreference
-            android:key="toggle_lock_screen_rotation_preference"
-            android:persistent="false"
-            android:title="@string/accelerometer_title"
-            settings:controller="com.android.settings.accessibility.LockScreenRotationPreferenceController"/>
-
-        <Preference
-            android:fragment="com.android.settings.accessibility.VibrationSettings"
-            android:key="vibration_preference_screen"
-            android:persistent="false"
-            android:title="@string/accessibility_vibration_settings_title"
-            settings:controller="com.android.settings.accessibility.VibrationPreferenceController"/>
-
         <Preference
             android:fragment="com.android.settings.accessibility.TapAssistanceFragment"
             android:key="tap_assistance_preference_screen"
@@ -92,12 +73,17 @@
             settings:searchable="true"/>
 
         <Preference
-            android:fragment="com.android.settings.gestures.SystemNavigationGestureSettings"
-            android:key="gesture_system_navigation_input_summary_accessibility"
+            android:fragment="com.android.settings.accessibility.SystemControlsFragment"
+            android:key="system_controls_preference_screen"
+            android:title="@string/accessibility_system_controls_title"
+            settings:searchable="true"/>
+
+        <Preference
+            android:fragment="com.android.settings.accessibility.VibrationSettings"
+            android:key="vibration_preference_screen"
             android:persistent="false"
-            android:title="@string/system_navigation_title"
-            settings:searchable="false"
-            settings:controller="com.android.settings.gestures.SystemNavigationPreferenceController"/>
+            android:title="@string/accessibility_vibration_settings_title"
+            settings:controller="com.android.settings.accessibility.VibrationPreferenceController"/>
 
     </PreferenceCategory>
 
diff --git a/res/xml/accessibility_system_controls.xml b/res/xml/accessibility_system_controls.xml
new file mode 100644
index 0000000..12797d1
--- /dev/null
+++ b/res/xml/accessibility_system_controls.xml
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2021 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.
+-->
+<PreferenceScreen
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:settings="http://schemas.android.com/apk/res-auto"
+    android:key="accessibility_system_controls"
+    android:persistent="false"
+    android:title="@string/accessibility_system_controls_title">
+
+    <Preference
+        android:fragment="com.android.settings.gestures.SystemNavigationGestureSettings"
+        android:key="gesture_system_navigation_input_summary_accessibility"
+        android:persistent="false"
+        android:title="@string/system_navigation_title"
+        settings:searchable="false"
+        settings:controller="com.android.settings.gestures.SystemNavigationPreferenceController"/>
+
+    <SwitchPreference
+        android:key="toggle_power_button_ends_call_preference"
+        android:persistent="false"
+        android:title="@string/accessibility_power_button_ends_call_prerefence_title"
+        settings:controller="com.android.settings.accessibility.PowerButtonEndsCallPreferenceController"/>
+
+    <SwitchPreference
+        android:key="toggle_lock_screen_rotation_preference"
+        android:persistent="false"
+        android:title="@string/accelerometer_title"
+        settings:controller="com.android.settings.accessibility.LockScreenRotationPreferenceController"/>
+</PreferenceScreen>
\ No newline at end of file
diff --git a/src/com/android/settings/accessibility/SystemControlsFragment.java b/src/com/android/settings/accessibility/SystemControlsFragment.java
new file mode 100644
index 0000000..237f2b4
--- /dev/null
+++ b/src/com/android/settings/accessibility/SystemControlsFragment.java
@@ -0,0 +1,50 @@
+/*
+ * Copyright (C) 2021 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.settings.accessibility;
+
+import android.app.settings.SettingsEnums;
+
+import com.android.settings.R;
+import com.android.settings.dashboard.DashboardFragment;
+import com.android.settings.search.BaseSearchIndexProvider;
+import com.android.settingslib.search.SearchIndexable;
+
+/** Accessibility settings for system controls. */
+@SearchIndexable(forTarget = SearchIndexable.ALL & ~SearchIndexable.ARC)
+public class SystemControlsFragment extends DashboardFragment {
+
+    private static final String TAG = "SystemControlsFragment";
+
+    @Override
+    public int getMetricsCategory() {
+        return SettingsEnums.ACCESSIBILITY_SYSTEM_CONTROLS;
+    }
+
+    @Override
+    protected int getPreferenceScreenResId() {
+        return R.xml.accessibility_system_controls;
+    }
+
+    @Override
+    protected String getLogTag() {
+        return TAG;
+    }
+
+    public static final BaseSearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
+            new BaseSearchIndexProvider(R.xml.accessibility_system_controls);
+
+}
diff --git a/tests/robotests/src/com/android/settings/accessibility/SystemControlsFragmentTest.java b/tests/robotests/src/com/android/settings/accessibility/SystemControlsFragmentTest.java
new file mode 100644
index 0000000..4b12900
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/accessibility/SystemControlsFragmentTest.java
@@ -0,0 +1,50 @@
+/*
+ * Copyright (C) 2021 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.settings.accessibility;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import android.content.Context;
+
+import androidx.test.core.app.ApplicationProvider;
+
+import com.android.settings.R;
+import com.android.settings.testutils.XmlTestUtils;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.robolectric.RobolectricTestRunner;
+
+import java.util.List;
+
+/** Tests for {@link SystemControlsFragment}. */
+@RunWith(RobolectricTestRunner.class)
+public class SystemControlsFragmentTest {
+
+    private Context mContext = ApplicationProvider.getApplicationContext();
+
+    @Test
+    public void getNonIndexableKeys_existInXmlLayout() {
+        final List<String> niks = SystemControlsFragment.SEARCH_INDEX_DATA_PROVIDER
+                .getNonIndexableKeys(mContext);
+        final List<String> keys =
+                XmlTestUtils.getKeysFromPreferenceXml(mContext,
+                        R.xml.accessibility_system_controls);
+
+        assertThat(keys).containsAtLeastElementsIn(niks);
+    }
+}