Snap for 7163567 from 5315f373fa to sc-v2-release

Change-Id: I83bd159f8b7b09b91c3665aa32e4a62b98ad0931
This commit is contained in:
android-build-team Robot
2021-02-23 02:08:56 +00:00
18 changed files with 293 additions and 149 deletions

View File

@@ -20,7 +20,47 @@
android:id="@+id/setup_wizard_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout="@layout/sud_glif_blank_template"
style="?attr/fingerprint_layout_theme">
<LinearLayout
style="@style/SudContentFrame"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipToPadding="false"
android:clipChildren="false"
android:orientation="vertical">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="@+id/sud_layout_description"
style="@style/SudDescription.Glif"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minLines="3"
android:text="@string/security_settings_fingerprint_enroll_start_message" />
<TextView
android:id="@+id/repeat_message"
style="@style/SudDescription.Glif"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/security_settings_fingerprint_enroll_repeat_message"
android:visibility="invisible" />
</FrameLayout>
<TextView
android:id="@+id/error_text"
style="@style/TextAppearance.ErrorText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal|bottom"
android:accessibilityLiveRegion="polite"
android:gravity="center_horizontal"
android:visibility="invisible" />
</LinearLayout>
</com.google.android.setupdesign.GlifLayout>

View File

@@ -1,77 +0,0 @@
<?xml version="1.0" encoding="utf-8"?><!--
~ Copyright (C) 2015 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
-->
<com.android.settings.biometrics.fingerprint.UdfpsEnrollLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/setup_wizard_layout"
style="?attr/fingerprint_layout_theme"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<ImageView
android:id="@+id/sud_layout_icon"
style="@style/SudGlifIcon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="?attr/sudGlifHeaderGravity"
android:layout_marginEnd="0dp"
android:layout_marginStart="0dp"
android:src="@drawable/ic_fingerprint_header" />
<TextView
android:id="@+id/suc_layout_title"
style="@style/SudGlifHeaderTitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginEnd="0dp"
android:layout_marginStart="0dp" />
<FrameLayout
android:id="@+id/description_area"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="@+id/sud_layout_description"
style="@style/SudDescription.Glif"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/security_settings_fingerprint_enroll_start_message" />
<TextView
android:id="@+id/repeat_message"
style="@style/SudDescription.Glif"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/security_settings_fingerprint_enroll_repeat_message"
android:visibility="invisible" />
</FrameLayout>
<TextView
android:id="@+id/error_text"
style="@style/TextAppearance.ErrorText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal|bottom"
android:layout_marginBottom="16dp"
android:accessibilityLiveRegion="polite"
android:gravity="center_horizontal"
android:paddingEnd="5dp"
android:paddingStart="5dp"
android:visibility="invisible" />
</com.android.settings.biometrics.fingerprint.UdfpsEnrollLayout>

View File

@@ -20,7 +20,7 @@
android:key="display_settings_screen"
android:title="@string/display_settings"
settings:keywords="@string/keywords_display"
settings:initialExpandedChildrenCount="5">
settings:initialExpandedChildrenCount="6">
<com.android.settingslib.RestrictedPreference
android:key="brightness"

View File

@@ -78,7 +78,6 @@
<SwitchPreference
android:key="visiblepattern_profile"
android:summary="@string/summary_placeholder"
android:title="@string/lockpattern_settings_enable_visible_pattern_title_profile"
settings:controller="com.android.settings.security.VisiblePatternProfilePreferenceController" />

View File

@@ -35,4 +35,9 @@
android:key="transcode_default"
android:title="@string/transcode_default"
settings:controller="com.android.settings.development.transcode.TranscodeDefaultOptionPreferenceController" />
<SwitchPreference
android:key="transcode_notification"
android:title="@string/transcode_notification"
settings:controller="com.android.settings.development.transcode.TranscodeNotificationPreferenceController" />
</PreferenceScreen>

View File

