diff --git a/res/xml/development_settings.xml b/res/xml/development_settings.xml
index 621351681cd..a0d670fda0d 100644
--- a/res/xml/development_settings.xml
+++ b/res/xml/development_settings.xml
@@ -109,11 +109,6 @@
android:title="@string/color_temperature"
android:summary="@string/color_temperature_desc" />
-
-
diff --git a/res/xml/system_dashboard_fragment.xml b/res/xml/system_dashboard_fragment.xml
index 9228ddd5f5a..21a5c151d15 100644
--- a/res/xml/system_dashboard_fragment.xml
+++ b/res/xml/system_dashboard_fragment.xml
@@ -65,6 +65,14 @@
+
+
0) {
- Log.d(TAG, "Restore call waiting to " + callForwardingInfo);
+ && callForwardingInfo[i] != null) {
+ Log.d(TAG, "Restore call forwarding to " + callForwardingInfo[i]);
tm.setCallForwarding(callForwardingInfo[i], null, null);
}
}
diff --git a/src/com/android/settings/system/DisableAutomaticUpdatesPreferenceController.java b/src/com/android/settings/system/DisableAutomaticUpdatesPreferenceController.java
new file mode 100644
index 00000000000..a8f7fb194b1
--- /dev/null
+++ b/src/com/android/settings/system/DisableAutomaticUpdatesPreferenceController.java
@@ -0,0 +1,59 @@
+/*
+ * Copyright (C) 2017 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 android.provider.Settings;
+
+import androidx.annotation.VisibleForTesting;
+
+import com.android.settings.core.TogglePreferenceController;
+
+/** A controller maintains the state of Automatic System Update feature. */
+public class DisableAutomaticUpdatesPreferenceController extends TogglePreferenceController {
+
+ // We use the "disabled status" in code, but show the opposite text
+ // "Automatic system updates" on screen. So a value 0 indicates the
+ // automatic update is enabled.
+ @VisibleForTesting
+ static final int DISABLE_UPDATES_SETTING = 1;
+ @VisibleForTesting
+ static final int ENABLE_UPDATES_SETTING = 0;
+
+ public DisableAutomaticUpdatesPreferenceController(Context context, String key) {
+ super(context, key);
+ }
+
+ @Override
+ public int getAvailabilityStatus() {
+ return AVAILABLE;
+ }
+
+ @Override
+ public boolean isChecked() {
+ return Settings.Global.getInt(mContext.getContentResolver(),
+ Settings.Global.OTA_DISABLE_AUTOMATIC_UPDATE, ENABLE_UPDATES_SETTING /* default */)
+ == ENABLE_UPDATES_SETTING;
+ }
+
+ @Override
+ public boolean setChecked(boolean isChecked) {
+ return Settings.Global.putInt(mContext.getContentResolver(),
+ Settings.Global.OTA_DISABLE_AUTOMATIC_UPDATE,
+ isChecked ? ENABLE_UPDATES_SETTING : DISABLE_UPDATES_SETTING);
+ }
+}
diff --git a/tests/robotests/src/com/android/settings/bluetooth/BluetoothDetailsCompanionAppsControllerTest.java b/tests/robotests/src/com/android/settings/bluetooth/BluetoothDetailsCompanionAppsControllerTest.java
index 3f49938412b..92bfb38334f 100644
--- a/tests/robotests/src/com/android/settings/bluetooth/BluetoothDetailsCompanionAppsControllerTest.java
+++ b/tests/robotests/src/com/android/settings/bluetooth/BluetoothDetailsCompanionAppsControllerTest.java
@@ -30,6 +30,7 @@ import android.content.pm.PackageManager;
import androidx.preference.Preference;
import androidx.preference.PreferenceCategory;
+import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
@@ -41,6 +42,7 @@ import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
+@Ignore("b/191992001")
@RunWith(RobolectricTestRunner.class)
public class BluetoothDetailsCompanionAppsControllerTest extends
BluetoothDetailsControllerTestBase {
diff --git a/tests/robotests/src/com/android/settings/development/DisableAutomaticUpdatesPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/development/DisableAutomaticUpdatesPreferenceControllerTest.java
deleted file mode 100644
index d5c0b5d4d99..00000000000
--- a/tests/robotests/src/com/android/settings/development/DisableAutomaticUpdatesPreferenceControllerTest.java
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
- * Copyright (C) 2017 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.development;
-
-import static com.google.common.truth.Truth.assertThat;
-
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
-import android.content.Context;
-import android.provider.Settings;
-
-import androidx.preference.PreferenceScreen;
-import androidx.preference.SwitchPreference;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
-import org.robolectric.RobolectricTestRunner;
-import org.robolectric.RuntimeEnvironment;
-
-@RunWith(RobolectricTestRunner.class)
-public class DisableAutomaticUpdatesPreferenceControllerTest {
-
- @Mock
- private PreferenceScreen mPreferenceScreen;
- @Mock
- private SwitchPreference mPreference;
-
- private Context mContext;
- private DisableAutomaticUpdatesPreferenceController mController;
-
- @Before
- public void setup() {
- MockitoAnnotations.initMocks(this);
- mContext = RuntimeEnvironment.application;
- mController = new DisableAutomaticUpdatesPreferenceController(mContext);
- when(mPreferenceScreen.findPreference(mController.getPreferenceKey())).thenReturn(
- mPreference);
- mController.displayPreference(mPreferenceScreen);
- }
-
- @Test
- public void onPreferenceChanged_turnOnAutomaticUpdates() {
- mController.onPreferenceChange(null, true);
-
- final int mode = Settings.Global.getInt(mContext.getContentResolver(),
- Settings.Global.OTA_DISABLE_AUTOMATIC_UPDATE, -1);
-
- assertThat(mode).isEqualTo(
- DisableAutomaticUpdatesPreferenceController.ENABLE_UPDATES_SETTING);
- }
-
- @Test
- public void onPreferenceChanged_turnOffAutomaticUpdates() {
- mController.onPreferenceChange(null, false);
-
- final int mode = Settings.Global.getInt(mContext.getContentResolver(),
- Settings.Global.OTA_DISABLE_AUTOMATIC_UPDATE, -1);
-
- assertThat(mode).isEqualTo(
- DisableAutomaticUpdatesPreferenceController.DISABLE_UPDATES_SETTING);
- }
-
- @Test
- public void updateState_preferenceShouldBeChecked() {
- Settings.Global
- .putInt(mContext.getContentResolver(), Settings.Global.OTA_DISABLE_AUTOMATIC_UPDATE,
- DisableAutomaticUpdatesPreferenceController.ENABLE_UPDATES_SETTING);
- mController.updateState(mPreference);
-
- verify(mPreference).setChecked(true);
- }
-
- @Test
- public void updateState_preferenceShouldNotBeChecked() {
- Settings.Global
- .putInt(mContext.getContentResolver(), Settings.Global.OTA_DISABLE_AUTOMATIC_UPDATE,
- DisableAutomaticUpdatesPreferenceController.DISABLE_UPDATES_SETTING);
- mController.updateState(mPreference);
-
- verify(mPreference).setChecked(false);
- }
-
- @Test
- public void onDeveloperOptionsDisabled_shouldDisablePreference() {
- mController.onDeveloperOptionsDisabled();
-
- verify(mPreference).setEnabled(false);
- verify(mPreference).setChecked(false);
- }
-}
diff --git a/tests/robotests/src/com/android/settings/gestures/LongPressPowerButtonPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/gestures/LongPressPowerButtonPreferenceControllerTest.java
index 053fa5a12d7..8ff50abff8f 100644
--- a/tests/robotests/src/com/android/settings/gestures/LongPressPowerButtonPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/gestures/LongPressPowerButtonPreferenceControllerTest.java
@@ -199,7 +199,7 @@ public class LongPressPowerButtonPreferenceControllerTest {
@Test
public void preferenceUnchecked_assistDefault_setNoAction() {
- // Value out of range chosen deliberately.
+ // Ensure that the Assistant is the default behavior for LPP.
when(mResources.getInteger(
com.android.internal.R.integer.config_longPressOnPowerBehavior))
.thenReturn(
@@ -209,13 +209,12 @@ public class LongPressPowerButtonPreferenceControllerTest {
assertThat(Settings.Global.getInt(mContext.getContentResolver(),
Settings.Global.POWER_BUTTON_LONG_PRESS, -1)).isEqualTo(
- LongPressPowerButtonPreferenceController.LONG_PRESS_POWER_NO_ACTION);
+ LongPressPowerButtonPreferenceController.LONG_PRESS_POWER_GLOBAL_ACTIONS);
assertThat(Settings.Global.getInt(mContext.getContentResolver(),
Settings.Global.KEY_CHORD_POWER_VOLUME_UP, -1)).isEqualTo(
LongPressPowerButtonPreferenceController.KEY_CHORD_POWER_VOLUME_UP_NO_ACTION);
- verify(mController.mAssistSwitch).setSummary(
- getString(
- R.string.power_menu_summary_long_press_for_assist_disabled_no_action));
+ verify(mController.mAssistSwitch).setSummary(getString(
+ R.string.power_menu_summary_long_press_for_assist_disabled_with_power_menu));
}
private String getString(@StringRes int id) {
diff --git a/tests/robotests/src/com/android/settings/system/DisableAutomaticUpdatesPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/system/DisableAutomaticUpdatesPreferenceControllerTest.java
new file mode 100644
index 00000000000..db8486edbcc
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/system/DisableAutomaticUpdatesPreferenceControllerTest.java
@@ -0,0 +1,102 @@
+/*
+ * 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.system;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import android.content.Context;
+import android.provider.Settings;
+
+import androidx.preference.PreferenceScreen;
+import androidx.preference.SwitchPreference;
+
+import com.android.settings.core.BasePreferenceController;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.robolectric.RobolectricTestRunner;
+import org.robolectric.RuntimeEnvironment;
+
+@RunWith(RobolectricTestRunner.class)
+public class DisableAutomaticUpdatesPreferenceControllerTest {
+
+ @Mock
+ private PreferenceScreen mPreferenceScreen;
+ @Mock
+ private SwitchPreference mPreference;
+
+ private Context mContext;
+ private DisableAutomaticUpdatesPreferenceController mController;
+
+ @Before
+ public void setup() {
+ MockitoAnnotations.initMocks(this);
+ mContext = RuntimeEnvironment.application;
+ mController = new DisableAutomaticUpdatesPreferenceController(mContext, "test");
+ }
+
+ @Test
+ public void getAvailabilityStatus_shouldReturnAVAILABLE() {
+ assertThat(mController.getAvailabilityStatus()).isEqualTo(
+ BasePreferenceController.AVAILABLE);
+ }
+
+ @Test
+ public void isChecked_valueIsZeroInProvider_shouldReturnTrue() {
+ Settings.Global.putInt(mContext.getContentResolver(),
+ Settings.Global.OTA_DISABLE_AUTOMATIC_UPDATE,
+ DisableAutomaticUpdatesPreferenceController.ENABLE_UPDATES_SETTING);
+
+ assertThat(mController.isChecked()).isTrue();
+ }
+
+ @Test
+ public void isChecked_valueIsOneInProvider_shouldReturnFalse() {
+ Settings.Global.putInt(mContext.getContentResolver(),
+ Settings.Global.OTA_DISABLE_AUTOMATIC_UPDATE,
+ DisableAutomaticUpdatesPreferenceController.DISABLE_UPDATES_SETTING);
+
+ assertThat(mController.isChecked()).isFalse();
+ }
+
+ @Test
+ public void setChecked_true_providerValueIsZero() {
+ mController.setChecked(true);
+
+ int value = Settings.Global.getInt(mContext.getContentResolver(),
+ Settings.Global.OTA_DISABLE_AUTOMATIC_UPDATE,
+ DisableAutomaticUpdatesPreferenceController.ENABLE_UPDATES_SETTING /* default */);
+
+ assertThat(value).isEqualTo(
+ DisableAutomaticUpdatesPreferenceController.ENABLE_UPDATES_SETTING);
+ }
+
+ @Test
+ public void setChecked_false_providerValueIsOne() {
+ mController.setChecked(false);
+
+ int value = Settings.Global.getInt(mContext.getContentResolver(),
+ Settings.Global.OTA_DISABLE_AUTOMATIC_UPDATE,
+ DisableAutomaticUpdatesPreferenceController.ENABLE_UPDATES_SETTING /* default */);
+
+ assertThat(value).isEqualTo(
+ DisableAutomaticUpdatesPreferenceController.DISABLE_UPDATES_SETTING);
+ }
+}