Loading res/values/bools.xml +3 −0 Original line number Diff line number Diff line Loading @@ -156,6 +156,9 @@ <!-- Whether assist_and_voice_input should be shown or not. --> <bool name="config_show_assist_and_voice_input">true</bool> <!-- Whether reset_dashboard should be shown or not. --> <bool name="config_show_reset_dashboard">true</bool> <!-- Whether system_update_settings should be shown or not. --> <bool name="config_show_system_update_settings">true</bool> Loading res/xml/system_dashboard_fragment.xml +2 −1 Original line number Diff line number Diff line Loading @@ -46,7 +46,8 @@ android:summary="@string/reset_dashboard_summary" android:icon="@drawable/ic_restore" android:order="-50" android:fragment="com.android.settings.system.ResetDashboardFragment" /> android:fragment="com.android.settings.system.ResetDashboardFragment" settings:controller="com.android.settings.system.ResetPreferenceController"/> <!-- System updates --> <Preference Loading src/com/android/settings/system/ResetPreferenceController.java 0 → 100644 +35 −0 Original line number Diff line number Diff line /* * Copyright (C) 2018 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.system; import android.content.Context; import com.android.settings.R; import com.android.settings.core.BasePreferenceController; public class ResetPreferenceController extends BasePreferenceController { public ResetPreferenceController(Context context, String preferenceKey) { super(context, preferenceKey); } @Override public int getAvailabilityStatus() { return mContext.getResources().getBoolean(R.bool.config_show_reset_dashboard) ? AVAILABLE : DISABLED_UNSUPPORTED; } } tests/robotests/res/values-mcc999/config.xml +1 −0 Original line number Diff line number Diff line Loading @@ -55,6 +55,7 @@ <bool name="config_show_tts_settings_summary">false</bool> <bool name="config_show_pointer_speed">false</bool> <bool name="config_show_vibrate_input_devices">false</bool> <bool name="config_show_reset_dashboard">false</bool> <bool name="config_show_system_update_settings">false</bool> <bool name="config_wifi_support_connected_mac_randomization">false</bool> <bool name="config_show_device_model">false</bool> Loading tests/robotests/src/com/android/settings/system/ResetPreferenceControllerTest.java 0 → 100644 +56 −0 Original line number Diff line number Diff line /* * Copyright (C) 2016 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.system; import static com.google.common.truth.Truth.assertThat; import android.content.Context; import com.android.settings.testutils.SettingsRobolectricTestRunner; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.MockitoAnnotations; import org.robolectric.RuntimeEnvironment; import org.robolectric.annotation.Config; @RunWith(SettingsRobolectricTestRunner.class) public class ResetPreferenceControllerTest { private static final String KEY_RESET_DASHBOARD = "reset_dashboard"; private Context mContext; private ResetPreferenceController mController; @Before public void setUp() { MockitoAnnotations.initMocks(this); mContext = RuntimeEnvironment.application; mController = new ResetPreferenceController(mContext, KEY_RESET_DASHBOARD); } @Test public void isAvailable_byDefault_true() { assertThat(mController.isAvailable()).isTrue(); } @Test @Config(qualifiers = "mcc999") public void isAvailable_ifNotVisible_false() { assertThat(mController.isAvailable()).isFalse(); } } No newline at end of file Loading
res/values/bools.xml +3 −0 Original line number Diff line number Diff line Loading @@ -156,6 +156,9 @@ <!-- Whether assist_and_voice_input should be shown or not. --> <bool name="config_show_assist_and_voice_input">true</bool> <!-- Whether reset_dashboard should be shown or not. --> <bool name="config_show_reset_dashboard">true</bool> <!-- Whether system_update_settings should be shown or not. --> <bool name="config_show_system_update_settings">true</bool> Loading
res/xml/system_dashboard_fragment.xml +2 −1 Original line number Diff line number Diff line Loading @@ -46,7 +46,8 @@ android:summary="@string/reset_dashboard_summary" android:icon="@drawable/ic_restore" android:order="-50" android:fragment="com.android.settings.system.ResetDashboardFragment" /> android:fragment="com.android.settings.system.ResetDashboardFragment" settings:controller="com.android.settings.system.ResetPreferenceController"/> <!-- System updates --> <Preference Loading
src/com/android/settings/system/ResetPreferenceController.java 0 → 100644 +35 −0 Original line number Diff line number Diff line /* * Copyright (C) 2018 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.system; import android.content.Context; import com.android.settings.R; import com.android.settings.core.BasePreferenceController; public class ResetPreferenceController extends BasePreferenceController { public ResetPreferenceController(Context context, String preferenceKey) { super(context, preferenceKey); } @Override public int getAvailabilityStatus() { return mContext.getResources().getBoolean(R.bool.config_show_reset_dashboard) ? AVAILABLE : DISABLED_UNSUPPORTED; } }
tests/robotests/res/values-mcc999/config.xml +1 −0 Original line number Diff line number Diff line Loading @@ -55,6 +55,7 @@ <bool name="config_show_tts_settings_summary">false</bool> <bool name="config_show_pointer_speed">false</bool> <bool name="config_show_vibrate_input_devices">false</bool> <bool name="config_show_reset_dashboard">false</bool> <bool name="config_show_system_update_settings">false</bool> <bool name="config_wifi_support_connected_mac_randomization">false</bool> <bool name="config_show_device_model">false</bool> Loading
tests/robotests/src/com/android/settings/system/ResetPreferenceControllerTest.java 0 → 100644 +56 −0 Original line number Diff line number Diff line /* * Copyright (C) 2016 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.system; import static com.google.common.truth.Truth.assertThat; import android.content.Context; import com.android.settings.testutils.SettingsRobolectricTestRunner; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.MockitoAnnotations; import org.robolectric.RuntimeEnvironment; import org.robolectric.annotation.Config; @RunWith(SettingsRobolectricTestRunner.class) public class ResetPreferenceControllerTest { private static final String KEY_RESET_DASHBOARD = "reset_dashboard"; private Context mContext; private ResetPreferenceController mController; @Before public void setUp() { MockitoAnnotations.initMocks(this); mContext = RuntimeEnvironment.application; mController = new ResetPreferenceController(mContext, KEY_RESET_DASHBOARD); } @Test public void isAvailable_byDefault_true() { assertThat(mController.isAvailable()).isTrue(); } @Test @Config(qualifiers = "mcc999") public void isAvailable_ifNotVisible_false() { assertThat(mController.isAvailable()).isFalse(); } } No newline at end of file