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

Commit 94c9aadc authored by Yohei Yukawa's avatar Yohei Yukawa Committed by android-build-merger
Browse files

Merge "Fix stale InputMethodManager#mFullscreenMode." into nyc-dev

am: 9f76abc8

* commit '9f76abc8':
  Fix stale InputMethodManager#mFullscreenMode.

Change-Id: If27212387cd76bb6cc7f1cd1d844bd3ca07915e8
parents b8b157b6 9f76abc8
Loading
Loading
Loading
Loading
+19 −6
Original line number Original line Diff line number Diff line
@@ -39,6 +39,7 @@ import android.os.RemoteException;
import android.os.ResultReceiver;
import android.os.ResultReceiver;
import android.os.ServiceManager;
import android.os.ServiceManager;
import android.os.Trace;
import android.os.Trace;
import android.text.TextUtils;
import android.text.style.SuggestionSpan;
import android.text.style.SuggestionSpan;
import android.util.Log;
import android.util.Log;
import android.util.Pools.Pool;
import android.util.Pools.Pool;
@@ -553,8 +554,9 @@ public final class InputMethodManager {
        }
        }


        @Override
        @Override
        protected void onReportFullscreenMode(boolean enabled) {
        protected void onReportFullscreenMode(boolean enabled, boolean calledInBackground) {
            mParentInputMethodManager.setFullscreenMode(enabled);
            mParentInputMethodManager.onReportFullscreenMode(enabled, calledInBackground,
                    getInputMethodId());
        }
        }


        @Override
        @Override
@@ -563,6 +565,7 @@ public final class InputMethodManager {
                    + "connection=" + getInputConnection()
                    + "connection=" + getInputConnection()
                    + " finished=" + isFinished()
                    + " finished=" + isFinished()
                    + " mParentInputMethodManager.mActive=" + mParentInputMethodManager.mActive
                    + " mParentInputMethodManager.mActive=" + mParentInputMethodManager.mActive
                    + " mInputMethodId=" + getInputMethodId()
                    + "}";
                    + "}";
        }
        }
    }
    }
@@ -718,9 +721,14 @@ public final class InputMethodManager {
    }
    }


    /** @hide */
    /** @hide */
    public void setFullscreenMode(boolean fullScreen) {
    public void onReportFullscreenMode(boolean fullScreen, boolean calledInBackground,
            String inputMethodId) {
        synchronized (mH) {
            if (!calledInBackground || TextUtils.equals(mCurId, inputMethodId)) {
                mFullscreenMode = fullScreen;
                mFullscreenMode = fullScreen;
            }
            }
        }
    }


    /** @hide */
    /** @hide */
    public void registerSuggestionSpansForNotification(SuggestionSpan[] spans) {
    public void registerSuggestionSpansForNotification(SuggestionSpan[] spans) {
@@ -746,8 +754,10 @@ public final class InputMethodManager {
     * your UI, else returns false.
     * your UI, else returns false.
     */
     */
    public boolean isFullscreenMode() {
    public boolean isFullscreenMode() {
        synchronized (mH) {
            return mFullscreenMode;
            return mFullscreenMode;
        }
        }
    }


    /**
    /**
     * Return true if the given view is the currently active view for the
     * Return true if the given view is the currently active view for the
@@ -1254,6 +1264,9 @@ public final class InputMethodManager {
                        mCurId = res.id;
                        mCurId = res.id;
                        mNextUserActionNotificationSequenceNumber =
                        mNextUserActionNotificationSequenceNumber =
                                res.userActionNotificationSequenceNumber;
                                res.userActionNotificationSequenceNumber;
                        if (mServedInputConnectionWrapper != null) {
                            mServedInputConnectionWrapper.setInputMethodId(mCurId);
                        }
                    } else {
                    } else {
                        if (res.channel != null && res.channel != mCurChannel) {
                        if (res.channel != null && res.channel != mCurChannel) {
                            res.channel.dispose();
                            res.channel.dispose();
+28 −6
Original line number Original line Diff line number Diff line
@@ -71,6 +71,8 @@ public abstract class IInputConnectionWrapper extends IInputContext.Stub {
    private Object mLock = new Object();
    private Object mLock = new Object();
    @GuardedBy("mLock")
    @GuardedBy("mLock")
    private boolean mFinished = false;
    private boolean mFinished = false;
    @GuardedBy("mLock")
    private String mInputMethodId;


    static class SomeArgs {
    static class SomeArgs {
        Object arg1;
        Object arg1;
@@ -109,6 +111,18 @@ public abstract class IInputConnectionWrapper extends IInputContext.Stub {
        }
        }
    }
    }


    public String getInputMethodId() {
        synchronized (mLock) {
            return mInputMethodId;
        }
    }

    public void setInputMethodId(final String inputMethodId) {
        synchronized (mLock) {
            mInputMethodId = inputMethodId;
        }
    }

    abstract protected boolean isActive();
    abstract protected boolean isActive();


    /**
    /**
@@ -119,9 +133,11 @@ public abstract class IInputConnectionWrapper extends IInputContext.Stub {


    /**
    /**
     * Called when the input method started or stopped full-screen mode.
     * Called when the input method started or stopped full-screen mode.
     *
     * @param enabled {@code true} if the input method starts full-screen mode.
     * @param calledInBackground {@code true} if this input connection is in a state when incoming
     * events are usually ignored.
     */
     */
    abstract protected void onReportFullscreenMode(boolean enabled);
    abstract protected void onReportFullscreenMode(boolean enabled, boolean calledInBackground);


    public void getTextAfterCursor(int length, int flags, int seq, IInputContextCallback callback) {
    public void getTextAfterCursor(int length, int flags, int seq, IInputContextCallback callback) {
        dispatchMessage(obtainMessageIISC(DO_GET_TEXT_AFTER_CURSOR, length, flags, seq, callback));
        dispatchMessage(obtainMessageIISC(DO_GET_TEXT_AFTER_CURSOR, length, flags, seq, callback));
@@ -464,13 +480,19 @@ public abstract class IInputConnectionWrapper extends IInputContext.Stub {
            }
            }
            case DO_REPORT_FULLSCREEN_MODE: {
            case DO_REPORT_FULLSCREEN_MODE: {
                InputConnection ic = getInputConnection();
                InputConnection ic = getInputConnection();
                if (ic == null) {
                boolean isBackground = false;
                if (ic == null || !isActive()) {
                    Log.w(TAG, "reportFullscreenMode on inexistent InputConnection");
                    Log.w(TAG, "reportFullscreenMode on inexistent InputConnection");
                    return;
                    isBackground = true;
                }
                }
                final boolean enabled = msg.arg1 == 1;
                final boolean enabled = msg.arg1 == 1;
                if (!isBackground) {
                    ic.reportFullscreenMode(enabled);
                    ic.reportFullscreenMode(enabled);
                onReportFullscreenMode(enabled);
                }
                // Due to the nature of asynchronous event handling, currently InputMethodService
                // has relied on the fact that #reportFullscreenMode() can be handled even when the
                // InputConnection is inactive.  We have to notify this event to InputMethodManager.
                onReportFullscreenMode(enabled, isBackground);
                return;
                return;
            }
            }
            case DO_PERFORM_PRIVATE_COMMAND: {
            case DO_PERFORM_PRIVATE_COMMAND: {