Prevent apps from spamming addAccountExplicitly.
See comment here for the discussion on solution
https://b.corp.google.com/issues/169762606#comment14
Change-Id: If212df3a3b7be1de0fb26b8e88b2fcbb8077c253
Bug: 169762606
(cherry picked from commit 11053c17b3)
Change-Id: I6494366a5695daedc3f4f0046da9e130a5363f5f
Merged-In: If212df3a3b7be1de0fb26b8e88b2fcbb8077c253
This commit is contained in:
@@ -28,6 +28,7 @@ import android.util.ArraySet;
|
||||
import android.util.Log;
|
||||
import com.android.internal.annotations.GuardedBy;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
@@ -80,6 +81,12 @@ public class Account implements Parcelable {
|
||||
if (TextUtils.isEmpty(type)) {
|
||||
throw new IllegalArgumentException("the type must not be empty: " + type);
|
||||
}
|
||||
if (name.length() > 200) {
|
||||
throw new IllegalArgumentException("account name is longer than 200 characters");
|
||||
}
|
||||
if (type.length() > 200) {
|
||||
throw new IllegalArgumentException("account type is longer than 200 characters");
|
||||
}
|
||||
this.name = name;
|
||||
this.type = type;
|
||||
this.accessId = accessId;
|
||||
|
||||
@@ -1790,6 +1790,11 @@ public class AccountManagerService
|
||||
+ ", skipping since the account already exists");
|
||||
return false;
|
||||
}
|
||||
if (accounts.accountsDb.findAllDeAccounts().size() > 100) {
|
||||
Log.w(TAG, "insertAccountIntoDatabase: " + account
|
||||
+ ", skipping since more than 50 accounts on device exist");
|
||||
return false;
|
||||
}
|
||||
long accountId = accounts.accountsDb.insertCeAccount(account, password);
|
||||
if (accountId < 0) {
|
||||
Log.w(TAG, "insertAccountIntoDatabase: " + account
|
||||
|
||||
Reference in New Issue
Block a user