Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b6be744b authored by songferngwang's avatar songferngwang
Browse files

Modify the preferredSimDialogFragment

After the telephony flag resetPrimarySimDefaultValues on, the telephony
set the preferred default subscription to remaining sim. Therefore, here
can ask whether the user uses [remaining SIM] for mobile data or not

Bug: 349783684
Test: remove the sim card, and settings show "use mobile data" dialog
Flag: EXEMPT bugfix
Change-Id: I5e3399e777bf1e8ef7998074082e55635eb23eb4
parent c537bfa8
Loading
Loading
Loading
Loading
+3 −4
Original line number Diff line number Diff line
@@ -3058,10 +3058,9 @@
    <string name="sim_change_data_ok">
        Use <xliff:g id="carrier" example="Verizon">%1$s</xliff:g>
    </string>
    <!-- Title for the dialog asking to user to change the preferred SIM  [CHAR LIMIT=30] -->
    <string name="sim_preferred_title">Update preferred SIM?</string>
    <!-- Message for the dialog asking to user to change the preferred SIM  [CHAR LIMIT=NONE] -->
    <string name="sim_preferred_message"><xliff:g id="new_sim">%1$s</xliff:g> is the only SIM in your device. Do you want to use this SIM for mobile data, calls, and SMS messages?</string>
    <string name="sim_preferred_message"><xliff:g id="new_sim">%1$s</xliff:g> is now your primary SIM</string>
    <!-- Title for the dialog asking user to enable auto data switch upon enabling multi-SIM  [CHAR LIMIT=30] -->
    <string name="enable_auto_data_switch_dialog_title">Improve mobile data coverage?</string>
@@ -7563,7 +7562,7 @@
    <string name="select_sim_for_sms">Select a SIM for SMS</string>
    <!-- Message for switching data SIM; switching takes a while -->
    <string name="data_switch_started">Switching data SIM, this may take up to a minute\u2026</string>
    <!-- Title for selecting specific sim for data in settings.  [CHAR LIMIT=40] -->
    <!-- Title for selecting specific sim/preferred sim for data in settings.  [CHAR LIMIT=40] -->
    <string name="select_specific_sim_for_data_title">Use <xliff:g id="new_sim" example="carrierA">%1$s</xliff:g> for mobile data?</string>
    <!-- Message for selecting specific sim for data in settings.  [CHAR LIMIT=NONE] -->
    <string name="select_specific_sim_for_data_msg">If you switch to <xliff:g id="new_sim" example="carrierA">%1$s</xliff:g>, <xliff:g id="old_sim" example="carrierB">%2$s</xliff:g> will no longer be used for mobile data.</string>
+12 −5
Original line number Diff line number Diff line
@@ -37,8 +37,8 @@ import com.android.settings.R;
import com.android.settings.network.SubscriptionUtil;

/**
 * Presents a dialog asking the user if they want to update all services to use a given "preferred"
 * SIM. Typically this would be used in a case where a device goes from having multiple SIMs down to
 * After androidV, presents a dialog asking the user if they want to update the mobile data.
 * Typically this would be used in a case where a device goes from having multiple SIMs down to
 * only one.
 */
public class PreferredSimDialogFragment extends SimDialogFragment implements
@@ -48,7 +48,7 @@ public class PreferredSimDialogFragment extends SimDialogFragment implements
    public static PreferredSimDialogFragment newInstance() {
        final PreferredSimDialogFragment fragment = new PreferredSimDialogFragment();
        final Bundle args = initArguments(SimDialogActivity.PREFERRED_PICK,
                R.string.sim_preferred_title);
                R.string.select_specific_sim_for_data_title);
        fragment.setArguments(args);
        return fragment;
    }
@@ -57,7 +57,6 @@ public class PreferredSimDialogFragment extends SimDialogFragment implements
    @Override
    public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) {
        final AlertDialog dialog = new AlertDialog.Builder(getContext())
                .setTitle(getTitleResId())
                .setPositiveButton(R.string.yes, this)
                .setNegativeButton(R.string.no, null)
                .create();
@@ -104,10 +103,18 @@ public class PreferredSimDialogFragment extends SimDialogFragment implements
            dismiss();
            return;
        }
        Log.d(TAG, "SubscriptionInfo: " + info);
        final CharSequence simName =
                SubscriptionUtil.getUniqueSubscriptionDisplayName(info, getContext());
        final String title =
                getContext().getString(
                        getTitleResId(),
                        simName);
        final String message =
                getContext().getString(
                        R.string.sim_preferred_message,
                        SubscriptionUtil.getUniqueSubscriptionDisplayName(info, getContext()));
                        simName);
        dialog.setTitle(title);
        dialog.setMessage(message);
    }

+1 −2
Original line number Diff line number Diff line
@@ -122,6 +122,7 @@ public class SimDialogActivity extends FragmentActivity {

    private void showOrUpdateDialog() {
        final int dialogType = getIntent().getIntExtra(DIALOG_TYPE_KEY, INVALID_PICK);
        Log.d(TAG, "dialogType:" + dialogType);

        if (dialogType == PICK_DISMISS) {
            finishAndRemoveTask();
@@ -379,8 +380,6 @@ public class SimDialogActivity extends FragmentActivity {

    private void setPreferredSim(final int subId) {
        setDefaultDataSubId(subId);
        setDefaultSmsSubId(subId);
        setDefaultCallsSubId(subId);
    }

    private PhoneAccountHandle subscriptionIdToPhoneAccountHandle(final int subId) {