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

Commit 935a7af5 authored by Felix Stern's avatar Felix Stern
Browse files

Cleanup warnings in IMMS

Bug: 433659053
Test: atest com.android.server.inputmethod
Flag: EXEMPT cleanup
Change-Id: Ia596b17b21b14d7ddc7eb542caee5330a9113645
parent 3d7e6c22
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
@@ -499,7 +498,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;
@@ -530,7 +530,7 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl.
        }

        AccessibilitySessionState(@NonNull ClientState client, int id,
                IAccessibilityInputMethodSession session) {
                @NonNull IAccessibilityInputMethodSession session) {
            mClient = client;
            mId = id;
            mSession = session;
@@ -565,7 +565,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")
@@ -761,7 +761,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);
@@ -1261,13 +1261,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();
@@ -1320,7 +1320,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);
    }
@@ -1660,12 +1660,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,
@@ -1980,7 +1977,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)
     */
@@ -2200,10 +2197,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")
@@ -2348,8 +2342,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) {
@@ -2425,11 +2419,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;

@@ -2438,7 +2430,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);
@@ -2588,7 +2580,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)
@@ -2755,8 +2747,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;
        }
@@ -4322,7 +4314,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();
        }
@@ -4512,7 +4504,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);
        }
@@ -4735,7 +4727,7 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl.
                                && !isShowRequestedForCurrentWindow(userId)) {
                            userData.mEnabledSession.mSession.removeImeSurface();
                        }
                    } catch (RemoteException e) {
                    } catch (RemoteException ignored) {
                    }
                }
                return true;
@@ -4751,7 +4743,7 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl.
                                && userData.mEnabledSession.mSession != null) {
                            userData.mEnabledSession.mSession.removeImeSurface();
                        }
                    } catch (RemoteException e) {
                    } catch (RemoteException ignored) {
                    }
                }
                return true;
@@ -4811,8 +4803,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);
                }
@@ -5253,7 +5246,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)) {
@@ -5645,7 +5638,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;
@@ -6085,7 +6078,7 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl.
        @NonNull
        final InputMethodManagerService mService;

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

@@ -6551,7 +6544,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