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

Commit 3afc74b5 authored by Nicolas Roard's avatar Nicolas Roard
Browse files

Update to ToT RemoteCompose

bug: 412684851
Flag: EXEMPT External Libraries
Test: in GoB
Change-Id: Idbeae0cbaecab9839f986b7bce08f816b16573a3
parent f8e8d178
Loading
Loading
Loading
Loading
+2 −2
Original line number Original line Diff line number Diff line
@@ -66,11 +66,11 @@ public class CoreDocument implements Serializable {


    // Semantic version
    // Semantic version
    public static final int MAJOR_VERSION = 1;
    public static final int MAJOR_VERSION = 1;
    public static final int MINOR_VERSION = 1;
    public static final int MINOR_VERSION = 2;
    public static final int PATCH_VERSION = 0;
    public static final int PATCH_VERSION = 0;


    // Internal version level
    // Internal version level
    public static final int DOCUMENT_API_LEVEL = 7;
    public static final int DOCUMENT_API_LEVEL = 8;


    // We also keep a more fine-grained BUILD number, exposed as
    // We also keep a more fine-grained BUILD number, exposed as
    // ID_API_LEVEL = DOCUMENT_API_LEVEL + BUILD
    // ID_API_LEVEL = DOCUMENT_API_LEVEL + BUILD
+6 −1
Original line number Original line Diff line number Diff line
@@ -79,6 +79,7 @@ import com.android.internal.widget.remotecompose.core.operations.PathAppend;
import com.android.internal.widget.remotecompose.core.operations.PathCombine;
import com.android.internal.widget.remotecompose.core.operations.PathCombine;
import com.android.internal.widget.remotecompose.core.operations.PathCreate;
import com.android.internal.widget.remotecompose.core.operations.PathCreate;
import com.android.internal.widget.remotecompose.core.operations.PathData;
import com.android.internal.widget.remotecompose.core.operations.PathData;
import com.android.internal.widget.remotecompose.core.operations.PathExpression;
import com.android.internal.widget.remotecompose.core.operations.PathTween;
import com.android.internal.widget.remotecompose.core.operations.PathTween;
import com.android.internal.widget.remotecompose.core.operations.Rem;
import com.android.internal.widget.remotecompose.core.operations.Rem;
import com.android.internal.widget.remotecompose.core.operations.RootContentBehavior;
import com.android.internal.widget.remotecompose.core.operations.RootContentBehavior;
@@ -274,6 +275,7 @@ public class Operations {
    public static final int DRAW_TO_BITMAP = 190;
    public static final int DRAW_TO_BITMAP = 190;
    public static final int WAKE_IN = 191;
    public static final int WAKE_IN = 191;
    public static final int ID_LOOKUP = 192;
    public static final int ID_LOOKUP = 192;
    public static final int PATH_EXPRESSION = 193;


    ///////////////////////////////////////// ======================
    ///////////////////////////////////////// ======================


@@ -371,6 +373,7 @@ public class Operations {
    public static final int PROFILE_WIDGETS = 0x100;
    public static final int PROFILE_WIDGETS = 0x100;
    public static final int PROFILE_ANDROIDX = 0x200;
    public static final int PROFILE_ANDROIDX = 0x200;
    public static final int PROFILE_ANDROID_NATIVE = 0x400;
    public static final int PROFILE_ANDROID_NATIVE = 0x400;
    public static final int PROFILE_WEAR_WIDGETS = 0x800;


    /**
    /**
     * Returns true if the operation exists for the given api level
     * Returns true if the operation exists for the given api level
@@ -446,6 +449,7 @@ public class Operations {
            sMapV7AndroidX.put(DRAW_TO_BITMAP, DrawToBitmap::read);
            sMapV7AndroidX.put(DRAW_TO_BITMAP, DrawToBitmap::read);
            sMapV7AndroidX.put(WAKE_IN, WakeIn::read);
            sMapV7AndroidX.put(WAKE_IN, WakeIn::read);
            sMapV7AndroidX.put(ID_LOOKUP, IdLookup::read);
            sMapV7AndroidX.put(ID_LOOKUP, IdLookup::read);
            sMapV7AndroidX.put(PATH_EXPRESSION, PathExpression::read);
        }
        }
        return sMapV7AndroidX;
        return sMapV7AndroidX;
    }
    }
@@ -476,7 +480,8 @@ public class Operations {
            sMapV7Widgets.put(DRAW_BITMAP_TEXT_ANCHORED, DrawBitmapTextAnchored::read);
            sMapV7Widgets.put(DRAW_BITMAP_TEXT_ANCHORED, DrawBitmapTextAnchored::read);
            sMapV7Widgets.put(DRAW_TO_BITMAP, DrawToBitmap::read);
            sMapV7Widgets.put(DRAW_TO_BITMAP, DrawToBitmap::read);
            sMapV7Widgets.put(WAKE_IN, WakeIn::read);
            sMapV7Widgets.put(WAKE_IN, WakeIn::read);
            sMapV7AndroidX.put(ID_LOOKUP, IdLookup::read);
            sMapV7Widgets.put(ID_LOOKUP, IdLookup::read);
            sMapV7Widgets.put(PATH_EXPRESSION, PathExpression::read);
        }
        }
        return sMapV7Widgets;
        return sMapV7Widgets;
    }
    }
+15 −2
Original line number Original line Diff line number Diff line
@@ -56,11 +56,19 @@ public interface Platform {
    /**
    /**
     * Converts a platform-specific path object into a platform-independent float buffer
     * Converts a platform-specific path object into a platform-independent float buffer
     *
     *
     * @param path
     * @param path path object
     * @return
     * @return float array of the path
     */
     */
    @Nullable float [] pathToFloatArray(@NonNull Object path);
    @Nullable float [] pathToFloatArray(@NonNull Object path);


    /**
     * Parse a path represented as a string and returns a Path object
     *
     * @param pathData path data
     * @return platform path
     */
    @NonNull Object parsePath(@NonNull String pathData);

    enum LogCategory {
    enum LogCategory {
        DEBUG,
        DEBUG,
        INFO,
        INFO,
@@ -125,6 +133,11 @@ public interface Platform {
                    throw new UnsupportedOperationException();
                    throw new UnsupportedOperationException();
                }
                }


                @Override
                public @NonNull Object parsePath(@NonNull String pathData) {
                    throw new UnsupportedOperationException();
                }

                @Override
                @Override
                public void log(@NonNull LogCategory category, @NonNull String message) {}
                public void log(@NonNull LogCategory category, @NonNull String message) {}
            };
            };
+235 −0
Original line number Original line Diff line number Diff line
@@ -79,6 +79,7 @@ import com.android.internal.widget.remotecompose.core.operations.PathAppend;
import com.android.internal.widget.remotecompose.core.operations.PathCombine;
import com.android.internal.widget.remotecompose.core.operations.PathCombine;
import com.android.internal.widget.remotecompose.core.operations.PathCreate;
import com.android.internal.widget.remotecompose.core.operations.PathCreate;
import com.android.internal.widget.remotecompose.core.operations.PathData;
import com.android.internal.widget.remotecompose.core.operations.PathData;
import com.android.internal.widget.remotecompose.core.operations.PathExpression;
import com.android.internal.widget.remotecompose.core.operations.PathTween;
import com.android.internal.widget.remotecompose.core.operations.PathTween;
import com.android.internal.widget.remotecompose.core.operations.Rem;
import com.android.internal.widget.remotecompose.core.operations.Rem;
import com.android.internal.widget.remotecompose.core.operations.RootContentBehavior;
import com.android.internal.widget.remotecompose.core.operations.RootContentBehavior;
@@ -99,6 +100,7 @@ import com.android.internal.widget.remotecompose.core.operations.Utils;
import com.android.internal.widget.remotecompose.core.operations.WakeIn;
import com.android.internal.widget.remotecompose.core.operations.WakeIn;
import com.android.internal.widget.remotecompose.core.operations.layout.CanvasContent;
import com.android.internal.widget.remotecompose.core.operations.layout.CanvasContent;
import com.android.internal.widget.remotecompose.core.operations.layout.CanvasOperations;
import com.android.internal.widget.remotecompose.core.operations.layout.CanvasOperations;
import com.android.internal.widget.remotecompose.core.operations.layout.ClickModifierOperation;
import com.android.internal.widget.remotecompose.core.operations.layout.ComponentStart;
import com.android.internal.widget.remotecompose.core.operations.layout.ComponentStart;
import com.android.internal.widget.remotecompose.core.operations.layout.ContainerEnd;
import com.android.internal.widget.remotecompose.core.operations.layout.ContainerEnd;
import com.android.internal.widget.remotecompose.core.operations.layout.ImpulseOperation;
import com.android.internal.widget.remotecompose.core.operations.layout.ImpulseOperation;
@@ -106,6 +108,10 @@ import com.android.internal.widget.remotecompose.core.operations.layout.ImpulseP
import com.android.internal.widget.remotecompose.core.operations.layout.LayoutComponentContent;
import com.android.internal.widget.remotecompose.core.operations.layout.LayoutComponentContent;
import com.android.internal.widget.remotecompose.core.operations.layout.LoopOperation;
import com.android.internal.widget.remotecompose.core.operations.layout.LoopOperation;
import com.android.internal.widget.remotecompose.core.operations.layout.RootLayoutComponent;
import com.android.internal.widget.remotecompose.core.operations.layout.RootLayoutComponent;
import com.android.internal.widget.remotecompose.core.operations.layout.TouchCancelModifierOperation;
import com.android.internal.widget.remotecompose.core.operations.layout.TouchDownModifierOperation;
import com.android.internal.widget.remotecompose.core.operations.layout.TouchUpModifierOperation;
import com.android.internal.widget.remotecompose.core.operations.layout.animation.AnimationSpec;
import com.android.internal.widget.remotecompose.core.operations.layout.managers.BoxLayout;
import com.android.internal.widget.remotecompose.core.operations.layout.managers.BoxLayout;
import com.android.internal.widget.remotecompose.core.operations.layout.managers.CanvasLayout;
import com.android.internal.widget.remotecompose.core.operations.layout.managers.CanvasLayout;
import com.android.internal.widget.remotecompose.core.operations.layout.managers.CollapsibleColumnLayout;
import com.android.internal.widget.remotecompose.core.operations.layout.managers.CollapsibleColumnLayout;
@@ -119,7 +125,12 @@ import com.android.internal.widget.remotecompose.core.operations.layout.managers
import com.android.internal.widget.remotecompose.core.operations.layout.modifiers.BackgroundModifierOperation;
import com.android.internal.widget.remotecompose.core.operations.layout.modifiers.BackgroundModifierOperation;
import com.android.internal.widget.remotecompose.core.operations.layout.modifiers.BorderModifierOperation;
import com.android.internal.widget.remotecompose.core.operations.layout.modifiers.BorderModifierOperation;
import com.android.internal.widget.remotecompose.core.operations.layout.modifiers.ClipRectModifierOperation;
import com.android.internal.widget.remotecompose.core.operations.layout.modifiers.ClipRectModifierOperation;
import com.android.internal.widget.remotecompose.core.operations.layout.modifiers.CollapsiblePriorityModifierOperation;
import com.android.internal.widget.remotecompose.core.operations.layout.modifiers.ComponentVisibilityOperation;
import com.android.internal.widget.remotecompose.core.operations.layout.modifiers.DrawContentOperation;
import com.android.internal.widget.remotecompose.core.operations.layout.modifiers.GraphicsLayerModifierOperation;
import com.android.internal.widget.remotecompose.core.operations.layout.modifiers.GraphicsLayerModifierOperation;
import com.android.internal.widget.remotecompose.core.operations.layout.modifiers.HeightInModifierOperation;
import com.android.internal.widget.remotecompose.core.operations.layout.modifiers.HeightModifierOperation;
import com.android.internal.widget.remotecompose.core.operations.layout.modifiers.MarqueeModifierOperation;
import com.android.internal.widget.remotecompose.core.operations.layout.modifiers.MarqueeModifierOperation;
import com.android.internal.widget.remotecompose.core.operations.layout.modifiers.OffsetModifierOperation;
import com.android.internal.widget.remotecompose.core.operations.layout.modifiers.OffsetModifierOperation;
import com.android.internal.widget.remotecompose.core.operations.layout.modifiers.PaddingModifierOperation;
import com.android.internal.widget.remotecompose.core.operations.layout.modifiers.PaddingModifierOperation;
@@ -127,12 +138,20 @@ import com.android.internal.widget.remotecompose.core.operations.layout.modifier
import com.android.internal.widget.remotecompose.core.operations.layout.modifiers.RoundedClipRectModifierOperation;
import com.android.internal.widget.remotecompose.core.operations.layout.modifiers.RoundedClipRectModifierOperation;
import com.android.internal.widget.remotecompose.core.operations.layout.modifiers.RunActionOperation;
import com.android.internal.widget.remotecompose.core.operations.layout.modifiers.RunActionOperation;
import com.android.internal.widget.remotecompose.core.operations.layout.modifiers.ScrollModifierOperation;
import com.android.internal.widget.remotecompose.core.operations.layout.modifiers.ScrollModifierOperation;
import com.android.internal.widget.remotecompose.core.operations.layout.modifiers.ValueFloatChangeActionOperation;
import com.android.internal.widget.remotecompose.core.operations.layout.modifiers.ValueFloatExpressionChangeActionOperation;
import com.android.internal.widget.remotecompose.core.operations.layout.modifiers.ValueIntegerChangeActionOperation;
import com.android.internal.widget.remotecompose.core.operations.layout.modifiers.ValueIntegerExpressionChangeActionOperation;
import com.android.internal.widget.remotecompose.core.operations.layout.modifiers.ValueStringChangeActionOperation;
import com.android.internal.widget.remotecompose.core.operations.layout.modifiers.WidthInModifierOperation;
import com.android.internal.widget.remotecompose.core.operations.layout.modifiers.WidthModifierOperation;
import com.android.internal.widget.remotecompose.core.operations.layout.modifiers.ZIndexModifierOperation;
import com.android.internal.widget.remotecompose.core.operations.layout.modifiers.ZIndexModifierOperation;
import com.android.internal.widget.remotecompose.core.operations.matrix.MatrixConstant;
import com.android.internal.widget.remotecompose.core.operations.matrix.MatrixConstant;
import com.android.internal.widget.remotecompose.core.operations.matrix.MatrixExpression;
import com.android.internal.widget.remotecompose.core.operations.matrix.MatrixExpression;
import com.android.internal.widget.remotecompose.core.operations.matrix.MatrixVectorMath;
import com.android.internal.widget.remotecompose.core.operations.matrix.MatrixVectorMath;
import com.android.internal.widget.remotecompose.core.operations.paint.PaintBundle;
import com.android.internal.widget.remotecompose.core.operations.paint.PaintBundle;
import com.android.internal.widget.remotecompose.core.operations.utilities.easing.FloatAnimation;
import com.android.internal.widget.remotecompose.core.operations.utilities.easing.FloatAnimation;
import com.android.internal.widget.remotecompose.core.semantics.CoreSemantics;
import com.android.internal.widget.remotecompose.core.types.BooleanConstant;
import com.android.internal.widget.remotecompose.core.types.BooleanConstant;
import com.android.internal.widget.remotecompose.core.types.IntegerConstant;
import com.android.internal.widget.remotecompose.core.types.IntegerConstant;
import com.android.internal.widget.remotecompose.core.types.LongConstant;
import com.android.internal.widget.remotecompose.core.types.LongConstant;
@@ -775,6 +794,20 @@ public class RemoteComposeBuffer {
        return id;
        return id;
    }
    }


    /**
     * Add a path object
     *
     * @param id the path id
     * @param pathData the path data
     * @return the id of the path on the wire
     */
    public int addPathData(int id, @NonNull float [] pathData, int winding) {
        if (mApiLevel < 7 && winding != 0) {
            throw new RuntimeException("winding not supported in API level < 7");
        }
        PathData.apply(mBuffer, id | (winding << 24), pathData);
        return id;
    }
    /**
    /**
     * Adds a paint Bundle to the doc
     * Adds a paint Bundle to the doc
     *
     *
@@ -2194,4 +2227,206 @@ public class RemoteComposeBuffer {
    public void wakeIn(float seconds) {
    public void wakeIn(float seconds) {
        WakeIn.apply(mBuffer, seconds);
        WakeIn.apply(mBuffer, seconds);
    }
    }

    /**
     * Add a path expression
     *
     * @param id output id
     * @param expressionX expression for x
     * @param expressionY expression for y
     * @param start start value
     * @param end end value
     * @param count count value
     * @param flags flags
     */
    public void addPathExpression(
            int id,
            @NonNull float [] expressionX,
            @Nullable float [] expressionY,
            float start,
            float end,
            float count,
            int flags) {
        PathExpression.apply(mBuffer, id, expressionX, expressionY, start, end, count, flags);
    }

    /**
     * Add a component visibility operation
     * @param valueId id of the value
     */
    public void addComponentVisibilityOperation(int valueId) {
        ComponentVisibilityOperation.apply(mBuffer, valueId);
    }

    /**
     * Add a width modifier operation
     * @param type type of operation
     * @param value value of the operation
     */
    public void addWidthModifierOperation(int type, float value) {
        WidthModifierOperation.apply(mBuffer,  type, value);
    }

    /**
     * Add a height modifier operation
     * @param type type of operation
     * @param value value of the operation
     */
    public void addHeightModifierOperation(int type, float value) {
        HeightModifierOperation.apply(mBuffer,  type, value);
    }

    /**
     * Add a height in modifier operation
     * @param min min value
     * @param max max value
     */
    public void addHeightInModifierOperation(float min, float max) {
        HeightInModifierOperation.apply(mBuffer,  min, max);
    }

    /**
     * Add a touch down modifier operation
     */
    public void addTouchDownModifierOperation() {
        TouchDownModifierOperation.apply(mBuffer);
    }

    /**
     * Add a touch up modifier operation
     */
    public void addTouchUpModifierOperation() {
        TouchUpModifierOperation.apply(mBuffer);
    }

    /**
     * Add a touch cancel modifier operation
     */
    public void addTouchCancelModifierOperation() {
        TouchCancelModifierOperation.apply(mBuffer);
    }

    /**
     * Add a width in modifier operation
     */
    public void addWidthInModifierOperation(float min, float max) {
        WidthInModifierOperation.apply(mBuffer,  min, max);
    }

    /**
     * Add a draw content operation
     */
    public void addDrawContentOperation() {
        DrawContentOperation.apply(mBuffer);
    }

    /**
     * Add a semantics modifier operation
     */
    public void addSemanticsModifier(int contentDescriptionId,
                                     byte role,
                                     int textId,
                                     int stateDescriptionId,
                                     int mode,
                                     boolean enabled,
                                     boolean clickable) {
        CoreSemantics.apply(
                mBuffer, contentDescriptionId,
                role,
                textId,
                stateDescriptionId,
                mode,
                enabled,
                clickable);
    }

    /**
     * Add a click modifier operation
     */
    public void addClickModifierOperation() {
        ClickModifierOperation.apply(mBuffer);
    }

    /**
     * Add a collapsible priority modifier operation
     * @param orientation orientation
     * @param priority priority
     */
    public void addCollapsiblePriorityModifier(int orientation, float priority) {
        CollapsiblePriorityModifierOperation.apply(mBuffer, orientation, priority);
    }

    /**
     * Add an animation spec modifier operation
     * @param animationId animation id
     * @param motionDuration duration of the motion
     * @param motionEasingType easing type
     * @param visibilityDuration duration of the visibility
     * @param visibilityEasingType easing type
     * @param enterAnimation enter animation
     * @param exitAnimation exit animation
     */
    public void addAnimationSpecModifier(int animationId,
                                         float motionDuration,
                                         int motionEasingType,
                                         float visibilityDuration,
                                         int visibilityEasingType,
                                         int enterAnimation,
                                         int exitAnimation) {
        AnimationSpec.apply(mBuffer,
                animationId,
                motionDuration,
                motionEasingType,
                visibilityDuration,
                visibilityEasingType,
                enterAnimation,
                exitAnimation);
    }

    /**
     * Add a value string change action operation
     * @param destTextId dest text id
     * @param srcTextId src text id
     */
    public void addValueStringChangeActionOperation(int destTextId, int srcTextId) {
        ValueStringChangeActionOperation.apply(mBuffer, destTextId, srcTextId);
    }

    /**
     * Add a value integer expression change action operation
     * @param destIntegerId dest integer id
     * @param srcIntegerId src integer id
     */
    public void addValueIntegerExpressionChangeActionOperation(
            long destIntegerId,
            long srcIntegerId) {
        ValueIntegerExpressionChangeActionOperation.apply(mBuffer, destIntegerId, srcIntegerId);
    }

    /**
     * Add a value float change action operation
     * @param valueId dest value id
     * @param value value
     */
    public void addValueFloatChangeActionOperation(int valueId, float value) {
        ValueFloatChangeActionOperation.apply(mBuffer, valueId, value);
    }

    /**
     * Add a value integer change action operation
     * @param valueId dest value id
     * @param value value
     */
    public void addValueIntegerChangeActionOperation(int valueId, int value) {
        ValueIntegerChangeActionOperation.apply(mBuffer, valueId, value);
    }

    /**
     * Add a value float expression change action operation
     * @param mValueId dest value id
     * @param mValue value
     */
    public void addValueFloatExpressionChangeActionOperation(int mValueId, int mValue) {
        ValueFloatExpressionChangeActionOperation.apply(mBuffer, mValueId, mValue);
    }
}
}
+19 −0
Original line number Original line Diff line number Diff line
@@ -55,6 +55,7 @@ public class RemoteComposeState implements CollectionsAccess {
    // path information
    // path information
    private final IntMap<Object> mPathMap = new IntMap<>();
    private final IntMap<Object> mPathMap = new IntMap<>();
    private final IntMap<float[]> mPathData = new IntMap<>();
    private final IntMap<float[]> mPathData = new IntMap<>();
    private final IntIntMap mPathWinding = new IntIntMap();


    private boolean[] mColorOverride = new boolean[sMaxColors];
    private boolean[] mColorOverride = new boolean[sMaxColors];
    @NonNull private final IntMap<ArrayAccess> mCollectionMap = new IntMap<>();
    @NonNull private final IntMap<ArrayAccess> mCollectionMap = new IntMap<>();
@@ -182,6 +183,24 @@ public class RemoteComposeState implements CollectionsAccess {
        return mPathData.get(id);
        return mPathData.get(id);
    }
    }


    /**
     * Get the winding associated with the path id
     * @param id the id of the path
     * @return the winding
     */
    public int getPathWinding(int id) {
        return mPathWinding.get(id);
    }

    /**
     * Set the winding associated with the path id
     * @param id the id of the path
     * @param winding the winding
     */
    public void putPathWinding(int id, int winding) {
        mPathWinding.put(id, winding);
    }

    /**
    /**
     * Adds a data Override.
     * Adds a data Override.
     *
     *
Loading