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

Commit ab1ddfbb authored by John Shao's avatar John Shao Committed by Automerger Merge Worker
Browse files

Don't allow importing contacts to accounts passed in by intent unless it is...

Don't allow importing contacts to accounts passed in by intent unless it is valid am: c8c222bc am: 8c7f6ee2 am: 2134eeb0 am: 711cffaa am: 202cb05e am: d6b9d2c4 am: ad86f138 am: 91fd3332 am: 75a0bdc5

Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Contacts/+/24309801



Change-Id: I510ed79f11701feb02ebb3e033920f0b3dd29038
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents cdb04dff 75a0bdc5
Loading
Loading
Loading
Loading
+22 −14
Original line number Diff line number Diff line
@@ -586,30 +586,38 @@ public class ImportVCardActivity extends Activity implements ImportVCardDialogFr
        String accountName = null;
        String accountType = null;
        String dataSet = null;
        boolean isNullAccount = false;
        final Intent intent = getIntent();
        if (intent != null) {
        if (intent != null
            && intent.hasExtra(SelectAccountActivity.ACCOUNT_NAME)
            && intent.hasExtra(SelectAccountActivity.ACCOUNT_TYPE)
            && intent.hasExtra(SelectAccountActivity.DATA_SET)) {
            accountName = intent.getStringExtra(SelectAccountActivity.ACCOUNT_NAME);
            accountType = intent.getStringExtra(SelectAccountActivity.ACCOUNT_TYPE);
            dataSet = intent.getStringExtra(SelectAccountActivity.DATA_SET);
            isNullAccount = TextUtils.isEmpty(accountName) && TextUtils.isEmpty(accountType)
                && TextUtils.isEmpty(dataSet);
        } else {
            Log.e(LOG_TAG, "intent does not exist");
        }

        if (!TextUtils.isEmpty(accountName) && !TextUtils.isEmpty(accountType)) {
            mAccount = new AccountWithDataSet(accountName, accountType, dataSet);
        } else {
        final AccountTypeManager accountTypes = AccountTypeManager.getInstance(this);
        final List<AccountWithDataSet> accountList = accountTypes.blockForWritableAccounts();
            if (accountList.size() == 0) {
        if ((!TextUtils.isEmpty(accountName) && !TextUtils.isEmpty(accountType)) || isNullAccount) {
            AccountWithDataSet selected = new AccountWithDataSet(accountName, accountType,
                dataSet);
            if (accountList.contains(selected)) {
                mAccount = selected;
            }
        }

        if (accountList.isEmpty()) {
            mAccount = null;
            } else if (accountList.size() == 1) {
                mAccount = accountList.get(0);
            } else {
        } else if (mAccount == null) {
            startActivityForResult(new Intent(this, SelectAccountActivity.class),
                SELECT_ACCOUNT);
            return;
        }
        }

        if (isCallerSelf(this)) {
            startImport(sourceUri, sourceDisplayName);