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

Commit e6708df1 authored by Wenyi Wang's avatar Wenyi Wang Committed by Android (Google) Code Review
Browse files

Merge "Enable importing from SIM on pre-(L-MR1) SDKs" into ub-contactsdialer-b-dev

parents abf5ba95 13d952e1
Loading
Loading
Loading
Loading
+30 −20
Original line number Diff line number Diff line
@@ -42,6 +42,7 @@ import android.widget.TextView;
import android.widget.Toast;

import com.android.contacts.common.R;
import com.android.contacts.common.compat.CompatUtils;
import com.android.contacts.common.compat.PhoneNumberUtilsCompat;
import com.android.contacts.common.editor.SelectAccountDialogFragment;
import com.android.contacts.common.model.AccountTypeManager;
@@ -126,13 +127,13 @@ public class ImportExportDialogFragment extends DialogFragment

        final TelephonyManager manager =
                (TelephonyManager) getActivity().getSystemService(Context.TELEPHONY_SERVICE);

        mSubscriptionManager = SubscriptionManager.from(getActivity());

        if (res.getBoolean(R.bool.config_allow_import_from_vcf_file)) {
            adapter.add(new AdapterEntry(getString(R.string.import_from_vcf_file),
                    R.string.import_from_vcf_file));
        }

        if (CompatUtils.isMSIMCompatible()) {
            mSubscriptionManager = SubscriptionManager.from(getActivity());
            if (manager != null && res.getBoolean(R.bool.config_allow_sim_import)) {
                List<SubscriptionInfo> subInfoRecords = null;
                try {
@@ -153,6 +154,14 @@ public class ImportExportDialogFragment extends DialogFragment
                    }
                }
            }
        } else {
            if (manager != null && manager.hasIccCard()
                    && res.getBoolean(R.bool.config_allow_sim_import)) {
                adapter.add(new AdapterEntry(getString(R.string.import_from_sim),
                        R.string.import_from_sim, -1));
            }
        }

        if (res.getBoolean(R.bool.config_allow_export)) {
            if (contactsAreAvailable) {
                adapter.add(new AdapterEntry(getString(R.string.export_to_vcf_file),
@@ -288,7 +297,8 @@ public class ImportExportDialogFragment extends DialogFragment
        }

        AccountSelectionUtil.doImport(getActivity(), resId,
                (size == 1 ? accountList.get(0) : null), subscriptionId);
                (size == 1 ? accountList.get(0) : null),
                (CompatUtils.isMSIMCompatible() ? subscriptionId : -1));
        return true; // Close the dialog.
    }