Merge "Add metrics in AccountManager" into sc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
c03a2bfe05
@@ -1027,7 +1027,8 @@ public class AccountManager {
|
|||||||
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");
|
||||||
try {
|
try {
|
||||||
return mService.addAccountExplicitly(account, password, userdata);
|
return mService.addAccountExplicitly(
|
||||||
|
account, password, userdata, mContext.getOpPackageName());
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
throw e.rethrowFromSystemServer();
|
throw e.rethrowFromSystemServer();
|
||||||
}
|
}
|
||||||
@@ -1064,7 +1065,7 @@ public class AccountManager {
|
|||||||
throw new IllegalArgumentException("account is null");
|
throw new IllegalArgumentException("account is null");
|
||||||
try {
|
try {
|
||||||
return mService.addAccountExplicitlyWithVisibility(account, password, extras,
|
return mService.addAccountExplicitlyWithVisibility(account, password, extras,
|
||||||
visibility);
|
visibility, mContext.getOpPackageName());
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
throw e.rethrowFromSystemServer();
|
throw e.rethrowFromSystemServer();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ interface IAccountManager {
|
|||||||
in String[] features, String opPackageName);
|
in String[] features, String opPackageName);
|
||||||
void getAccountsByFeatures(in IAccountManagerResponse response, String accountType,
|
void getAccountsByFeatures(in IAccountManagerResponse response, String accountType,
|
||||||
in String[] features, String opPackageName);
|
in String[] features, String opPackageName);
|
||||||
boolean addAccountExplicitly(in Account account, String password, in Bundle extras);
|
boolean addAccountExplicitly(in Account account, String password, in Bundle extras, in String opPackageName);
|
||||||
void removeAccountAsUser(in IAccountManagerResponse response, in Account account,
|
void removeAccountAsUser(in IAccountManagerResponse response, in Account account,
|
||||||
boolean expectActivityLaunch, int userId);
|
boolean expectActivityLaunch, int userId);
|
||||||
boolean removeAccountExplicitly(in Account account);
|
boolean removeAccountExplicitly(in Account account);
|
||||||
@@ -107,7 +107,7 @@ interface IAccountManager {
|
|||||||
/* Returns Map<String, Integer> from package name to visibility with all values stored for given account */
|
/* Returns Map<String, Integer> from package name to visibility with all values stored for given account */
|
||||||
Map getPackagesAndVisibilityForAccount(in Account account);
|
Map getPackagesAndVisibilityForAccount(in Account account);
|
||||||
boolean addAccountExplicitlyWithVisibility(in Account account, String password, in Bundle extras,
|
boolean addAccountExplicitlyWithVisibility(in Account account, String password, in Bundle extras,
|
||||||
in Map visibility);
|
in Map visibility, in String opPackageName);
|
||||||
boolean setAccountVisibility(in Account a, in String packageName, int newVisibility);
|
boolean setAccountVisibility(in Account a, in String packageName, int newVisibility);
|
||||||
int getAccountVisibility(in Account a, in String packageName);
|
int getAccountVisibility(in Account a, in String packageName);
|
||||||
/* Type may be null returns Map <Account, Integer>*/
|
/* Type may be null returns Map <Account, Integer>*/
|
||||||
|
|||||||
@@ -42,6 +42,7 @@ import android.app.INotificationManager;
|
|||||||
import android.app.Notification;
|
import android.app.Notification;
|
||||||
import android.app.NotificationManager;
|
import android.app.NotificationManager;
|
||||||
import android.app.PendingIntent;
|
import android.app.PendingIntent;
|
||||||
|
import android.app.admin.DevicePolicyEventLogger;
|
||||||
import android.app.admin.DevicePolicyManager;
|
import android.app.admin.DevicePolicyManager;
|
||||||
import android.app.admin.DevicePolicyManagerInternal;
|
import android.app.admin.DevicePolicyManagerInternal;
|
||||||
import android.content.BroadcastReceiver;
|
import android.content.BroadcastReceiver;
|
||||||
@@ -85,6 +86,7 @@ import android.os.StrictMode;
|
|||||||
import android.os.SystemClock;
|
import android.os.SystemClock;
|
||||||
import android.os.UserHandle;
|
import android.os.UserHandle;
|
||||||
import android.os.UserManager;
|
import android.os.UserManager;
|
||||||
|
import android.stats.devicepolicy.DevicePolicyEnums;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.util.Pair;
|
import android.util.Pair;
|
||||||
@@ -105,7 +107,6 @@ import com.android.internal.util.Preconditions;
|
|||||||
import com.android.server.LocalServices;
|
import com.android.server.LocalServices;
|
||||||
import com.android.server.ServiceThread;
|
import com.android.server.ServiceThread;
|
||||||
import com.android.server.SystemService;
|
import com.android.server.SystemService;
|
||||||
import com.android.server.SystemService.TargetUser;
|
|
||||||
|
|
||||||
import com.google.android.collect.Lists;
|
import com.google.android.collect.Lists;
|
||||||
import com.google.android.collect.Sets;
|
import com.google.android.collect.Sets;
|
||||||
@@ -456,7 +457,7 @@ public class AccountManagerService
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean addAccountExplicitlyWithVisibility(Account account, String password,
|
public boolean addAccountExplicitlyWithVisibility(Account account, String password,
|
||||||
Bundle extras, Map packageToVisibility) {
|
Bundle extras, Map packageToVisibility, String opPackageName) {
|
||||||
Bundle.setDefusable(extras, true);
|
Bundle.setDefusable(extras, true);
|
||||||
int callingUid = Binder.getCallingUid();
|
int callingUid = Binder.getCallingUid();
|
||||||
int userId = UserHandle.getCallingUserId();
|
int userId = UserHandle.getCallingUserId();
|
||||||
@@ -481,7 +482,7 @@ public class AccountManagerService
|
|||||||
try {
|
try {
|
||||||
UserAccounts accounts = getUserAccounts(userId);
|
UserAccounts accounts = getUserAccounts(userId);
|
||||||
return addAccountInternal(accounts, account, password, extras, callingUid,
|
return addAccountInternal(accounts, account, password, extras, callingUid,
|
||||||
(Map<String, Integer>) packageToVisibility);
|
(Map<String, Integer>) packageToVisibility, opPackageName);
|
||||||
} finally {
|
} finally {
|
||||||
restoreCallingIdentity(identityToken);
|
restoreCallingIdentity(identityToken);
|
||||||
}
|
}
|
||||||
@@ -1650,8 +1651,10 @@ public class AccountManagerService
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean addAccountExplicitly(Account account, String password, Bundle extras) {
|
public boolean addAccountExplicitly(
|
||||||
return addAccountExplicitlyWithVisibility(account, password, extras, null);
|
Account account, String password, Bundle extras, String opPackageName) {
|
||||||
|
return addAccountExplicitlyWithVisibility(
|
||||||
|
account, password, extras, /* packageToVisibility= */ null, opPackageName);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -1807,7 +1810,8 @@ public class AccountManagerService
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean addAccountInternal(UserAccounts accounts, Account account, String password,
|
private boolean addAccountInternal(UserAccounts accounts, Account account, String password,
|
||||||
Bundle extras, int callingUid, Map<String, Integer> packageToVisibility) {
|
Bundle extras, int callingUid, Map<String, Integer> packageToVisibility,
|
||||||
|
String opPackageName) {
|
||||||
Bundle.setDefusable(extras, true);
|
Bundle.setDefusable(extras, true);
|
||||||
if (account == null) {
|
if (account == null) {
|
||||||
return false;
|
return false;
|
||||||
@@ -1879,9 +1883,59 @@ public class AccountManagerService
|
|||||||
// Only send LOGIN_ACCOUNTS_CHANGED when the database changed.
|
// Only send LOGIN_ACCOUNTS_CHANGED when the database changed.
|
||||||
sendAccountsChangedBroadcast(accounts.userId);
|
sendAccountsChangedBroadcast(accounts.userId);
|
||||||
|
|
||||||
|
logAddAccountExplicitlyMetrics(opPackageName, account.type, packageToVisibility);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void logAddAccountExplicitlyMetrics(
|
||||||
|
String callerPackage, String accountType,
|
||||||
|
@Nullable Map<String, Integer> accountVisibility) {
|
||||||
|
// Although this is not a 'device policy' API, enterprise is the current use case.
|
||||||
|
DevicePolicyEventLogger
|
||||||
|
.createEvent(DevicePolicyEnums.ADD_ACCOUNT_EXPLICITLY)
|
||||||
|
.setStrings(
|
||||||
|
TextUtils.emptyIfNull(accountType),
|
||||||
|
TextUtils.emptyIfNull(callerPackage),
|
||||||
|
findPackagesPerVisibility(accountVisibility))
|
||||||
|
.write();
|
||||||
|
}
|
||||||
|
|
||||||
|
private String[] findPackagesPerVisibility(@Nullable Map<String, Integer> accountVisibility) {
|
||||||
|
Map<Integer, Set<String>> packagesPerVisibility = new HashMap<>();
|
||||||
|
if (accountVisibility != null) {
|
||||||
|
for (Entry<String, Integer> entry : accountVisibility.entrySet()) {
|
||||||
|
if (!packagesPerVisibility.containsKey(entry.getValue())) {
|
||||||
|
packagesPerVisibility.put(entry.getValue(), new HashSet<>());
|
||||||
|
}
|
||||||
|
packagesPerVisibility.get(entry.getValue()).add(entry.getKey());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
String[] packagesPerVisibilityStr = new String[5];
|
||||||
|
packagesPerVisibilityStr[AccountManager.VISIBILITY_UNDEFINED] = getPackagesForVisibilityStr(
|
||||||
|
AccountManager.VISIBILITY_UNDEFINED, packagesPerVisibility);
|
||||||
|
packagesPerVisibilityStr[AccountManager.VISIBILITY_VISIBLE] = getPackagesForVisibilityStr(
|
||||||
|
AccountManager.VISIBILITY_VISIBLE, packagesPerVisibility);
|
||||||
|
packagesPerVisibilityStr[AccountManager.VISIBILITY_USER_MANAGED_VISIBLE] =
|
||||||
|
getPackagesForVisibilityStr(
|
||||||
|
AccountManager.VISIBILITY_USER_MANAGED_VISIBLE, packagesPerVisibility);
|
||||||
|
packagesPerVisibilityStr[AccountManager.VISIBILITY_NOT_VISIBLE] =
|
||||||
|
getPackagesForVisibilityStr(
|
||||||
|
AccountManager.VISIBILITY_NOT_VISIBLE, packagesPerVisibility);
|
||||||
|
packagesPerVisibilityStr[AccountManager.VISIBILITY_USER_MANAGED_NOT_VISIBLE] =
|
||||||
|
getPackagesForVisibilityStr(
|
||||||
|
AccountManager.VISIBILITY_USER_MANAGED_NOT_VISIBLE, packagesPerVisibility);
|
||||||
|
return packagesPerVisibilityStr;
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getPackagesForVisibilityStr(
|
||||||
|
int visibility, Map<Integer, Set<String>> packagesPerVisibility) {
|
||||||
|
return visibility + ":"
|
||||||
|
+ (packagesPerVisibility.containsKey(visibility)
|
||||||
|
? TextUtils.join(",", packagesPerVisibility.get(visibility))
|
||||||
|
: "");
|
||||||
|
}
|
||||||
|
|
||||||
private boolean isLocalUnlockedUser(int userId) {
|
private boolean isLocalUnlockedUser(int userId) {
|
||||||
synchronized (mUsers) {
|
synchronized (mUsers) {
|
||||||
return mLocalUnlockedUsers.get(userId);
|
return mLocalUnlockedUsers.get(userId);
|
||||||
@@ -2898,6 +2952,7 @@ public class AccountManagerService
|
|||||||
if (!customTokens && permissionGranted) {
|
if (!customTokens && permissionGranted) {
|
||||||
String authToken = readAuthTokenInternal(accounts, account, authTokenType);
|
String authToken = readAuthTokenInternal(accounts, account, authTokenType);
|
||||||
if (authToken != null) {
|
if (authToken != null) {
|
||||||
|
logGetAuthTokenMetrics(callerPkg, account.type);
|
||||||
Bundle result = new Bundle();
|
Bundle result = new Bundle();
|
||||||
result.putString(AccountManager.KEY_AUTHTOKEN, authToken);
|
result.putString(AccountManager.KEY_AUTHTOKEN, authToken);
|
||||||
result.putString(AccountManager.KEY_ACCOUNT_NAME, account.name);
|
result.putString(AccountManager.KEY_ACCOUNT_NAME, account.name);
|
||||||
@@ -2920,6 +2975,7 @@ public class AccountManagerService
|
|||||||
callerPkg,
|
callerPkg,
|
||||||
callerPkgSigDigest);
|
callerPkgSigDigest);
|
||||||
if (token != null) {
|
if (token != null) {
|
||||||
|
logGetAuthTokenMetrics(callerPkg, account.type);
|
||||||
if (Log.isLoggable(TAG, Log.VERBOSE)) {
|
if (Log.isLoggable(TAG, Log.VERBOSE)) {
|
||||||
Log.v(TAG, "getAuthToken: cache hit ofr custom token authenticator.");
|
Log.v(TAG, "getAuthToken: cache hit ofr custom token authenticator.");
|
||||||
}
|
}
|
||||||
@@ -2958,6 +3014,7 @@ public class AccountManagerService
|
|||||||
mAuthenticator.getAuthTokenLabel(this, authTokenType);
|
mAuthenticator.getAuthTokenLabel(this, authTokenType);
|
||||||
} else {
|
} else {
|
||||||
mAuthenticator.getAuthToken(this, account, authTokenType, loginOptions);
|
mAuthenticator.getAuthToken(this, account, authTokenType, loginOptions);
|
||||||
|
logGetAuthTokenMetrics(callerPkg, account.type);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3040,6 +3097,16 @@ public class AccountManagerService
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void logGetAuthTokenMetrics(final String callerPackage, String accountType) {
|
||||||
|
// Although this is not a 'device policy' API, enterprise is the current use case.
|
||||||
|
DevicePolicyEventLogger
|
||||||
|
.createEvent(DevicePolicyEnums.GET_ACCOUNT_AUTH_TOKEN)
|
||||||
|
.setStrings(
|
||||||
|
TextUtils.emptyIfNull(callerPackage),
|
||||||
|
TextUtils.emptyIfNull(accountType))
|
||||||
|
.write();
|
||||||
|
}
|
||||||
|
|
||||||
private byte[] calculatePackageSignatureDigest(String callerPkg) {
|
private byte[] calculatePackageSignatureDigest(String callerPkg) {
|
||||||
MessageDigest digester;
|
MessageDigest digester;
|
||||||
try {
|
try {
|
||||||
@@ -3189,38 +3256,8 @@ public class AccountManagerService
|
|||||||
userId);
|
userId);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
addAccountAndLogMetrics(response, accountType, authTokenType, requiredFeatures,
|
||||||
final int pid = Binder.getCallingPid();
|
expectActivityLaunch, optionsIn, userId);
|
||||||
final Bundle options = (optionsIn == null) ? new Bundle() : optionsIn;
|
|
||||||
options.putInt(AccountManager.KEY_CALLER_UID, uid);
|
|
||||||
options.putInt(AccountManager.KEY_CALLER_PID, pid);
|
|
||||||
|
|
||||||
int usrId = UserHandle.getCallingUserId();
|
|
||||||
final long identityToken = clearCallingIdentity();
|
|
||||||
try {
|
|
||||||
UserAccounts accounts = getUserAccounts(usrId);
|
|
||||||
logRecordWithUid(
|
|
||||||
accounts, AccountsDb.DEBUG_ACTION_CALLED_ACCOUNT_ADD, AccountsDb.TABLE_ACCOUNTS,
|
|
||||||
uid);
|
|
||||||
new Session(accounts, response, accountType, expectActivityLaunch,
|
|
||||||
true /* stripAuthTokenFromResult */, null /* accountName */,
|
|
||||||
false /* authDetailsRequired */, true /* updateLastAuthenticationTime */) {
|
|
||||||
@Override
|
|
||||||
public void run() throws RemoteException {
|
|
||||||
mAuthenticator.addAccount(this, mAccountType, authTokenType, requiredFeatures,
|
|
||||||
options);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected String toDebugString(long now) {
|
|
||||||
return super.toDebugString(now) + ", addAccount"
|
|
||||||
+ ", accountType " + accountType
|
|
||||||
+ ", requiredFeatures " + Arrays.toString(requiredFeatures);
|
|
||||||
}
|
|
||||||
}.bind();
|
|
||||||
} finally {
|
|
||||||
restoreCallingIdentity(identityToken);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -3270,7 +3307,14 @@ public class AccountManagerService
|
|||||||
userId);
|
userId);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
addAccountAndLogMetrics(response, accountType, authTokenType, requiredFeatures,
|
||||||
|
expectActivityLaunch, optionsIn, userId);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void addAccountAndLogMetrics(
|
||||||
|
IAccountManagerResponse response, String accountType,
|
||||||
|
String authTokenType, String[] requiredFeatures,
|
||||||
|
boolean expectActivityLaunch, Bundle optionsIn, int userId) {
|
||||||
final int pid = Binder.getCallingPid();
|
final int pid = Binder.getCallingPid();
|
||||||
final int uid = Binder.getCallingUid();
|
final int uid = Binder.getCallingUid();
|
||||||
final Bundle options = (optionsIn == null) ? new Bundle() : optionsIn;
|
final Bundle options = (optionsIn == null) ? new Bundle() : optionsIn;
|
||||||
@@ -3288,8 +3332,12 @@ public class AccountManagerService
|
|||||||
false /* authDetailsRequired */, true /* updateLastAuthenticationTime */) {
|
false /* authDetailsRequired */, true /* updateLastAuthenticationTime */) {
|
||||||
@Override
|
@Override
|
||||||
public void run() throws RemoteException {
|
public void run() throws RemoteException {
|
||||||
mAuthenticator.addAccount(this, mAccountType, authTokenType, requiredFeatures,
|
mAuthenticator.addAccount(
|
||||||
options);
|
this, mAccountType, authTokenType, requiredFeatures, options);
|
||||||
|
String callerPackage = options.getString(
|
||||||
|
AccountManager.KEY_ANDROID_PACKAGE_NAME);
|
||||||
|
logAddAccountMetrics(
|
||||||
|
callerPackage, accountType, requiredFeatures, authTokenType);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -3298,8 +3346,8 @@ public class AccountManagerService
|
|||||||
+ ", accountType " + accountType
|
+ ", accountType " + accountType
|
||||||
+ ", requiredFeatures "
|
+ ", requiredFeatures "
|
||||||
+ (requiredFeatures != null
|
+ (requiredFeatures != null
|
||||||
? TextUtils.join(",", requiredFeatures)
|
? TextUtils.join(",", requiredFeatures)
|
||||||
: null);
|
: null);
|
||||||
}
|
}
|
||||||
}.bind();
|
}.bind();
|
||||||
} finally {
|
} finally {
|
||||||
@@ -3307,6 +3355,22 @@ public class AccountManagerService
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void logAddAccountMetrics(
|
||||||
|
String callerPackage, String accountType, String[] requiredFeatures,
|
||||||
|
String authTokenType) {
|
||||||
|
// Although this is not a 'device policy' API, enterprise is the current use case.
|
||||||
|
DevicePolicyEventLogger
|
||||||
|
.createEvent(DevicePolicyEnums.ADD_ACCOUNT)
|
||||||
|
.setStrings(
|
||||||
|
TextUtils.emptyIfNull(accountType),
|
||||||
|
TextUtils.emptyIfNull(callerPackage),
|
||||||
|
TextUtils.emptyIfNull(authTokenType),
|
||||||
|
requiredFeatures == null
|
||||||
|
? ""
|
||||||
|
: TextUtils.join(";", requiredFeatures))
|
||||||
|
.write();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void startAddAccountSession(
|
public void startAddAccountSession(
|
||||||
final IAccountManagerResponse response,
|
final IAccountManagerResponse response,
|
||||||
@@ -3378,6 +3442,7 @@ public class AccountManagerService
|
|||||||
public void run() throws RemoteException {
|
public void run() throws RemoteException {
|
||||||
mAuthenticator.startAddAccountSession(this, mAccountType, authTokenType,
|
mAuthenticator.startAddAccountSession(this, mAccountType, authTokenType,
|
||||||
requiredFeatures, options);
|
requiredFeatures, options);
|
||||||
|
logAddAccountMetrics(callerPkg, accountType, requiredFeatures, authTokenType);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -203,12 +203,18 @@ public class AccountManagerServiceTest extends AndroidTestCase {
|
|||||||
Account a12 = new Account("account1", AccountManagerServiceTestFixtures.ACCOUNT_TYPE_2);
|
Account a12 = new Account("account1", AccountManagerServiceTestFixtures.ACCOUNT_TYPE_2);
|
||||||
Account a22 = new Account("account2", AccountManagerServiceTestFixtures.ACCOUNT_TYPE_2);
|
Account a22 = new Account("account2", AccountManagerServiceTestFixtures.ACCOUNT_TYPE_2);
|
||||||
Account a32 = new Account("account3", AccountManagerServiceTestFixtures.ACCOUNT_TYPE_2);
|
Account a32 = new Account("account3", AccountManagerServiceTestFixtures.ACCOUNT_TYPE_2);
|
||||||
mAms.addAccountExplicitly(a11, "p11", null);
|
mAms.addAccountExplicitly(
|
||||||
mAms.addAccountExplicitly(a12, "p12", null);
|
a11, /* password= */ "p11", /* extras= */ null, /* callerPackage= */ null);
|
||||||
mAms.addAccountExplicitly(a21, "p21", null);
|
mAms.addAccountExplicitly(
|
||||||
mAms.addAccountExplicitly(a22, "p22", null);
|
a12, /* password= */ "p12", /* extras= */ null, /* callerPackage= */ null);
|
||||||
mAms.addAccountExplicitly(a31, "p31", null);
|
mAms.addAccountExplicitly(
|
||||||
mAms.addAccountExplicitly(a32, "p32", null);
|
a21, /* password= */ "p21", /* extras= */ null, /* callerPackage= */ null);
|
||||||
|
mAms.addAccountExplicitly(
|
||||||
|
a22, /* password= */ "p22", /* extras= */ null, /* callerPackage= */ null);
|
||||||
|
mAms.addAccountExplicitly(
|
||||||
|
a31, /* password= */ "p31", /* extras= */ null, /* callerPackage= */ null);
|
||||||
|
mAms.addAccountExplicitly(
|
||||||
|
a32, /* password= */ "p32", /* extras= */ null, /* callerPackage= */ null);
|
||||||
|
|
||||||
String[] list = new String[]{AccountManagerServiceTestFixtures.CALLER_PACKAGE};
|
String[] list = new String[]{AccountManagerServiceTestFixtures.CALLER_PACKAGE};
|
||||||
when(mMockPackageManager.getPackagesForUid(anyInt())).thenReturn(list);
|
when(mMockPackageManager.getPackagesForUid(anyInt())).thenReturn(list);
|
||||||
@@ -246,8 +252,10 @@ public class AccountManagerServiceTest extends AndroidTestCase {
|
|||||||
unlockSystemUser();
|
unlockSystemUser();
|
||||||
Account a11 = new Account("account1", AccountManagerServiceTestFixtures.ACCOUNT_TYPE_1);
|
Account a11 = new Account("account1", AccountManagerServiceTestFixtures.ACCOUNT_TYPE_1);
|
||||||
Account a12 = new Account("account1", AccountManagerServiceTestFixtures.ACCOUNT_TYPE_2);
|
Account a12 = new Account("account1", AccountManagerServiceTestFixtures.ACCOUNT_TYPE_2);
|
||||||
mAms.addAccountExplicitly(a11, "p11", null);
|
mAms.addAccountExplicitly(
|
||||||
mAms.addAccountExplicitly(a12, "p12", null);
|
a11, /* password= */ "p11", /* extras= */ null, /* callerPackage= */ null);
|
||||||
|
mAms.addAccountExplicitly(
|
||||||
|
a12, /* password= */ "p12", /* extras= */ null, /* callerPackage= */ null);
|
||||||
|
|
||||||
assertEquals("p11", mAms.getPassword(a11));
|
assertEquals("p11", mAms.getPassword(a11));
|
||||||
assertEquals("p12", mAms.getPassword(a12));
|
assertEquals("p12", mAms.getPassword(a12));
|
||||||
@@ -271,8 +279,8 @@ public class AccountManagerServiceTest extends AndroidTestCase {
|
|||||||
u12.putString("a", "a_a12");
|
u12.putString("a", "a_a12");
|
||||||
u12.putString("b", "b_a12");
|
u12.putString("b", "b_a12");
|
||||||
u12.putString("c", "c_a12");
|
u12.putString("c", "c_a12");
|
||||||
mAms.addAccountExplicitly(a11, "p11", u11);
|
mAms.addAccountExplicitly(a11, /* password= */ "p11", u11, /* callerPackage= */ null);
|
||||||
mAms.addAccountExplicitly(a12, "p12", u12);
|
mAms.addAccountExplicitly(a12, /* password= */ "p12", u12, /* callerPackage= */ null);
|
||||||
|
|
||||||
assertEquals("a_a11", mAms.getUserData(a11, "a"));
|
assertEquals("a_a11", mAms.getUserData(a11, "a"));
|
||||||
assertEquals("b_a11", mAms.getUserData(a11, "b"));
|
assertEquals("b_a11", mAms.getUserData(a11, "b"));
|
||||||
@@ -297,8 +305,10 @@ public class AccountManagerServiceTest extends AndroidTestCase {
|
|||||||
unlockSystemUser();
|
unlockSystemUser();
|
||||||
Account a11 = new Account("account1", AccountManagerServiceTestFixtures.ACCOUNT_TYPE_1);
|
Account a11 = new Account("account1", AccountManagerServiceTestFixtures.ACCOUNT_TYPE_1);
|
||||||
Account a12 = new Account("account1", AccountManagerServiceTestFixtures.ACCOUNT_TYPE_2);
|
Account a12 = new Account("account1", AccountManagerServiceTestFixtures.ACCOUNT_TYPE_2);
|
||||||
mAms.addAccountExplicitly(a11, "p11", null);
|
mAms.addAccountExplicitly(
|
||||||
mAms.addAccountExplicitly(a12, "p12", null);
|
a11, /* password= */ "p11", /* extras= */ null, /* callerPackage= */ null);
|
||||||
|
mAms.addAccountExplicitly(
|
||||||
|
a12, /* password= */ "p12", /* extras= */ null, /* callerPackage= */ null);
|
||||||
|
|
||||||
mAms.setAuthToken(a11, "att1", "a11_att1");
|
mAms.setAuthToken(a11, "att1", "a11_att1");
|
||||||
mAms.setAuthToken(a11, "att2", "a11_att2");
|
mAms.setAuthToken(a11, "att2", "a11_att2");
|
||||||
@@ -334,8 +344,10 @@ public class AccountManagerServiceTest extends AndroidTestCase {
|
|||||||
unlockSystemUser();
|
unlockSystemUser();
|
||||||
Account a1 = new Account("account1", AccountManagerServiceTestFixtures.ACCOUNT_TYPE_1);
|
Account a1 = new Account("account1", AccountManagerServiceTestFixtures.ACCOUNT_TYPE_1);
|
||||||
Account a2 = new Account("account2", AccountManagerServiceTestFixtures.ACCOUNT_TYPE_2);
|
Account a2 = new Account("account2", AccountManagerServiceTestFixtures.ACCOUNT_TYPE_2);
|
||||||
mAms.addAccountExplicitly(a1, "p1", null);
|
mAms.addAccountExplicitly(
|
||||||
mAms.addAccountExplicitly(a2, "p2", null);
|
a1, /* password= */ "p1", /* extras= */ null, /* callerPackage= */ null);
|
||||||
|
mAms.addAccountExplicitly(
|
||||||
|
a2, /* password= */ "p2", /* extras= */ null, /* callerPackage= */ null);
|
||||||
|
|
||||||
Context originalContext = ((MyMockContext)getContext()).mTestContext;
|
Context originalContext = ((MyMockContext)getContext()).mTestContext;
|
||||||
// create a separate instance of AMS. It initially assumes that user0 is locked
|
// create a separate instance of AMS. It initially assumes that user0 is locked
|
||||||
@@ -1426,7 +1438,11 @@ public class AccountManagerServiceTest extends AndroidTestCase {
|
|||||||
when(mMockPackageManager.getPackagesForUid(anyInt())).thenReturn(list);
|
when(mMockPackageManager.getPackagesForUid(anyInt())).thenReturn(list);
|
||||||
|
|
||||||
unlockSystemUser();
|
unlockSystemUser();
|
||||||
mAms.addAccountExplicitly(AccountManagerServiceTestFixtures.ACCOUNT_SUCCESS, "p1", null);
|
mAms.addAccountExplicitly(
|
||||||
|
AccountManagerServiceTestFixtures.ACCOUNT_SUCCESS,
|
||||||
|
/* password= */ "p1",
|
||||||
|
/* extras= */ null,
|
||||||
|
/* callerPackage= */ null);
|
||||||
Account[] addedAccounts =
|
Account[] addedAccounts =
|
||||||
mAms.getAccounts(UserHandle.USER_SYSTEM, mContext.getOpPackageName());
|
mAms.getAccounts(UserHandle.USER_SYSTEM, mContext.getOpPackageName());
|
||||||
assertEquals(1, addedAccounts.length);
|
assertEquals(1, addedAccounts.length);
|
||||||
@@ -1508,9 +1524,17 @@ public class AccountManagerServiceTest extends AndroidTestCase {
|
|||||||
AccountManager.VISIBILITY_USER_MANAGED_NOT_VISIBLE);
|
AccountManager.VISIBILITY_USER_MANAGED_NOT_VISIBLE);
|
||||||
|
|
||||||
mAms.addAccountExplicitlyWithVisibility(
|
mAms.addAccountExplicitlyWithVisibility(
|
||||||
AccountManagerServiceTestFixtures.ACCOUNT_SUCCESS, "P11", null, visibility1);
|
AccountManagerServiceTestFixtures.ACCOUNT_SUCCESS,
|
||||||
|
/* password= */ "P11",
|
||||||
|
/* extras= */ null,
|
||||||
|
visibility1,
|
||||||
|
/* callerPackage= */ null);
|
||||||
mAms.addAccountExplicitlyWithVisibility(
|
mAms.addAccountExplicitlyWithVisibility(
|
||||||
AccountManagerServiceTestFixtures.ACCOUNT_INTERVENE, "P12", null, visibility2);
|
AccountManagerServiceTestFixtures.ACCOUNT_INTERVENE,
|
||||||
|
/* password= */ "P12",
|
||||||
|
/* extras= */ null,
|
||||||
|
visibility2,
|
||||||
|
/* callerPackage= */ null);
|
||||||
|
|
||||||
Account[] accounts = mAms.getAccountsByTypeForPackage(
|
Account[] accounts = mAms.getAccountsByTypeForPackage(
|
||||||
null, "otherPackageName",
|
null, "otherPackageName",
|
||||||
@@ -1631,7 +1655,11 @@ public class AccountManagerServiceTest extends AndroidTestCase {
|
|||||||
when(mMockContext.getPackageManager()).thenReturn(mMockPackageManager);
|
when(mMockContext.getPackageManager()).thenReturn(mMockPackageManager);
|
||||||
String[] list = new String[]{AccountManagerServiceTestFixtures.CALLER_PACKAGE};
|
String[] list = new String[]{AccountManagerServiceTestFixtures.CALLER_PACKAGE};
|
||||||
when(mMockPackageManager.getPackagesForUid(anyInt())).thenReturn(list);
|
when(mMockPackageManager.getPackagesForUid(anyInt())).thenReturn(list);
|
||||||
mAms.addAccountExplicitly(AccountManagerServiceTestFixtures.ACCOUNT_SUCCESS, "p11", null);
|
mAms.addAccountExplicitly(
|
||||||
|
AccountManagerServiceTestFixtures.ACCOUNT_SUCCESS,
|
||||||
|
/* password= */ "p11",
|
||||||
|
/* extras= */ null,
|
||||||
|
/* callerPackage= */ null);
|
||||||
|
|
||||||
mAms.setAuthToken(AccountManagerServiceTestFixtures.ACCOUNT_SUCCESS,
|
mAms.setAuthToken(AccountManagerServiceTestFixtures.ACCOUNT_SUCCESS,
|
||||||
"authTokenType", AccountManagerServiceTestFixtures.AUTH_TOKEN);
|
"authTokenType", AccountManagerServiceTestFixtures.AUTH_TOKEN);
|
||||||
@@ -2438,7 +2466,11 @@ public class AccountManagerServiceTest extends AndroidTestCase {
|
|||||||
public void testGetAccountByTypeAndFeaturesWithNoFeaturesAndOneVisibleAccount()
|
public void testGetAccountByTypeAndFeaturesWithNoFeaturesAndOneVisibleAccount()
|
||||||
throws Exception {
|
throws Exception {
|
||||||
unlockSystemUser();
|
unlockSystemUser();
|
||||||
mAms.addAccountExplicitly(AccountManagerServiceTestFixtures.ACCOUNT_SUCCESS, "p11", null);
|
mAms.addAccountExplicitly(
|
||||||
|
AccountManagerServiceTestFixtures.ACCOUNT_SUCCESS,
|
||||||
|
/* password= */ "p11",
|
||||||
|
/* extras= */ null,
|
||||||
|
/* callerPackage= */ null);
|
||||||
mAms.getAccountByTypeAndFeatures(
|
mAms.getAccountByTypeAndFeatures(
|
||||||
mMockAccountManagerResponse,
|
mMockAccountManagerResponse,
|
||||||
AccountManagerServiceTestFixtures.ACCOUNT_TYPE_1,
|
AccountManagerServiceTestFixtures.ACCOUNT_TYPE_1,
|
||||||
@@ -2460,7 +2492,11 @@ public class AccountManagerServiceTest extends AndroidTestCase {
|
|||||||
visibility.put(AccountManagerServiceTestFixtures.CALLER_PACKAGE,
|
visibility.put(AccountManagerServiceTestFixtures.CALLER_PACKAGE,
|
||||||
AccountManager.VISIBILITY_USER_MANAGED_NOT_VISIBLE);
|
AccountManager.VISIBILITY_USER_MANAGED_NOT_VISIBLE);
|
||||||
mAms.addAccountExplicitlyWithVisibility(
|
mAms.addAccountExplicitlyWithVisibility(
|
||||||
AccountManagerServiceTestFixtures.ACCOUNT_SUCCESS, "p11", null, visibility);
|
AccountManagerServiceTestFixtures.ACCOUNT_SUCCESS,
|
||||||
|
/* password= */ "p11",
|
||||||
|
/* extras= */ null,
|
||||||
|
visibility,
|
||||||
|
/* callerPackage= */ null);
|
||||||
mAms.getAccountByTypeAndFeatures(
|
mAms.getAccountByTypeAndFeatures(
|
||||||
mMockAccountManagerResponse,
|
mMockAccountManagerResponse,
|
||||||
AccountManagerServiceTestFixtures.ACCOUNT_TYPE_1,
|
AccountManagerServiceTestFixtures.ACCOUNT_TYPE_1,
|
||||||
@@ -2476,8 +2512,16 @@ public class AccountManagerServiceTest extends AndroidTestCase {
|
|||||||
@SmallTest
|
@SmallTest
|
||||||
public void testGetAccountByTypeAndFeaturesWithNoFeaturesAndTwoAccounts() throws Exception {
|
public void testGetAccountByTypeAndFeaturesWithNoFeaturesAndTwoAccounts() throws Exception {
|
||||||
unlockSystemUser();
|
unlockSystemUser();
|
||||||
mAms.addAccountExplicitly(AccountManagerServiceTestFixtures.ACCOUNT_SUCCESS, "p11", null);
|
mAms.addAccountExplicitly(
|
||||||
mAms.addAccountExplicitly(AccountManagerServiceTestFixtures.ACCOUNT_INTERVENE, "p12", null);
|
AccountManagerServiceTestFixtures.ACCOUNT_SUCCESS,
|
||||||
|
/* password= */ "p11",
|
||||||
|
/* extras= */ null,
|
||||||
|
/* callerPackage= */ null);
|
||||||
|
mAms.addAccountExplicitly(
|
||||||
|
AccountManagerServiceTestFixtures.ACCOUNT_INTERVENE,
|
||||||
|
/* password= */ "p12",
|
||||||
|
/* extras= */ null,
|
||||||
|
/* callerPackage= */ null);
|
||||||
|
|
||||||
mAms.getAccountByTypeAndFeatures(
|
mAms.getAccountByTypeAndFeatures(
|
||||||
mMockAccountManagerResponse,
|
mMockAccountManagerResponse,
|
||||||
@@ -2519,7 +2563,11 @@ public class AccountManagerServiceTest extends AndroidTestCase {
|
|||||||
public void testGetAccountByTypeAndFeaturesWithFeaturesAndNoQualifiedAccount()
|
public void testGetAccountByTypeAndFeaturesWithFeaturesAndNoQualifiedAccount()
|
||||||
throws Exception {
|
throws Exception {
|
||||||
unlockSystemUser();
|
unlockSystemUser();
|
||||||
mAms.addAccountExplicitly(AccountManagerServiceTestFixtures.ACCOUNT_INTERVENE, "p12", null);
|
mAms.addAccountExplicitly(
|
||||||
|
AccountManagerServiceTestFixtures.ACCOUNT_INTERVENE,
|
||||||
|
/* password= */ "p12",
|
||||||
|
/* extras= */ null,
|
||||||
|
/* callerPackage= */ null);
|
||||||
final CountDownLatch latch = new CountDownLatch(1);
|
final CountDownLatch latch = new CountDownLatch(1);
|
||||||
mAms.getAccountByTypeAndFeatures(
|
mAms.getAccountByTypeAndFeatures(
|
||||||
mMockAccountManagerResponse,
|
mMockAccountManagerResponse,
|
||||||
@@ -2539,8 +2587,16 @@ public class AccountManagerServiceTest extends AndroidTestCase {
|
|||||||
public void testGetAccountByTypeAndFeaturesWithFeaturesAndOneQualifiedAccount()
|
public void testGetAccountByTypeAndFeaturesWithFeaturesAndOneQualifiedAccount()
|
||||||
throws Exception {
|
throws Exception {
|
||||||
unlockSystemUser();
|
unlockSystemUser();
|
||||||
mAms.addAccountExplicitly(AccountManagerServiceTestFixtures.ACCOUNT_SUCCESS, "p11", null);
|
mAms.addAccountExplicitly(
|
||||||
mAms.addAccountExplicitly(AccountManagerServiceTestFixtures.ACCOUNT_INTERVENE, "p12", null);
|
AccountManagerServiceTestFixtures.ACCOUNT_SUCCESS,
|
||||||
|
/* password= */ "p11",
|
||||||
|
/* extras= */ null,
|
||||||
|
/* callerPackage= */ null);
|
||||||
|
mAms.addAccountExplicitly(
|
||||||
|
AccountManagerServiceTestFixtures.ACCOUNT_INTERVENE,
|
||||||
|
/* password= */ "p12",
|
||||||
|
/* extras= */ null,
|
||||||
|
/* callerPackage= */ null);
|
||||||
final CountDownLatch latch = new CountDownLatch(1);
|
final CountDownLatch latch = new CountDownLatch(1);
|
||||||
mAms.getAccountByTypeAndFeatures(
|
mAms.getAccountByTypeAndFeatures(
|
||||||
mMockAccountManagerResponse,
|
mMockAccountManagerResponse,
|
||||||
@@ -2564,7 +2620,11 @@ public class AccountManagerServiceTest extends AndroidTestCase {
|
|||||||
visibility.put(AccountManagerServiceTestFixtures.CALLER_PACKAGE,
|
visibility.put(AccountManagerServiceTestFixtures.CALLER_PACKAGE,
|
||||||
AccountManager.VISIBILITY_USER_MANAGED_NOT_VISIBLE);
|
AccountManager.VISIBILITY_USER_MANAGED_NOT_VISIBLE);
|
||||||
mAms.addAccountExplicitlyWithVisibility(
|
mAms.addAccountExplicitlyWithVisibility(
|
||||||
AccountManagerServiceTestFixtures.ACCOUNT_SUCCESS, "p11", null, visibility);
|
AccountManagerServiceTestFixtures.ACCOUNT_SUCCESS,
|
||||||
|
/* password= */ "p11",
|
||||||
|
/* extras= */ null,
|
||||||
|
visibility,
|
||||||
|
/* callerPackage= */ null);
|
||||||
final CountDownLatch latch = new CountDownLatch(1);
|
final CountDownLatch latch = new CountDownLatch(1);
|
||||||
mAms.getAccountByTypeAndFeatures(
|
mAms.getAccountByTypeAndFeatures(
|
||||||
mMockAccountManagerResponse,
|
mMockAccountManagerResponse,
|
||||||
@@ -2583,9 +2643,21 @@ public class AccountManagerServiceTest extends AndroidTestCase {
|
|||||||
public void testGetAccountByTypeAndFeaturesWithFeaturesAndTwoQualifiedAccount()
|
public void testGetAccountByTypeAndFeaturesWithFeaturesAndTwoQualifiedAccount()
|
||||||
throws Exception {
|
throws Exception {
|
||||||
unlockSystemUser();
|
unlockSystemUser();
|
||||||
mAms.addAccountExplicitly(AccountManagerServiceTestFixtures.ACCOUNT_SUCCESS, "p11", null);
|
mAms.addAccountExplicitly(
|
||||||
mAms.addAccountExplicitly(AccountManagerServiceTestFixtures.ACCOUNT_SUCCESS_2, "p12", null);
|
AccountManagerServiceTestFixtures.ACCOUNT_SUCCESS,
|
||||||
mAms.addAccountExplicitly(AccountManagerServiceTestFixtures.ACCOUNT_INTERVENE, "p13", null);
|
/* password= */ "p11",
|
||||||
|
/* extras= */ null,
|
||||||
|
/* callerPackage= */ null);
|
||||||
|
mAms.addAccountExplicitly(
|
||||||
|
AccountManagerServiceTestFixtures.ACCOUNT_SUCCESS_2,
|
||||||
|
/* password= */ "p12",
|
||||||
|
/* extras= */ null,
|
||||||
|
/* callerPackage= */ null);
|
||||||
|
mAms.addAccountExplicitly(
|
||||||
|
AccountManagerServiceTestFixtures.ACCOUNT_INTERVENE,
|
||||||
|
/* password= */ "p13",
|
||||||
|
/* extras= */ null,
|
||||||
|
/* callerPackage= */ null);
|
||||||
final CountDownLatch latch = new CountDownLatch(1);
|
final CountDownLatch latch = new CountDownLatch(1);
|
||||||
mAms.getAccountByTypeAndFeatures(
|
mAms.getAccountByTypeAndFeatures(
|
||||||
mMockAccountManagerResponse,
|
mMockAccountManagerResponse,
|
||||||
@@ -2666,8 +2738,16 @@ public class AccountManagerServiceTest extends AndroidTestCase {
|
|||||||
public void testGetAccountsByFeaturesNullFeatureReturnsAllAccounts() throws Exception {
|
public void testGetAccountsByFeaturesNullFeatureReturnsAllAccounts() throws Exception {
|
||||||
unlockSystemUser();
|
unlockSystemUser();
|
||||||
|
|
||||||
mAms.addAccountExplicitly(AccountManagerServiceTestFixtures.ACCOUNT_SUCCESS, "p11", null);
|
mAms.addAccountExplicitly(
|
||||||
mAms.addAccountExplicitly(AccountManagerServiceTestFixtures.ACCOUNT_INTERVENE, "p12", null);
|
AccountManagerServiceTestFixtures.ACCOUNT_SUCCESS,
|
||||||
|
/* password= */ "p11",
|
||||||
|
/* extras= */ null,
|
||||||
|
/* callerPackage= */ null);
|
||||||
|
mAms.addAccountExplicitly(
|
||||||
|
AccountManagerServiceTestFixtures.ACCOUNT_INTERVENE,
|
||||||
|
/* password= */ "p12",
|
||||||
|
/* extras= */ null,
|
||||||
|
/* callerPackage= */ null);
|
||||||
|
|
||||||
final CountDownLatch latch = new CountDownLatch(1);
|
final CountDownLatch latch = new CountDownLatch(1);
|
||||||
Response response = new Response(latch, mMockAccountManagerResponse);
|
Response response = new Response(latch, mMockAccountManagerResponse);
|
||||||
@@ -2691,8 +2771,16 @@ public class AccountManagerServiceTest extends AndroidTestCase {
|
|||||||
public void testGetAccountsByFeaturesReturnsAccountsWithFeaturesOnly() throws Exception {
|
public void testGetAccountsByFeaturesReturnsAccountsWithFeaturesOnly() throws Exception {
|
||||||
unlockSystemUser();
|
unlockSystemUser();
|
||||||
|
|
||||||
mAms.addAccountExplicitly(AccountManagerServiceTestFixtures.ACCOUNT_SUCCESS, "p11", null);
|
mAms.addAccountExplicitly(
|
||||||
mAms.addAccountExplicitly(AccountManagerServiceTestFixtures.ACCOUNT_INTERVENE, "p12", null);
|
AccountManagerServiceTestFixtures.ACCOUNT_SUCCESS,
|
||||||
|
/* password= */ "p11",
|
||||||
|
/* extras= */ null,
|
||||||
|
/* callerPackage= */ null);
|
||||||
|
mAms.addAccountExplicitly(
|
||||||
|
AccountManagerServiceTestFixtures.ACCOUNT_INTERVENE,
|
||||||
|
/* password= */ "p12",
|
||||||
|
/* extras= */ null,
|
||||||
|
/* callerPackage= */ null);
|
||||||
|
|
||||||
final CountDownLatch latch = new CountDownLatch(1);
|
final CountDownLatch latch = new CountDownLatch(1);
|
||||||
Response response = new Response(latch, mMockAccountManagerResponse);
|
Response response = new Response(latch, mMockAccountManagerResponse);
|
||||||
@@ -2713,8 +2801,16 @@ public class AccountManagerServiceTest extends AndroidTestCase {
|
|||||||
@SmallTest
|
@SmallTest
|
||||||
public void testGetAccountsByFeaturesError() throws Exception {
|
public void testGetAccountsByFeaturesError() throws Exception {
|
||||||
unlockSystemUser();
|
unlockSystemUser();
|
||||||
mAms.addAccountExplicitly(AccountManagerServiceTestFixtures.ACCOUNT_SUCCESS, "p11", null);
|
mAms.addAccountExplicitly(
|
||||||
mAms.addAccountExplicitly(AccountManagerServiceTestFixtures.ACCOUNT_ERROR, "p12", null);
|
AccountManagerServiceTestFixtures.ACCOUNT_SUCCESS,
|
||||||
|
/* password= */ "p11",
|
||||||
|
/* extras= */ null,
|
||||||
|
/* callerPackage= */ null);
|
||||||
|
mAms.addAccountExplicitly(
|
||||||
|
AccountManagerServiceTestFixtures.ACCOUNT_ERROR,
|
||||||
|
/* password= */ "p12",
|
||||||
|
/* extras= */ null,
|
||||||
|
/* callerPackage= */ null);
|
||||||
|
|
||||||
final CountDownLatch latch = new CountDownLatch(1);
|
final CountDownLatch latch = new CountDownLatch(1);
|
||||||
Response response = new Response(latch, mMockAccountManagerResponse);
|
Response response = new Response(latch, mMockAccountManagerResponse);
|
||||||
@@ -2758,7 +2854,11 @@ public class AccountManagerServiceTest extends AndroidTestCase {
|
|||||||
new String [] {AccountManagerServiceTestFixtures.ACCOUNT_TYPE_1},
|
new String [] {AccountManagerServiceTestFixtures.ACCOUNT_TYPE_1},
|
||||||
"testpackage"); // opPackageName
|
"testpackage"); // opPackageName
|
||||||
|
|
||||||
mAms.addAccountExplicitly(AccountManagerServiceTestFixtures.ACCOUNT_SUCCESS, "p11", null);
|
mAms.addAccountExplicitly(
|
||||||
|
AccountManagerServiceTestFixtures.ACCOUNT_SUCCESS,
|
||||||
|
/* password= */ "p11",
|
||||||
|
/* extras= */ null,
|
||||||
|
/* callerPackage= */ null);
|
||||||
// Notification about new account
|
// Notification about new account
|
||||||
updateBroadcastCounters(2);
|
updateBroadcastCounters(2);
|
||||||
assertEquals(mVisibleAccountsChangedBroadcasts, 1);
|
assertEquals(mVisibleAccountsChangedBroadcasts, 1);
|
||||||
@@ -2772,9 +2872,16 @@ public class AccountManagerServiceTest extends AndroidTestCase {
|
|||||||
new String [] {AccountManagerServiceTestFixtures.ACCOUNT_TYPE_2},
|
new String [] {AccountManagerServiceTestFixtures.ACCOUNT_TYPE_2},
|
||||||
"testpackage"); // opPackageName
|
"testpackage"); // opPackageName
|
||||||
|
|
||||||
mAms.addAccountExplicitly(AccountManagerServiceTestFixtures.ACCOUNT_SUCCESS, "p11", null);
|
|
||||||
mAms.addAccountExplicitly(
|
mAms.addAccountExplicitly(
|
||||||
AccountManagerServiceTestFixtures.ACCOUNT_INTERVENE, "p11", null);
|
AccountManagerServiceTestFixtures.ACCOUNT_SUCCESS,
|
||||||
|
/* password= */ "p11",
|
||||||
|
/* extras= */ null,
|
||||||
|
/* callerPackage= */ null);
|
||||||
|
mAms.addAccountExplicitly(
|
||||||
|
AccountManagerServiceTestFixtures.ACCOUNT_INTERVENE,
|
||||||
|
/* password= */ "p11",
|
||||||
|
/* extras= */ null,
|
||||||
|
/* callerPackage= */ null);
|
||||||
// Notification about new account
|
// Notification about new account
|
||||||
|
|
||||||
updateBroadcastCounters(2);
|
updateBroadcastCounters(2);
|
||||||
@@ -2794,14 +2901,21 @@ public class AccountManagerServiceTest extends AndroidTestCase {
|
|||||||
new String [] {AccountManagerServiceTestFixtures.ACCOUNT_TYPE_1},
|
new String [] {AccountManagerServiceTestFixtures.ACCOUNT_TYPE_1},
|
||||||
AccountManagerServiceTestFixtures.CALLER_PACKAGE);
|
AccountManagerServiceTestFixtures.CALLER_PACKAGE);
|
||||||
mAms.addAccountExplicitlyWithVisibility(
|
mAms.addAccountExplicitlyWithVisibility(
|
||||||
AccountManagerServiceTestFixtures.ACCOUNT_SUCCESS, "p11", null, visibility);
|
AccountManagerServiceTestFixtures.ACCOUNT_SUCCESS,
|
||||||
|
/* password= */ "p11",
|
||||||
|
/* extras= */ null, visibility,
|
||||||
|
/* callerPackage= */ null);
|
||||||
mAms.unregisterAccountListener(
|
mAms.unregisterAccountListener(
|
||||||
new String [] {AccountManagerServiceTestFixtures.ACCOUNT_TYPE_1},
|
new String [] {AccountManagerServiceTestFixtures.ACCOUNT_TYPE_1},
|
||||||
AccountManagerServiceTestFixtures.CALLER_PACKAGE);
|
AccountManagerServiceTestFixtures.CALLER_PACKAGE);
|
||||||
|
|
||||||
addAccountRemovedReceiver(AccountManagerServiceTestFixtures.CALLER_PACKAGE);
|
addAccountRemovedReceiver(AccountManagerServiceTestFixtures.CALLER_PACKAGE);
|
||||||
mAms.addAccountExplicitlyWithVisibility(
|
mAms.addAccountExplicitlyWithVisibility(
|
||||||
AccountManagerServiceTestFixtures.ACCOUNT_INTERVENE, "p11", null, visibility);
|
AccountManagerServiceTestFixtures.ACCOUNT_INTERVENE,
|
||||||
|
/* password= */ "p11",
|
||||||
|
/* extras= */ null,
|
||||||
|
visibility,
|
||||||
|
/* callerPackage= */ null);
|
||||||
|
|
||||||
updateBroadcastCounters(3);
|
updateBroadcastCounters(3);
|
||||||
assertEquals(mVisibleAccountsChangedBroadcasts, 1);
|
assertEquals(mVisibleAccountsChangedBroadcasts, 1);
|
||||||
@@ -2839,7 +2953,11 @@ public class AccountManagerServiceTest extends AndroidTestCase {
|
|||||||
new String [] {AccountManagerServiceTestFixtures.ACCOUNT_TYPE_1},
|
new String [] {AccountManagerServiceTestFixtures.ACCOUNT_TYPE_1},
|
||||||
"testpackage3"); // opPackageName
|
"testpackage3"); // opPackageName
|
||||||
mAms.addAccountExplicitlyWithVisibility(
|
mAms.addAccountExplicitlyWithVisibility(
|
||||||
AccountManagerServiceTestFixtures.ACCOUNT_SUCCESS, "p11", null, visibility);
|
AccountManagerServiceTestFixtures.ACCOUNT_SUCCESS,
|
||||||
|
/* password= */ "p11",
|
||||||
|
/* extras= */ null,
|
||||||
|
visibility,
|
||||||
|
/* callerPackage= */ null);
|
||||||
updateBroadcastCounters(4);
|
updateBroadcastCounters(4);
|
||||||
assertEquals(mVisibleAccountsChangedBroadcasts, 3);
|
assertEquals(mVisibleAccountsChangedBroadcasts, 3);
|
||||||
assertEquals(mLoginAccountsChangedBroadcasts, 1);
|
assertEquals(mLoginAccountsChangedBroadcasts, 1);
|
||||||
@@ -2856,7 +2974,10 @@ public class AccountManagerServiceTest extends AndroidTestCase {
|
|||||||
|
|
||||||
// Add account of another type.
|
// Add account of another type.
|
||||||
mAms.addAccountExplicitly(
|
mAms.addAccountExplicitly(
|
||||||
AccountManagerServiceTestFixtures.ACCOUNT_SUCCESS_TYPE_2, "p11", null);
|
AccountManagerServiceTestFixtures.ACCOUNT_SUCCESS_TYPE_2,
|
||||||
|
/* password= */ "p11",
|
||||||
|
/* extras= */ null,
|
||||||
|
/* callerPackage= */ null);
|
||||||
|
|
||||||
updateBroadcastCounters(8);
|
updateBroadcastCounters(8);
|
||||||
assertEquals(mVisibleAccountsChangedBroadcasts, 5);
|
assertEquals(mVisibleAccountsChangedBroadcasts, 5);
|
||||||
@@ -2884,7 +3005,11 @@ public class AccountManagerServiceTest extends AndroidTestCase {
|
|||||||
new String [] {AccountManagerServiceTestFixtures.ACCOUNT_TYPE_1},
|
new String [] {AccountManagerServiceTestFixtures.ACCOUNT_TYPE_1},
|
||||||
"testpackage3"); // opPackageName
|
"testpackage3"); // opPackageName
|
||||||
mAms.addAccountExplicitlyWithVisibility(
|
mAms.addAccountExplicitlyWithVisibility(
|
||||||
AccountManagerServiceTestFixtures.ACCOUNT_SUCCESS, "p11", null, visibility);
|
AccountManagerServiceTestFixtures.ACCOUNT_SUCCESS,
|
||||||
|
/* password= */ "p11",
|
||||||
|
/* extras= */ null,
|
||||||
|
visibility,
|
||||||
|
/* callerPackage= */ null);
|
||||||
|
|
||||||
updateBroadcastCounters(2);
|
updateBroadcastCounters(2);
|
||||||
assertEquals(mVisibleAccountsChangedBroadcasts, 1);
|
assertEquals(mVisibleAccountsChangedBroadcasts, 1);
|
||||||
@@ -2904,7 +3029,11 @@ public class AccountManagerServiceTest extends AndroidTestCase {
|
|||||||
mAms.registerAccountListener(
|
mAms.registerAccountListener(
|
||||||
new String [] {AccountManagerServiceTestFixtures.ACCOUNT_TYPE_1},
|
new String [] {AccountManagerServiceTestFixtures.ACCOUNT_TYPE_1},
|
||||||
"testpackage"); // opPackageName
|
"testpackage"); // opPackageName
|
||||||
mAms.addAccountExplicitly(AccountManagerServiceTestFixtures.ACCOUNT_SUCCESS, "p11", null);
|
mAms.addAccountExplicitly(
|
||||||
|
AccountManagerServiceTestFixtures.ACCOUNT_SUCCESS,
|
||||||
|
/* password= */ "p11",
|
||||||
|
/* extras= */ null,
|
||||||
|
/* callerPackage= */ null);
|
||||||
mAms.setPassword(AccountManagerServiceTestFixtures.ACCOUNT_SUCCESS, "pwd");
|
mAms.setPassword(AccountManagerServiceTestFixtures.ACCOUNT_SUCCESS, "pwd");
|
||||||
updateBroadcastCounters(4);
|
updateBroadcastCounters(4);
|
||||||
assertEquals(mVisibleAccountsChangedBroadcasts, 2);
|
assertEquals(mVisibleAccountsChangedBroadcasts, 2);
|
||||||
@@ -2963,7 +3092,8 @@ public class AccountManagerServiceTest extends AndroidTestCase {
|
|||||||
|
|
||||||
Account a1 = new Account("account1",
|
Account a1 = new Account("account1",
|
||||||
AccountManagerServiceTestFixtures.ACCOUNT_TYPE_1);
|
AccountManagerServiceTestFixtures.ACCOUNT_TYPE_1);
|
||||||
mAms.addAccountExplicitly(a1, "p1", null);
|
mAms.addAccountExplicitly(
|
||||||
|
a1, /* password= */ "p1", /* extras= */ null, /* callerPackage= */ null);
|
||||||
List<String> errors = Collections.synchronizedList(new ArrayList<>());
|
List<String> errors = Collections.synchronizedList(new ArrayList<>());
|
||||||
int readerCount = 2;
|
int readerCount = 2;
|
||||||
ExecutorService es = Executors.newFixedThreadPool(readerCount + 1);
|
ExecutorService es = Executors.newFixedThreadPool(readerCount + 1);
|
||||||
@@ -3040,7 +3170,8 @@ public class AccountManagerServiceTest extends AndroidTestCase {
|
|||||||
|
|
||||||
Account a1 = new Account("account1",
|
Account a1 = new Account("account1",
|
||||||
AccountManagerServiceTestFixtures.ACCOUNT_TYPE_1);
|
AccountManagerServiceTestFixtures.ACCOUNT_TYPE_1);
|
||||||
mAms.addAccountExplicitly(a1, "p1", null);
|
mAms.addAccountExplicitly(
|
||||||
|
a1, /* password= */ "p1", /* extras= */ null, /* callerPackage= */ null);
|
||||||
List<String> errors = Collections.synchronizedList(new ArrayList<>());
|
List<String> errors = Collections.synchronizedList(new ArrayList<>());
|
||||||
int readerCount = 2;
|
int readerCount = 2;
|
||||||
ExecutorService es = Executors.newFixedThreadPool(readerCount + 1);
|
ExecutorService es = Executors.newFixedThreadPool(readerCount + 1);
|
||||||
|
|||||||
Reference in New Issue
Block a user