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

Commit 634dbbcc authored by Cosmin Băieș's avatar Cosmin Băieș
Browse files

Track IME user requests explicitly

This adds a from_user property to the ImeRequestFinished atom, to allow
tracking IME requests that come directly as a result of user
interaction, as these are more important metrics-wise.

Test: android.view.inputmethod.cts.InputMethodStatsTest
Bug: 303041796
Change-Id: I93f6262912b3a28a3c32d819560fb54b7b1d9251
parent 6b135b01
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -168,7 +168,8 @@ public final class ImeInsetsSourceConsumer extends InsetsSourceConsumer {
            statsToken = ImeTracker.forLogging().onRequestHide(null /* component */,
                    Process.myUid(),
                    ImeTracker.ORIGIN_CLIENT_HIDE_SOFT_INPUT,
                    SoftInputShowHideReason.HIDE_SOFT_INPUT_BY_INSETS_API);
                    SoftInputShowHideReason.HIDE_SOFT_INPUT_BY_INSETS_API,
                    mController.getHost().isHandlingPointerEvent() /* fromUser */);
        }

        ImeTracker.forLogging().onProgress(statsToken,
+9 −2
Original line number Diff line number Diff line
@@ -224,6 +224,11 @@ public class InsetsController implements WindowInsetsController, InsetsAnimation
         * @param running {@code true} if there is any animation running; {@code false} otherwise.
         */
        default void notifyAnimationRunningStateChanged(boolean running) {}

        /** @see ViewRootImpl#isHandlingPointerEvent */
        default boolean isHandlingPointerEvent() {
            return false;
        }
    }

    private static final String TAG = "InsetsController";
@@ -1063,7 +1068,8 @@ public class InsetsController implements WindowInsetsController, InsetsAnimation
        if ((types & ime()) != 0) {
            statsToken = ImeTracker.forLogging().onRequestShow(null /* component */,
                    Process.myUid(), ImeTracker.ORIGIN_CLIENT_SHOW_SOFT_INPUT,
                    SoftInputShowHideReason.SHOW_SOFT_INPUT_BY_INSETS_API);
                    SoftInputShowHideReason.SHOW_SOFT_INPUT_BY_INSETS_API,
                    mHost.isHandlingPointerEvent() /* fromUser */);
        }

        show(types, false /* fromIme */, statsToken);
@@ -1168,7 +1174,8 @@ public class InsetsController implements WindowInsetsController, InsetsAnimation
        if ((types & ime()) != 0) {
            statsToken = ImeTracker.forLogging().onRequestHide(null /* component */,
                    Process.myUid(), ImeTracker.ORIGIN_CLIENT_HIDE_SOFT_INPUT,
                    SoftInputShowHideReason.HIDE_SOFT_INPUT_BY_INSETS_API);
                    SoftInputShowHideReason.HIDE_SOFT_INPUT_BY_INSETS_API,
                    mHost.isHandlingPointerEvent() /* fromUser */);
        }

        hide(types, false /* fromIme */, statsToken);
+9 −0
Original line number Diff line number Diff line
@@ -7542,6 +7542,15 @@ public final class ViewRootImpl implements ViewParent,
        }
    }
    /**
     * Returns whether this view is currently handling a pointer event.
     *
     * @hide
     */
    public boolean isHandlingPointerEvent() {
        return mAttachInfo.mHandlingPointerEvent;
    }
    private void resetPointerIcon(MotionEvent event) {
        mPointerIconType = null;
        mResolvedPointerIcon = null;
+5 −0
Original line number Diff line number Diff line
@@ -286,6 +286,11 @@ public class ViewRootInsetsControllerHost implements InsetsController.Host {
        }
    }

    @Override
    public boolean isHandlingPointerEvent() {
        return mViewRoot != null && mViewRoot.isHandlingPointerEvent();
    }

    private boolean isVisibleToUser() {
        return mViewRoot.getHostVisibility() == View.VISIBLE;
    }
+4 −4
Original line number Diff line number Diff line
@@ -575,14 +575,14 @@ final class IInputMethodManagerGlobalInvoker {
    @AnyThread
    @NonNull
    static ImeTracker.Token onRequestShow(@NonNull String tag, int uid,
            @ImeTracker.Origin int origin, @SoftInputShowHideReason int reason) {
            @ImeTracker.Origin int origin, @SoftInputShowHideReason int reason, boolean fromUser) {
        final IImeTracker service = getImeTrackerService();
        if (service == null) {
            // Create token with "fake" binder if the service was not found.
            return new ImeTracker.Token(new Binder(), tag);
        }
        try {
            return service.onRequestShow(tag, uid, origin, reason);
            return service.onRequestShow(tag, uid, origin, reason, fromUser);
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
@@ -592,14 +592,14 @@ final class IInputMethodManagerGlobalInvoker {
    @AnyThread
    @NonNull
    static ImeTracker.Token onRequestHide(@NonNull String tag, int uid,
            @ImeTracker.Origin int origin, @SoftInputShowHideReason int reason) {
            @ImeTracker.Origin int origin, @SoftInputShowHideReason int reason, boolean fromUser) {
        final IImeTracker service = getImeTrackerService();
        if (service == null) {
            // Create token with "fake" binder if the service was not found.
            return new ImeTracker.Token(new Binder(), tag);
        }
        try {
            return service.onRequestHide(tag, uid, origin, reason);
            return service.onRequestHide(tag, uid, origin, reason, fromUser);
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
Loading