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

Commit c2f344e8 authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Handle onUserStopped to lock the user storage again" into main

parents ec6079d5 cbd74f55
Loading
Loading
Loading
Loading
+15 −0
Original line number Diff line number Diff line
@@ -1126,6 +1126,21 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl.
                }
            });
        }

        @Override
        public void onUserStopped(@NonNull TargetUser user) {
            final int userId = user.getUserIdentifier();
            // Called on ActivityManager thread.
            SecureSettingsWrapper.onUserStopped(userId);
            mService.mIoHandler.post(() -> {
                final var additionalSubtypeMap = AdditionalSubtypeMapRepository.get(userId);
                final var settings = InputMethodManagerService.queryInputMethodServicesInternal(
                        mService.mContext, userId, additionalSubtypeMap,
                        DirectBootAwareness.AUTO).getMethodMap();
                InputMethodSettingsRepository.put(userId,
                        InputMethodSettings.create(settings, userId));
            });
        }
    }

    @GuardedBy("ImfLock.class")
+17 −0
Original line number Diff line number Diff line
@@ -376,6 +376,23 @@ final class SecureSettingsWrapper {
        putOrGet(userId, readerWriter);
    }

    /**
     * Called when a user is stopped, which changes the user storage to the locked state again.
     *
     * @param userId the ID of the user whose storage is being locked again.
     */
    @AnyThread
    static void onUserStopped(@UserIdInt int userId) {
        final LockedUserImpl lockedUserImpl = new LockedUserImpl(userId, sContentResolver);
        synchronized (sMutationLock) {
            final ReaderWriter current = sUserMap.get(userId);
            if (current == null || current instanceof LockedUserImpl) {
                return;
            }
            sUserMap = sUserMap.cloneWithPutOrSelf(userId, lockedUserImpl);
        }
    }

    /**
     * Put the given string {@code value} to {@code key}.
     *