am 29124960: Merge "[Modify LastAuthenticatedTimestamp behaviour]:" into mnc-dev
* commit '29124960c6a39bf062caaccfc6810bea54d45cef': [Modify LastAuthenticatedTimestamp behaviour]:
This commit is contained in:
committed by
Android Git Automerger
commit
4ddc0add7b
@@ -209,7 +209,8 @@ public class AccountManager {
|
|||||||
/**
|
/**
|
||||||
* Bundle key used to supply the last time the credentials of the account
|
* Bundle key used to supply the last time the credentials of the account
|
||||||
* were authenticated successfully. Time is specified in milliseconds since
|
* were authenticated successfully. Time is specified in milliseconds since
|
||||||
* epoch.
|
* epoch. Associated time is updated on successful authentication of account
|
||||||
|
* on adding account, confirming credentials, or updating credentials.
|
||||||
*/
|
*/
|
||||||
public static final String KEY_LAST_AUTHENTICATED_TIME = "lastAuthenticatedTime";
|
public static final String KEY_LAST_AUTHENTICATED_TIME = "lastAuthenticatedTime";
|
||||||
|
|
||||||
@@ -651,18 +652,25 @@ public class AccountManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds an account directly to the AccountManager. Normally used by sign-up
|
* Adds an account directly to the AccountManager. Normally used by sign-up
|
||||||
* wizards associated with authenticators, not directly by applications.
|
* wizards associated with authenticators, not directly by applications.
|
||||||
*
|
* <p>Calling this method does not update the last authenticated timestamp,
|
||||||
|
* referred by {@link #KEY_LAST_AUTHENTICATED_TIME}. To update it, call
|
||||||
|
* {@link #notifyAccountAuthenticated(Account)} after getting success.
|
||||||
|
* However, if this method is called when it is triggered by addAccount() or
|
||||||
|
* addAccountAsUser() or similar functions, then there is no need to update
|
||||||
|
* timestamp manually as it is updated automatically by framework on
|
||||||
|
* successful completion of the mentioned functions.
|
||||||
* <p>It is safe to call this method from the main thread.
|
* <p>It is safe to call this method from the main thread.
|
||||||
* <p>This method requires the caller to have a signature match with the
|
* <p>This method requires the caller to have a signature match with the
|
||||||
* authenticator that owns the specified account.
|
* authenticator that owns the specified account.
|
||||||
*
|
*
|
||||||
* @param account The {@link Account} to add
|
* @param account The {@link Account} to add
|
||||||
* @param password The password to associate with the account, null for none
|
* @param password The password to associate with the account, null for none
|
||||||
* @param userdata String values to use for the account's userdata, null for none
|
* @param userdata String values to use for the account's userdata, null for
|
||||||
|
* none
|
||||||
* @return True if the account was successfully added, false if the account
|
* @return True if the account was successfully added, false if the account
|
||||||
* already exists, the account is null, or another error occurs.
|
* already exists, the account is null, or another error occurs.
|
||||||
*/
|
*/
|
||||||
public boolean addAccountExplicitly(Account account, String password, Bundle userdata) {
|
public boolean addAccountExplicitly(Account account, String password, Bundle userdata) {
|
||||||
if (account == null) throw new IllegalArgumentException("account is null");
|
if (account == null) throw new IllegalArgumentException("account is null");
|
||||||
@@ -976,17 +984,19 @@ public class AccountManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets or forgets a saved password. This modifies the local copy of the
|
* Sets or forgets a saved password. This modifies the local copy of the
|
||||||
* password used to automatically authenticate the user; it does
|
* password used to automatically authenticate the user; it does not change
|
||||||
* not change the user's account password on the server. Intended for use
|
* the user's account password on the server. Intended for use by the
|
||||||
* by the authenticator, not directly by applications.
|
* authenticator, not directly by applications.
|
||||||
*
|
* <p>Calling this method does not update the last authenticated timestamp,
|
||||||
|
* referred by {@link #KEY_LAST_AUTHENTICATED_TIME}. To update it, call
|
||||||
|
* {@link #notifyAccountAuthenticated(Account)} after getting success.
|
||||||
* <p>It is safe to call this method from the main thread.
|
* <p>It is safe to call this method from the main thread.
|
||||||
*
|
|
||||||
* <p>This method requires the caller to have a signature match with the
|
* <p>This method requires the caller to have a signature match with the
|
||||||
* authenticator that manages the specified account.
|
* authenticator that manages the specified account.
|
||||||
*
|
*
|
||||||
* @param account The account whose password is to be set. Cannot be {@code null}.
|
* @param account The account whose password is to be set. Cannot be
|
||||||
|
* {@code null}.
|
||||||
* @param password The password to set, null to clear the password
|
* @param password The password to set, null to clear the password
|
||||||
*/
|
*/
|
||||||
public void setPassword(final Account account, final String password) {
|
public void setPassword(final Account account, final String password) {
|
||||||
|
|||||||
@@ -1591,13 +1591,6 @@ public class AccountManagerService
|
|||||||
try {
|
try {
|
||||||
final ContentValues values = new ContentValues();
|
final ContentValues values = new ContentValues();
|
||||||
values.put(ACCOUNTS_PASSWORD, password);
|
values.put(ACCOUNTS_PASSWORD, password);
|
||||||
long time = 0;
|
|
||||||
// Only set current time, if it is a valid password. For clear password case, it
|
|
||||||
// should not be set.
|
|
||||||
if (password != null) {
|
|
||||||
time = System.currentTimeMillis();
|
|
||||||
}
|
|
||||||
values.put(ACCOUNTS_LAST_AUTHENTICATE_TIME_EPOCH_MILLIS, time);
|
|
||||||
final long accountId = getAccountIdLocked(db, account);
|
final long accountId = getAccountIdLocked(db, account);
|
||||||
if (accountId >= 0) {
|
if (accountId >= 0) {
|
||||||
final String[] argsAccountId = {String.valueOf(accountId)};
|
final String[] argsAccountId = {String.valueOf(accountId)};
|
||||||
@@ -2130,7 +2123,7 @@ public class AccountManagerService
|
|||||||
try {
|
try {
|
||||||
new Session(accounts, response, accountType, expectActivityLaunch,
|
new Session(accounts, response, accountType, expectActivityLaunch,
|
||||||
true /* stripAuthTokenFromResult */, null /* accountName */,
|
true /* stripAuthTokenFromResult */, null /* accountName */,
|
||||||
false /* authDetailsRequired */) {
|
false /* authDetailsRequired */, true /* updateLastAuthenticationTime */) {
|
||||||
@Override
|
@Override
|
||||||
public void run() throws RemoteException {
|
public void run() throws RemoteException {
|
||||||
mAuthenticator.addAccount(this, mAccountType, authTokenType, requiredFeatures,
|
mAuthenticator.addAccount(this, mAccountType, authTokenType, requiredFeatures,
|
||||||
@@ -2207,7 +2200,7 @@ public class AccountManagerService
|
|||||||
try {
|
try {
|
||||||
new Session(accounts, response, accountType, expectActivityLaunch,
|
new Session(accounts, response, accountType, expectActivityLaunch,
|
||||||
true /* stripAuthTokenFromResult */, null /* accountName */,
|
true /* stripAuthTokenFromResult */, null /* accountName */,
|
||||||
false /* authDetailsRequired */) {
|
false /* authDetailsRequired */, true /* updateLastAuthenticationTime */) {
|
||||||
@Override
|
@Override
|
||||||
public void run() throws RemoteException {
|
public void run() throws RemoteException {
|
||||||
mAuthenticator.addAccount(this, mAccountType, authTokenType, requiredFeatures,
|
mAuthenticator.addAccount(this, mAccountType, authTokenType, requiredFeatures,
|
||||||
@@ -2940,14 +2933,14 @@ public class AccountManagerService
|
|||||||
if (result != null) {
|
if (result != null) {
|
||||||
boolean isSuccessfulConfirmCreds = result.getBoolean(
|
boolean isSuccessfulConfirmCreds = result.getBoolean(
|
||||||
AccountManager.KEY_BOOLEAN_RESULT, false);
|
AccountManager.KEY_BOOLEAN_RESULT, false);
|
||||||
boolean isSuccessfulUpdateCreds =
|
boolean isSuccessfulUpdateCredsOrAddAccount =
|
||||||
result.containsKey(AccountManager.KEY_ACCOUNT_NAME)
|
result.containsKey(AccountManager.KEY_ACCOUNT_NAME)
|
||||||
&& result.containsKey(AccountManager.KEY_ACCOUNT_TYPE);
|
&& result.containsKey(AccountManager.KEY_ACCOUNT_TYPE);
|
||||||
// We should only update lastAuthenticated time, if
|
// We should only update lastAuthenticated time, if
|
||||||
// mUpdateLastAuthenticatedTime is true and the confirmRequest
|
// mUpdateLastAuthenticatedTime is true and the confirmRequest
|
||||||
// or updateRequest was successful
|
// or updateRequest was successful
|
||||||
boolean needUpdate = mUpdateLastAuthenticatedTime
|
boolean needUpdate = mUpdateLastAuthenticatedTime
|
||||||
&& (isSuccessfulConfirmCreds || isSuccessfulUpdateCreds);
|
&& (isSuccessfulConfirmCreds || isSuccessfulUpdateCredsOrAddAccount);
|
||||||
if (needUpdate || mAuthDetailsRequired) {
|
if (needUpdate || mAuthDetailsRequired) {
|
||||||
boolean accountPresent = isAccountPresentForCaller(mAccountName, mAccountType);
|
boolean accountPresent = isAccountPresentForCaller(mAccountName, mAccountType);
|
||||||
if (needUpdate && accountPresent) {
|
if (needUpdate && accountPresent) {
|
||||||
|
|||||||
Reference in New Issue
Block a user