Snap for 5633711 from dd1545b098
to qt-c2f2-release
Change-Id: I1c05a1a0fb0d6e0715fec349482b04a6bfde3a30
This commit is contained in:
@@ -4837,9 +4837,9 @@
|
||||
<!-- Title for the accessibility preference screen to enable triple-tap gesture screen magnification. [CHAR LIMIT=35] -->
|
||||
<string name="accessibility_screen_magnification_gestures_title">Magnify with triple-tap</string>
|
||||
<!-- Title for the accessibility preference screen to enable navigation bar screen magnification. [CHAR LIMIT=35] -->
|
||||
<string name="accessibility_screen_magnification_navbar_title">Magnify with button</string>
|
||||
<string name="accessibility_screen_magnification_navbar_title">Magnify with shortcut</string>
|
||||
<!-- Summary for the accessibility magnification setting indicating both "Magnify with button" and "Magnify with triple-tap" are enabled [CHAR LIMIT=50] -->
|
||||
<string name="accessibility_screen_magnification_state_navbar_gesture">Magnify with button & triple-tap</string>
|
||||
<string name="accessibility_screen_magnification_state_navbar_gesture">Magnify with shortcut & triple-tap</string>
|
||||
<!-- Summary for the accessibility preference to enable screen magnification. [CHAR LIMIT=25] -->
|
||||
<string name="accessibility_preference_magnification_summary">Zoom in on screen</string>
|
||||
<!-- Short summary for Magnification gesture. Tells the user that this feature allows the user to magnify the screen by tapping 3 times. Appears in accessibility portion of setup wizard -->
|
||||
@@ -4849,7 +4849,25 @@
|
||||
<!-- Summary for the accessibility preference screen to enable screen magnification gestures. [CHAR LIMIT=none] -->
|
||||
<string name="accessibility_screen_magnification_summary"><b>To zoom</b>, quickly tap the screen 3 times.\n<ul><li>Drag 2 or more fingers to scroll</li>\n<li>Pinch 2 or more fingers to adjust zoom</li></ul>\n\n<b>To zoom temporarily</b>, quickly tap the screen 3 times and hold down your finger on the third tap.\n<ul><li>Drag to move around the screen</li>\n<li>Lift finger to zoom out</li></ul>\n\nYou can\'t zoom in on the keyboard and navigation bar.</string>
|
||||
<!-- Summary for the accessibility preference screen to enable screen magnification via the nav bar. [CHAR LIMIT=none] -->
|
||||
<string name="accessibility_screen_magnification_navbar_summary">When magnification is turned on, use the Accessibility button at the bottom of the screen to quickly magnify.\n\n<b>To zoom</b>, tap the Accessibility button, then tap anywhere on the screen.\n<ul><li>Drag 2 or more fingers to scroll</li>\n<li>Pinch 2 or more fingers to adjust zoom</li></ul>\n\n<b>To zoom temporarily</b>, tap the Accessibility button, then touch & hold anywhere on the screen.\n<ul><li>Drag to move around the screen</li>\n<li>Lift finger to zoom out</li></ul>\n\nYou can’t zoom in on the keyboard or navigation bar.</string>
|
||||
<string name="accessibility_screen_magnification_navbar_summary">When magnification is turned on, you can zoom in on your screen.\n\n<b>To zoom</b>, start magnification, then tap anywhere on the screen.\n<ul><li>• Drag 2 or more fingers to scroll</li>\n<li>• Pinch 2 or more fingers to adjust zoom</li></ul>\n\n<b>To zoom temporarily</b>, start magnification, then touch & hold anywhere on the screen.\n<ul><li>• Drag to move around the screen</li>\n<li>• Lift finger to zoom out</li></ul>\n\nYou can’t zoom in on the keyboard or navigation bar.</string>
|
||||
<!-- Title for the Accessibility tutorial dialog in Accessibility service with button. [CHAR LIMIT=50] -->
|
||||
<string name="accessibility_tutorial_dialog_title_button">Use accessibility button to open</string>
|
||||
<!-- Title for the Accessibility tutorial dialog in Accessibility service with gesture. [CHAR LIMIT=50] -->
|
||||
<string name="accessibility_tutorial_dialog_title_gesture">Use gesture to open</string>
|
||||
<!-- Title for the Accessibility tutorial dialog in gesture navigation settings. [CHAR LIMIT=50] -->
|
||||
<string name="accessibility_tutorial_dialog_title_gesture_settings">Use new accessibility gesture</string>
|
||||
<!-- Message for the Accessibility tutorial dialog when user enables an accessibility service while using the 3-button nav bar. [CHAR LIMIT=NONE] -->
|
||||
<string name="accessibility_tutorial_dialog_message_button">To turn this service on or off, tap the accessibility button<xliff:g id="accessibility_icon" example="[Icon]">%s</xliff:g>on the bottom of your screen.\n\nTo switch between services, touch & hold the accessibility button.</string>
|
||||
<!-- Message for the Accessibility tutorial dialog when user enables an accessibility service while using gesture navigation and touch exploration is not enabled. [CHAR LIMIT=NONE] -->
|
||||
<string name="accessibility_tutorial_dialog_message_gesture_without_talkback">To turn this service on or off, swipe up from the bottom of the screen with two fingers.\n\nTo switch between services, swipe up with two fingers and hold.</string>
|
||||
<!-- Message for the Accessibility tutorial dialog when user enables an accessibility service while using gesture navigation and touch exploration is enabled. [CHAR LIMIT=NONE] -->
|
||||
<string name="accessibility_tutorial_dialog_message_gesture_with_talkback">To turn this service on or off, swipe up from the bottom of the screen with three fingers.\n\nTo switch between services, swipe up with three fingers and hold.</string>
|
||||
<!-- Message for the Accessibility tutorial dialog when user chooses gesture navigation in navigation settings, an accessibility service is using the accessibility button, and touch exploration is disabled. [CHAR LIMIT=NONE] -->
|
||||
<string name="accessibility_tutorial_dialog_message_gesture_settings_without_talkback">To turn an accessibility service on or off, swipe up from the bottom of the screen with two fingers.\n\nTo switch between services, swipe up with two fingers and hold.</string>
|
||||
<!-- Message for the Accessibility tutorial dialog when user chooses gesture navigation in navigation settings, an accessibility service is using the accessibility button, and touch exploration is enabled. [CHAR LIMIT=NONE] -->
|
||||
<string name="accessibility_tutorial_dialog_message_gesture_settings_with_talkback">To turn an accessibility service on or off, swipe up from the bottom of the screen with three fingers.\n\nTo switch between services, swipe up with three fingers and hold.</string>
|
||||
<!-- Button for the Accessibility tutorial dialog to dismiss the dialog when user clicks it. [CHAR LIMIT=10] -->
|
||||
<string name="accessibility_tutorial_dialog_button">Got it</string>
|
||||
<!-- Summary text appearing on the accessibility preference screen to enable screen magnification from the nav bar when the feature is enabled, but the accessibility button is not configured correctly for the feature to be used [CHAR LIMIT=none] -->
|
||||
<string name="accessibility_screen_magnification_navbar_configuration_warning">The Accessibility button is set to <xliff:g id="service" example="Select to Speak">%1$s</xliff:g>. To use magnification, touch & hold the Accessibility button, then select magnification.</string>
|
||||
<!-- Title for the preference to configure the accessibility shortcut, which uses the volume keys. [CHAR LIMIT=35] -->
|
||||
@@ -10611,11 +10629,6 @@
|
||||
<!-- UI debug setting: preference summary - describes the behavior of forcing full raw GNSS satellite measurements [CHAR LIMIT=NONE] -->
|
||||
<string name="enable_gnss_raw_meas_full_tracking_summary">Track all GNSS constellations and frequencies with no duty cycling</string>
|
||||
|
||||
<!-- UI debug setting: preference title - allow background activity starts [CHAR LIMIT=60] -->
|
||||
<string name="allow_background_activity_starts">Allow background activity starts</string>
|
||||
<!-- UI debug setting: preference summary - describes the behavior of allowing background activity starts [CHAR LIMIT=NONE] -->
|
||||
<string name="allow_background_activity_starts_summary">Allows all background activity starts</string>
|
||||
|
||||
<!-- UI debug setting: preference title - show all crash dialogs [CHAR LIMIT=60] -->
|
||||
<string name="show_first_crash_dialog">Always show crash dialog</string>
|
||||
<!-- UI debug setting: preference summary - describes the behavior of showing a dialog every time an app crashes [CHAR LIMIT=NONE] -->
|
||||
|
@@ -507,11 +507,6 @@
|
||||
android:fragment="com.android.settings.applications.appops.BackgroundCheckSummary"
|
||||
android:title="@string/background_check_pref" />
|
||||
|
||||
<SwitchPreference
|
||||
android:key="allow_background_activity_starts"
|
||||
android:title="@string/allow_background_activity_starts"
|
||||
android:summary="@string/allow_background_activity_starts_summary" />
|
||||
|
||||
<SwitchPreference
|
||||
android:key="show_first_crash_dialog"
|
||||
android:title="@string/show_first_crash_dialog"
|
||||
|
@@ -85,6 +85,12 @@
|
||||
android:summary="@string/mms_message_summary"
|
||||
settings:controller="com.android.settings.network.telephony.MmsMessagePreferenceController"/>
|
||||
|
||||
<SwitchPreference
|
||||
android:key="data_during_calls"
|
||||
android:title="@string/data_during_calls_title"
|
||||
android:summary="@string/data_during_calls_summary"
|
||||
settings:controller="com.android.settings.network.telephony.DataDuringCallsPreferenceController"/>
|
||||
|
||||
<SwitchPreference
|
||||
android:key="enhanced_4g_lte"
|
||||
android:title="@string/enhanced_4g_lte_mode_title"
|
||||
|
@@ -1,91 +0,0 @@
|
||||
/*
|
||||
* 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.development;
|
||||
|
||||
import android.content.Context;
|
||||
import android.provider.DeviceConfig;
|
||||
import android.provider.Settings;
|
||||
|
||||
import androidx.preference.Preference;
|
||||
import androidx.preference.SwitchPreference;
|
||||
|
||||
import com.android.internal.annotations.VisibleForTesting;
|
||||
import com.android.settings.core.PreferenceControllerMixin;
|
||||
import com.android.settingslib.development.DeveloperOptionsPreferenceController;
|
||||
|
||||
public class AllowBackgroundActivityStartsPreferenceController
|
||||
extends DeveloperOptionsPreferenceController
|
||||
implements Preference.OnPreferenceChangeListener, PreferenceControllerMixin {
|
||||
|
||||
private static final String BACKGROUND_ACTIVITY_STARTS_ENABLED_KEY
|
||||
= "allow_background_activity_starts";
|
||||
|
||||
/** Key in DeviceConfig that stores the default for the preference (as a boolean). */
|
||||
@VisibleForTesting
|
||||
static final String KEY_DEFAULT_BACKGROUND_ACTIVITY_STARTS_ENABLED =
|
||||
"default_background_activity_starts_enabled";
|
||||
|
||||
public AllowBackgroundActivityStartsPreferenceController(Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPreferenceKey() {
|
||||
return BACKGROUND_ACTIVITY_STARTS_ENABLED_KEY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||
writeSetting((boolean) newValue);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateState(Preference preference) {
|
||||
final int mode = Settings.Global.getInt(mContext.getContentResolver(),
|
||||
Settings.Global.BACKGROUND_ACTIVITY_STARTS_ENABLED, -1);
|
||||
|
||||
boolean isEnabled = mode < 0 ? isDefaultEnabled() : mode != 0;
|
||||
((SwitchPreference) mPreference).setChecked(isEnabled);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDeveloperOptionsSwitchDisabled() {
|
||||
super.onDeveloperOptionsSwitchDisabled();
|
||||
clearSetting();
|
||||
updateState(mPreference);
|
||||
}
|
||||
|
||||
private void writeSetting(boolean isEnabled) {
|
||||
Settings.Global.putInt(mContext.getContentResolver(),
|
||||
Settings.Global.BACKGROUND_ACTIVITY_STARTS_ENABLED, isEnabled ? 1 : 0);
|
||||
}
|
||||
|
||||
private void clearSetting() {
|
||||
Settings.Global.putInt(mContext.getContentResolver(),
|
||||
Settings.Global.BACKGROUND_ACTIVITY_STARTS_ENABLED, -1);
|
||||
}
|
||||
|
||||
private boolean isDefaultEnabled() {
|
||||
// The default in the absence of user preference is settable via DeviceConfig.
|
||||
// Note that the default default is disabled.
|
||||
return DeviceConfig.getBoolean(
|
||||
DeviceConfig.NAMESPACE_ACTIVITY_MANAGER,
|
||||
KEY_DEFAULT_BACKGROUND_ACTIVITY_STARTS_ENABLED,
|
||||
/*defaultValue*/ false);
|
||||
}
|
||||
}
|
@@ -473,7 +473,6 @@ public class DevelopmentSettingsDashboardFragment extends RestrictedDashboardFra
|
||||
controllers.add(new ProfileGpuRenderingPreferenceController(context));
|
||||
controllers.add(new KeepActivitiesPreferenceController(context));
|
||||
controllers.add(new BackgroundProcessLimitPreferenceController(context));
|
||||
controllers.add(new AllowBackgroundActivityStartsPreferenceController(context));
|
||||
controllers.add(new ShowFirstCrashDialogPreferenceController(context));
|
||||
controllers.add(new AppsNotRespondingPreferenceController(context));
|
||||
controllers.add(new NotificationChannelWarningsPreferenceController(context));
|
||||
|
@@ -0,0 +1,104 @@
|
||||
/*
|
||||
* 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.network.telephony;
|
||||
|
||||
import static androidx.lifecycle.Lifecycle.Event.ON_PAUSE;
|
||||
import static androidx.lifecycle.Lifecycle.Event.ON_RESUME;
|
||||
|
||||
import android.content.Context;
|
||||
import android.telephony.SubscriptionManager;
|
||||
import android.telephony.TelephonyManager;
|
||||
|
||||
import androidx.lifecycle.Lifecycle;
|
||||
import androidx.lifecycle.LifecycleObserver;
|
||||
import androidx.lifecycle.OnLifecycleEvent;
|
||||
import androidx.preference.Preference;
|
||||
import androidx.preference.PreferenceScreen;
|
||||
import androidx.preference.SwitchPreference;
|
||||
|
||||
import com.android.settings.network.SubscriptionsChangeListener;
|
||||
|
||||
public class DataDuringCallsPreferenceController extends TelephonyTogglePreferenceController
|
||||
implements LifecycleObserver,
|
||||
SubscriptionsChangeListener.SubscriptionsChangeListenerClient {
|
||||
|
||||
private SwitchPreference mPreference;
|
||||
private SubscriptionsChangeListener mChangeListener;
|
||||
private TelephonyManager mManager;
|
||||
|
||||
public DataDuringCallsPreferenceController(Context context,
|
||||
String preferenceKey) {
|
||||
super(context, preferenceKey);
|
||||
mChangeListener = new SubscriptionsChangeListener(mContext, this);
|
||||
}
|
||||
|
||||
public void init(Lifecycle lifecycle, int subId) {
|
||||
this.mSubId = subId;
|
||||
mManager = mContext.getSystemService(TelephonyManager.class).createForSubscriptionId(subId);
|
||||
lifecycle.addObserver(this);
|
||||
}
|
||||
|
||||
@OnLifecycleEvent(ON_RESUME)
|
||||
public void onResume() {
|
||||
mChangeListener.start();
|
||||
}
|
||||
|
||||
@OnLifecycleEvent(ON_PAUSE)
|
||||
public void onPause() {
|
||||
mChangeListener.stop();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void displayPreference(PreferenceScreen screen) {
|
||||
super.displayPreference(screen);
|
||||
mPreference = screen.findPreference(getPreferenceKey());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isChecked() {
|
||||
return mManager.isDataAllowedInVoiceCall();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setChecked(boolean isChecked) {
|
||||
mManager.setDataAllowedDuringVoiceCall(isChecked);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getAvailabilityStatus(int subId) {
|
||||
if (mSubId == SubscriptionManager.INVALID_SUBSCRIPTION_ID ||
|
||||
SubscriptionManager.getDefaultDataSubscriptionId() == mSubId) {
|
||||
return CONDITIONALLY_UNAVAILABLE;
|
||||
}
|
||||
return AVAILABLE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateState(Preference preference) {
|
||||
super.updateState(preference);
|
||||
preference.setVisible(isAvailable());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAirplaneModeChanged(boolean airplaneModeEnabled) {}
|
||||
|
||||
@Override
|
||||
public void onSubscriptionsChanged() {
|
||||
updateState(mPreference);
|
||||
}
|
||||
}
|
@@ -138,6 +138,7 @@ public class MobileNetworkSettings extends RestrictedDashboardFragment {
|
||||
use(CarrierSettingsVersionPreferenceController.class).init(mSubId);
|
||||
use(BillingCyclePreferenceController.class).init(mSubId);
|
||||
use(MmsMessagePreferenceController.class).init(mSubId);
|
||||
use(DataDuringCallsPreferenceController.class).init(getLifecycle(), mSubId);
|
||||
use(DisabledSubscriptionController.class).init(getLifecycle(), mSubId);
|
||||
use(DeleteSimProfilePreferenceController.class).init(mSubId, this,
|
||||
REQUEST_CODE_DELETE_SUBSCRIPTION);
|
||||
|
@@ -4,3 +4,4 @@ com.android.settings.testutils.FakeInvalidSliderController
|
||||
com.android.settings.core.TogglePreferenceControllerTest$FakeToggle
|
||||
com.android.settings.accessibility.AccessibilitySlicePreferenceController
|
||||
com.android.settings.network.telephony.MmsMessagePreferenceController
|
||||
com.android.settings.network.telephony.DataDuringCallsPreferenceController
|
||||
|
@@ -1,159 +0,0 @@
|
||||
/*
|
||||
* 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.development;
|
||||
|
||||
import static com.android.settings.development.AllowBackgroundActivityStartsPreferenceController.KEY_DEFAULT_BACKGROUND_ACTIVITY_STARTS_ENABLED;
|
||||
|
||||
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.DeviceConfig;
|
||||
import android.provider.Settings;
|
||||
|
||||
import androidx.preference.PreferenceScreen;
|
||||
import androidx.preference.SwitchPreference;
|
||||
|
||||
import com.android.settings.testutils.shadow.ShadowDeviceConfig;
|
||||
|
||||
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;
|
||||
import org.robolectric.annotation.Config;
|
||||
|
||||
@RunWith(RobolectricTestRunner.class)
|
||||
@Config(shadows = {ShadowDeviceConfig.class})
|
||||
public class AllowBackgroundActivityStartsPreferenceControllerTest {
|
||||
|
||||
@Mock
|
||||
private SwitchPreference mPreference;
|
||||
@Mock
|
||||
private PreferenceScreen mPreferenceScreen;
|
||||
|
||||
private Context mContext;
|
||||
private AllowBackgroundActivityStartsPreferenceController mController;
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
mContext = RuntimeEnvironment.application;
|
||||
mController = new AllowBackgroundActivityStartsPreferenceController(mContext);
|
||||
when(mPreferenceScreen.findPreference(mController.getPreferenceKey()))
|
||||
.thenReturn(mPreference);
|
||||
mController.displayPreference(mPreferenceScreen);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void onPreferenceChange_settingEnabled_allowBackgroundActivityStartsShouldBeOn() {
|
||||
mController.onPreferenceChange(mPreference, true /* new value */);
|
||||
|
||||
assertThat(getModeFroMSettings()).isEqualTo(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void onPreferenceChange_settingDisabled_allowBackgroundActivityStartsShouldBeOff() {
|
||||
mController.onPreferenceChange(mPreference, false /* new value */);
|
||||
|
||||
assertThat(getModeFroMSettings()).isEqualTo(0);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void updateState_settingDisabled_preferenceShouldNotBeChecked() {
|
||||
Settings.Global.putInt(mContext.getContentResolver(),
|
||||
Settings.Global.BACKGROUND_ACTIVITY_STARTS_ENABLED, 0);
|
||||
mController.updateState(mPreference);
|
||||
|
||||
verify(mPreference).setChecked(false);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void updateState_settingEnabled_preferenceShouldBeChecked() {
|
||||
Settings.Global.putInt(mContext.getContentResolver(),
|
||||
Settings.Global.BACKGROUND_ACTIVITY_STARTS_ENABLED, 1);
|
||||
mController.updateState(mPreference);
|
||||
|
||||
verify(mPreference).setChecked(true);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void updateState_settingReset_defaultDisabled_preferenceShouldNotBeChecked() {
|
||||
setDefault(false);
|
||||
mController.updateState(mPreference);
|
||||
|
||||
verify(mPreference).setChecked(false);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void updateState_settingReset_defaultEnabled_preferenceShouldBeChecked() {
|
||||
setDefault(true);
|
||||
mController.updateState(mPreference);
|
||||
|
||||
verify(mPreference).setChecked(true);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void onDeveloperOptionsSwitchDisabled_noDefault_shouldResetPreference() {
|
||||
mController.onDeveloperOptionsSwitchDisabled();
|
||||
|
||||
verify(mPreference).setChecked(false);
|
||||
verify(mPreference).setEnabled(false);
|
||||
|
||||
assertThat(getModeFroMSettings()).isEqualTo(-1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void onDeveloperOptionsSwitchDisabled_defaultDisabled_shouldResetPreference() {
|
||||
setDefault(false);
|
||||
mController.onDeveloperOptionsSwitchDisabled();
|
||||
|
||||
verify(mPreference).setChecked(false);
|
||||
verify(mPreference).setEnabled(false);
|
||||
|
||||
assertThat(getModeFroMSettings()).isEqualTo(-1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void onDeveloperOptionsSwitchDisabled_defaultEnabled_shouldResetPreference() {
|
||||
setDefault(true);
|
||||
mController.onDeveloperOptionsSwitchDisabled();
|
||||
|
||||
verify(mPreference).setChecked(true);
|
||||
verify(mPreference).setEnabled(false);
|
||||
|
||||
assertThat(getModeFroMSettings()).isEqualTo(-1);
|
||||
}
|
||||
|
||||
private int getModeFroMSettings() {
|
||||
return Settings.Global.getInt(mContext.getContentResolver(),
|
||||
Settings.Global.BACKGROUND_ACTIVITY_STARTS_ENABLED, 999 /* default */);
|
||||
}
|
||||
|
||||
private void setDefault(boolean defaultEnabled) {
|
||||
DeviceConfig.setProperty(
|
||||
DeviceConfig.NAMESPACE_ACTIVITY_MANAGER,
|
||||
KEY_DEFAULT_BACKGROUND_ACTIVITY_STARTS_ENABLED,
|
||||
Boolean.toString(defaultEnabled),
|
||||
false /* makeDefault */);
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,134 @@
|
||||
/*
|
||||
* 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.network;
|
||||
|
||||
import static android.telephony.SubscriptionManager.INVALID_SUBSCRIPTION_ID;
|
||||
|
||||
import static com.android.settings.core.BasePreferenceController.CONDITIONALLY_UNAVAILABLE;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import static org.mockito.ArgumentMatchers.anyInt;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.Mockito.doReturn;
|
||||
import static org.mockito.Mockito.spy;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import android.content.Context;
|
||||
import android.telephony.TelephonyManager;
|
||||
|
||||
import androidx.lifecycle.Lifecycle;
|
||||
import androidx.preference.PreferenceScreen;
|
||||
import androidx.preference.SwitchPreference;
|
||||
|
||||
import com.android.settings.network.telephony.DataDuringCallsPreferenceController;
|
||||
|
||||
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;
|
||||
import org.robolectric.annotation.Config;
|
||||
import org.robolectric.shadows.ShadowSubscriptionManager;
|
||||
|
||||
@RunWith(RobolectricTestRunner.class)
|
||||
@Config(shadows = ShadowSubscriptionManager.class)
|
||||
public class DataDuringCallsPreferenceControllerTest {
|
||||
private static final String PREF_KEY = "pref_key";
|
||||
private static final int SUB_ID_1 = 111;
|
||||
private static final int SUB_ID_2 = 222;
|
||||
|
||||
@Mock
|
||||
private TelephonyManager mTelephonyManager;
|
||||
@Mock
|
||||
private Lifecycle mLifecycle;
|
||||
@Mock
|
||||
private PreferenceScreen mPreferenceScreen;
|
||||
|
||||
private Context mContext;
|
||||
private SwitchPreference mSwitchPreference;
|
||||
private DataDuringCallsPreferenceController mController;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
mContext = spy(RuntimeEnvironment.application);
|
||||
doReturn(mTelephonyManager).when(mContext).getSystemService(eq(TelephonyManager.class));
|
||||
when(mTelephonyManager.createForSubscriptionId(anyInt())).thenReturn(mTelephonyManager);
|
||||
mSwitchPreference = new SwitchPreference(mContext);
|
||||
when(mPreferenceScreen.findPreference(PREF_KEY)).thenReturn(mSwitchPreference);
|
||||
mController = new DataDuringCallsPreferenceController(mContext, PREF_KEY);
|
||||
mController.init(mLifecycle, SUB_ID_1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getAvailabilityStatus_noInit_notAvailable() {
|
||||
ShadowSubscriptionManager.setDefaultDataSubscriptionId(SUB_ID_1);
|
||||
DataDuringCallsPreferenceController controller =
|
||||
new DataDuringCallsPreferenceController(mContext, PREF_KEY);
|
||||
|
||||
// note that we purposely don't call init first on the controller
|
||||
assertThat(controller.getAvailabilityStatus(INVALID_SUBSCRIPTION_ID)).isEqualTo(
|
||||
CONDITIONALLY_UNAVAILABLE);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void displayPreference_defaultForData_notAvailable() {
|
||||
ShadowSubscriptionManager.setDefaultDataSubscriptionId(SUB_ID_1);
|
||||
|
||||
mController.displayPreference(mPreferenceScreen);
|
||||
|
||||
assertThat(mController.isAvailable()).isFalse();
|
||||
assertThat(mSwitchPreference.isVisible()).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void displayPreference_notDefaultForData_available() {
|
||||
ShadowSubscriptionManager.setDefaultDataSubscriptionId(SUB_ID_2);
|
||||
|
||||
mController.displayPreference(mPreferenceScreen);
|
||||
|
||||
assertThat(mController.isAvailable()).isTrue();
|
||||
assertThat(mSwitchPreference.isVisible()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void onSubscriptionsChanged_becomesDefaultForData_notAvailable() {
|
||||
ShadowSubscriptionManager.setDefaultDataSubscriptionId(SUB_ID_2);
|
||||
|
||||
mController.displayPreference(mPreferenceScreen);
|
||||
ShadowSubscriptionManager.setDefaultDataSubscriptionId(SUB_ID_1);
|
||||
mController.onSubscriptionsChanged();
|
||||
|
||||
assertThat(mController.isAvailable()).isFalse();
|
||||
assertThat(mSwitchPreference.isVisible()).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void onSubscriptionsChanged_noLongerDefaultForData_available() {
|
||||
ShadowSubscriptionManager.setDefaultDataSubscriptionId(SUB_ID_1);
|
||||
|
||||
mController.displayPreference(mPreferenceScreen);
|
||||
ShadowSubscriptionManager.setDefaultDataSubscriptionId(SUB_ID_2);
|
||||
mController.onSubscriptionsChanged();
|
||||
|
||||
assertThat(mController.isAvailable()).isTrue();
|
||||
assertThat(mSwitchPreference.isVisible()).isTrue();
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user