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

Commit 041232a7 authored by Fyodor Kupolov's avatar Fyodor Kupolov
Browse files

Copy shared accounts after the user is unlocked

Previously accounts were copied in onUserStarted. At that stage only
encryption-aware authenticators could run.

Bug: 27274434
Change-Id: I4f2dbdc09e81087d960067e7930ce3b9cff829ab
parent 26b27543
Loading
Loading
Loading
Loading
+7 −11
Original line number Diff line number Diff line
@@ -315,15 +315,15 @@ public class AccountManagerService

        IntentFilter userFilter = new IntentFilter();
        userFilter.addAction(Intent.ACTION_USER_REMOVED);
        userFilter.addAction(Intent.ACTION_USER_STARTED);
        userFilter.addAction(Intent.ACTION_USER_UNLOCKED);
        mContext.registerReceiverAsUser(new BroadcastReceiver() {
            @Override
            public void onReceive(Context context, Intent intent) {
                String action = intent.getAction();
                if (Intent.ACTION_USER_REMOVED.equals(action)) {
                    onUserRemoved(intent);
                } else if (Intent.ACTION_USER_STARTED.equals(action)) {
                    onUserStarted(intent);
                } else if (Intent.ACTION_USER_UNLOCKED.equals(action)) {
                    onUserUnlocked(intent);
                }
            }
        }, UserHandle.ALL, userFilter, null, null);
@@ -513,7 +513,7 @@ public class AccountManagerService
        }
    }

    private void onUserStarted(Intent intent) {
    private void onUserUnlocked(Intent intent) {
        int userId = intent.getIntExtra(Intent.EXTRA_USER_HANDLE, -1);
        if (userId < 1) return;

@@ -991,14 +991,10 @@ public class AccountManagerService
        for (UserInfo user : users) {
            if (user.isRestricted() && (parentUserId == user.restrictedProfileParentId)) {
                addSharedAccountAsUser(account, user.id);
                try {
                    if (ActivityManagerNative.getDefault().isUserRunning(user.id, 0)) {
                if (mUserManager.isUserUnlocked(user.id)) {
                    mMessageHandler.sendMessage(mMessageHandler.obtainMessage(
                            MESSAGE_COPY_SHARED_ACCOUNT, parentUserId, user.id, account));
                }
                } catch (RemoteException re) {
                    // Shouldn't happen
                }
            }
        }
    }