Add account for managed user
Bug: 16056552 Change-Id: I225a1b447d9b4024703b82be8a1fa66359d9e9a1
This commit is contained in:
@@ -98,7 +98,7 @@ public class AddAccountSettings extends Activity {
|
|||||||
Utils.hasMultipleUsers(AddAccountSettings.this));
|
Utils.hasMultipleUsers(AddAccountSettings.this));
|
||||||
addAccountOptions.putParcelable(EXTRA_USER, mUserHandle);
|
addAccountOptions.putParcelable(EXTRA_USER, mUserHandle);
|
||||||
intent.putExtras(addAccountOptions);
|
intent.putExtras(addAccountOptions);
|
||||||
startActivityForResult(intent, ADD_ACCOUNT_REQUEST);
|
startActivityForResultAsUser(intent, ADD_ACCOUNT_REQUEST, mUserHandle);
|
||||||
} else {
|
} else {
|
||||||
setResult(RESULT_OK);
|
setResult(RESULT_OK);
|
||||||
if (mPendingIntent != null) {
|
if (mPendingIntent != null) {
|
||||||
@@ -199,22 +199,15 @@ public class AddAccountSettings extends Activity {
|
|||||||
mPendingIntent = PendingIntent.getBroadcast(this, 0, new Intent(), 0);
|
mPendingIntent = PendingIntent.getBroadcast(this, 0, new Intent(), 0);
|
||||||
addAccountOptions.putParcelable(KEY_CALLER_IDENTITY, mPendingIntent);
|
addAccountOptions.putParcelable(KEY_CALLER_IDENTITY, mPendingIntent);
|
||||||
addAccountOptions.putBoolean(EXTRA_HAS_MULTIPLE_USERS, Utils.hasMultipleUsers(this));
|
addAccountOptions.putBoolean(EXTRA_HAS_MULTIPLE_USERS, Utils.hasMultipleUsers(this));
|
||||||
// TODO: We need an API to add an account to a different user. See: http://b/15466880
|
AccountManager.get(this).addAccountAsUser(
|
||||||
int userId = mUserHandle.getIdentifier();
|
|
||||||
int callingUserId = UserHandle.getCallingUserId();
|
|
||||||
if (userId != callingUserId) {
|
|
||||||
Log.w(TAG, "Cannot add an account for user " + userId + " from " + callingUserId + ".");
|
|
||||||
finish();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
AccountManager.get(this).addAccount(
|
|
||||||
accountType,
|
accountType,
|
||||||
null, /* authTokenType */
|
null, /* authTokenType */
|
||||||
null, /* requiredFeatures */
|
null, /* requiredFeatures */
|
||||||
addAccountOptions,
|
addAccountOptions,
|
||||||
null,
|
null,
|
||||||
mCallback,
|
mCallback,
|
||||||
null /* handler */);
|
null /* handler */,
|
||||||
|
mUserHandle);
|
||||||
mAddAccountCalled = true;
|
mAddAccountCalled = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user