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

Commit 2be64fc4 authored by Nikolas Havrikov's avatar Nikolas Havrikov
Browse files

Move encapsulated members to binding controller

Bug: 205676419
Test: make
Change-Id: Ic3d525a4e1bf8f20f6e62ab6bb061f8bad09535d
parent 29e2529c
Loading
Loading
Loading
Loading
+119 −0
Original line number Original line Diff line number Diff line
@@ -17,6 +17,10 @@
package com.android.server.inputmethod;
package com.android.server.inputmethod;


import android.annotation.NonNull;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.content.Intent;
import android.os.IBinder;
import android.view.inputmethod.InputMethodInfo;


/**
/**
 * A controller managing the state of the input method binding.
 * A controller managing the state of the input method binding.
@@ -27,7 +31,122 @@ final class InputMethodBindingController {


    private final InputMethodManagerService mService;
    private final InputMethodManagerService mService;


    private long mLastBindTime;
    private boolean mHasConnection;
    @Nullable private String mCurId;
    @Nullable private String mSelectedMethodId;
    @Nullable private Intent mCurIntent;
    private IBinder mCurToken;
    private int mCurSeq;


    InputMethodBindingController(@NonNull InputMethodManagerService service) {
    InputMethodBindingController(@NonNull InputMethodManagerService service) {
        mService = service;
        mService = service;
    }
    }

    /**
     * Time that we last initiated a bind to the input method, to determine
     * if we should try to disconnect and reconnect to it.
     */
    long getLastBindTime() {
        return mLastBindTime;
    }

    void setLastBindTime(long lastBindTime) {
        mLastBindTime = lastBindTime;
    }

    /**
     * Set to true if our ServiceConnection is currently actively bound to
     * a service (whether or not we have gotten its IBinder back yet).
     */
    boolean hasConnection() {
        return mHasConnection;
    }

    void setHasConnection(boolean hasConnection) {
        mHasConnection = hasConnection;
    }

    /**
     * Id obtained with {@link InputMethodInfo#getId()} for the input method that we are currently
     * connected to or in the process of connecting to.
     *
     * <p>This can be {@code null} when no input method is connected.</p>
     *
     * @see #getSelectedMethodId()
     */
    @Nullable
    String getCurId() {
        return mCurId;
    }

    void setCurId(@Nullable String curId) {
        mCurId = curId;
    }

    /**
     * Id obtained with {@link InputMethodInfo#getId()} for the currently selected input method.
     * This is to be synchronized with the secure settings keyed with
     * {@link android.provider.Settings.Secure#DEFAULT_INPUT_METHOD}.
     *
     * <p>This can be transiently {@code null} when the system is re-initializing input method
     * settings, e.g., the system locale is just changed.</p>
     *
     * <p>Note that {@link #getCurId()} is used to track which IME is being connected to
     * {@link com.android.server.inputmethod.InputMethodManagerService}.</p>
     *
     * @see #getCurId()
     */
    @Nullable
    String getSelectedMethodId() {
        return mSelectedMethodId;
    }

    void setSelectedMethodId(@Nullable String selectedMethodId) {
        mSelectedMethodId = selectedMethodId;
    }

    /**
     * The token we have made for the currently active input method, to
     * identify it in the future.
     */
    IBinder getCurToken() {
        return mCurToken;
    }

    void setCurToken(IBinder curToken) {
        mCurToken = curToken;
    }

    /**
     * The Intent used to connect to the current input method.
     */
    @Nullable
    Intent getCurIntent() {
        return mCurIntent;
    }

    void setCurIntent(@Nullable Intent curIntent) {
        mCurIntent = curIntent;
    }

    /**
     * The current binding sequence number, incremented every time there is
     * a new bind performed.
     */
    int getSequenceNumber() {
        return mCurSeq;
    }

    /**
     * Increase the current binding sequence number by one.
     * Reset to 1 on overflow.
     */
    void advanceSequenceNumber() {
        mCurSeq += 1;
        if (mCurSeq <= 0) {
            mCurSeq = 1;
        }
    }
}
}
+17 −35
Original line number Original line Diff line number Diff line
@@ -469,28 +469,26 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
     * <p>This can be transiently {@code null} when the system is re-initializing input method
     * <p>This can be transiently {@code null} when the system is re-initializing input method
     * settings, e.g., the system locale is just changed.</p>
     * settings, e.g., the system locale is just changed.</p>
     *
     *
     * <p>Note that {@link #getCurId()} is used to track which IME is being connected to
     * <p>Note that {@link InputMethodBindingController#getCurId()} is used to track which IME is
     * {@link InputMethodManagerService}.</p>
     * being connected to {@link InputMethodManagerService}.</p>
     *
     *
     * @see #getCurId()
     * @see InputMethodBindingController#getCurId()
     */
     */
    @Nullable
    @Nullable
    private String getSelectedMethodId() {
    private String getSelectedMethodId() {
        return mSelectedMethodId;
        return mBindingController.getSelectedMethodId();
    }
    }


    private void setSelectedMethodId(@Nullable String selectedMethodId) {
    private void setSelectedMethodId(@Nullable String selectedMethodId) {
        mSelectedMethodId = selectedMethodId;
        mBindingController.setSelectedMethodId(selectedMethodId);
    }
    }
    @Nullable
    private String mSelectedMethodId;


    /**
    /**
     * The current binding sequence number, incremented every time there is
     * The current binding sequence number, incremented every time there is
     * a new bind performed.
     * a new bind performed.
     */
     */
    private int getSequenceNumber() {
    private int getSequenceNumber() {
        return mCurSeq;
        return mBindingController.getSequenceNumber();
    }
    }


    /**
    /**
@@ -498,14 +496,9 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
     * Reset to 1 on overflow.
     * Reset to 1 on overflow.
     */
     */
    private void advanceSequenceNumber() {
    private void advanceSequenceNumber() {
        mCurSeq += 1;
        mBindingController.advanceSequenceNumber();
        if (mCurSeq <= 0) {
            mCurSeq = 1;
        }
    }
    }


    private int mCurSeq;

    /**
    /**
     * {@code true} if the Ime policy has been set to {@link WindowManager#DISPLAY_IME_POLICY_HIDE}.
     * {@code true} if the Ime policy has been set to {@link WindowManager#DISPLAY_IME_POLICY_HIDE}.
     *
     *
@@ -565,16 +558,13 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
     */
     */
    @Nullable
    @Nullable
    private String getCurId() {
    private String getCurId() {
        return mCurId;
        return mBindingController.getCurId();
    }
    }


    private void setCurId(@Nullable String curId) {
    private void setCurId(@Nullable String curId) {
        mCurId = curId;
        mBindingController.setCurId(curId);
    }
    }


    @Nullable
    private String mCurId;

    /**
    /**
     * The current subtype of the current input method.
     * The current subtype of the current input method.
     */
     */
@@ -590,13 +580,12 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
     * a service (whether or not we have gotten its IBinder back yet).
     * a service (whether or not we have gotten its IBinder back yet).
     */
     */
    private boolean hasConnection() {
    private boolean hasConnection() {
        return mHasConnection;
        return mBindingController.hasConnection();
    }
    }


    private void setHasConnection(boolean hasConnection) {
    private void setHasConnection(boolean hasConnection) {
        mHasConnection = hasConnection;
        mBindingController.setHasConnection(hasConnection);
    }
    }
    private boolean mHasConnection;


    /**
    /**
     * Set if the client has asked for the input method to be shown.
     * Set if the client has asked for the input method to be shown.
@@ -628,30 +617,25 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
     */
     */
    @Nullable
    @Nullable
    private Intent getCurIntent() {
    private Intent getCurIntent() {
        return mCurIntent;
        return mBindingController.getCurIntent();
    }
    }


    private void setCurIntent(@Nullable Intent curIntent) {
    private void setCurIntent(@Nullable Intent curIntent) {
        mCurIntent = curIntent;
        mBindingController.setCurIntent(curIntent);
    }
    }


    @Nullable
    private Intent mCurIntent;

    /**
    /**
     * The token we have made for the currently active input method, to
     * The token we have made for the currently active input method, to
     * identify it in the future.
     * identify it in the future.
     */
     */
    private IBinder getCurToken() {
    private IBinder getCurToken() {
        return mCurToken;
        return mBindingController.getCurToken();
    }
    }


    private void setCurToken(IBinder curToken) {
    private void setCurToken(IBinder curToken) {
        mCurToken = curToken;
        mBindingController.setCurToken(curToken);
    }
    }


    private IBinder mCurToken;

    /**
    /**
     * The displayId of current active input method.
     * The displayId of current active input method.
     */
     */
@@ -688,15 +672,13 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
     * if we should try to disconnect and reconnect to it.
     * if we should try to disconnect and reconnect to it.
     */
     */
    private long getLastBindTime() {
    private long getLastBindTime() {
        return mLastBindTime;
        return mBindingController.getLastBindTime();
    }
    }


    private void setLastBindTime(long lastBindTime) {
    private void setLastBindTime(long lastBindTime) {
        mLastBindTime = lastBindTime;
        mBindingController.setLastBindTime(lastBindTime);
    }
    }


    private long mLastBindTime;

    /**
    /**
     * Have we called mCurMethod.bindInput()?
     * Have we called mCurMethod.bindInput()?
     */
     */