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

Commit cd0cf05b authored by Yohei Yukawa's avatar Yohei Yukawa Committed by Automerger Merge Worker
Browse files

Merge "Revert "Avoid IME restart for configChanges"" into sc-dev am: b2e45a2d

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

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I7c3745ca21c85eac1fe672302a215f1603f20579
parents 8f66a30f b2e45a2d
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -51297,7 +51297,6 @@ package android.view.inputmethod {
    method public int describeContents();
    method public void dump(android.util.Printer, String);
    method public android.content.ComponentName getComponent();
    method public int getConfigChanges();
    method public String getId();
    method public int getIsDefaultResourceId();
    method public String getPackageName();
+0 −4
Original line number Diff line number Diff line
@@ -2660,10 +2660,6 @@ package android.view.inputmethod {
    method @NonNull public static android.view.inputmethod.InlineSuggestionsResponse newInlineSuggestionsResponse(@NonNull java.util.List<android.view.inputmethod.InlineSuggestion>);
  }

  public final class InputMethodInfo implements android.os.Parcelable {
    ctor public InputMethodInfo(@NonNull String, @NonNull String, @NonNull CharSequence, @NonNull String, int);
  }

  public final class InputMethodManager {
    method public int getDisplayId();
    method public boolean hasActiveInputConnection(@Nullable android.view.View);
+3 −4
Original line number Diff line number Diff line
@@ -171,7 +171,7 @@ class IInputMethodWrapper extends IInputMethod.Stub
                SomeArgs args = (SomeArgs) msg.obj;
                try {
                    inputMethod.initializeInternal((IBinder) args.arg1, msg.arg1,
                            (IInputMethodPrivilegedOperations) args.arg2, (int) args.arg3);
                            (IInputMethodPrivilegedOperations) args.arg2);
                } finally {
                    args.recycle();
                }
@@ -280,10 +280,9 @@ class IInputMethodWrapper extends IInputMethod.Stub
    @BinderThread
    @Override
    public void initializeInternal(IBinder token, int displayId,
            IInputMethodPrivilegedOperations privOps, int configChanges) {
            IInputMethodPrivilegedOperations privOps) {
        mCaller.executeOrSendMessage(
                mCaller.obtainMessageIOOO(DO_INITIALIZE_INTERNAL, displayId, token, privOps,
                        configChanges));
                mCaller.obtainMessageIOO(DO_INITIALIZE_INTERNAL, displayId, token, privOps));
    }

    @BinderThread
+3 −49
Original line number Diff line number Diff line
@@ -70,7 +70,6 @@ import android.compat.annotation.ChangeId;
import android.compat.annotation.EnabledSince;
import android.compat.annotation.UnsupportedAppUsage;
import android.content.Context;
import android.content.pm.ActivityInfo;
import android.content.pm.PackageManager;
import android.content.res.Configuration;
import android.content.res.Resources;
@@ -132,7 +131,6 @@ import android.widget.TextView;
import android.window.WindowMetricsHelper;

