Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 462de7cd authored by Justin Dunlap's avatar Justin Dunlap Committed by Android Build Coastguard Worker
Browse files

Revert "DO NOT MERGE"

This reverts commit aa58f990.

Reason for revert: For security branch cherrypicking only

BUG=262757901

Change-Id: Ie81a93e7046ae6111c2871ebe05f1461cf5b2545
(cherry picked from commit eeb77dcc770240a46c40a0d1f25ffa7a11fefb26)
Merged-In: Ie81a93e7046ae6111c2871ebe05f1461cf5b2545
parent 1eb450d9
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -30,6 +30,7 @@ import android.util.Log;

import com.android.internal.annotations.GuardedBy;

import java.util.Objects;
import java.util.Set;

/**
@@ -85,6 +86,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;
+0 −12
Original line number Diff line number Diff line
@@ -1807,14 +1807,6 @@ public class AccountManagerService
        if (account == null) {
            return false;
        }
        if (account.name != null && account.name.length() > 200) {
            Log.w(TAG, "Account cannot be added - Name longer than 200 chars");
            return false;
        }
        if (account.type != null && account.type.length() > 200) {
            Log.w(TAG, "Account cannot be added - Name longer than 200 chars");
            return false;
        }
        if (!isLocalUnlockedUser(accounts.userId)) {
            Log.w(TAG, "Account " + account.toSafeString() + " cannot be added - user "
                    + accounts.userId + " is locked. callingUid=" + callingUid);
@@ -2008,10 +2000,6 @@ public class AccountManagerService
                + ", pid " + Binder.getCallingPid());
        }
        if (accountToRename == null) throw new IllegalArgumentException("account is null");
        if (newName != null && newName.length() > 200) {
            Log.e(TAG, "renameAccount failed - account name longer than 200");
            throw new IllegalArgumentException("account name longer than 200");
        }
        int userId = UserHandle.getCallingUserId();
        if (!isAccountManagedByCaller(accountToRename.type, callingUid, userId)) {
            String msg = String.format(
+0 −22
Original line number Diff line number Diff line
@@ -36,7 +36,6 @@ import android.accounts.CantAddAccountActivity;
import android.accounts.IAccountManagerResponse;
import android.app.AppOpsManager;
import android.app.INotificationManager;
import android.app.PropertyInvalidatedCache;
import android.app.admin.DevicePolicyManager;
import android.app.admin.DevicePolicyManagerInternal;
import android.content.BroadcastReceiver;
@@ -133,8 +132,6 @@ public class AccountManagerServiceTest extends AndroidTestCase {
    protected void setUp() throws Exception {
        MockitoAnnotations.initMocks(this);

        PropertyInvalidatedCache.disableForTestMode();

        when(mMockPackageManager.checkSignatures(anyInt(), anyInt()))
                    .thenReturn(PackageManager.SIGNATURE_MATCH);
        final UserInfo ui = new UserInfo(UserHandle.USER_SYSTEM, "user0", 0);
@@ -244,25 +241,6 @@ public class AccountManagerServiceTest extends AndroidTestCase {
        assertEquals(a31, accounts[1]);
    }

    @SmallTest
    public void testCheckAddAccountLongName() throws Exception {
        unlockSystemUser();
        String longString = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
                + "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
                + "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
                + "aaaaa";
        Account a11 = new Account(longString, AccountManagerServiceTestFixtures.ACCOUNT_TYPE_1);

        mAms.addAccountExplicitly(a11, /* password= */ "p11", /* extras= */ null);

        String[] list = new String[]{AccountManagerServiceTestFixtures.CALLER_PACKAGE};
        when(mMockPackageManager.getPackagesForUid(anyInt())).thenReturn(list);
        Account[] accounts = mAms.getAccountsAsUser(null,
                UserHandle.getCallingUserId(), mContext.getOpPackageName());
        assertEquals(0, accounts.length);
    }


    @SmallTest
    public void testPasswords() throws Exception {
        unlockSystemUser();