Merge "[Provider Model] Show all carrier's name on MobileNetworkSummaryController's summary"
This commit is contained in:
43
res/drawable/ic_sim_card.xml
Normal file
43
res/drawable/ic_sim_card.xml
Normal file
@@ -0,0 +1,43 @@
|
||||
<!--
|
||||
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.
|
||||
-->
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="20dp"
|
||||
android:height="20dp"
|
||||
android:viewportWidth="20"
|
||||
android:viewportHeight="20"
|
||||
android:tint="?attr/colorControlNormal">
|
||||
<path
|
||||
android:fillColor="@android:color/white"
|
||||
android:pathData="M14.5,2H8L4,6v10.5C4,17.33 4.67,18 5.5,18h9c0.83,0 1.5,-0.67 1.5,-1.5v-13C16,2.67 15.33,2 14.5,2zM14.5,16.5h-9V6.62L8.62,3.5h5.88V16.5z"/>
|
||||
<path
|
||||
android:fillColor="@android:color/white"
|
||||
android:pathData="M6.5,9h1.5v3h-1.5z"/>
|
||||
<path
|
||||
android:fillColor="@android:color/white"
|
||||
android:pathData="M6.5,13.5h1.5v1.5h-1.5z"/>
|
||||
<path
|
||||
android:fillColor="@android:color/white"
|
||||
android:pathData="M12,13.5h1.5v1.5h-1.5z"/>
|
||||
<path
|
||||
android:fillColor="@android:color/white"
|
||||
android:pathData="M9.25,9h1.5v1.5h-1.5z"/>
|
||||
<path
|
||||
android:fillColor="@android:color/white"
|
||||
android:pathData="M12,9h1.5v3h-1.5z"/>
|
||||
<path
|
||||
android:fillColor="@android:color/white"
|
||||
android:pathData="M9.25,12h1.5v3h-1.5z"/>
|
||||
</vector>
|
@@ -48,7 +48,7 @@
|
||||
android:key="mobile_network_list"
|
||||
android:title="@string/provider_network_settings_title"
|
||||
android:summary="@string/summary_placeholder"
|
||||
android:icon="@drawable/ic_network_cell"
|
||||
android:icon="@drawable/ic_sim_card"
|
||||
android:order="-15"
|
||||
settings:keywords="@string/keywords_more_mobile_networks"
|
||||
settings:userRestriction="no_config_mobile_networks"
|
||||
|
@@ -45,6 +45,7 @@ import com.android.settingslib.core.AbstractPreferenceController;
|
||||
import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class MobileNetworkSummaryController extends AbstractPreferenceController implements
|
||||
SubscriptionsChangeListener.SubscriptionsChangeListenerClient, LifecycleObserver,
|
||||
@@ -124,12 +125,20 @@ public class MobileNetworkSummaryController extends AbstractPreferenceController
|
||||
return subs.get(0).getDisplayName();
|
||||
}
|
||||
} else {
|
||||
if (com.android.settings.Utils.isProviderModelEnabled(mContext)) {
|
||||
return getSummaryForProviderModel(subs);
|
||||
}
|
||||
final int count = subs.size();
|
||||
return mContext.getResources().getQuantityString(R.plurals.mobile_network_summary_count,
|
||||
count, count);
|
||||
}
|
||||
}
|
||||
|
||||
private CharSequence getSummaryForProviderModel(List<SubscriptionInfo> subs) {
|
||||
return String.join(", ", subs.stream().map(SubscriptionInfo::getDisplayName)
|
||||
.collect(Collectors.toList()));
|
||||
}
|
||||
|
||||
private void startAddSimFlow() {
|
||||
final Intent intent = new Intent(EuiccManager.ACTION_PROVISION_EMBEDDED_SUBSCRIPTION);
|
||||
intent.putExtra(EuiccManager.EXTRA_FORCE_PROVISION, true);
|
||||
|
@@ -23,6 +23,7 @@ import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.ArgumentMatchers.notNull;
|
||||
import static org.mockito.Mockito.atLeastOnce;
|
||||
import static org.mockito.Mockito.doNothing;
|
||||
import static org.mockito.Mockito.doReturn;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.never;
|
||||
import static org.mockito.Mockito.spy;
|
||||
@@ -39,10 +40,12 @@ import android.telephony.SubscriptionManager;
|
||||
import android.telephony.TelephonyManager;
|
||||
import android.telephony.euicc.EuiccManager;
|
||||
import android.text.TextUtils;
|
||||
import android.util.FeatureFlagUtils;
|
||||
|
||||
import androidx.lifecycle.Lifecycle;
|
||||
import androidx.preference.PreferenceScreen;
|
||||
|
||||
import com.android.settings.core.FeatureFlags;
|
||||
import com.android.settings.network.telephony.MobileNetworkActivity;
|
||||
import com.android.settings.widget.AddPreference;
|
||||
import com.android.settingslib.RestrictedLockUtils;
|
||||
@@ -61,7 +64,6 @@ import org.robolectric.RuntimeEnvironment;
|
||||
import java.util.Arrays;
|
||||
|
||||
@RunWith(RobolectricTestRunner.class)
|
||||
@Ignore
|
||||
public class MobileNetworkSummaryControllerTest {
|
||||
@Mock
|
||||
private Lifecycle mLifecycle;
|
||||
@@ -84,10 +86,11 @@ public class MobileNetworkSummaryControllerTest {
|
||||
public void setUp() {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
mContext = spy(RuntimeEnvironment.application);
|
||||
when(mContext.getSystemService(TelephonyManager.class)).thenReturn(mTelephonyManager);
|
||||
when(mContext.getSystemService(SubscriptionManager.class)).thenReturn(mSubscriptionManager);
|
||||
when(mContext.getSystemService(EuiccManager.class)).thenReturn(mEuiccManager);
|
||||
when(mContext.getSystemService(UserManager.class)).thenReturn(mUserManager);
|
||||
doReturn(mTelephonyManager).when(mContext).getSystemService(TelephonyManager.class);
|
||||
doReturn(mSubscriptionManager).when(mContext).getSystemService(SubscriptionManager.class);
|
||||
doReturn(mEuiccManager).when(mContext).getSystemService(EuiccManager.class);
|
||||
doReturn(mUserManager).when(mContext).getSystemService(UserManager.class);
|
||||
|
||||
when(mTelephonyManager.getNetworkCountryIso()).thenReturn("");
|
||||
when(mSubscriptionManager.isActiveSubscriptionId(anyInt())).thenReturn(true);
|
||||
when(mEuiccManager.isEnabled()).thenReturn(true);
|
||||
@@ -211,6 +214,7 @@ public class MobileNetworkSummaryControllerTest {
|
||||
|
||||
@Test
|
||||
public void getSummary_twoSubscriptions_correctSummaryAndFragment() {
|
||||
FeatureFlagUtils.setEnabled(mContext, FeatureFlagUtils.SETTINGS_PROVIDER_MODEL, false);
|
||||
final SubscriptionInfo sub1 = mock(SubscriptionInfo.class);
|
||||
final SubscriptionInfo sub2 = mock(SubscriptionInfo.class);
|
||||
when(sub1.getSubscriptionId()).thenReturn(1);
|
||||
@@ -225,6 +229,7 @@ public class MobileNetworkSummaryControllerTest {
|
||||
|
||||
@Test
|
||||
public void getSummaryAfterUpdate_twoSubscriptionsBecomesOne_correctSummaryAndFragment() {
|
||||
FeatureFlagUtils.setEnabled(mContext, FeatureFlagUtils.SETTINGS_PROVIDER_MODEL, false);
|
||||
final SubscriptionInfo sub1 = mock(SubscriptionInfo.class);
|
||||
final SubscriptionInfo sub2 = mock(SubscriptionInfo.class);
|
||||
when(sub1.getSubscriptionId()).thenReturn(1);
|
||||
@@ -253,6 +258,7 @@ public class MobileNetworkSummaryControllerTest {
|
||||
|
||||
@Test
|
||||
public void getSummaryAfterUpdate_oneSubscriptionBecomesTwo_correctSummaryAndFragment() {
|
||||
FeatureFlagUtils.setEnabled(mContext, FeatureFlagUtils.SETTINGS_PROVIDER_MODEL, false);
|
||||
final SubscriptionInfo sub1 = mock(SubscriptionInfo.class);
|
||||
final SubscriptionInfo sub2 = mock(SubscriptionInfo.class);
|
||||
when(sub1.getSubscriptionId()).thenReturn(1);
|
||||
@@ -279,6 +285,27 @@ public class MobileNetworkSummaryControllerTest {
|
||||
assertThat(mPreference.getFragment()).isEqualTo(MobileNetworkListFragment.class.getName());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getSummary_providerModel_Enabled() {
|
||||
final SubscriptionInfo sub1 = mock(SubscriptionInfo.class);
|
||||
final SubscriptionInfo sub2 = mock(SubscriptionInfo.class);
|
||||
when(sub1.getSubscriptionId()).thenReturn(1);
|
||||
when(sub2.getSubscriptionId()).thenReturn(2);
|
||||
when(sub1.getDisplayName()).thenReturn("sub1");
|
||||
when(sub2.getDisplayName()).thenReturn("sub2");
|
||||
|
||||
SubscriptionUtil.setAvailableSubscriptionsForTesting(Arrays.asList(sub1, sub2));
|
||||
FeatureFlagUtils.setEnabled(mContext, FeatureFlagUtils.SETTINGS_PROVIDER_MODEL, true);
|
||||
mController.displayPreference(mPreferenceScreen);
|
||||
mController.onResume();
|
||||
assertThat(mController.getSummary()).isEqualTo("sub1, sub2");
|
||||
|
||||
FeatureFlagUtils.setEnabled(mContext, FeatureFlagUtils.SETTINGS_PROVIDER_MODEL, false);
|
||||
mController.displayPreference(mPreferenceScreen);
|
||||
mController.onResume();
|
||||
assertThat(mController.getSummary()).isEqualTo("2 SIMs");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void addButton_noSubscriptionsNoEuiccMgr_noAddClickListener() {
|
||||
when(mEuiccManager.isEnabled()).thenReturn(false);
|
||||
|
Reference in New Issue
Block a user