Loading src/com/android/settings/network/MobileNetworkListFragment.java +6 −1 Original line number Diff line number Diff line Loading @@ -60,6 +60,10 @@ public class MobileNetworkListFragment extends DashboardFragment { @Override protected List<AbstractPreferenceController> createPreferenceControllers(Context context) { final List<AbstractPreferenceController> controllers = new ArrayList<>(); if (!SubscriptionUtil.isSimHardwareVisible(getContext())) { finishFragment(); return controllers; } NetworkProviderSimsCategoryController simCategoryPrefCtrl = new NetworkProviderSimsCategoryController(context, KEY_PREFERENCE_CATEGORY_SIM, Loading Loading @@ -88,7 +92,8 @@ public class MobileNetworkListFragment extends DashboardFragment { @Override protected boolean isPageSearchEnabled(Context context) { return context.getSystemService(UserManager.class).isAdminUser(); return SubscriptionUtil.isSimHardwareVisible(context) && context.getSystemService(UserManager.class).isAdminUser(); } }; } src/com/android/settings/network/telephony/MobileNetworkSettings.java +6 −1 Original line number Diff line number Diff line Loading @@ -120,6 +120,10 @@ public class MobileNetworkSettings extends AbstractMobileNetworkSettings { @Override protected List<AbstractPreferenceController> createPreferenceControllers(Context context) { if (!SubscriptionUtil.isSimHardwareVisible(context)) { finishFragment(); return Arrays.asList(); } if (getArguments() == null) { Intent intent = getIntent(); if (intent != null) { Loading Loading @@ -398,7 +402,8 @@ public class MobileNetworkSettings extends AbstractMobileNetworkSettings { /** suppress full page if user is not admin */ @Override protected boolean isPageSearchEnabled(Context context) { return context.getSystemService(UserManager.class).isAdminUser(); return SubscriptionUtil.isSimHardwareVisible(context) && context.getSystemService(UserManager.class).isAdminUser(); } }; Loading src/com/android/settings/network/telephony/MobileNetworkUtils.java +7 −0 Original line number Diff line number Diff line Loading @@ -264,6 +264,9 @@ public class MobileNetworkUtils { * the user has enabled development mode. */ public static boolean showEuiccSettings(Context context) { if (!SubscriptionUtil.isSimHardwareVisible(context)) { return false; } long timeForAccess = SystemClock.elapsedRealtime(); try { Boolean isShow = ((Future<Boolean>) ThreadUtils.postOnBackgroundThread(() -> { Loading Loading @@ -1015,6 +1018,10 @@ public class MobileNetworkUtils { } public static void launchMobileNetworkSettings(Context context, SubscriptionInfo info) { if (!SubscriptionUtil.isSimHardwareVisible(context)) { Log.e(TAG, "launchMobileNetworkSettings fail, device without such UI."); return; } final int subId = info.getSubscriptionId(); if (subId == SubscriptionManager.INVALID_SUBSCRIPTION_ID) { Log.d(TAG, "launchMobileNetworkSettings fail, subId is invalid."); Loading tests/robotests/src/com/android/settings/network/MobileNetworkListFragmentTest.java +10 −0 Original line number Diff line number Diff line Loading @@ -21,8 +21,10 @@ import static com.google.common.truth.Truth.assertThat; import static org.mockito.Mockito.when; import android.content.Context; import android.content.res.Resources; import android.os.UserManager; import com.android.settings.R; import com.android.settings.search.BaseSearchIndexProvider; import org.junit.Before; Loading @@ -38,6 +40,8 @@ public class MobileNetworkListFragmentTest { @Mock private Context mContext; @Mock private Resources mResources; @Mock private UserManager mUserManager; private MobileNetworkListFragment mFragment; Loading @@ -55,6 +59,9 @@ public class MobileNetworkListFragmentTest { final BaseSearchIndexProvider provider = (BaseSearchIndexProvider) mFragment.SEARCH_INDEX_DATA_PROVIDER; when(mContext.getResources()).thenReturn(mResources); when(mResources.getBoolean(R.bool.config_show_sim_info)).thenReturn(true); final Object obj = ReflectionHelpers.callInstanceMethod(provider, "isPageSearchEnabled", ReflectionHelpers.ClassParameter.from(Context.class, mContext)); final boolean isEnabled = (Boolean) obj; Loading @@ -69,6 +76,9 @@ public class MobileNetworkListFragmentTest { final BaseSearchIndexProvider provider = (BaseSearchIndexProvider) mFragment.SEARCH_INDEX_DATA_PROVIDER; when(mContext.getResources()).thenReturn(mResources); when(mResources.getBoolean(R.bool.config_show_sim_info)).thenReturn(true); final Object obj = ReflectionHelpers.callInstanceMethod(provider, "isPageSearchEnabled", ReflectionHelpers.ClassParameter.from(Context.class, mContext)); final boolean isEnabled = (Boolean) obj; Loading tests/robotests/src/com/android/settings/network/telephony/MobileNetworkSettingsTest.java +8 −0 Original line number Diff line number Diff line Loading @@ -29,6 +29,7 @@ import static org.mockito.Mockito.when; import android.app.Activity; import android.app.usage.NetworkStatsManager; import android.content.Context; import android.content.res.Resources; import android.net.NetworkPolicyManager; import android.os.Bundle; import android.os.UserManager; Loading @@ -37,6 +38,7 @@ import android.telephony.TelephonyManager; import androidx.fragment.app.FragmentActivity; import com.android.settings.R; import com.android.settings.datausage.DataUsageSummaryPreferenceController; import com.android.settings.search.BaseSearchIndexProvider; import com.android.settings.testutils.shadow.ShadowEntityHeaderController; Loading Loading @@ -68,12 +70,18 @@ public class MobileNetworkSettingsTest { private FragmentActivity mActivity; private Context mContext; private Resources mResources; private MobileNetworkSettings mFragment; @Before public void setUp() { MockitoAnnotations.initMocks(this); mContext = spy(RuntimeEnvironment.application); mResources = spy(mContext.getResources()); when(mContext.getResources()).thenReturn(mResources); when(mResources.getBoolean(R.bool.config_show_sim_info)).thenReturn(true); when(mActivity.getSystemService(TelephonyManager.class)).thenReturn(mTelephonyManager); when(mTelephonyManager.createForSubscriptionId(anyInt())).thenReturn(mTelephonyManager); when(mContext.getSystemService(NetworkStatsManager.class)).thenReturn(mNetworkStatsManager); Loading Loading
src/com/android/settings/network/MobileNetworkListFragment.java +6 −1 Original line number Diff line number Diff line Loading @@ -60,6 +60,10 @@ public class MobileNetworkListFragment extends DashboardFragment { @Override protected List<AbstractPreferenceController> createPreferenceControllers(Context context) { final List<AbstractPreferenceController> controllers = new ArrayList<>(); if (!SubscriptionUtil.isSimHardwareVisible(getContext())) { finishFragment(); return controllers; } NetworkProviderSimsCategoryController simCategoryPrefCtrl = new NetworkProviderSimsCategoryController(context, KEY_PREFERENCE_CATEGORY_SIM, Loading Loading @@ -88,7 +92,8 @@ public class MobileNetworkListFragment extends DashboardFragment { @Override protected boolean isPageSearchEnabled(Context context) { return context.getSystemService(UserManager.class).isAdminUser(); return SubscriptionUtil.isSimHardwareVisible(context) && context.getSystemService(UserManager.class).isAdminUser(); } }; }
src/com/android/settings/network/telephony/MobileNetworkSettings.java +6 −1 Original line number Diff line number Diff line Loading @@ -120,6 +120,10 @@ public class MobileNetworkSettings extends AbstractMobileNetworkSettings { @Override protected List<AbstractPreferenceController> createPreferenceControllers(Context context) { if (!SubscriptionUtil.isSimHardwareVisible(context)) { finishFragment(); return Arrays.asList(); } if (getArguments() == null) { Intent intent = getIntent(); if (intent != null) { Loading Loading @@ -398,7 +402,8 @@ public class MobileNetworkSettings extends AbstractMobileNetworkSettings { /** suppress full page if user is not admin */ @Override protected boolean isPageSearchEnabled(Context context) { return context.getSystemService(UserManager.class).isAdminUser(); return SubscriptionUtil.isSimHardwareVisible(context) && context.getSystemService(UserManager.class).isAdminUser(); } }; Loading
src/com/android/settings/network/telephony/MobileNetworkUtils.java +7 −0 Original line number Diff line number Diff line Loading @@ -264,6 +264,9 @@ public class MobileNetworkUtils { * the user has enabled development mode. */ public static boolean showEuiccSettings(Context context) { if (!SubscriptionUtil.isSimHardwareVisible(context)) { return false; } long timeForAccess = SystemClock.elapsedRealtime(); try { Boolean isShow = ((Future<Boolean>) ThreadUtils.postOnBackgroundThread(() -> { Loading Loading @@ -1015,6 +1018,10 @@ public class MobileNetworkUtils { } public static void launchMobileNetworkSettings(Context context, SubscriptionInfo info) { if (!SubscriptionUtil.isSimHardwareVisible(context)) { Log.e(TAG, "launchMobileNetworkSettings fail, device without such UI."); return; } final int subId = info.getSubscriptionId(); if (subId == SubscriptionManager.INVALID_SUBSCRIPTION_ID) { Log.d(TAG, "launchMobileNetworkSettings fail, subId is invalid."); Loading
tests/robotests/src/com/android/settings/network/MobileNetworkListFragmentTest.java +10 −0 Original line number Diff line number Diff line Loading @@ -21,8 +21,10 @@ import static com.google.common.truth.Truth.assertThat; import static org.mockito.Mockito.when; import android.content.Context; import android.content.res.Resources; import android.os.UserManager; import com.android.settings.R; import com.android.settings.search.BaseSearchIndexProvider; import org.junit.Before; Loading @@ -38,6 +40,8 @@ public class MobileNetworkListFragmentTest { @Mock private Context mContext; @Mock private Resources mResources; @Mock private UserManager mUserManager; private MobileNetworkListFragment mFragment; Loading @@ -55,6 +59,9 @@ public class MobileNetworkListFragmentTest { final BaseSearchIndexProvider provider = (BaseSearchIndexProvider) mFragment.SEARCH_INDEX_DATA_PROVIDER; when(mContext.getResources()).thenReturn(mResources); when(mResources.getBoolean(R.bool.config_show_sim_info)).thenReturn(true); final Object obj = ReflectionHelpers.callInstanceMethod(provider, "isPageSearchEnabled", ReflectionHelpers.ClassParameter.from(Context.class, mContext)); final boolean isEnabled = (Boolean) obj; Loading @@ -69,6 +76,9 @@ public class MobileNetworkListFragmentTest { final BaseSearchIndexProvider provider = (BaseSearchIndexProvider) mFragment.SEARCH_INDEX_DATA_PROVIDER; when(mContext.getResources()).thenReturn(mResources); when(mResources.getBoolean(R.bool.config_show_sim_info)).thenReturn(true); final Object obj = ReflectionHelpers.callInstanceMethod(provider, "isPageSearchEnabled", ReflectionHelpers.ClassParameter.from(Context.class, mContext)); final boolean isEnabled = (Boolean) obj; Loading
tests/robotests/src/com/android/settings/network/telephony/MobileNetworkSettingsTest.java +8 −0 Original line number Diff line number Diff line Loading @@ -29,6 +29,7 @@ import static org.mockito.Mockito.when; import android.app.Activity; import android.app.usage.NetworkStatsManager; import android.content.Context; import android.content.res.Resources; import android.net.NetworkPolicyManager; import android.os.Bundle; import android.os.UserManager; Loading @@ -37,6 +38,7 @@ import android.telephony.TelephonyManager; import androidx.fragment.app.FragmentActivity; import com.android.settings.R; import com.android.settings.datausage.DataUsageSummaryPreferenceController; import com.android.settings.search.BaseSearchIndexProvider; import com.android.settings.testutils.shadow.ShadowEntityHeaderController; Loading Loading @@ -68,12 +70,18 @@ public class MobileNetworkSettingsTest { private FragmentActivity mActivity; private Context mContext; private Resources mResources; private MobileNetworkSettings mFragment; @Before public void setUp() { MockitoAnnotations.initMocks(this); mContext = spy(RuntimeEnvironment.application); mResources = spy(mContext.getResources()); when(mContext.getResources()).thenReturn(mResources); when(mResources.getBoolean(R.bool.config_show_sim_info)).thenReturn(true); when(mActivity.getSystemService(TelephonyManager.class)).thenReturn(mTelephonyManager); when(mTelephonyManager.createForSubscriptionId(anyInt())).thenReturn(mTelephonyManager); when(mContext.getSystemService(NetworkStatsManager.class)).thenReturn(mNetworkStatsManager); Loading