/** * Return a set of account types specified by the intent as well as supported by the * AccountManager. */ private Set<String> getReleventAccountTypes(final Intent intent) { // An account type is relevant iff it is allowed by the caller and supported by the account // manager. Set<String> setOfRelevantAccountTypes; final String[] allowedAccountTypes = intent.getStringArrayExtra(EXTRA_ALLOWABLE_ACCOUNT_TYPES_STRING_ARRAY); AuthenticatorDescription[] descs = VAccountManager.get().getAuthenticatorTypes(); Set<String> supportedAccountTypes = new HashSet<String>(descs.length); for (AuthenticatorDescription desc : descs) { supportedAccountTypes.add(desc.type); } if (allowedAccountTypes != null) { setOfRelevantAccountTypes = new HashSet<>(); Collections.addAll(setOfRelevantAccountTypes, allowedAccountTypes); setOfRelevantAccountTypes.retainAll(supportedAccountTypes); } else { setOfRelevantAccountTypes = supportedAccountTypes; } return setOfRelevantAccountTypes; }
@Override public void run(final AccountManagerFuture<Bundle> accountManagerFuture) { try { final Bundle accountManagerResult = accountManagerFuture.getResult(); final Intent intent = accountManagerResult.getParcelable( AccountManager.KEY_INTENT); if (intent != null) { mPendingRequest = REQUEST_ADD_ACCOUNT; mExistingAccounts = VAccountManager.get().getAccounts(mCallingUserId, null); intent.setFlags(intent.getFlags() & ~Intent.FLAG_ACTIVITY_NEW_TASK); startActivityForResult(intent, REQUEST_ADD_ACCOUNT); return; } } catch (OperationCanceledException e) { setResult(Activity.RESULT_CANCELED); finish(); return; } catch (IOException e) { } catch (AuthenticatorException e) { } Bundle bundle = new Bundle(); bundle.putString(AccountManager.KEY_ERROR_MESSAGE, "error communicating with server"); setResult(Activity.RESULT_OK, new Intent().putExtras(bundle)); finish(); }
protected void runAddAccountForAuthenticator(String type) { if (Log.isLoggable(TAG, Log.VERBOSE)) { Log.v(TAG, "runAddAccountForAuthenticator: " + type); } final Bundle options = getIntent().getBundleExtra( ChooseTypeAndAccountActivity.EXTRA_ADD_ACCOUNT_OPTIONS_BUNDLE); final String[] requiredFeatures = getIntent().getStringArrayExtra( ChooseTypeAndAccountActivity.EXTRA_ADD_ACCOUNT_REQUIRED_FEATURES_STRING_ARRAY); final String authTokenType = getIntent().getStringExtra( ChooseTypeAndAccountActivity.EXTRA_ADD_ACCOUNT_AUTH_TOKEN_TYPE_STRING); VAccountManager.get().addAccount(mCallingUserId, type, authTokenType, requiredFeatures, options, null /* activity */, this /* callback */, null /* Handler */); }
private void buildTypeToAuthDescriptionMap() { for(AuthenticatorDescription desc : VAccountManager.get().getAuthenticatorTypes()) { String name = null; Drawable icon = null; try { Resources res = VirtualCore.get().getResources(desc.packageName); icon = res.getDrawable(desc.iconId); final CharSequence sequence = res.getText(desc.labelId); name = sequence.toString(); name = sequence.toString(); } catch (Resources.NotFoundException e) { // Nothing we can do much here, just log VLog.w(TAG, "No icon resource for account type " + desc.type); } AuthInfo authInfo = new AuthInfo(desc, name, icon); mTypeToAuthenticatorInfo.put(desc.type, authInfo); } }
Account[] currentAccounts = VAccountManager.get().getAccounts(mCallingUserId, null); Set<Account> preExistingAccounts = new HashSet<>(); for (Parcelable accountParcel : mExistingAccounts) {
mDescriptionOverride = intent.getStringExtra(EXTRA_DESCRIPTION_TEXT_OVERRIDE); mAccounts = getAcceptableAccountChoices(VAccountManager.get());
/** * Return a set of account types specified by the intent as well as supported by the * AccountManager. */ private Set<String> getReleventAccountTypes(final Intent intent) { // An account type is relevant iff it is allowed by the caller and supported by the account // manager. Set<String> setOfRelevantAccountTypes; final String[] allowedAccountTypes = intent.getStringArrayExtra(EXTRA_ALLOWABLE_ACCOUNT_TYPES_STRING_ARRAY); AuthenticatorDescription[] descs = VAccountManager.get().getAuthenticatorTypes(); Set<String> supportedAccountTypes = new HashSet<String>(descs.length); for (AuthenticatorDescription desc : descs) { supportedAccountTypes.add(desc.type); } if (allowedAccountTypes != null) { setOfRelevantAccountTypes = new HashSet<>(); Collections.addAll(setOfRelevantAccountTypes, allowedAccountTypes); setOfRelevantAccountTypes.retainAll(supportedAccountTypes); } else { setOfRelevantAccountTypes = supportedAccountTypes; } return setOfRelevantAccountTypes; }
@Override public void run(final AccountManagerFuture<Bundle> accountManagerFuture) { try { final Bundle accountManagerResult = accountManagerFuture.getResult(); final Intent intent = accountManagerResult.getParcelable( AccountManager.KEY_INTENT); if (intent != null) { mPendingRequest = REQUEST_ADD_ACCOUNT; mExistingAccounts = VAccountManager.get().getAccounts(mCallingUserId, null); intent.setFlags(intent.getFlags() & ~Intent.FLAG_ACTIVITY_NEW_TASK); startActivityForResult(intent, REQUEST_ADD_ACCOUNT); return; } } catch (OperationCanceledException e) { setResult(Activity.RESULT_CANCELED); finish(); return; } catch (IOException e) { } catch (AuthenticatorException e) { } Bundle bundle = new Bundle(); bundle.putString(AccountManager.KEY_ERROR_MESSAGE, "error communicating with server"); setResult(Activity.RESULT_OK, new Intent().putExtras(bundle)); finish(); }
protected void runAddAccountForAuthenticator(String type) { if (Log.isLoggable(TAG, Log.VERBOSE)) { Log.v(TAG, "runAddAccountForAuthenticator: " + type); } final Bundle options = getIntent().getBundleExtra( ChooseTypeAndAccountActivity.EXTRA_ADD_ACCOUNT_OPTIONS_BUNDLE); final String[] requiredFeatures = getIntent().getStringArrayExtra( ChooseTypeAndAccountActivity.EXTRA_ADD_ACCOUNT_REQUIRED_FEATURES_STRING_ARRAY); final String authTokenType = getIntent().getStringExtra( ChooseTypeAndAccountActivity.EXTRA_ADD_ACCOUNT_AUTH_TOKEN_TYPE_STRING); VAccountManager.get().addAccount(mCallingUserId, type, authTokenType, requiredFeatures, options, null /* activity */, this /* callback */, null /* Handler */); }
/** * Return a set of account types specified by the intent as well as supported by the * AccountManager. */ private Set<String> getReleventAccountTypes(final Intent intent) { // An account type is relevant iff it is allowed by the caller and supported by the account // manager. Set<String> setOfRelevantAccountTypes; final String[] allowedAccountTypes = intent.getStringArrayExtra(EXTRA_ALLOWABLE_ACCOUNT_TYPES_STRING_ARRAY); AuthenticatorDescription[] descs = VAccountManager.get().getAuthenticatorTypes(); Set<String> supportedAccountTypes = new HashSet<String>(descs.length); for (AuthenticatorDescription desc : descs) { supportedAccountTypes.add(desc.type); } if (allowedAccountTypes != null) { setOfRelevantAccountTypes = new HashSet<>(); Collections.addAll(setOfRelevantAccountTypes, allowedAccountTypes); setOfRelevantAccountTypes.retainAll(supportedAccountTypes); } else { setOfRelevantAccountTypes = supportedAccountTypes; } return setOfRelevantAccountTypes; }
@Override public void run(final AccountManagerFuture<Bundle> accountManagerFuture) { try { final Bundle accountManagerResult = accountManagerFuture.getResult(); final Intent intent = accountManagerResult.getParcelable( AccountManager.KEY_INTENT); if (intent != null) { mPendingRequest = REQUEST_ADD_ACCOUNT; mExistingAccounts = VAccountManager.get().getAccounts(mCallingUserId, null); intent.setFlags(intent.getFlags() & ~Intent.FLAG_ACTIVITY_NEW_TASK); startActivityForResult(intent, REQUEST_ADD_ACCOUNT); return; } } catch (OperationCanceledException e) { setResult(Activity.RESULT_CANCELED); finish(); return; } catch (IOException e) { } catch (AuthenticatorException e) { } Bundle bundle = new Bundle(); bundle.putString(AccountManager.KEY_ERROR_MESSAGE, "error communicating with server"); setResult(Activity.RESULT_OK, new Intent().putExtras(bundle)); finish(); }
protected void runAddAccountForAuthenticator(String type) { if (Log.isLoggable(TAG, Log.VERBOSE)) { Log.v(TAG, "runAddAccountForAuthenticator: " + type); } final Bundle options = getIntent().getBundleExtra( ChooseTypeAndAccountActivity.EXTRA_ADD_ACCOUNT_OPTIONS_BUNDLE); final String[] requiredFeatures = getIntent().getStringArrayExtra( ChooseTypeAndAccountActivity.EXTRA_ADD_ACCOUNT_REQUIRED_FEATURES_STRING_ARRAY); final String authTokenType = getIntent().getStringExtra( ChooseTypeAndAccountActivity.EXTRA_ADD_ACCOUNT_AUTH_TOKEN_TYPE_STRING); VAccountManager.get().addAccount(mCallingUserId, type, authTokenType, requiredFeatures, options, null /* activity */, this /* callback */, null /* Handler */); }
private void buildTypeToAuthDescriptionMap() { for(AuthenticatorDescription desc : VAccountManager.get().getAuthenticatorTypes()) { String name = null; Drawable icon = null; try { Resources res = VirtualCore.get().getResources(desc.packageName); icon = res.getDrawable(desc.iconId); final CharSequence sequence = res.getText(desc.labelId); name = sequence.toString(); name = sequence.toString(); } catch (Resources.NotFoundException e) { // Nothing we can do much here, just log VLog.w(TAG, "No icon resource for account type " + desc.type); } AuthInfo authInfo = new AuthInfo(desc, name, icon); mTypeToAuthenticatorInfo.put(desc.type, authInfo); } }
Account[] currentAccounts = VAccountManager.get().getAccounts(mCallingUserId, null); Set<Account> preExistingAccounts = new HashSet<>(); for (Parcelable accountParcel : mExistingAccounts) {
mDescriptionOverride = intent.getStringExtra(EXTRA_DESCRIPTION_TEXT_OVERRIDE); mAccounts = getAcceptableAccountChoices(VAccountManager.get());
private void buildTypeToAuthDescriptionMap() { for(AuthenticatorDescription desc : VAccountManager.get().getAuthenticatorTypes()) { String name = null; Drawable icon = null; try { Resources res = VirtualCore.get().getResources(desc.packageName); icon = res.getDrawable(desc.iconId); final CharSequence sequence = res.getText(desc.labelId); name = sequence.toString(); name = sequence.toString(); } catch (Resources.NotFoundException e) { // Nothing we can do much here, just log VLog.w(TAG, "No icon resource for account type " + desc.type); } AuthInfo authInfo = new AuthInfo(desc, name, icon); mTypeToAuthenticatorInfo.put(desc.type, authInfo); } }
Account[] currentAccounts = VAccountManager.get().getAccounts(mCallingUserId, null); Set<Account> preExistingAccounts = new HashSet<>(); for (Parcelable accountParcel : mExistingAccounts) {
mDescriptionOverride = intent.getStringExtra(EXTRA_DESCRIPTION_TEXT_OVERRIDE); mAccounts = getAcceptableAccountChoices(VAccountManager.get());