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

Commit 4b03c792 authored by Felix Stern's avatar Felix Stern Committed by Android (Google) Code Review
Browse files

Merge "Cleanup warnings in IMMS" into main

parents e2ff33ed 935a7af5
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -25,5 +25,5 @@ import com.android.internal.inputmethod.IInputMethodSession;
 */

oneway interface IInputMethodSessionCallback {
    void sessionCreated(IInputMethodSession session);
    void sessionCreated(@nullable IInputMethodSession session);
}
+1 −1
Original line number Diff line number Diff line
@@ -121,7 +121,7 @@ class AccessibilityServiceConnection extends AbstractAccessibilityServiceConnect

        @RequiresNoPermission
        @Override
        public void sessionCreated(IAccessibilityInputMethodSession session, int id) {
        public void sessionCreated(@NonNull IAccessibilityInputMethodSession session, int id) {
            Trace.traceBegin(TRACE_TAG_WINDOW_MANAGER, "ASC.sessionCreated");
            final long ident = Binder.clearCallingIdentity();
            try {
+31 −38
Original line number Diff line number Diff line
@@ -223,7 +223,6 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl.
    private static final Integer VIRTUAL_STYLUS_ID_FOR_TEST = 999999;
    static final boolean DEBUG = false;
    static final String TAG = "InputMethodManagerService";
    public static final String PROTO_ARG = "--proto";

    /**
     * Timeout in milliseconds in {@link #systemRunning()} to make sure that users are initialized
@@ -473,7 +472,8 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl.
        }

        SessionState(@NonNull ClientState client, @NonNull IInputMethodInvoker method,
                IInputMethodSession session, InputChannel channel, @UserIdInt int userId) {
                @Nullable IInputMethodSession session, @NonNull InputChannel channel,
                @UserIdInt int userId) {
            mClient = client;
            mMethod = method;
            mSession = session;
@@ -504,7 +504,7 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl.
        }

        AccessibilitySessionState(@NonNull ClientState client, int id,
                IAccessibilityInputMethodSession session) {
                @NonNull IAccessibilityInputMethodSession session) {
            mClient = client;
            mId = id;
            mSession = session;
@@ -539,7 +539,7 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl.
    /**
     * Map of window perceptible states indexed by their associated window tokens.
     *
     * The value {@code true} indicates that IME has not been mostly hidden via
     * <p>The value {@code true} indicates that IME has not been mostly hidden via
     * {@link android.view.InsetsController} for the given window.
     */
    @GuardedBy("ImfLock.class")
@@ -735,7 +735,7 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl.
         * <p>This field must be accessed only from callback methods in {@link PackageMonitor},
         * which should be bound to {@link #getRegisteredHandler()}.</p>
         */
        private ArrayList<String> mDataClearedPackages = new ArrayList<>();
        private final ArrayList<String> mDataClearedPackages = new ArrayList<>();

        private MyPackageMonitor() {
            super(true);
@@ -1235,13 +1235,13 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl.
                    ? new InputMethodMenuControllerNew() : null;

            mClientController = new ClientController(mPackageManagerInternal);
            mClientController.addClientControllerCallback(c -> onClientRemoved(c));
            mClientController.addClientControllerCallback(this::onClientRemoved);

            mPreventImeStartupUnlessTextEditor = mRes.getBoolean(
                    com.android.internal.R.bool.config_preventImeStartupUnlessTextEditor);
            mNonPreemptibleInputMethods = mRes.getStringArray(
                    com.android.internal.R.array.config_nonPreemptibleInputMethods);
            Runnable discardDelegationTextRunnable = () -> discardHandwritingDelegationText();
            Runnable discardDelegationTextRunnable = this::discardHandwritingDelegationText;
            mHwController = new HandwritingModeController(mContext, uiLooper,
                    new InkWindowInitializer(), discardDelegationTextRunnable);
            registerDeviceListenerAndCheckStylusSupport();
@@ -1294,7 +1294,7 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl.
            Slog.i(TAG, "No default found");
            return;
        }
        final InputMethodInfo defIm = suitableImes.get(0);
        final InputMethodInfo defIm = suitableImes.getFirst();
        ProtoLog.v(IMMS_DEBUG, "Default found, using %s", defIm.getId());
        setSelectedInputMethodAndSubtypeLocked(defIm, NOT_A_SUBTYPE_INDEX, false, userId);
    }
@@ -1634,12 +1634,9 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl.
            @NonNull Context context, @UserIdInt int userId) {
        // If user is a profile, use preference of it`s parent profile.
        final int profileParentUserId = mUserManagerInternal.getProfileParentId(userId);
        if (Settings.Secure.getIntForUser(context.getContentResolver(),
        return Settings.Secure.getIntForUser(context.getContentResolver(),
                Settings.Secure.STYLUS_HANDWRITING_ENABLED,
                Settings.Secure.STYLUS_HANDWRITING_DEFAULT_VALUE, profileParentUserId) == 0) {
            return false;
        }
        return true;
                Settings.Secure.STYLUS_HANDWRITING_DEFAULT_VALUE, profileParentUserId) != 0;
    }

    private List<InputMethodInfo> getInputMethodListInternal(@UserIdInt int userId,
@@ -1954,7 +1951,7 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl.
     * Called by {@link #startInputOrWindowGainedFocusInternalLocked} to bind/unbind/attach the
     * selected InputMethod to the given focused IME client.
     *
     * Note that this should be called after validating if the IME client has IME focus.
     * <p>Note that this should be called after validating if the IME client has IME focus.
     *
     * @see WindowManagerInternal#hasInputMethodClientFocus(IBinder, int, int, int)
     */
@@ -2174,10 +2171,7 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl.
        if (imi == null) {
            return false;
        }
        if (ArrayUtils.contains(mNonPreemptibleInputMethods, imi.getPackageName())) {
            return false;
        }
        return true;
        return !ArrayUtils.contains(mNonPreemptibleInputMethods, imi.getPackageName());
    }

    @GuardedBy("ImfLock.class")
@@ -2321,8 +2315,8 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl.
    }

    @BinderThread
    void onSessionCreated(IInputMethodInvoker method, IInputMethodSession session,
            InputChannel channel, @UserIdInt int userId) {
    void onSessionCreated(IInputMethodInvoker method, @Nullable IInputMethodSession session,
            @NonNull InputChannel channel, @UserIdInt int userId) {
        Trace.traceBegin(TRACE_TAG_WINDOW_MANAGER, "IMMS.onSessionCreated");
        try {
            synchronized (ImfLock.class) {
@@ -2398,11 +2392,9 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl.
            ProtoLog.v(IMMS_DEBUG, "Creating new session for client %s", cs);
            final InputChannel serverChannel;
            final InputChannel clientChannel;
            {
            final InputChannel[] channels = InputChannel.openInputChannelPair(cs.toString());
            serverChannel = channels[0];
            clientChannel = channels[1];
            }

            cs.mSessionRequested = true;

@@ -2411,7 +2403,7 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl.
            final IInputMethodSessionCallback.Stub callback =
                    new IInputMethodSessionCallback.Stub() {
                        @Override
                        public void sessionCreated(IInputMethodSession session) {
                        public void sessionCreated(@Nullable IInputMethodSession session) {
                            final long ident = Binder.clearCallingIdentity();
                            try {
                                onSessionCreated(curMethod, session, serverChannel, userId);
@@ -2561,7 +2553,7 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl.
            try {
                applicationInfo = userAwarePackageManager.getApplicationInfo(packageName,
                        PackageManager.ApplicationInfoFlags.of(0));
            } catch (PackageManager.NameNotFoundException e) {
            } catch (PackageManager.NameNotFoundException ignored) {
            }
            final CharSequence contentDescription = applicationInfo != null
                    ? userAwarePackageManager.getApplicationLabel(applicationInfo)
@@ -2728,8 +2720,8 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl.
            case InputMethodService.BACK_DISPOSITION_WILL_NOT_DISMISS:
                dismissImeOnBackKeyPressed = false;
                break;
            default:
            case InputMethodService.BACK_DISPOSITION_DEFAULT:
            default:
                dismissImeOnBackKeyPressed = ((vis & InputMethodService.IME_VISIBLE) != 0);
                break;
        }
@@ -4295,7 +4287,7 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl.
        // a new Stylus is detected. If IME supports handwriting, and we don't have
        // handwriting initialized, lets do it now.
        final var bindingController = getInputMethodBindingController(mCurrentImeUserId);
        if (!mHwController.getCurrentRequestId().isPresent()
        if (mHwController.getCurrentRequestId().isEmpty()
                && bindingController.supportsStylusHandwriting()) {
            scheduleResetStylusHandwriting();
        }
@@ -4485,7 +4477,7 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl.
    @GuardedBy("ImfLock.class")
    private void resetStylusHandwritingLocked(int requestId) {
        final OptionalInt curRequest = mHwController.getCurrentRequestId();
        if (!curRequest.isPresent() || curRequest.getAsInt() != requestId) {
        if (curRequest.isEmpty() || curRequest.getAsInt() != requestId) {
            Slog.w(TAG, "IME requested to finish handwriting with a mismatched requestId: "
                    + requestId);
        }
@@ -4708,7 +4700,7 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl.
                                && !isShowRequestedForCurrentWindow(userId)) {
                            userData.mEnabledSession.mSession.removeImeSurface();
                        }
                    } catch (RemoteException e) {
                    } catch (RemoteException ignored) {
                    }
                }
                return true;
@@ -4724,7 +4716,7 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl.
                                && userData.mEnabledSession.mSession != null) {
                            userData.mEnabledSession.mSession.removeImeSurface();
                        }
                    } catch (RemoteException e) {
                    } catch (RemoteException ignored) {
                    }
                }
                return true;
@@ -4784,8 +4776,9 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl.
            case MSG_PREPARE_HANDWRITING_DELEGATION:
                synchronized (ImfLock.class) {
                    int userId = msg.arg1;
                    String delegate = (String) ((Pair) msg.obj).first;
                    String delegator = (String) ((Pair) msg.obj).second;
                    final var pair = (Pair<String, String>) msg.obj;
                    String delegate = pair.first;
                    String delegator = pair.second;
                    mHwController.prepareStylusHandwritingDelegation(
                            userId, delegate, delegator, /* connectionless= */ false);
                }
@@ -5226,7 +5219,7 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl.
        final InputMethodSettings settings = InputMethodSettingsRepository.get(userId);
        settings.putSelectedDefaultDeviceInputMethod(null);

        InputMethodInfo imi = settings.getMethodMap().get(newDefaultIme);
        final InputMethodInfo imi = settings.getMethodMap().get(newDefaultIme);
        int lastSubtypeIndex = NOT_A_SUBTYPE_INDEX;
        // newDefaultIme is empty when there is no candidate for the selected IME.
        if (imi != null && !TextUtils.isEmpty(newDefaultIme)) {
@@ -5618,7 +5611,7 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl.

        @Override
        public void onSessionForAccessibilityCreated(int accessibilityConnectionId,
                IAccessibilityInputMethodSession session, @UserIdInt int userId) {
                @NonNull IAccessibilityInputMethodSession session, @UserIdInt int userId) {
            synchronized (ImfLock.class) {
                final var userData = getUserData(userId);
                final var bindingController = userData.mBindingController;
@@ -6058,7 +6051,7 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl.
        @NonNull
        final InputMethodManagerService mService;

        ShellCommandImpl(InputMethodManagerService service) {
        ShellCommandImpl(@NonNull InputMethodManagerService service) {
            mService = service;
        }

@@ -6524,7 +6517,7 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl.
        boolean isImeTraceEnabled = ImeTracing.getInstance().isEnabled();
        synchronized (ImfLock.class) {
            // TODO(b/322816970): Replace this with lambda.
            mClientController.forAllClients(new Consumer<ClientState>() {
            mClientController.forAllClients(new Consumer<>() {

                @GuardedBy("ImfLock.class")
                @Override