OSDN Git Service

Add flag to hide top-level accessibility.
authorBen Lin <linben@google.com>
Sat, 2 Mar 2019 00:13:23 +0000 (16:13 -0800)
committerBen Lin <linben@google.com>
Sat, 2 Mar 2019 00:13:23 +0000 (16:13 -0800)
Bug: None
Test: robotests
Change-Id: I67cee6054e54389812bc025e637029547c8f2896

res/values/config.xml
res/xml/top_level_settings.xml
src/com/android/settings/accessibility/TopLevelAccessibilityPreferenceController.java [new file with mode: 0644]
tests/robotests/res/values-mcc999/config.xml
tests/robotests/src/com/android/settings/accessibility/TopLevelAccessibilityPreferenceControllerTest.java [new file with mode: 0644]

index beeac0c..e6ada66 100755 (executable)
     <!-- Whether device_model should be shown or not. -->
     <bool name="config_show_device_model">true</bool>
 
+    <!-- Whether top_level_accessibility should be shown or not. -->
+    <bool name="config_show_top_level_accessibility">true</bool>
+
     <!-- Whether top_level_battery should be shown or not. -->
     <bool name="config_show_top_level_battery">true</bool>
 
index 9f4f902..64b620a 100644 (file)
         android:summary="@string/accessibility_settings_summary"
         android:icon="@drawable/ic_homepage_accessibility"
         android:order="-20"
-        android:fragment="com.android.settings.accessibility.AccessibilitySettings"/>
+        android:fragment="com.android.settings.accessibility.AccessibilitySettings"
+        settings:controller="com.android.settings.accessibility.TopLevelAccessibilityPreferenceController"/>
 
     <Preference
         android:key="top_level_system"
diff --git a/src/com/android/settings/accessibility/TopLevelAccessibilityPreferenceController.java b/src/com/android/settings/accessibility/TopLevelAccessibilityPreferenceController.java
new file mode 100644 (file)
index 0000000..41040a0
--- /dev/null
@@ -0,0 +1,38 @@
+/*
+ * Copyright (C) 2019 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.content.Context;
+
+import com.android.settings.R;
+import com.android.settings.core.BasePreferenceController;
+
+public class TopLevelAccessibilityPreferenceController extends BasePreferenceController {
+
+    public TopLevelAccessibilityPreferenceController(Context context,
+            String preferenceKey) {
+        super(context, preferenceKey);
+    }
+
+    @Override
+    public int getAvailabilityStatus() {
+        return mContext.getResources().getBoolean(R.bool.config_show_top_level_accessibility)
+        ? AVAILABLE_UNSEARCHABLE
+        : UNSUPPORTED_ON_DEVICE;
+    }
+}
+
index b54781d..776a4d0 100644 (file)
@@ -57,6 +57,7 @@
     <bool name="config_show_reset_dashboard">false</bool>
     <bool name="config_show_system_update_settings">false</bool>
     <bool name="config_show_device_model">false</bool>
+    <bool name="config_show_top_level_accessibility">false</bool>
     <bool name="config_show_top_level_battery">false</bool>
     <bool name="config_show_top_level_connected_devices">false</bool>
     <bool name="config_show_top_level_display">false</bool>
diff --git a/tests/robotests/src/com/android/settings/accessibility/TopLevelAccessibilityPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/accessibility/TopLevelAccessibilityPreferenceControllerTest.java
new file mode 100644 (file)
index 0000000..809d8b4
--- /dev/null
@@ -0,0 +1,59 @@
+/*
+ * Copyright (C) 2019 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.android.settings.core.BasePreferenceController.AVAILABLE_UNSEARCHABLE;
+import static com.android.settings.core.BasePreferenceController.UNSUPPORTED_ON_DEVICE;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import android.content.Context;
+
+import com.android.settings.R;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.robolectric.RobolectricTestRunner;
+import org.robolectric.RuntimeEnvironment;
+import org.robolectric.annotation.Config;
+import org.robolectric.annotation.Implementation;
+import org.robolectric.annotation.Implements;
+
+@RunWith(RobolectricTestRunner.class)
+public class TopLevelAccessibilityPreferenceControllerTest {
+
+    private Context mContext;
+    private TopLevelAccessibilityPreferenceController mController;
+
+    @Before
+    public void setUp() {
+        mContext = RuntimeEnvironment.application;
+        mController = new TopLevelAccessibilityPreferenceController(mContext, "test_key");
+    }
+
+    @Test
+    public void getAvailibilityStatus_availableByDefault() {
+        assertThat(mController.getAvailabilityStatus()).isEqualTo(AVAILABLE_UNSEARCHABLE);
+    }
+
+    @Test
+    @Config(qualifiers = "mcc999")
+    public void getAvailabilityStatus_unsupportedWhenSet() {
+        assertThat(mController.getAvailabilityStatus()).isEqualTo(UNSUPPORTED_ON_DEVICE);
+    }
+}