Commit 5b672136 authored by Boris Sazonov's avatar Boris Sazonov Committed by Commit Bot

[Unity][Android] Check for null before getting the account name

This CL checks that Intent received by
SigninFragmentBase.onActivityResult isn't null before trying to get
account name from it. The Intent can be null on older Android versions,
leading to a crash. Also, after this CL AccountPickerDialogFragment
won't be dismissed if onActivityResult can't get the account name from
the Intent, letting the user to select the account manually.

Bug: None
Change-Id: I4740410da75023ee73fb90b6f7f9659982b96190
Reviewed-on: https://chromium-review.googlesource.com/c/1335577Reviewed-by: default avatarMihai Sardarescu <msarda@chromium.org>
Commit-Queue: Boris Sazonov <bsazonov@chromium.org>
Cr-Commit-Position: refs/heads/master@{#607978}
parent 0955e76b
......@@ -547,13 +547,16 @@ public abstract class SigninFragmentBase
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == ADD_ACCOUNT_REQUEST_CODE && resultCode == Activity.RESULT_OK) {
if (data == null) return;
String addedAccountName = data.getStringExtra(AccountManager.KEY_ACCOUNT_NAME);
if (addedAccountName == null) return;
// Found the account name, dismiss the account picker dialog if it is shown.
AccountPickerDialogFragment accountPickerFragment = getAccountPickerDialogFragment();
if (accountPickerFragment != null) {
accountPickerFragment.dismiss();
}
String addedAccountName = data.getStringExtra(AccountManager.KEY_ACCOUNT_NAME);
if (addedAccountName == null) return;
// Wait for the account cache to be updated and select newly-added account.
AccountManagerFacade.get().waitForPendingUpdates(() -> {
mAccountSelectionPending = true;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment