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

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

Merge changes I453200fd,I706654ec

* changes:
  Hide IInputMethodManager.{add,remove}Client() from apps
  Move InputMethodManagerInternal to server package
parents 09ab1797 e24ed79e
Loading
Loading
Loading
Loading
+0 −3
Original line number Diff line number Diff line
@@ -43,9 +43,6 @@ interface IInputMethodManager {
    // TODO: We should change the return type from List to List<Parcelable>
    // Currently there is a bug that aidl doesn't accept List<Parcelable>
    List getShortcutInputMethodsAndSubtypes();
    void addClient(in IInputMethodClient client,
            in IInputContext inputContext, int uid, int pid);
    void removeClient(in IInputMethodClient client);

    void finishInput(in IInputMethodClient client);
    boolean showSoftInput(in IInputMethodClient client, int flags,
+28 −14
Original line number Diff line number Diff line
@@ -115,7 +115,6 @@ import android.view.inputmethod.InputConnectionInspector;
import android.view.inputmethod.InputMethod;
import android.view.inputmethod.InputMethodInfo;
import android.view.inputmethod.InputMethodManager;
import android.view.inputmethod.InputMethodManagerInternal;
import android.view.inputmethod.InputMethodSubtype;
import android.view.inputmethod.InputMethodSubtype.InputMethodSubtypeBuilder;
import android.widget.ArrayAdapter;
@@ -148,6 +147,7 @@ import com.android.internal.view.IInputMethodSession;
import com.android.internal.view.IInputSessionCallback;
import com.android.internal.view.InputBindResult;
import com.android.internal.view.InputMethodClient;
import com.android.server.inputmethod.InputMethodManagerInternal;
import com.android.server.statusbar.StatusBarManagerService;
import com.android.server.wm.WindowManagerInternal;

@@ -204,6 +204,8 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
    static final int MSG_START_INPUT = 2000;
    static final int MSG_START_VR_INPUT = 2010;

    static final int MSG_ADD_CLIENT = 2980;
    static final int MSG_REMOVE_CLIENT = 2990;
    static final int MSG_UNBIND_CLIENT = 3000;
    static final int MSG_BIND_CLIENT = 3010;
    static final int MSG_SET_ACTIVE = 3020;
@@ -1712,22 +1714,13 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
        }
    }

    @Override
    public void addClient(IInputMethodClient client, IInputContext inputContext, int uid, int pid) {
        if (Binder.getCallingUid() != Process.SYSTEM_UID) {
            throw new SecurityException("Only system process can call this method.");
        }
    void addClient(ClientState clientState) {
        synchronized (mMethodMap) {
            mClients.put(client.asBinder(), new ClientState(client,
                    inputContext, uid, pid));
            mClients.put(clientState.client.asBinder(), clientState);
        }
    }

    @Override
    public void removeClient(IInputMethodClient client) {
        if (Binder.getCallingUid() != Process.SYSTEM_UID) {
            throw new SecurityException("Only system process can call this method.");
        }
    void removeClient(IInputMethodClient client) {
        synchronized (mMethodMap) {
            ClientState cs = mClients.remove(client.asBinder());
            if (cs != null) {
@@ -3413,6 +3406,15 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
                return true;
            }

            // ---------------------------------------------------------
            case MSG_ADD_CLIENT:
                addClient((ClientState) msg.obj);
                return true;

            case MSG_REMOVE_CLIENT:
                removeClient((IInputMethodClient) msg.obj);
                return true;

            // ---------------------------------------------------------

            case MSG_UNBIND_CLIENT:
@@ -4404,7 +4406,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
        }
    }

    private static final class LocalServiceImpl implements InputMethodManagerInternal {
    private static final class LocalServiceImpl extends InputMethodManagerInternal {
        @NonNull
        private final Handler mHandler;

@@ -4412,6 +4414,18 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
            mHandler = handler;
        }

        @Override
        public void addClient(IInputMethodClient client, IInputContext inputContext, int uid,
                int pid) {
            mHandler.sendMessage(mHandler.obtainMessage(MSG_ADD_CLIENT,
                    new ClientState(client, inputContext, uid, pid)));
        }

        @Override
        public void removeClient(IInputMethodClient client) {
            mHandler.sendMessage(mHandler.obtainMessage(MSG_REMOVE_CLIENT, client));
        }

        @Override
        public void setInteractive(boolean interactive) {
            // Do everything in handler so as not to block the caller.
+93 −0
Original line number Diff line number Diff line
@@ -14,29 +14,80 @@
 * limitations under the License.
 */

package android.view.inputmethod;
package com.android.server.inputmethod;

import android.content.ComponentName;

import com.android.internal.view.IInputContext;
import com.android.internal.view.IInputMethodClient;

/**
 * Input method manager local system service interface.
 *
 * @hide Only for use within the system server.
 */
public interface InputMethodManagerInternal {
public abstract class InputMethodManagerInternal {
    /**
     * Called by the window manager service when a client process is being attached to the window
     * manager service.
     * @param client {@link android.os.Binder} proxy that is associated with the singleton instance
     *               of {@link android.view.inputmethod.InputMethodManager} that runs on the client
     *               process
     * @param inputContext communication channel for the dummy
     *                     {@link android.view.inputmethod.InputConnection}
     * @param uid UID of the client process
     * @param pid PID of the client process
     */
    public abstract void addClient(IInputMethodClient client, IInputContext inputContext, int uid,
            int pid);

    /**
     * Called by the window manager service when a client process is being attached to the window
     * manager service.
     * @param client {@link android.os.Binder} proxy that is associated with the singleton instance
     *               of {@link android.view.inputmethod.InputMethodManager} that runs on the client
     *               process
     */
    public abstract void removeClient(IInputMethodClient client);

    /**
     * Called by the power manager to tell the input method manager whether it
     * should start watching for wake events.
     */
    void setInteractive(boolean interactive);
    public abstract void setInteractive(boolean interactive);

    /**
     * Hides the current input method, if visible.
     */
    void hideCurrentInputMethod();
    public abstract void hideCurrentInputMethod();

    /**
     * Switches to VR InputMethod defined in the packageName of {@param componentName}.
     */
    void startVrInputMethodNoCheck(ComponentName componentName);
    public abstract void startVrInputMethodNoCheck(ComponentName componentName);

    /**
     * Fake implementation of {@link InputMethodManagerInternal}.  All the methods do nothing.
     */
    public static final InputMethodManagerInternal NOP =
            new InputMethodManagerInternal() {
                @Override
                public void addClient(IInputMethodClient client, IInputContext inputContext,
                        int uid, int pid) {
                }

                @Override
                public void removeClient(IInputMethodClient client) {
                }

                @Override
                public void setInteractive(boolean interactive) {
                }

                @Override
                public void hideCurrentInputMethod() {
                }

                @Override
                public void startVrInputMethodNoCheck(ComponentName componentName) {
                }
            };
}
+1 −1
Original line number Diff line number Diff line
@@ -257,7 +257,6 @@ import android.view.animation.Animation;
import android.view.animation.AnimationSet;
import android.view.animation.AnimationUtils;
import android.view.autofill.AutofillManagerInternal;
import android.view.inputmethod.InputMethodManagerInternal;

import com.android.internal.R;
import com.android.internal.accessibility.AccessibilityShortcutController;
@@ -276,6 +275,7 @@ import com.android.internal.widget.PointerLocationView;
import com.android.server.GestureLauncherService;
import com.android.server.LocalServices;
import com.android.server.SystemServiceManager;
import com.android.server.inputmethod.InputMethodManagerInternal;
import com.android.server.policy.keyguard.KeyguardServiceDelegate;
import com.android.server.policy.keyguard.KeyguardServiceDelegate.DrawnListener;
import com.android.server.policy.keyguard.KeyguardStateMonitor.StateCallback;
+1 −1
Original line number Diff line number Diff line
@@ -48,13 +48,13 @@ import android.provider.Settings;
import android.util.EventLog;
import android.util.Slog;
import android.util.StatsLog;
import android.view.inputmethod.InputMethodManagerInternal;

import com.android.internal.app.IBatteryStats;
import com.android.internal.logging.MetricsLogger;
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
import com.android.server.EventLogTags;
import com.android.server.LocalServices;
import com.android.server.inputmethod.InputMethodManagerInternal;
import com.android.server.policy.WindowManagerPolicy;
import com.android.server.statusbar.StatusBarManagerInternal;

Loading