Merge "Prevent apps from spamming addAccountExplicitly. See comment here for the discussion on solution https://b.corp.google.com/issues/169762606#comment14" into pi-dev am: a0226b4d47
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/15405290 Change-Id: I0073721ed49e40043625eae71f37e7e95b987340
This commit is contained in:
@@ -30,6 +30,7 @@ import android.util.Log;
|
|||||||
|
|
||||||
import com.android.internal.annotations.GuardedBy;
|
import com.android.internal.annotations.GuardedBy;
|
||||||
|
|
||||||
|
import java.util.Objects;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -85,6 +86,12 @@ public class Account implements Parcelable {
|
|||||||
if (TextUtils.isEmpty(type)) {
|
if (TextUtils.isEmpty(type)) {
|
||||||
throw new IllegalArgumentException("the type must not be empty: " + 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.name = name;
|
||||||
this.type = type;
|
this.type = type;
|
||||||
this.accessId = accessId;
|
this.accessId = accessId;
|
||||||
|
|||||||
@@ -1787,6 +1787,11 @@ public class AccountManagerService
|
|||||||
+ ", skipping since the account already exists");
|
+ ", skipping since the account already exists");
|
||||||
return false;
|
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);
|
long accountId = accounts.accountsDb.insertCeAccount(account, password);
|
||||||
if (accountId < 0) {
|
if (accountId < 0) {
|
||||||
Log.w(TAG, "insertAccountIntoDatabase: " + account.toSafeString()
|
Log.w(TAG, "insertAccountIntoDatabase: " + account.toSafeString()
|
||||||
|
|||||||
Reference in New Issue
Block a user