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

Commit 945c97ed authored by Fyodor Kupolov's avatar Fyodor Kupolov
Browse files

Purge user data on ACTION_USER_REMOVED

Bug: 62850350
Change-Id: Id2e9db53778b8616a40e6752c3b7b390af05910d
Test: manual
parent bfa13138
Loading
Loading
Loading
Loading
+18 −4
Original line number Diff line number Diff line
@@ -162,7 +162,8 @@ public class AccountManagerService

        @Override
        public void onStopUser(int userHandle) {
            mService.onStopUser(userHandle);
            Slog.i(TAG, "onStopUser " + userHandle);
            mService.purgeUserData(userHandle);
        }
    }

@@ -314,6 +315,21 @@ public class AccountManagerService

        injector.addLocalService(new AccountManagerInternalImpl());

        IntentFilter userFilter = new IntentFilter();
        userFilter.addAction(Intent.ACTION_USER_REMOVED);
        mContext.registerReceiverAsUser(new BroadcastReceiver() {
            @Override
            public void onReceive(Context context, Intent intent) {
                String action = intent.getAction();
                if (Intent.ACTION_USER_REMOVED.equals(action)) {
                    int userId = intent.getIntExtra(Intent.EXTRA_USER_HANDLE, -1);
                    if (userId < 1) return;
                    Slog.i(TAG, "User " + userId + " removed");
                    purgeUserData(userId);
                }
            }
        }, UserHandle.ALL, userFilter, null, null);

        // Need to cancel account request notifications if the update/install can access the account
        new PackageMonitor() {
            @Override
@@ -1360,9 +1376,7 @@ public class AccountManagerService
        }
    }


    private void onStopUser(int userId) {
        Log.i(TAG, "onStopUser " + userId);
    private void purgeUserData(int userId) {
        UserAccounts accounts;
        synchronized (mUsers) {
            accounts = mUsers.get(userId);