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

Commit 170b8aed authored by Justin Ghan's avatar Justin Ghan Committed by Android (Google) Code Review
Browse files

Merge changes from topics "allow-home-delegator", "remote-handwriting" into main

* changes:
  Handwriting delegation from RemoteViews
  View API to allow handwriting delegation from the home screen
parents d0e4c7ff 8443c426
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -52054,6 +52054,7 @@ package android.view {
    method public float getHandwritingBoundsOffsetLeft();
    method public float getHandwritingBoundsOffsetRight();
    method public float getHandwritingBoundsOffsetTop();
    method @FlaggedApi("android.view.inputmethod.home_screen_handwriting_delegator") public int getHandwritingDelegateFlags();
    method @Nullable public Runnable getHandwritingDelegatorCallback();
    method public final boolean getHasOverlappingRendering();
    method public final int getHeight();
@@ -52427,6 +52428,7 @@ package android.view {
    method public void setForegroundTintMode(@Nullable android.graphics.PorterDuff.Mode);
    method @FlaggedApi("android.view.flags.view_velocity_api") public void setFrameContentVelocity(float);
    method public void setHandwritingBoundsOffsets(float, float, float, float);
    method @FlaggedApi("android.view.inputmethod.home_screen_handwriting_delegator") public void setHandwritingDelegateFlags(int);
    method public void setHandwritingDelegatorCallback(@Nullable Runnable);
    method public void setHapticFeedbackEnabled(boolean);
    method public void setHasTransientState(boolean);
@@ -55682,6 +55684,7 @@ package android.view.inputmethod {
  public final class InputMethodManager {
    method public boolean acceptStylusHandwritingDelegation(@NonNull android.view.View);
    method public boolean acceptStylusHandwritingDelegation(@NonNull android.view.View, @NonNull String);
    method @FlaggedApi("android.view.inputmethod.home_screen_handwriting_delegator") public boolean acceptStylusHandwritingDelegation(@NonNull android.view.View, @NonNull String, int);
    method public void dispatchKeyEventFromInputMethod(@Nullable android.view.View, @NonNull android.view.KeyEvent);
    method public void displayCompletions(android.view.View, android.view.inputmethod.CompletionInfo[]);
    method @Nullable public android.view.inputmethod.InputMethodInfo getCurrentInputMethodInfo();
@@ -55729,6 +55732,7 @@ package android.view.inputmethod {
    method public void updateExtractedText(android.view.View, int, android.view.inputmethod.ExtractedText);
    method public void updateSelection(android.view.View, int, int, int, int);
    method @Deprecated public void viewClicked(android.view.View);
    field @FlaggedApi("android.view.inputmethod.home_screen_handwriting_delegator") public static final int HANDWRITING_DELEGATE_FLAG_HOME_DELEGATOR_ALLOWED = 1; // 0x1
    field public static final int HIDE_IMPLICIT_ONLY = 1; // 0x1
    field public static final int HIDE_NOT_ALWAYS = 2; // 0x2
    field public static final int RESULT_HIDDEN = 3; // 0x3
@@ -59546,6 +59550,7 @@ package android.widget {
    method public void setOnClickFillInIntent(@IdRes int, android.content.Intent);
    method public void setOnClickPendingIntent(@IdRes int, android.app.PendingIntent);
    method public void setOnClickResponse(@IdRes int, @NonNull android.widget.RemoteViews.RemoteResponse);
    method @FlaggedApi("android.view.inputmethod.home_screen_handwriting_delegator") public void setOnStylusHandwritingPendingIntent(@IdRes int, @Nullable android.app.PendingIntent);
    method public void setPendingIntentTemplate(@IdRes int, android.app.PendingIntent);
    method public void setProgressBar(@IdRes int, int, int, boolean);
    method public void setRadioGroupChecked(@IdRes int, @IdRes int);
+27 −1
Original line number Diff line number Diff line
@@ -34,6 +34,7 @@ import static android.view.flags.Flags.FLAG_TOOLKIT_SET_FRAME_RATE_READ_ONLY;
import static android.view.flags.Flags.FLAG_VIEW_VELOCITY_API;
import static android.view.flags.Flags.toolkitSetFrameRateReadOnly;
import static android.view.flags.Flags.viewVelocityApi;
import static android.view.inputmethod.Flags.FLAG_HOME_SCREEN_HANDWRITING_DELEGATOR;
import static com.android.internal.util.FrameworkStatsLog.TOUCH_GESTURE_CLASSIFIED__CLASSIFICATION__DEEP_PRESS;
import static com.android.internal.util.FrameworkStatsLog.TOUCH_GESTURE_CLASSIFIED__CLASSIFICATION__LONG_PRESS;
@@ -5154,9 +5155,10 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
    private Runnable mHandwritingDelegatorCallback;
    private String mAllowedHandwritingDelegatePackageName;
    // These two fields are set if the view is a handwriting delegate.
    // These three fields are set if the view is a handwriting delegate.
    private boolean mIsHandwritingDelegate;
    private String mAllowedHandwritingDelegatorPackageName;
    private @InputMethodManager.HandwritingDelegateFlags int mHandwritingDelegateFlags;
    /**
     * Solid color to use as a background when creating the drawing cache. Enables
@@ -12746,6 +12748,30 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
        return mAllowedHandwritingDelegatorPackageName;
    }
    /**
     * Sets flags configuring the handwriting delegation behavior for this delegate editor view.
     *
     * <p>This method has no effect unless {@link #setIsHandwritingDelegate} is also called to
     * configure this view to act as a handwriting delegate.
     *
     * @param flags {@link InputMethodManager#HANDWRITING_DELEGATE_FLAG_HOME_DELEGATOR_ALLOWED} or
     *     {@code 0}
     */
    @FlaggedApi(FLAG_HOME_SCREEN_HANDWRITING_DELEGATOR)
    public void setHandwritingDelegateFlags(
            @InputMethodManager.HandwritingDelegateFlags int flags) {
        mHandwritingDelegateFlags = flags;
    }
    /**
     * Returns flags configuring the handwriting delegation behavior for this delegate editor view,
     * as set by {@link #setHandwritingDelegateFlags}.
     */
    @FlaggedApi(FLAG_HOME_SCREEN_HANDWRITING_DELEGATOR)
    public @InputMethodManager.HandwritingDelegateFlags int getHandwritingDelegateFlags() {
        return mHandwritingDelegateFlags;
    }
    /**
     * Gets the coordinates of this view in the coordinate space of the
     * {@link Surface} that contains the view.
+3 −2
Original line number Diff line number Diff line
@@ -514,14 +514,15 @@ final class IInputMethodManagerGlobalInvoker {
            @NonNull IInputMethodClient client,
            @UserIdInt int userId,
            @NonNull String delegatePackageName,
            @NonNull String delegatorPackageName) {
            @NonNull String delegatorPackageName,
            @InputMethodManager.HandwritingDelegateFlags int flags) {
        final IInputMethodManager service = getService();
        if (service == null) {
            return false;
        }
        try {
            return service.acceptStylusHandwritingDelegation(
                    client, userId, delegatePackageName, delegatorPackageName);
                    client, userId, delegatePackageName, delegatorPackageName, flags);
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
+57 −8
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
package android.view.inputmethod;

import static android.os.Trace.TRACE_TAG_WINDOW_MANAGER;
import static android.view.inputmethod.Flags.FLAG_HOME_SCREEN_HANDWRITING_DELEGATOR;
import static android.view.inputmethod.InputConnection.CURSOR_UPDATE_IMMEDIATE;
import static android.view.inputmethod.InputConnection.CURSOR_UPDATE_MONITOR;
import static android.view.inputmethod.InputMethodEditorTraceProto.InputMethodClientsTraceProto.ClientSideProto.DISPLAY_ID;
@@ -425,6 +426,23 @@ public final class InputMethodManager {
    private static final boolean OPTIMIZE_NONEDITABLE_VIEWS =
            SystemProperties.getBoolean("debug.imm.optimize_noneditable_views", true);

    /** @hide */
    @IntDef(flag = true, prefix = { "HANDWRITING_DELEGATE_FLAG_" }, value = {
            HANDWRITING_DELEGATE_FLAG_HOME_DELEGATOR_ALLOWED,
    })
    @Retention(RetentionPolicy.SOURCE)
    public @interface HandwritingDelegateFlags {}

    /**
     * Flag indicating that views from the default home screen ({@link Intent#CATEGORY_HOME}) may
     * act as a handwriting delegator for the delegate editor view. If set, views from the home
     * screen package will be trusted for handwriting delegation, in addition to views in the {@code
     * delegatorPackageName} passed to {@link #acceptStylusHandwritingDelegation(View, String,
     * int)}.
     */
    @FlaggedApi(FLAG_HOME_SCREEN_HANDWRITING_DELEGATOR)
    public static final int HANDWRITING_DELEGATE_FLAG_HOME_DELEGATOR_ALLOWED = 0x0001;

    /**
     * @deprecated Use {@link IInputMethodManagerGlobalInvoker} instead.
     */
@@ -2345,17 +2363,20 @@ public final class InputMethodManager {
     * @see #isStylusHandwritingAvailable()
     */
    public void startStylusHandwriting(@NonNull View view) {
        startStylusHandwritingInternal(view, null /* delegatorPackageName */);
        startStylusHandwritingInternal(
                view, /* delegatorPackageName= */ null, /* handwritingDelegateFlags= */ 0);
    }

    private boolean startStylusHandwritingInternal(
            @NonNull View view, @Nullable String delegatorPackageName) {
            @NonNull View view, @Nullable String delegatorPackageName,
            @HandwritingDelegateFlags int handwritingDelegateFlags) {
        Objects.requireNonNull(view);

        // Re-dispatch if there is a context mismatch.
        final InputMethodManager fallbackImm = getFallbackInputMethodManagerIfNecessary(view);
        if (fallbackImm != null) {
            fallbackImm.startStylusHandwritingInternal(view, delegatorPackageName);
            fallbackImm.startStylusHandwritingInternal(
                    view, delegatorPackageName, handwritingDelegateFlags);
        }

        boolean useDelegation = !TextUtils.isEmpty(delegatorPackageName);
@@ -2375,7 +2396,7 @@ public final class InputMethodManager {
            if (useDelegation) {
                return IInputMethodManagerGlobalInvoker.acceptStylusHandwritingDelegation(
                        mClient, UserHandle.myUserId(), view.getContext().getOpPackageName(),
                        delegatorPackageName);
                        delegatorPackageName, handwritingDelegateFlags);
            } else {
                IInputMethodManagerGlobalInvoker.startStylusHandwriting(mClient);
            }
@@ -2470,16 +2491,17 @@ public final class InputMethodManager {
     */
    public boolean acceptStylusHandwritingDelegation(@NonNull View delegateView) {
        return startStylusHandwritingInternal(
                delegateView, delegateView.getContext().getOpPackageName());
                delegateView, delegateView.getContext().getOpPackageName(),
                delegateView.getHandwritingDelegateFlags());
    }

    /**
     * Accepts and starts a stylus handwriting session on the delegate view, if handwriting
     * initiation delegation was previously requested using
     * {@link #prepareStylusHandwritingDelegation(View, String)} from te delegator and the view
     * {@link #prepareStylusHandwritingDelegation(View, String)} from the delegator and the view
     * belongs to a specified delegate package.
     *
     * <p>Note: If delegator and delegate are in same application package use
     * <p>Note: If delegator and delegate are in the same application package, use
     * {@link #acceptStylusHandwritingDelegation(View)} instead.</p>
     *
     * @param delegateView delegate view capable of receiving input via {@link InputConnection}
@@ -2493,8 +2515,35 @@ public final class InputMethodManager {
    public boolean acceptStylusHandwritingDelegation(
            @NonNull View delegateView, @NonNull String delegatorPackageName) {
        Objects.requireNonNull(delegatorPackageName);
        return startStylusHandwritingInternal(
                delegateView, delegatorPackageName, delegateView.getHandwritingDelegateFlags());
    }

    /**
     * Accepts and starts a stylus handwriting session on the delegate view, if handwriting
     * initiation delegation was previously requested using {@link
     * #prepareStylusHandwritingDelegation(View, String)} from the delegator and the view belongs to
     * a specified delegate package.
     *
     * <p>Note: If delegator and delegate are in the same application package, use {@link
     * #acceptStylusHandwritingDelegation(View)} instead.
     *
     * @param delegateView delegate view capable of receiving input via {@link InputConnection} on
     *     which {@link #startStylusHandwriting(View)} will be called.
     * @param delegatorPackageName package name of the delegator that handled initial stylus stroke.
     * @param flags {@link #HANDWRITING_DELEGATE_FLAG_HOME_DELEGATOR_ALLOWED} or {@code 0}
     * @return {@code true} if view belongs to allowed delegate package declared in {@link
     *     #prepareStylusHandwritingDelegation(View, String)} and handwriting session can start.
     * @see #prepareStylusHandwritingDelegation(View, String)
     * @see #acceptStylusHandwritingDelegation(View)
     */
    @FlaggedApi(FLAG_HOME_SCREEN_HANDWRITING_DELEGATOR)
    public boolean acceptStylusHandwritingDelegation(
            @NonNull View delegateView, @NonNull String delegatorPackageName,
            @HandwritingDelegateFlags int flags) {
        Objects.requireNonNull(delegatorPackageName);

        return startStylusHandwritingInternal(delegateView, delegatorPackageName);
        return startStylusHandwritingInternal(delegateView, delegatorPackageName, flags);
    }

    /**
+7 −0
Original line number Diff line number Diff line
@@ -31,3 +31,10 @@ flag {
    bug: "284527000"
    is_fixed_read_only: true
}

flag {
    name: "home_screen_handwriting_delegator"
    namespace: "input_method"
    description: "Feature flag for supporting stylus handwriting delegation from RemoteViews on the home screen"
    bug: "279959705"
}
Loading