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

Commit a3eccfb8 authored by Fyodor Kupolov's avatar Fyodor Kupolov Committed by Android (Google) Code Review
Browse files

Merge "Copy shared accounts after the user is unlocked" into nyc-dev

parents fcbc1645 041232a7
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
                }
            }
        }
    }