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 Original line Diff line number Diff line
@@ -315,15 +315,15 @@ public class AccountManagerService


        IntentFilter userFilter = new IntentFilter();
        IntentFilter userFilter = new IntentFilter();
        userFilter.addAction(Intent.ACTION_USER_REMOVED);
        userFilter.addAction(Intent.ACTION_USER_REMOVED);
        userFilter.addAction(Intent.ACTION_USER_STARTED);
        userFilter.addAction(Intent.ACTION_USER_UNLOCKED);
        mContext.registerReceiverAsUser(new BroadcastReceiver() {
        mContext.registerReceiverAsUser(new BroadcastReceiver() {
            @Override
            @Override
            public void onReceive(Context context, Intent intent) {
            public void onReceive(Context context, Intent intent) {
                String action = intent.getAction();
                String action = intent.getAction();
                if (Intent.ACTION_USER_REMOVED.equals(action)) {
                if (Intent.ACTION_USER_REMOVED.equals(action)) {
                    onUserRemoved(intent);
                    onUserRemoved(intent);
                } else if (Intent.ACTION_USER_STARTED.equals(action)) {
                } else if (Intent.ACTION_USER_UNLOCKED.equals(action)) {
                    onUserStarted(intent);
                    onUserUnlocked(intent);
                }
                }
            }
            }
        }, UserHandle.ALL, userFilter, null, null);
        }, 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);
        int userId = intent.getIntExtra(Intent.EXTRA_USER_HANDLE, -1);
        if (userId < 1) return;
        if (userId < 1) return;


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