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

Commit 83b7d72a authored by Yohei Yukawa's avatar Yohei Yukawa
Browse files

Remove redundant synchronized blocks

Unless it is also touching any internal field that needs to be
synchronized with InputMethodManager#mH, just making IPC to
InputMethodManagerService (IMMS) does not need any additional
serialization in the caller side.  IMMS itself already has internal
lock to serializate incoming operations.

Bug: 114418674
Test: atest CtsInputMethodTestCases CtsInputMethodServiceHostTestCases
Change-Id: I214d2c481c9fe862fbb9ec0759df2c798915b9f0
parent 826a36c1
Loading
Loading
Loading
Loading
+39 −57
Original line number Diff line number Diff line
@@ -2147,17 +2147,15 @@ public final class InputMethodManager {
     * @hide
     */
    public void showInputMethodPicker(boolean showAuxiliarySubtypes) {
        synchronized (mH) {
        final int mode = showAuxiliarySubtypes
                ? SHOW_IM_PICKER_MODE_INCLUDE_AUXILIARY_SUBTYPES
                : SHOW_IM_PICKER_MODE_EXCLUDE_AUXILIARY_SUBTYPES;
        try {
                final int mode = showAuxiliarySubtypes ?
                        SHOW_IM_PICKER_MODE_INCLUDE_AUXILIARY_SUBTYPES:
                        SHOW_IM_PICKER_MODE_EXCLUDE_AUXILIARY_SUBTYPES;
            mService.showInputMethodPickerFromClient(mClient, mode);
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
    }
    }

    private void showInputMethodPickerLocked() {
        try {
@@ -2193,14 +2191,12 @@ public final class InputMethodManager {
     * subtypes of all input methods will be shown.
     */
    public void showInputMethodAndSubtypeEnabler(String imiId) {
        synchronized (mH) {
        try {
            mService.showInputMethodAndSubtypeEnablerFromClient(mClient, imiId);
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
    }
    }

    /**
     * Returns the current input method subtype. This subtype is one of the subtypes in
@@ -2223,14 +2219,12 @@ public final class InputMethodManager {
     */
    @RequiresPermission(WRITE_SECURE_SETTINGS)
    public boolean setCurrentInputMethodSubtype(InputMethodSubtype subtype) {
        synchronized (mH) {
        try {
            return mService.setCurrentInputMethodSubtype(subtype);
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
    }
    }

    /**
     * Notify that a user took some action with this input method.
@@ -2313,14 +2307,12 @@ public final class InputMethodManager {
     */
    @UnsupportedAppUsage
    public int getInputMethodWindowVisibleHeight() {
        synchronized (mH) {
        try {
            return mService.getInputMethodWindowVisibleHeight();
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
    }
    }

    /**
     * Force switch to the last used input method and subtype. If the last input method didn't have
@@ -2343,14 +2335,12 @@ public final class InputMethodManager {
     * @hide
     */
    public boolean switchToPreviousInputMethodInternal(IBinder imeToken) {
        synchronized (mH) {
        try {
            return mService.switchToPreviousInputMethod(imeToken);
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
    }
    }

    /**
     * Force switch to the next input method and subtype. If there is no IME enabled except
@@ -2374,14 +2364,12 @@ public final class InputMethodManager {
     * @hide
     */
    public boolean switchToNextInputMethodInternal(IBinder imeToken, boolean onlyCurrentIme) {
        synchronized (mH) {
        try {
            return mService.switchToNextInputMethod(imeToken, onlyCurrentIme);
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
    }
    }

    /**
     * Returns true if the current IME needs to offer the users ways to switch to a next input
@@ -2406,14 +2394,12 @@ public final class InputMethodManager {
     * @hide
     */
    public boolean shouldOfferSwitchingToNextInputMethodInternal(IBinder imeToken) {
        synchronized (mH) {
        try {
            return mService.shouldOfferSwitchingToNextInputMethod(imeToken);
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
    }
    }

    /**
     * Set additional input method subtypes. Only a process which shares the same uid with the IME
@@ -2441,24 +2427,20 @@ public final class InputMethodManager {
     * @param subtypes subtypes will be added as additional subtypes of the current input method.
     */
    public void setAdditionalInputMethodSubtypes(String imiId, InputMethodSubtype[] subtypes) {
        synchronized (mH) {
        try {
            mService.setAdditionalInputMethodSubtypes(imiId, subtypes);
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
    }
    }

    public InputMethodSubtype getLastInputMethodSubtype() {
        synchronized (mH) {
        try {
            return mService.getLastInputMethodSubtype();
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
    }
    }

    void doDump(FileDescriptor fd, PrintWriter fout, String[] args) {
        final Printer p = new PrintWriterPrinter(fout);