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

Commit d51e70f2 authored by Charles Chen's avatar Charles Chen Committed by Automerger Merge Worker
Browse files

Migrate InputMethodService to WindowProviderService am: fc7a1b5b am: 3e85eb66

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/14597714

Change-Id: I5107af6cf95f26d74752ce4917552dbe2d422fa3
parents 35069b56 3e85eb66
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -1270,6 +1270,12 @@ package android.hardware.soundtrigger {

package android.inputmethodservice {

  public abstract class AbstractInputMethodService extends android.window.WindowProviderService implements android.view.KeyEvent.Callback {
    method public final int getInitialDisplayId();
    method @Nullable public final android.os.Bundle getWindowContextOptions();
    method public final int getWindowType();
  }

  @UiContext public class InputMethodService extends android.inputmethodservice.AbstractInputMethodService {
    field public static final long FINISH_INPUT_NO_FALLBACK_CONNECTION = 156215187L; // 0x94fa793L
  }
@@ -3259,6 +3265,7 @@ package android.window {
  @UiContext public abstract class WindowProviderService extends android.app.Service {
    ctor public WindowProviderService();
    method public final void attachToWindowToken(@NonNull android.os.IBinder);
    method @NonNull public int getInitialDisplayId();
    method @Nullable public android.os.Bundle getWindowContextOptions();
    method public abstract int getWindowType();
  }
+0 −6
Original line number Diff line number Diff line
@@ -3194,12 +3194,6 @@ class ContextImpl extends Context {
    @UnsupportedAppUsage
    final void setOuterContext(@NonNull Context context) {
        mOuterContext = context;
        // TODO(b/149463653): check if we still need this method after migrating IMS to
        //  WindowContext.
        if (mOuterContext.isUiContext() && mContextType <= CONTEXT_TYPE_DISPLAY_CONTEXT) {
            mContextType = CONTEXT_TYPE_WINDOW_CONTEXT;
            mIsConfigurationBasedContext = true;
        }
    }

    @UnsupportedAppUsage
+47 −3
Original line number Diff line number Diff line
@@ -18,16 +18,23 @@ package android.inputmethodservice;

import android.annotation.MainThread;
import android.annotation.NonNull;
import android.app.Service;
import android.annotation.Nullable;
import android.content.Context;
import android.content.Intent;
import android.content.res.Configuration;
import android.os.Bundle;
import android.os.IBinder;
import android.os.RemoteException;
import android.util.proto.ProtoOutputStream;
import android.view.KeyEvent;
import android.view.MotionEvent;
import android.view.WindowManager;
import android.view.WindowManagerGlobal;
import android.view.inputmethod.InputConnection;
import android.view.inputmethod.InputContentInfo;
import android.view.inputmethod.InputMethod;
import android.view.inputmethod.InputMethodSession;
import android.window.WindowProviderService;

import java.io.FileDescriptor;
import java.io.PrintWriter;
@@ -44,9 +51,22 @@ import java.io.PrintWriter;
 * implement.  This base class takes care of reporting your InputMethod from
 * the service when clients bind to it, but provides no standard implementation
 * of the InputMethod interface itself.  Derived classes must implement that
 * interface.
 * interface.</p>
 *
 * <p>After {@link android.os.Build.VERSION_CODES#S}, the maximum possible area to show the soft
 * input may not be the entire screen. For example, some devices may support to show the soft input
 * on only half of screen.</p>
 *
 * <p>In that case, moving the soft input from one half screen to another will trigger a
 * {@link android.content.res.Resources} update to match the new {@link Configuration} and
 * this {@link AbstractInputMethodService} may also receive a
 * {@link #onConfigurationChanged(Configuration)} callback if there's notable configuration changes
 * </p>
 *
 * @see android.content.ComponentCallbacks#onConfigurationChanged(Configuration)
 * @see Context#isUiContext Context#isUiContext to see the concept of UI Context.
 */
public abstract class AbstractInputMethodService extends Service
public abstract class AbstractInputMethodService extends WindowProviderService
        implements KeyEvent.Callback {
    private InputMethod mInputMethod;
    
@@ -272,9 +292,33 @@ public abstract class AbstractInputMethodService extends Service
    public void notifyUserActionIfNecessary() {
    }

    // TODO(b/149463653): remove it in T. We missed the API deadline in S.
    /** @hide */
    @Override
    public final boolean isUiContext() {
        return true;
    }

    /** @hide */
    @Override
    public final int getWindowType() {
        return WindowManager.LayoutParams.TYPE_INPUT_METHOD;
    }

    /** @hide */
    @Override
    @Nullable
    public final Bundle getWindowContextOptions() {
        return null;
    }

    /** @hide */
    @Override
    public final int getInitialDisplayId() {
        try {
            return WindowManagerGlobal.getWindowManagerService().getImeDisplayId();
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
    }
}
+3 −0
Original line number Diff line number Diff line
@@ -629,10 +629,13 @@ public class InputMethodService extends AbstractInputMethodService {
                throw new IllegalStateException(
                        "attachToken() must be called at most once. token=" + token);
            }
            attachToWindowToken(token);
            mToken = token;
            mWindow.setToken(token);
        }

        // TODO(b/149463653): remove updateInputMethodDisplay(int displayId) since we'll get the
        // right display by attachToWindowToken
        /**
         * {@inheritDoc}
         * @hide
+7 −0
Original line number Diff line number Diff line
@@ -865,4 +865,11 @@ interface IWindowManager
    void unregisterCrossWindowBlurEnabledListener(ICrossWindowBlurEnabledListener listener);

    boolean isTaskSnapshotSupported();

    /**
     * Returns the preferred display ID to show software keyboard.
     *
     * @see android.window.WindowProviderService#getLaunchedDisplayId
     */
    int getImeDisplayId();
}
Loading