Skip to content

Commit

Permalink
Merge "[Settings][Back port] configuration for hidding SIM remove UI"…
Browse files Browse the repository at this point in the history
… into tm-qpr-dev
  • Loading branch information
Bonian Chen authored and Android (Google) Code Review committed Nov 7, 2022
2 parents ab2e7bf + a964b09 commit 15f0cd6
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 3 deletions.
1 change: 1 addition & 0 deletions res/xml/reset_dashboard_fragment.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
<Preference
android:key="erase_euicc_data"
android:title="@string/reset_esim_title"
settings:isPreferenceVisible="@bool/config_show_sim_info"
settings:controller="com.android.settings.network.EraseEuiccDataController" />

<!-- Factory reset -->
Expand Down
11 changes: 10 additions & 1 deletion src/com/android/settings/MainClear.java
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@

import com.android.settings.core.InstrumentedFragment;
import com.android.settings.enterprise.ActionDisabledByAdminDialogHelper;
import com.android.settings.network.SubscriptionUtil;
import com.android.settings.password.ChooseLockSettingsHelper;
import com.android.settings.password.ConfirmLockPattern;
import com.android.settingslib.RestrictedLockUtilsInternal;
Expand Down Expand Up @@ -381,6 +382,14 @@ public void onScrollChange(View v, int scrollX, int scrollY, int oldScrollX,
mScrollView.getViewTreeObserver().addOnGlobalLayoutListener(this);
}

/**
* Whether to show any UI which is SIM related.
*/
@VisibleForTesting
boolean showAnySubscriptionInfo(Context context) {
return (context != null) && SubscriptionUtil.isSimHardwareVisible(context);
}

/**
* Whether to show strings indicating that the eUICC will be wiped.
*
Expand All @@ -390,7 +399,7 @@ public void onScrollChange(View v, int scrollX, int scrollY, int oldScrollX,
@VisibleForTesting
boolean showWipeEuicc() {
Context context = getContext();
if (!isEuiccEnabled(context)) {
if (!showAnySubscriptionInfo(context) || !isEuiccEnabled(context)) {
return false;
}
ContentResolver cr = context.getContentResolver();
Expand Down
3 changes: 3 additions & 0 deletions src/com/android/settings/ResetNetwork.java
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,9 @@ public void onClick(View v) {
}

private List<SubscriptionInfo> getActiveSubscriptionInfoList() {
if (!SubscriptionUtil.isSimHardwareVisible(getActivity())) {
return Collections.emptyList();
}
SubscriptionManager mgr = getActivity().getSystemService(SubscriptionManager.class);
if (mgr == null) {
Log.w(TAG, "No SubscriptionManager");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ public boolean handlePreferenceTreeClick(Preference preference) {

@Override
public int getAvailabilityStatus() {
return mContext.getPackageManager().hasSystemFeature(
return SubscriptionUtil.isSimHardwareVisible(mContext) &&
mContext.getPackageManager().hasSystemFeature(
PackageManager.FEATURE_TELEPHONY_EUICC) ? AVAILABLE_UNSEARCHABLE
: UNSUPPORTED_ON_DEVICE;
}
Expand Down
5 changes: 4 additions & 1 deletion tests/robotests/src/com/android/settings/MainClearTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,10 @@ public class MainClearTest {
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
mMainClear = spy(new MainClear());
mMainClear = spy(new MainClear() {
@Override
boolean showAnySubscriptionInfo(Context context) { return true; }
});
mActivity = Robolectric.setupActivity(FragmentActivity.class);
mShadowActivity = Shadows.shadowOf(mActivity);
UserManager userManager = mActivity.getSystemService(UserManager.class);
Expand Down

0 comments on commit 15f0cd6

Please sign in to comment.