@@ -144,12 +144,7 @@ public class FingerprintEnrollEnrolling extends BiometricsEnrollEnrolling {
mCanAssumeUdfps = props.size() == 1 && props.get(0).isAnyUdfpsType();
if (mCanAssumeUdfps) {
// Use a custom layout since animations, etc must be based off of the sensor's physical
// location.
setContentView(R.layout.udfps_enroll_enrolling);
final UdfpsEnrollLayout udfpsEnrollLayout = (UdfpsEnrollLayout) getLayoutInflater()
.inflate(R.layout.udfps_enroll_layout, null /* root */);
getLayout().addView(udfpsEnrollLayout);
} else {
setContentView(R.layout.fingerprint_enroll_enrolling);
}

View File

@@ -36,11 +36,6 @@ import com.android.settings.password.ChooseLockSettingsHelper;
public class SetupFingerprintEnrollFindSensor extends FingerprintEnrollFindSensor {
@Override
protected int getContentView() {
return R.layout.fingerprint_enroll_find_sensor;
}
@Override
protected Intent getFingerprintEnrollingIntent() {
Intent intent = new Intent(this, SetupFingerprintEnrollEnrolling.class);

View File

@@ -1,42 +0,0 @@
/*
* Copyright (C) 2020 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.biometrics.fingerprint;
import android.content.Context;
import android.hardware.fingerprint.FingerprintManager;
import android.hardware.fingerprint.FingerprintSensorPropertiesInternal;
import android.util.AttributeSet;
import android.view.View;
import android.view.WindowInsets;
import android.view.WindowManager;
import android.widget.LinearLayout;
import com.android.settings.R;
public class UdfpsEnrollLayout extends LinearLayout {
private static final String TAG = "UdfpsEnrollLayout";
public UdfpsEnrollLayout(Context context, AttributeSet attrs) {
super(context, attrs);
}
@Override
public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
}
}

View File

@@ -122,7 +122,7 @@ public class ForcePeakRefreshRatePreferenceController extends DeveloperOptionsPr
private float findPeakRefreshRate(Display.Mode[] modes) {
float peakRefreshRate = DEFAULT_REFRESH_RATE;
for (Display.Mode mode : modes) {
if (Math.round(mode.getRefreshRate()) > DEFAULT_REFRESH_RATE) {
if (Math.round(mode.getRefreshRate()) > peakRefreshRate) {
peakRefreshRate = mode.getRefreshRate();
}
}

View File

@@ -0,0 +1,53 @@
/*
* 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.development.transcode;
import android.content.Context;
import android.os.SystemProperties;
import com.android.internal.annotations.VisibleForTesting;
import com.android.settings.core.TogglePreferenceController;
/**
* The controller (in the Media transcoding settings) indicating the user's preference to show
* or hide the transcoding notifications.
*/
public class TranscodeNotificationPreferenceController extends TogglePreferenceController {
@VisibleForTesting
static final String TRANSCODE_NOTIFICATION_SYS_PROP_KEY =
"persist.sys.fuse.transcode_notification";
public TranscodeNotificationPreferenceController(Context context, String preferenceKey) {
super(context, preferenceKey);
}
@Override
public boolean isChecked() {
return SystemProperties.getBoolean(TRANSCODE_NOTIFICATION_SYS_PROP_KEY, true);
}
@Override
public boolean setChecked(boolean isChecked) {
SystemProperties.set(TRANSCODE_NOTIFICATION_SYS_PROP_KEY, String.valueOf(isChecked));
return true;
}
@Override
public int getAvailabilityStatus() {
return AVAILABLE;
}
}

View File

@@ -129,10 +129,11 @@ public class PeakRefreshRatePreferenceController extends TogglePreferenceControl
mDeviceConfigDisplaySettings.stopListening();
}
private float findPeakRefreshRate(Display.Mode[] modes) {
@VisibleForTesting
float findPeakRefreshRate(Display.Mode[] modes) {
float peakRefreshRate = DEFAULT_REFRESH_RATE;
for (Display.Mode mode : modes) {
if (Math.round(mode.getRefreshRate()) > DEFAULT_REFRESH_RATE) {
if (Math.round(mode.getRefreshRate()) > peakRefreshRate) {
peakRefreshRate = mode.getRefreshRate();
}
}

View File

@@ -88,8 +88,8 @@ public class BatterySaverButtonPreferenceController extends
@Override
public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen);
mPreference = (MainSwitchPreference) screen.findPreference(getPreferenceKey());
mPreference.setTitle(mContext.getString(R.string.battery_saver_main_switch_title));
mPreference = screen.findPreference(getPreferenceKey());
mPreference.setTitle(mContext.getString(R.string.battery_saver_master_switch_title));
mPreference.addOnSwitchChangeListener(this);
mPreference.updateStatus(isChecked());
}

View File

@@ -35,6 +35,7 @@ import android.telephony.SubscriptionInfo;
import android.telephony.SubscriptionManager;
import android.telephony.TelephonyDisplayInfo;
import android.telephony.TelephonyManager;
import android.text.Html;
import android.util.ArraySet;
import androidx.annotation.VisibleForTesting;
@@ -255,14 +256,17 @@ public class SubscriptionsPreferenceController extends AbstractPreferenceControl
mUpdateListener.onChildrenUpdated();
}
private String getMobilePreferenceSummary(int subId) {
private CharSequence getMobilePreferenceSummary(int subId) {
String result = mSubsPrefCtrlInjector.getNetworkType(
mContext, mConfig, mTelephonyDisplayInfo, subId);
if (!mTelephonyManager.isDataEnabled()) {
return mContext.getString(R.string.mobile_data_off_summary);
}
if (!result.isEmpty() && mSubsPrefCtrlInjector.isActiveCellularNetwork(mContext)) {
result = mContext.getString(R.string.preference_summary_default_combination,
mContext.getString(R.string.mobile_data_connection_active), result);
}
return result;
return Html.fromHtml(result, Html.FROM_HTML_MODE_LEGACY);
}
private Drawable getIcon(int subId) {

View File

@@ -35,6 +35,7 @@ import androidx.preference.PreferenceScreen;
import com.android.settings.R;
import com.android.settings.network.AllowedNetworkTypesListener;
import com.android.settings.network.SubscriptionsChangeListener;
import com.android.settings.network.telephony.TelephonyConstants.TelephonyManagerConstants;
import java.util.ArrayList;
@@ -47,7 +48,8 @@ import java.util.stream.Stream;
*/
public class EnabledNetworkModePreferenceController extends
TelephonyBasePreferenceController implements
ListPreference.OnPreferenceChangeListener, LifecycleObserver {
ListPreference.OnPreferenceChangeListener, LifecycleObserver,
SubscriptionsChangeListener.SubscriptionsChangeListenerClient {
private static final String LOG_TAG = "EnabledNetworkMode";
private AllowedNetworkTypesListener mAllowedNetworkTypesListener;
@@ -56,9 +58,11 @@ public class EnabledNetworkModePreferenceController extends
private TelephonyManager mTelephonyManager;
private CarrierConfigManager mCarrierConfigManager;
private PreferenceEntriesBuilder mBuilder;
private SubscriptionsChangeListener mSubscriptionsListener;
public EnabledNetworkModePreferenceController(Context context, String key) {
super(context, key);
mSubscriptionsListener = new SubscriptionsChangeListener(context, this);
}
@Override
@@ -85,6 +89,7 @@ public class EnabledNetworkModePreferenceController extends
@OnLifecycleEvent(ON_START)
public void onStart() {
mSubscriptionsListener.start();
if (mAllowedNetworkTypesListener == null) {
return;
}
@@ -93,6 +98,7 @@ public class EnabledNetworkModePreferenceController extends
@OnLifecycleEvent(ON_STOP)
public void onStop() {
mSubscriptionsListener.stop();
if (mAllowedNetworkTypesListener == null) {
return;
}
@@ -196,11 +202,14 @@ public class EnabledNetworkModePreferenceController extends
PreferenceEntriesBuilder(Context context, int subId) {
this.mContext = context;
this.mSubId = subId;
mCarrierConfigManager = mContext.getSystemService(CarrierConfigManager.class);
mTelephonyManager = mContext.getSystemService(TelephonyManager.class)
.createForSubscriptionId(mSubId);
updateConfig();
}
public void updateConfig() {
mTelephonyManager = mTelephonyManager.createForSubscriptionId(mSubId);
final PersistableBundle carrierConfig = mCarrierConfigManager.getConfigForSubId(mSubId);
mAllowed5gNetworkType = checkSupportedRadioBitmask(
mTelephonyManager.getAllowedNetworkTypesForReason(
@@ -214,6 +223,11 @@ public class EnabledNetworkModePreferenceController extends
&& carrierConfig.getBoolean(CarrierConfigManager.KEY_SHOW_CDMA_CHOICES_BOOL);
mShow4gForLTE = carrierConfig != null && carrierConfig.getBoolean(
CarrierConfigManager.KEY_SHOW_4G_FOR_LTE_DATA_ICON_BOOL);
Log.d(LOG_TAG, "PreferenceEntriesBuilder: subId" + mSubId
+ ",Supported5gRadioAccessFamily :" + mSupported5gRadioAccessFamily
+ ",mAllowed5gNetworkType :" + mAllowed5gNetworkType
+ ",IsGlobalCdma :" + mIsGlobalCdma
+ ",Show4gForLTE :" + mShow4gForLTE);
}
void setPreferenceEntries() {
@@ -818,4 +832,13 @@ public class EnabledNetworkModePreferenceController extends
}
}
@Override
public void onAirplaneModeChanged(boolean airplaneModeEnabled) {
}
@Override
public void onSubscriptionsChanged() {
mBuilder.updateConfig();
}
}

View File

@@ -24,6 +24,7 @@ import static com.google.common.truth.Truth.assertThat;
import android.content.Context;
import android.provider.Settings;
import android.view.Display;
import androidx.preference.SwitchPreference;
@@ -102,6 +103,21 @@ public class PeakRefreshRatePreferenceControllerTest {
assertThat(mController.isChecked()).isFalse();
}
@Test
public void findPeakRefreshRate_moreThanOneHigherThanDefault() {
Display.Mode lower = new Display.Mode(0, 0, 0, DEFAULT_REFRESH_RATE - 1);
Display.Mode def = new Display.Mode(0, 0, 0, DEFAULT_REFRESH_RATE);
Display.Mode higher = new Display.Mode(0, 0, 0, DEFAULT_REFRESH_RATE + 1);
Display.Mode higher1 = new Display.Mode(0, 0, 0, DEFAULT_REFRESH_RATE + 2);
assertThat(mController.findPeakRefreshRate(
new Display.Mode[] {lower, def, higher, higher1}))
.isEqualTo(DEFAULT_REFRESH_RATE + 2);
assertThat(mController.findPeakRefreshRate(
new Display.Mode[] {lower, def, higher1, higher}))
.isEqualTo(DEFAULT_REFRESH_RATE + 2);
}
private void enableSmoothDisplayPreference() {
mController.mPeakRefreshRate = 88f;

View File

@@ -0,0 +1,76 @@
/*
* 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.development.transcode;
import static com.android.settings.development.transcode.TranscodeNotificationPreferenceController.TRANSCODE_NOTIFICATION_SYS_PROP_KEY;
import static com.google.common.truth.Truth.assertThat;
import android.content.Context;
import android.os.SystemProperties;
import androidx.test.core.app.ApplicationProvider;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import com.android.settings.core.BasePreferenceController;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@RunWith(AndroidJUnit4.class)
public class TranscodeNotificationPreferenceControllerTest {
private TranscodeNotificationPreferenceController mUnderTest;
@Before
public void setUp() {
Context context = ApplicationProvider.getApplicationContext();
mUnderTest = new TranscodeNotificationPreferenceController(context, "notification_key");
}
@Test
public void isChecked_whenSysPropSet_shouldReturnTrue() {
SystemProperties.set(TRANSCODE_NOTIFICATION_SYS_PROP_KEY, "true");
assertThat(mUnderTest.isChecked()).isTrue();
}
@Test
public void isChecked_whenSysPropUnset_shouldReturnFalse() {
SystemProperties.set(TRANSCODE_NOTIFICATION_SYS_PROP_KEY, "false");
assertThat(mUnderTest.isChecked()).isFalse();
}
@Test
public void setChecked_withTrue_shouldSetSysProp() {
mUnderTest.setChecked(true);
assertThat(
SystemProperties.getBoolean(TRANSCODE_NOTIFICATION_SYS_PROP_KEY, false)).isTrue();
}
@Test
public void setChecked_withFalse_shouldUnsetSysProp() {
mUnderTest.setChecked(false);
assertThat(
SystemProperties.getBoolean(TRANSCODE_NOTIFICATION_SYS_PROP_KEY, true)).isFalse();
}
@Test
public void getAvailabilityStatus_shouldReturn_isAvailable() {
assertThat(mUnderTest.getAvailabilityStatus()).isEqualTo(
BasePreferenceController.AVAILABLE);
}
}

View File

@@ -16,7 +16,6 @@
package com.android.settings.network;
import static android.telephony.SignalStrength.NUM_SIGNAL_STRENGTH_BINS;
import static android.telephony.SignalStrength.SIGNAL_STRENGTH_GOOD;
import static android.telephony.SignalStrength.SIGNAL_STRENGTH_GREAT;
import static android.telephony.SubscriptionManager.INVALID_SUBSCRIPTION_ID;
@@ -24,6 +23,7 @@ import static android.telephony.SubscriptionManager.INVALID_SUBSCRIPTION_ID;
import static com.google.common.truth.Truth.assertThat;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyBoolean;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.ArgumentMatchers.eq;;
import static org.mockito.Mockito.doReturn;
@@ -47,6 +47,7 @@ import android.telephony.SubscriptionInfo;
import android.telephony.SubscriptionManager;
import android.telephony.TelephonyDisplayInfo;
import android.telephony.TelephonyManager;
import android.text.Html;
import androidx.lifecycle.LifecycleOwner;
import androidx.lifecycle.LifecycleRegistry;
@@ -371,14 +372,14 @@ public class SubscriptionsPreferenceControllerTest {
final Preference pref = new Preference(mContext);
final Drawable greatDrawWithoutCutOff = mock(Drawable.class);
doReturn(greatDrawWithoutCutOff).when(sInjector)
.getIcon(mContext, 4, NUM_SIGNAL_STRENGTH_BINS, true);
.getIcon(any(), anyInt(), anyInt(), anyBoolean());
mController.setIcon(pref, 1, true /* isDefaultForData */);
assertThat(pref.getIcon()).isEqualTo(greatDrawWithoutCutOff);
final Drawable greatDrawWithCutOff = mock(Drawable.class);
doReturn(greatDrawWithCutOff).when(sInjector)
.getIcon(mContext, 4, NUM_SIGNAL_STRENGTH_BINS, true);
.getIcon(any(), anyInt(), anyInt(), anyBoolean());
mController.setIcon(pref, 2, false /* isDefaultForData */);
assertThat(pref.getIcon()).isEqualTo(greatDrawWithCutOff);
}
@@ -416,7 +417,8 @@ public class SubscriptionsPreferenceControllerTest {
@Test
@UiThreadTest
public void displayPreference_providerAndHasMultiSimAndActive_connectedAndRat() {
final String expectedSummary = "Connected / 5G";
final CharSequence expectedSummary =
Html.fromHtml("Connected / 5G", Html.FROM_HTML_MODE_LEGACY);
final String networkType = "5G";
final List<SubscriptionInfo> sub = setupMockSubscriptions(2);
doReturn(true).when(sInjector).isProviderModelEnabled(mContext);
@@ -426,6 +428,7 @@ public class SubscriptionsPreferenceControllerTest {
doReturn(mock(MobileMappings.Config.class)).when(sInjector).getConfig(mContext);
doReturn(networkType)
.when(sInjector).getNetworkType(any(), any(), any(), anyInt());
when(mTelephonyManager.isDataEnabled()).thenReturn(true);
mController.onResume();
mController.displayPreference(mPreferenceScreen);
@@ -435,8 +438,11 @@ public class SubscriptionsPreferenceControllerTest {
@Test
@UiThreadTest
public void displayPreference_providerAndHasMultiSimAndNotActive_showRatOnly() {
final String expectedSummary = "5G";
public void displayPreference_providerAndHasMultiSimButMobileDataOff_notAutoConnect() {
final String dataOffSummary =
ResourcesUtils.getResourcesString(mContext, "mobile_data_off_summary");
final CharSequence expectedSummary =
Html.fromHtml(dataOffSummary, Html.FROM_HTML_MODE_LEGACY);
final String networkType = "5G";
final List<SubscriptionInfo> sub = setupMockSubscriptions(2);
doReturn(true).when(sInjector).isProviderModelEnabled(mContext);
@@ -449,6 +455,27 @@ public class SubscriptionsPreferenceControllerTest {
mController.onResume();
mController.displayPreference(mPreferenceScreen);
assertThat(mPreferenceCategory.getPreference(0).getSummary())
.isEqualTo(expectedSummary.toString());
}
@Test
@UiThreadTest
public void displayPreference_providerAndHasMultiSimAndNotActive_showRatOnly() {
final CharSequence expectedSummary = Html.fromHtml("5G", Html.FROM_HTML_MODE_LEGACY);
final String networkType = "5G";
final List<SubscriptionInfo> sub = setupMockSubscriptions(2);
doReturn(true).when(sInjector).isProviderModelEnabled(mContext);
doReturn(sub.get(0)).when(mSubscriptionManager).getDefaultDataSubscriptionInfo();
setupGetIconConditions(sub.get(0).getSubscriptionId(), false, true,
TelephonyManager.DATA_CONNECTED, ServiceState.STATE_IN_SERVICE);
doReturn(networkType)
.when(sInjector).getNetworkType(any(), any(), any(), anyInt());
when(mTelephonyManager.isDataEnabled()).thenReturn(true);
mController.onResume();
mController.displayPreference(mPreferenceScreen);
assertThat(mPreferenceCategory.getPreference(0).getSummary()).isEqualTo(expectedSummary);
}
@@ -467,7 +494,8 @@ public class SubscriptionsPreferenceControllerTest {
@Test
@UiThreadTest
public void onTelephonyDisplayInfoChanged_providerAndHasMultiSimAndActive_connectedAndRat() {
final String expectedSummary = "Connected / LTE";
final CharSequence expectedSummary =
Html.fromHtml("Connected / LTE", Html.FROM_HTML_MODE_LEGACY);
final String networkType = "LTE";
final List<SubscriptionInfo> sub = setupMockSubscriptions(2);
final TelephonyDisplayInfo telephonyDisplayInfo =
@@ -480,6 +508,7 @@ public class SubscriptionsPreferenceControllerTest {
doReturn(mock(MobileMappings.Config.class)).when(sInjector).getConfig(mContext);
doReturn(networkType)
.when(sInjector).getNetworkType(any(), any(), any(), anyInt());
when(mTelephonyManager.isDataEnabled()).thenReturn(true);
mController.onResume();
mController.displayPreference(mPreferenceScreen);
@@ -491,7 +520,8 @@ public class SubscriptionsPreferenceControllerTest {
@Test
@UiThreadTest
public void onTelephonyDisplayInfoChanged_providerAndHasMultiSimAndNotActive_showRat() {
final String expectedSummary = "LTE";
final CharSequence expectedSummary =
Html.fromHtml("LTE", Html.FROM_HTML_MODE_LEGACY);
final String networkType = "LTE";
final List<SubscriptionInfo> sub = setupMockSubscriptions(2);
final TelephonyDisplayInfo telephonyDisplayInfo =
@@ -504,6 +534,7 @@ public class SubscriptionsPreferenceControllerTest {
doReturn(mock(MobileMappings.Config.class)).when(sInjector).getConfig(mContext);
doReturn(networkType)
.when(sInjector).getNetworkType(any(), any(), any(), anyInt());
when(mTelephonyManager.isDataEnabled()).thenReturn(true);
mController.onResume();
mController.displayPreference(mPreferenceScreen);

View File

@@ -22,6 +22,8 @@ import static com.google.common.truth.Truth.assertThat;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import android.content.Context;
@@ -117,4 +119,27 @@ public final class Enable2gPreferenceControllerTest {
assertThat(mController.getAvailabilityStatus()).isEqualTo(AVAILABLE);
}
@Test
public void onPreferenceChange_update() {
// Set "Enable 2G" flag to "on"
when(mTelephonyManager.getAllowedNetworkTypesForReason(
TelephonyManager.ALLOWED_NETWORK_TYPES_REASON_ENABLE_2G)).thenReturn(
(long) (TelephonyManager.NETWORK_TYPE_BITMASK_GSM
| TelephonyManager.NETWORK_TYPE_BITMASK_LTE));
// Setup state to allow disabling
doReturn(true).when(mTelephonyManager).isRadioInterfaceCapabilitySupported(
mTelephonyManager.CAPABILITY_ALLOWED_NETWORK_TYPES_USED);
mPersistableBundle.putBoolean(CarrierConfigManager.KEY_HIDE_ENABLE_2G,
false);
// Disable 2G
boolean changed = mController.setChecked(false);
assertThat(changed).isEqualTo(true);
verify(mTelephonyManager, times(1)).setAllowedNetworkTypesForReason(
TelephonyManager.ALLOWED_NETWORK_TYPES_REASON_ENABLE_2G,
TelephonyManager.NETWORK_TYPE_BITMASK_LTE);
}
}