diff options
author | John Shao <johnshao@google.com> | 2023-08-07 23:15:34 +0000 |
---|---|---|
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | 2023-08-07 23:15:34 +0000 |
commit | 2134eeb0747d2cfc7356502fd2a8a4d59e52b6ce (patch) | |
tree | d9529de55b4165c30cd475847f78088164dc5c6e | |
parent | 795d642a1a45290256a3047fc6402e11d4c1e566 (diff) | |
parent | 8c7f6ee2ad6dd468c50ea989a679b83f23c0068b (diff) | |
download | Contacts-2134eeb0747d2cfc7356502fd2a8a4d59e52b6ce.tar.gz |
Don't allow importing contacts to accounts passed in by intent unless it is valid am: c8c222bc6c am: 8c7f6ee2ad
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Contacts/+/24309801
Change-Id: I859dda621ff7ccf1fa2d5bc64d913535f49081be
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
-rw-r--r-- | src/com/android/contacts/vcard/ImportVCardActivity.java | 36 |
1 files changed, 22 insertions, 14 deletions
diff --git a/src/com/android/contacts/vcard/ImportVCardActivity.java b/src/com/android/contacts/vcard/ImportVCardActivity.java index 38367c40f..8e2f98234 100644 --- a/src/com/android/contacts/vcard/ImportVCardActivity.java +++ b/src/com/android/contacts/vcard/ImportVCardActivity.java @@ -587,31 +587,39 @@ 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) { - mAccount = null; - } else if (accountList.size() == 1) { - mAccount = accountList.get(0); - } else { - startActivityForResult(new Intent(this, SelectAccountActivity.class), - SELECT_ACCOUNT); - return; + final AccountTypeManager accountTypes = AccountTypeManager.getInstance(this); + final List<AccountWithDataSet> accountList = accountTypes.blockForWritableAccounts(); + 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 (mAccount == null) { + startActivityForResult(new Intent(this, SelectAccountActivity.class), + SELECT_ACCOUNT); + return; + } + if (isCallerSelf(this)) { startImport(sourceUri, sourceDisplayName); } else { |