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

Commit 4dc27549 authored by Prabir Pradhan's avatar Prabir Pradhan
Browse files

InputMethodManagerInternal: Remove isAnyInputConnectionActive

IMMS will notify InputManagerService directly when the "isActive" state
changes, so there is no need to query IMMS.

Bug: 210460522
Test: manual
Change-Id: Ifeebcfbb37147b6afe3411e3ce759d2a0183353a
parent 4602686e
Loading
Loading
Loading
Loading
+0 −7
Original line number Diff line number Diff line
@@ -2846,13 +2846,6 @@ public class InputManagerService extends IInputManager.Stub
                lockedModifierState);
    }

    // Native callback.
    @SuppressWarnings("unused")
    boolean isInputMethodConnectionActive() {
        return mInputMethodManagerInternal != null
                && mInputMethodManagerInternal.isAnyInputConnectionActive();
    }

    /**
     * Callback interface implemented by the Window Manager.
     */
+0 −11
Original line number Diff line number Diff line
@@ -234,12 +234,6 @@ public abstract class InputMethodManagerInternal {
    public abstract void onSwitchKeyboardLayoutShortcut(int direction, int displayId,
            IBinder targetWindowToken);

    /**
     * Returns true if any InputConnection is currently active.
     * {@hide}
     */
    public abstract boolean isAnyInputConnectionActive();

    /**
     * Fake implementation of {@link InputMethodManagerInternal}. All the methods do nothing.
     */
@@ -331,11 +325,6 @@ public abstract class InputMethodManagerInternal {
                public void onSwitchKeyboardLayoutShortcut(int direction, int displayId,
                        IBinder targetWindowToken) {
                }

                @Override
                public boolean isAnyInputConnectionActive() {
                    return false;
                }
            };

    /**
+0 −8
Original line number Diff line number Diff line
@@ -5674,14 +5674,6 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub
                switchKeyboardLayoutLocked(direction);
            }
        }

        /**
         * Returns true if any InputConnection is currently active.
         */
        @Override
        public boolean isAnyInputConnectionActive() {
            return mCurInputConnection != null;
        }
    }

    @BinderThread
+16 −10
Original line number Diff line number Diff line
@@ -117,7 +117,6 @@ static struct {
    jmethodID notifySensorAccuracy;
    jmethodID notifyStickyModifierStateChanged;
    jmethodID notifyStylusGestureStarted;
    jmethodID isInputMethodConnectionActive;
    jmethodID notifyVibratorState;
    jmethodID filterInputEvent;
    jmethodID interceptKeyBeforeQueueing;
@@ -311,6 +310,7 @@ public:
    void setStylusButtonMotionEventsEnabled(bool enabled);
    FloatPoint getMouseCursorPosition(int32_t displayId);
    void setStylusPointerIconEnabled(bool enabled);
    void setInputMethodConnectionIsActive(bool isActive);

    /* --- InputReaderPolicyInterface implementation --- */

@@ -453,6 +453,9 @@ private:

        // True if a pointer icon should be shown for stylus pointers.
        bool stylusPointerIconEnabled{false};

        // True if there is an active input method connection.
        bool isInputMethodConnectionActive{false};
    } mLocked GUARDED_BY(mLock);

    std::atomic<bool> mInteractive;
@@ -1507,11 +1510,8 @@ void NativeInputManager::notifyStylusGestureStarted(int32_t deviceId, nsecs_t ev
}

bool NativeInputManager::isInputMethodConnectionActive() {
    JNIEnv* env = jniEnv();
    const jboolean result =
            env->CallBooleanMethod(mServiceObj, gServiceClassInfo.isInputMethodConnectionActive);
    checkAndClearExceptionFromCallback(env, "isInputMethodConnectionActive");
    return result;
    std::scoped_lock _l(mLock);
    return mLocked.isInputMethodConnectionActive;
}

std::optional<DisplayViewport> NativeInputManager::getPointerViewportForAssociatedDisplay(
@@ -1862,6 +1862,15 @@ void NativeInputManager::setStylusPointerIconEnabled(bool enabled) {
            InputReaderConfiguration::Change::DISPLAY_INFO);
}

void NativeInputManager::setInputMethodConnectionIsActive(bool isActive) {
    { // acquire lock
        std::scoped_lock _l(mLock);
        mLocked.isInputMethodConnectionActive = isActive;
    } // release lock

    mInputManager->getDispatcher().setInputMethodConnectionIsActive(isActive);
}

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

static NativeInputManager* getNativeInputManager(JNIEnv* env, jobject clazz) {
@@ -2857,7 +2866,7 @@ static void nativeSetAccessibilityStickyKeysEnabled(JNIEnv* env, jobject nativeI
static void nativeSetInputMethodConnectionIsActive(JNIEnv* env, jobject nativeImplObj,
                                                   jboolean isActive) {
    NativeInputManager* im = getNativeInputManager(env, nativeImplObj);
    im->getInputManager()->getDispatcher().setInputMethodConnectionIsActive(isActive);
    im->setInputMethodConnectionIsActive(isActive);
}

// ----------------------------------------------------------------------------
@@ -3035,9 +3044,6 @@ int register_android_server_InputManager(JNIEnv* env) {
    GET_METHOD_ID(gServiceClassInfo.notifyStylusGestureStarted, clazz, "notifyStylusGestureStarted",
                  "(IJ)V");

    GET_METHOD_ID(gServiceClassInfo.isInputMethodConnectionActive, clazz,
                  "isInputMethodConnectionActive", "()Z");

    GET_METHOD_ID(gServiceClassInfo.notifyVibratorState, clazz, "notifyVibratorState", "(IZ)V");

    GET_METHOD_ID(gServiceClassInfo.notifyNoFocusedWindowAnr, clazz, "notifyNoFocusedWindowAnr",