Snap for 7655495 from f4977c5e36
to sc-qpr1-release
Change-Id: I8e5e06c0d0e08186dd53767e125f327786c8d1ef
This commit is contained in:
@@ -109,11 +109,6 @@
|
||||
android:title="@string/color_temperature"
|
||||
android:summary="@string/color_temperature_desc" />
|
||||
|
||||
<SwitchPreference
|
||||
android:key="ota_disable_automatic_update"
|
||||
android:title="@string/ota_disable_automatic_update"
|
||||
android:summary="@string/ota_disable_automatic_update_summary" />
|
||||
|
||||
<Preference android:key="dsu_loader"
|
||||
android:title="@string/dsu_loader_title" />
|
||||
|
||||
|
@@ -65,6 +65,14 @@
|
||||
<intent android:action="android.settings.SYSTEM_UPDATE_SETTINGS"/>
|
||||
</Preference>
|
||||
|
||||
<SwitchPreference
|
||||
android:key="ota_disable_automatic_update"
|
||||
android:title="@string/ota_disable_automatic_update"
|
||||
android:summary="@string/ota_disable_automatic_update_summary"
|
||||
android:icon="@drawable/ic_system_update"
|
||||
android:order="-57"
|
||||
settings:controller="com.android.settings.system.DisableAutomaticUpdatesPreferenceController"/>
|
||||
|
||||
<Preference
|
||||
android:key="reset_dashboard"
|
||||
android:title="@string/reset_dashboard_title"
|
||||
|
@@ -175,7 +175,7 @@ public class BluetoothDetailsCompanionAppsController extends BluetoothDetailsCon
|
||||
*/
|
||||
@Override
|
||||
protected void refresh() {
|
||||
updatePreferences(mContext, mCachedDevice.getAddress(), mProfilesContainer);
|
||||
// Do nothing. More details in b/191992001
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -481,7 +481,6 @@ public class DevelopmentSettingsDashboardFragment extends RestrictedDashboardFra
|
||||
controllers.add(new PictureColorModePreferenceController(context, lifecycle));
|
||||
controllers.add(new WebViewAppPreferenceController(context));
|
||||
controllers.add(new CoolColorTemperaturePreferenceController(context));
|
||||
controllers.add(new DisableAutomaticUpdatesPreferenceController(context));
|
||||
controllers.add(new SelectDSUPreferenceController(context));
|
||||
controllers.add(new AdbPreferenceController(context, fragment));
|
||||
controllers.add(new ClearAdbKeysPreferenceController(context, fragment));
|
||||
|
@@ -1,76 +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 android.content.Context;
|
||||
import android.provider.Settings;
|
||||
|
||||
import androidx.annotation.VisibleForTesting;
|
||||
import androidx.preference.Preference;
|
||||
import androidx.preference.SwitchPreference;
|
||||
|
||||
import com.android.settings.core.PreferenceControllerMixin;
|
||||
import com.android.settingslib.development.DeveloperOptionsPreferenceController;
|
||||
|
||||
public class DisableAutomaticUpdatesPreferenceController extends
|
||||
DeveloperOptionsPreferenceController implements
|
||||
Preference.OnPreferenceChangeListener, PreferenceControllerMixin {
|
||||
|
||||
private static final String OTA_DISABLE_AUTOMATIC_UPDATE_KEY = "ota_disable_automatic_update";
|
||||
|
||||
// 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
|
||||
final static int DISABLE_UPDATES_SETTING = 1;
|
||||
@VisibleForTesting
|
||||
final static int ENABLE_UPDATES_SETTING = 0;
|
||||
|
||||
public DisableAutomaticUpdatesPreferenceController(Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPreferenceKey() {
|
||||
return OTA_DISABLE_AUTOMATIC_UPDATE_KEY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||
final boolean updatesEnabled = (Boolean) newValue;
|
||||
Settings.Global.putInt(mContext.getContentResolver(),
|
||||
Settings.Global.OTA_DISABLE_AUTOMATIC_UPDATE,
|
||||
updatesEnabled ? ENABLE_UPDATES_SETTING : DISABLE_UPDATES_SETTING);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateState(Preference preference) {
|
||||
final int updatesEnabled = Settings.Global.getInt(mContext.getContentResolver(),
|
||||
Settings.Global.OTA_DISABLE_AUTOMATIC_UPDATE, 0 /* default */);
|
||||
|
||||
((SwitchPreference) mPreference).setChecked(updatesEnabled != DISABLE_UPDATES_SETTING);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDeveloperOptionsSwitchDisabled() {
|
||||
super.onDeveloperOptionsSwitchDisabled();
|
||||
Settings.Global.putInt(mContext.getContentResolver(),
|
||||
Settings.Global.OTA_DISABLE_AUTOMATIC_UPDATE, DISABLE_UPDATES_SETTING);
|
||||
((SwitchPreference) mPreference).setChecked(false);
|
||||
}
|
||||
}
|
@@ -179,16 +179,18 @@ public class LongPressPowerButtonPreferenceController extends TogglePreferenceCo
|
||||
POWER_BUTTON_LONG_PRESS_SETTING, LONG_PRESS_POWER_ASSISTANT_VALUE);
|
||||
}
|
||||
|
||||
// We need to determine the right disabled value - we set it to device default
|
||||
// if it's different than Assist, otherwise we fallback to either global actions or power
|
||||
// menu.
|
||||
// We need to determine the right disabled value based on the device default
|
||||
// for long-press power.
|
||||
|
||||
// If the default is to start the assistant, then the fallback is GlobalActions.
|
||||
final int defaultPowerButtonValue = mContext.getResources().getInteger(
|
||||
POWER_BUTTON_LONG_PRESS_DEFAULT_VALUE_RESOURCE);
|
||||
if (defaultPowerButtonValue == LONG_PRESS_POWER_ASSISTANT_VALUE) {
|
||||
return Settings.Global.putInt(mContext.getContentResolver(),
|
||||
POWER_BUTTON_LONG_PRESS_SETTING, LONG_PRESS_POWER_NO_ACTION);
|
||||
POWER_BUTTON_LONG_PRESS_SETTING, LONG_PRESS_POWER_GLOBAL_ACTIONS);
|
||||
}
|
||||
|
||||
// If the default is something different than Assist, we use that default.
|
||||
return Settings.Global.putInt(mContext.getContentResolver(),
|
||||
POWER_BUTTON_LONG_PRESS_SETTING, defaultPowerButtonValue);
|
||||
}
|
||||
|
@@ -43,9 +43,8 @@ public class DisableSmartForwardingTask implements Runnable {
|
||||
}
|
||||
|
||||
if (callForwardingInfo != null
|
||||
&& callForwardingInfo[i] != null
|
||||
&& callForwardingInfo[i].getTimeoutSeconds() > 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);
|
||||
}
|
||||
}
|
||||
|
@@ -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);
|
||||
}
|
||||
}
|
@@ -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 {
|
||||
|
@@ -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);
|
||||
}
|
||||
}
|
@@ -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) {
|
||||
|
@@ -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);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user