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

Commit d9a916fe authored by Joanne Chung's avatar Joanne Chung
Browse files

Finish autofill integration with keyboard cleanup tasks

1. Only print log when debug is on.
2. Callback be notified when input does not start.
3. Avoid using hard code tag in Log class.
4. onCreateInlineSuggestionsRequest() do nothing in NOP.
5. Add missing javadoc.

Bug: 146525448
Test: manual verification
Change-Id: I41e1de92ffcdb8020aef99acbfec274e0294bad3
parent cdbf6678
Loading
Loading
Loading
Loading
+16 −5
Original line number Diff line number Diff line
@@ -517,7 +517,9 @@ public class InputMethodService extends AbstractInputMethodService {
        @Override
        public void onCreateInlineSuggestionsRequest(ComponentName componentName,
                AutofillId autofillId, IInlineSuggestionsRequestCallback cb) {
            if (DEBUG) {
                Log.d(TAG, "InputMethodService received onCreateInlineSuggestionsRequest()");
            }
            handleOnCreateInlineSuggestionsRequest(componentName, autofillId, cb);
        }

@@ -755,7 +757,12 @@ public class InputMethodService extends AbstractInputMethodService {
    private void handleOnCreateInlineSuggestionsRequest(@NonNull ComponentName componentName,
            @NonNull AutofillId autofillId, @NonNull IInlineSuggestionsRequestCallback callback) {
        if (!mInputStarted) {
            try {
                Log.w(TAG, "onStartInput() not called yet");
                callback.onInlineSuggestionsUnsupported();
            } catch (RemoteException e) {
                Log.w(TAG, "Failed to call onInlineSuggestionsUnsupported.", e);
            }
            return;
        }

@@ -768,8 +775,12 @@ public class InputMethodService extends AbstractInputMethodService {
    private void handleOnInlineSuggestionsResponse(@NonNull ComponentName componentName,
            @NonNull AutofillId autofillId, @NonNull InlineSuggestionsResponse response) {
        if (!mInlineSuggestionsRequestInfo.validate(componentName)) {
            Log.d(TAG, "Response component=" + componentName + " differs from request component="
                    + mInlineSuggestionsRequestInfo.mComponentName + ", ignoring response");
            if (DEBUG) {
                Log.d(TAG,
                        "Response component=" + componentName + " differs from request component="
                                + mInlineSuggestionsRequestInfo.mComponentName
                                + ", ignoring response");
            }
            return;
        }
        onInlineSuggestionsResponse(response);
@@ -841,7 +852,7 @@ public class InputMethodService extends AbstractInputMethodService {
         */
        public boolean validate(ComponentName componentName) {
            final boolean result = componentName.equals(mComponentName);
            if (!result) {
            if (DEBUG && !result) {
                Log.d(TAG, "Cached request info ComponentName=" + mComponentName
                        + " differs from received ComponentName=" + componentName);
            }
+7 −1
Original line number Diff line number Diff line
@@ -63,6 +63,8 @@ import com.android.internal.view.IInlineSuggestionsRequestCallback;
 * which is what clients use to communicate with the input method.
 */
public interface InputMethod {
    /** @hide **/
    public static final String TAG = "InputMethod";
    /**
     * This is the interface name that a service implementing an input
     * method should say that it supports -- that is, this is the action it
@@ -111,6 +113,10 @@ public interface InputMethod {
    /**
     * Called to notify the IME that Autofill Frameworks requested an inline suggestions request.
     *
     * @param componentName {@link ComponentName} of current app/activity.
     * @param autofillId {@link AutofillId} of currently focused field.
     * @param cb {@link IInlineSuggestionsRequestCallback} used to pass back the request object.
     *
     * @hide
     */
    default void onCreateInlineSuggestionsRequest(ComponentName componentName,
@@ -118,7 +124,7 @@ public interface InputMethod {
        try {
            cb.onInlineSuggestionsUnsupported();
        } catch (RemoteException e) {
            Log.w("InputMethod", "RemoteException calling onInlineSuggestionsUnsupported: " + e);
            Log.w(TAG, "Failed to call onInlineSuggestionsUnsupported.", e);
        }
    }

+7 −4
Original line number Diff line number Diff line
@@ -646,8 +646,10 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState

        @Override
        public void onInlineSuggestionsUnsupported() throws RemoteException {
            Log.i(TAG, "inline suggestions request unsupported, "
            if (sDebug) {
                Log.d(TAG, "inline suggestions request unsupported, "
                        + "falling back to regular autofill");
            }
            final Session session = mSession.get();
            if (session != null) {
                synchronized (session.mLock) {
@@ -660,8 +662,9 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState
        @Override
        public void onInlineSuggestionsRequest(InlineSuggestionsRequest request,
                IInlineSuggestionsResponseCallback callback) throws RemoteException {
            Log.i(TAG, "onInlineSuggestionsRequest() received: "
                    + request);
            if (sDebug) {
                Log.d(TAG, "onInlineSuggestionsRequest() received: " + request);
            }
            final Session session = mSession.get();
            if (session != null) {
                synchronized (session.mLock) {
+0 −8
Original line number Diff line number Diff line
@@ -19,8 +19,6 @@ package com.android.server.inputmethod;
import android.annotation.NonNull;
import android.annotation.UserIdInt;
import android.content.ComponentName;
import android.os.RemoteException;
import android.util.Log;
import android.view.autofill.AutofillId;
import android.view.inputmethod.InlineSuggestionsRequest;
import android.view.inputmethod.InputMethodInfo;
@@ -99,12 +97,6 @@ public abstract class InputMethodManagerInternal {
                @Override
                public void onCreateInlineSuggestionsRequest(ComponentName componentName,
                        AutofillId autofillId, IInlineSuggestionsRequestCallback cb) {
                    try {
                        cb.onInlineSuggestionsUnsupported();
                    } catch (RemoteException e) {
                        Log.w("IMManagerInternal", "RemoteException calling"
                                + " onInlineSuggestionsUnsupported: " + e);
                    }
                }
            };

+1 −3
Original line number Diff line number Diff line
@@ -59,7 +59,6 @@ import android.provider.Settings;
import android.text.TextUtils;
import android.util.ArrayMap;
import android.util.ArraySet;
import android.util.Log;
import android.util.Slog;
import android.util.SparseArray;
import android.view.InputChannel;
@@ -198,8 +197,7 @@ public final class MultiClientInputMethodManagerService {
                                //TODO(b/137800469): support multi client IMEs.
                                cb.onInlineSuggestionsUnsupported();
                            } catch (RemoteException e) {
                                Log.w("MultiClientIMManager", "RemoteException calling"
                                        + " onInlineSuggestionsUnsupported: " + e);
                                Slog.w(TAG, "Failed to call onInlineSuggestionsUnsupported.", e);
                            }
                        }
                    });