import com.android.internal.annotations.GuardedBy;
import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.inputmethod.IInputContentUriToken;
import com.android.internal.inputmethod.IInputMethodPrivilegedOperations;
import com.android.internal.inputmethod.InputMethodPrivilegedOperations;
@@ -515,8 +513,6 @@ public class InputMethodService extends AbstractInputMethodService {
    private boolean mIsAutomotive;
    private Handler mHandler;
    private boolean mImeSurfaceScheduledForRemoval;
    private Configuration mLastKnownConfig;
    private int mHandledConfigChanges;

    /**
     * An opaque {@link Binder} token of window requesting {@link InputMethodImpl#showSoftInput}
@@ -592,14 +588,12 @@ public class InputMethodService extends AbstractInputMethodService {
        @MainThread
        @Override
        public final void initializeInternal(@NonNull IBinder token, int displayId,
                IInputMethodPrivilegedOperations privilegedOperations,
                int configChanges) {
                IInputMethodPrivilegedOperations privilegedOperations) {
            if (InputMethodPrivilegedOperationsRegistry.isRegistered(token)) {
                Log.w(TAG, "The token has already registered, ignore this initialization.");
                return;
            }
            Trace.traceBegin(TRACE_TAG_WINDOW_MANAGER, "IMS.initializeInternal");
            mHandledConfigChanges = configChanges;
            mPrivOps.set(privilegedOperations);
            InputMethodPrivilegedOperationsRegistry.put(token, mPrivOps);
            updateInputMethodDisplay(displayId);
@@ -827,9 +821,6 @@ public class InputMethodService extends AbstractInputMethodService {
                setImeWindowStatus(mapToImeWindowStatus(), mBackDisposition);
            }
            final boolean isVisible = isInputViewShown();
            if (isVisible && getResources() != null) {
                mLastKnownConfig = getResources().getConfiguration();
            }
            final boolean visibilityChanged = isVisible != wasVisible;
            if (resultReceiver != null) {
                resultReceiver.send(visibilityChanged
@@ -1437,38 +1428,11 @@ public class InputMethodService extends AbstractInputMethodService {
     * state: {@link #onStartInput} if input is active, and
     * {@link #onCreateInputView} and {@link #onStartInputView} and related
     * appropriate functions if the UI is displayed.
     * <p>Starting with {@link Build.VERSION_CODES#S}, IMEs can opt into handling configuration
     * changes themselves instead of being restarted with
     * {@link android.R.styleable#InputMethod_configChanges}.
     */
    @Override public void onConfigurationChanged(Configuration newConfig) {
        super.onConfigurationChanged(newConfig);
        if (shouldImeRestartForConfig(newConfig)) {
        resetStateForNewConfiguration();
    }
    }

    /**
     * @return {@code true} if {@link InputMethodService} needs to restart to handle
     * .{@link #onConfigurationChanged(Configuration)}
     */
    @VisibleForTesting
    boolean shouldImeRestartForConfig(@NonNull Configuration newConfig) {
        if (mLastKnownConfig == null) {
            return true;
        }
        // If the new config is the same as the config this Service is already running with,
        // then don't bother calling resetStateForNewConfiguration.
        int diff = mLastKnownConfig.diffPublicOnly(newConfig);
        if (diff != 0) {
            // remove attrs not-relevant to IME service.
            diff &= ActivityInfo.CONFIG_KEYBOARD_HIDDEN;
            diff &= ActivityInfo.CONFIG_KEYBOARD;
            diff &= ActivityInfo.CONFIG_NAVIGATION;
        }
        int unhandledDiff = (diff & ~mHandledConfigChanges);
        return unhandledDiff != 0;
    }

    private void resetStateForNewConfiguration() {
        Trace.traceBegin(TRACE_TAG_WINDOW_MANAGER, "IMS.resetStateForNewConfiguration");
@@ -3218,16 +3182,6 @@ public class InputMethodService extends AbstractInputMethodService {
        }
    }
    
    @VisibleForTesting
    void setLastKnownConfig(@NonNull Configuration config) {
        mLastKnownConfig = config;
    }

    @VisibleForTesting
    void setHandledConfigChanges(int configChanges) {
        mHandledConfigChanges = configChanges;
    }

    void startExtractingText(boolean inputChanged) {
        final ExtractEditText eet = mExtractEditText;
        if (eet != null && getCurrentInputStarted()
+1 −1
Original line number Diff line number Diff line
@@ -105,7 +105,7 @@ public interface InputMethod {
     */
    @MainThread
    default void initializeInternal(IBinder token, int displayId,
            IInputMethodPrivilegedOperations privilegedOperations, int configChanges) {
            IInputMethodPrivilegedOperations privilegedOperations) {
        updateInputMethodDisplay(displayId);
        attachToken(token);
    }
Loading