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

Commit 267f3c2a authored by android-build-team Robot's avatar android-build-team Robot
Browse files

Snap for 6755001 from ac81a572 to rvc-qpr1-release

Change-Id: Ica70753ff8d8f3a7ff2f5921b20dd86f399315b2
parents 86622777 ac81a572
Loading
Loading
Loading
Loading
+18 −4
Original line number Diff line number Diff line
@@ -387,6 +387,7 @@ public class Editor {
    private final SuggestionHelper mSuggestionHelper = new SuggestionHelper();

    private boolean mFlagCursorDragFromAnywhereEnabled;
    private float mCursorDragDirectionMinXYRatio;
    private boolean mFlagInsertionHandleGesturesEnabled;

    // Specifies whether the new magnifier (with fish-eye effect) is enabled.
@@ -423,6 +424,11 @@ public class Editor {
        mFlagCursorDragFromAnywhereEnabled = AppGlobals.getIntCoreSetting(
                WidgetFlags.KEY_ENABLE_CURSOR_DRAG_FROM_ANYWHERE,
                WidgetFlags.ENABLE_CURSOR_DRAG_FROM_ANYWHERE_DEFAULT ? 1 : 0) != 0;
        final int cursorDragMinAngleFromVertical = AppGlobals.getIntCoreSetting(
                WidgetFlags.KEY_CURSOR_DRAG_MIN_ANGLE_FROM_VERTICAL,
                WidgetFlags.CURSOR_DRAG_MIN_ANGLE_FROM_VERTICAL_DEFAULT);
        mCursorDragDirectionMinXYRatio = EditorTouchState.getXYRatio(
                cursorDragMinAngleFromVertical);
        mFlagInsertionHandleGesturesEnabled = AppGlobals.getIntCoreSetting(
                WidgetFlags.KEY_ENABLE_INSERTION_HANDLE_GESTURES,
                WidgetFlags.ENABLE_INSERTION_HANDLE_GESTURES_DEFAULT ? 1 : 0) != 0;
@@ -432,6 +438,8 @@ public class Editor {
        if (TextView.DEBUG_CURSOR) {
            logCursor("Editor", "Cursor drag from anywhere is %s.",
                    mFlagCursorDragFromAnywhereEnabled ? "enabled" : "disabled");
            logCursor("Editor", "Cursor drag min angle from vertical is %d (= %f x/y ratio)",
                    cursorDragMinAngleFromVertical, mCursorDragDirectionMinXYRatio);
            logCursor("Editor", "Insertion handle gestures is %s.",
                    mFlagInsertionHandleGesturesEnabled ? "enabled" : "disabled");
            logCursor("Editor", "New magnifier is %s.",
@@ -457,6 +465,11 @@ public class Editor {
        mFlagCursorDragFromAnywhereEnabled = enabled;
    }

    @VisibleForTesting
    public void setCursorDragMinAngleFromVertical(int degreesFromVertical) {
        mCursorDragDirectionMinXYRatio = EditorTouchState.getXYRatio(degreesFromVertical);
    }

    @VisibleForTesting
    public boolean getFlagInsertionHandleGesturesEnabled() {
        return mFlagInsertionHandleGesturesEnabled;
@@ -6132,7 +6145,8 @@ public class Editor {
                            && mTextView.getLayout() != null
                            && mTextView.isFocused()
                            && mTouchState.isMovedEnoughForDrag()
                                && !mTouchState.isDragCloseToVertical()) {
                            && (mTouchState.getInitialDragDirectionXYRatio()
                            > mCursorDragDirectionMinXYRatio || mTouchState.isOnHandle())) {
                        startCursorDrag(event);
                    }
                    break;
+46 −9
Original line number Diff line number Diff line
@@ -59,7 +59,7 @@ public class EditorTouchState {
    private boolean mMultiTapInSameArea;

    private boolean mMovedEnoughForDrag;
    private boolean mIsDragCloseToVertical;
    private float mInitialDragDirectionXYRatio;

    public float getLastDownX() {
        return mLastDownX;
@@ -98,8 +98,23 @@ public class EditorTouchState {
        return mMovedEnoughForDrag;
    }

    public boolean isDragCloseToVertical() {
        return mIsDragCloseToVertical && !mIsOnHandle;
    /**
     * When {@link #isMovedEnoughForDrag()} is {@code true}, this function returns the x/y ratio for
     * the initial drag direction. Smaller values indicate that the direction is closer to vertical,
     * while larger values indicate that the direction is closer to horizontal. For example:
     * <ul>
     *     <li>if the drag direction is exactly vertical, this returns 0
     *     <li>if the drag direction is exactly horizontal, this returns {@link Float#MAX_VALUE}
     *     <li>if the drag direction is 45 deg from vertical, this returns 1
     *     <li>if the drag direction is 30 deg from vertical, this returns 0.58 (x delta is smaller
     *     than y delta)
     *     <li>if the drag direction is 60 deg from vertical, this returns 1.73 (x delta is bigger
     *     than y delta)
     * </ul>
     * This function never returns negative values, regardless of the direction of the drag.
     */
    public float getInitialDragDirectionXYRatio() {
        return mInitialDragDirectionXYRatio;
    }

    public void setIsOnHandle(boolean onHandle) {
@@ -155,7 +170,7 @@ public class EditorTouchState {
            mLastDownY = event.getY();
            mLastDownMillis = event.getEventTime();
            mMovedEnoughForDrag = false;
            mIsDragCloseToVertical = false;
            mInitialDragDirectionXYRatio = 0.0f;
        } else if (action == MotionEvent.ACTION_UP) {
            if (TextView.DEBUG_CURSOR) {
                logCursor("EditorTouchState", "ACTION_UP");
@@ -164,7 +179,7 @@ public class EditorTouchState {
            mLastUpY = event.getY();
            mLastUpMillis = event.getEventTime();
            mMovedEnoughForDrag = false;
            mIsDragCloseToVertical = false;
            mInitialDragDirectionXYRatio = 0.0f;
        } else if (action == MotionEvent.ACTION_MOVE) {
            if (!mMovedEnoughForDrag) {
                float deltaX = event.getX() - mLastDownX;
@@ -174,9 +189,8 @@ public class EditorTouchState {
                int touchSlop = config.getScaledTouchSlop();
                mMovedEnoughForDrag = distanceSquared > touchSlop * touchSlop;
                if (mMovedEnoughForDrag) {
                    // If the direction of the swipe motion is within 45 degrees of vertical, it is
                    // considered a vertical drag.
                    mIsDragCloseToVertical = Math.abs(deltaX) <= Math.abs(deltaY);
                    mInitialDragDirectionXYRatio = (deltaY == 0) ? Float.MAX_VALUE :
                            Math.abs(deltaX / deltaY);
                }
            }
        } else if (action == MotionEvent.ACTION_CANCEL) {
@@ -185,7 +199,7 @@ public class EditorTouchState {
            mMultiTapStatus = MultiTapStatus.NONE;
            mMultiTapInSameArea = false;
            mMovedEnoughForDrag = false;
            mIsDragCloseToVertical = false;
            mInitialDragDirectionXYRatio = 0.0f;
        }
    }

@@ -201,4 +215,27 @@ public class EditorTouchState {
        float distanceSquared = (deltaX * deltaX) + (deltaY * deltaY);
        return distanceSquared <= maxDistance * maxDistance;
    }

    /**
     * Returns the x/y ratio corresponding to the given angle relative to vertical. Smaller angle
     * values (ie, closer to vertical) will result in a smaller x/y ratio. For example:
     * <ul>
     *     <li>if the angle is 45 deg, the ratio is 1
     *     <li>if the angle is 30 deg, the ratio is 0.58 (x delta is smaller than y delta)
     *     <li>if the angle is 60 deg, the ratio is 1.73 (x delta is bigger than y delta)
     * </ul>
     * If the passed-in value is <= 0, this function returns 0. If the passed-in value is >= 90,
     * this function returns {@link Float#MAX_VALUE}.
     *
     * @see #getInitialDragDirectionXYRatio()
     */
    public static float getXYRatio(int angleFromVerticalInDegrees) {
        if (angleFromVerticalInDegrees <= 0) {
            return 0.0f;
        }
        if (angleFromVerticalInDegrees >= 90) {
            return Float.MAX_VALUE;
        }
        return (float) Math.tan(Math.toRadians(angleFromVerticalInDegrees));
    }
}
+22 −0
Original line number Diff line number Diff line
@@ -40,6 +40,28 @@ public final class WidgetFlags {
     */
    public static final boolean ENABLE_CURSOR_DRAG_FROM_ANYWHERE_DEFAULT = true;

    /**
     * Threshold for the direction of a swipe gesture in order for it to be handled as a cursor drag
     * rather than a scroll. The direction angle of the swipe gesture must exceed this value in
     * order to trigger cursor drag; otherwise, the swipe will be assumed to be a scroll gesture.
     * The value units for this flag is degrees and the valid range is [0,90] inclusive. If a value
     * < 0 is set, 0 will be used instead; if a value > 90 is set, 90 will be used instead.
     */
    public static final String CURSOR_DRAG_MIN_ANGLE_FROM_VERTICAL =
            "CursorControlFeature__min_angle_from_vertical_to_start_cursor_drag";

    /**
     * The key used in app core settings for the flag
     * {@link #CURSOR_DRAG_MIN_ANGLE_FROM_VERTICAL}.
     */
    public static final String KEY_CURSOR_DRAG_MIN_ANGLE_FROM_VERTICAL =
            "widget__min_angle_from_vertical_to_start_cursor_drag";

    /**
     * Default value for the flag {@link #CURSOR_DRAG_MIN_ANGLE_FROM_VERTICAL}.
     */
    public static final int CURSOR_DRAG_MIN_ANGLE_FROM_VERTICAL_DEFAULT = 45;

    /**
     * The flag of finger-to-cursor distance in DP for cursor dragging.
     * The value unit is DP and the range is {0..100}. If the value is out of range, the legacy
+0 −81
Original line number Diff line number Diff line
@@ -16,14 +16,8 @@

package com.android.internal.os.logging;

import android.content.ComponentName;
import android.content.Context;
import android.content.pm.PackageManager.NameNotFoundException;
import android.util.Pair;
import android.view.WindowManager.LayoutParams;

import com.android.internal.logging.MetricsLogger;
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
import com.android.internal.util.FrameworkStatsLog;

/**
@@ -32,81 +26,6 @@ import com.android.internal.util.FrameworkStatsLog;
 */
public class MetricsLoggerWrapper {

    private static final int METRIC_VALUE_DISMISSED_BY_TAP = 0;
    private static final int METRIC_VALUE_DISMISSED_BY_DRAG = 1;

    public static void logPictureInPictureDismissByTap(Context context,
            Pair<ComponentName, Integer> topActivityInfo) {
        MetricsLogger.action(context, MetricsEvent.ACTION_PICTURE_IN_PICTURE_DISMISSED,
                METRIC_VALUE_DISMISSED_BY_TAP);
        FrameworkStatsLog.write(FrameworkStatsLog.PICTURE_IN_PICTURE_STATE_CHANGED,
                getUid(context, topActivityInfo.first, topActivityInfo.second),
                topActivityInfo.first.flattenToString(),
                FrameworkStatsLog.PICTURE_IN_PICTURE_STATE_CHANGED__STATE__DISMISSED);
    }

    public static void logPictureInPictureDismissByDrag(Context context,
            Pair<ComponentName, Integer> topActivityInfo) {
        MetricsLogger.action(context,
                MetricsEvent.ACTION_PICTURE_IN_PICTURE_DISMISSED,
                METRIC_VALUE_DISMISSED_BY_DRAG);
        FrameworkStatsLog.write(FrameworkStatsLog.PICTURE_IN_PICTURE_STATE_CHANGED,
                getUid(context, topActivityInfo.first, topActivityInfo.second),
                topActivityInfo.first.flattenToString(),
                FrameworkStatsLog.PICTURE_IN_PICTURE_STATE_CHANGED__STATE__DISMISSED);
    }

    public static void logPictureInPictureMinimize(Context context, boolean isMinimized,
            Pair<ComponentName, Integer> topActivityInfo) {
        MetricsLogger.action(context, MetricsEvent.ACTION_PICTURE_IN_PICTURE_MINIMIZED,
                isMinimized);
        FrameworkStatsLog.write(FrameworkStatsLog.PICTURE_IN_PICTURE_STATE_CHANGED,
                getUid(context, topActivityInfo.first, topActivityInfo.second),
                topActivityInfo.first.flattenToString(),
                FrameworkStatsLog.PICTURE_IN_PICTURE_STATE_CHANGED__STATE__MINIMIZED);
    }

    /**
     * Get uid from component name and user Id
     * @return uid. -1 if not found.
     */
    private static int getUid(Context context, ComponentName componentName, int userId) {
        int uid = -1;
        if (componentName == null) {
            return uid;
        }
        try {
            uid = context.getPackageManager().getApplicationInfoAsUser(
                    componentName.getPackageName(), 0, userId).uid;
        } catch (NameNotFoundException e) {
        }
        return uid;
    }

    public static void logPictureInPictureMenuVisible(Context context, boolean menuStateFull) {
        MetricsLogger.visibility(context, MetricsEvent.ACTION_PICTURE_IN_PICTURE_MENU,
                menuStateFull);
    }

    public static void logPictureInPictureEnter(Context context,
            int uid, String shortComponentName, boolean supportsEnterPipOnTaskSwitch) {
        MetricsLogger.action(context, MetricsEvent.ACTION_PICTURE_IN_PICTURE_ENTERED,
                supportsEnterPipOnTaskSwitch);
        FrameworkStatsLog.write(FrameworkStatsLog.PICTURE_IN_PICTURE_STATE_CHANGED, uid,
                shortComponentName,
                FrameworkStatsLog.PICTURE_IN_PICTURE_STATE_CHANGED__STATE__ENTERED);
    }

    public static void logPictureInPictureFullScreen(Context context, int uid,
            String shortComponentName) {
        MetricsLogger.action(context,
                MetricsEvent.ACTION_PICTURE_IN_PICTURE_EXPANDED_TO_FULLSCREEN);
        FrameworkStatsLog.write(FrameworkStatsLog.PICTURE_IN_PICTURE_STATE_CHANGED,
                uid,
                shortComponentName,
                FrameworkStatsLog.PICTURE_IN_PICTURE_STATE_CHANGED__STATE__EXPANDED_TO_FULL_SCREEN);
    }

    public static void logAppOverlayEnter(int uid, String packageName, boolean changed, int type, boolean usingAlertWindow) {
        if (changed) {
            if (type != LayoutParams.TYPE_APPLICATION_OVERLAY) {
+4 −3
Original line number Diff line number Diff line
@@ -291,7 +291,7 @@ public class ScreenshotHelper {
            };

            Message msg = Message.obtain(null, screenshotType, screenshotRequest);
            final ServiceConnection myConn = mScreenshotConnection;

            Handler h = new Handler(handler.getLooper()) {
                @Override
                public void handleMessage(Message msg) {
@@ -304,8 +304,8 @@ public class ScreenshotHelper {
                            break;
                        case SCREENSHOT_MSG_PROCESS_COMPLETE:
                            synchronized (mScreenshotLock) {
                                if (myConn != null && mScreenshotConnection == myConn) {
                                    mContext.unbindService(myConn);
                                if (mScreenshotConnection != null) {
                                    mContext.unbindService(mScreenshotConnection);
                                    mScreenshotConnection = null;
                                    mScreenshotService = null;
                                }
@@ -368,6 +368,7 @@ public class ScreenshotHelper {
                }
            } else {
                Messenger messenger = new Messenger(mScreenshotService);

                try {
                    messenger.send(msg);
                } catch (RemoteException e) {
Loading