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

Commit b5adf996 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Automerger Merge Worker
Browse files

Merge "Remove android.view.inline deprecated API." into rvc-dev am: 9f11dd4b...

Merge "Remove android.view.inline deprecated API." into rvc-dev am: 9f11dd4b am: 55ae33c6 am: d7d67aa8

Change-Id: I69cdad41973ff1d96a73f33019b6fcf52c0b31e5
parents 2b07f1a9 d7d67aa8
Loading
Loading
Loading
Loading
+1 −14
Original line number Diff line number Diff line
@@ -19,7 +19,6 @@ package android.service.autofill;
import android.annotation.NonNull;
import android.annotation.Size;
import android.app.slice.Slice;
import android.compat.annotation.UnsupportedAppUsage;
import android.os.Parcel;
import android.os.Parcelable;
import android.widget.inline.InlinePresentationSpec;
@@ -67,18 +66,6 @@ public final class InlinePresentation implements Parcelable {
        return hints.toArray(new String[hints.size()]);
    }

    /**
     * @hide
     * @removed
     */
    @UnsupportedAppUsage
    public InlinePresentation(
            @NonNull Slice slice,
            @NonNull android.view.inline.InlinePresentationSpec inlinePresentationSpec,
            boolean pinned) {
        this(slice, inlinePresentationSpec.toWidget(), pinned);
    }



    // Code below generated by codegen v1.0.15.
@@ -245,7 +232,7 @@ public final class InlinePresentation implements Parcelable {
    };

    @DataClass.Generated(
            time = 1585633564226L,
            time = 1586992400667L,
            codegenVersion = "1.0.15",
            sourceFile = "frameworks/base/core/java/android/service/autofill/InlinePresentation.java",
            inputSignatures = "private final @android.annotation.NonNull android.app.slice.Slice mSlice\nprivate final @android.annotation.NonNull android.widget.inline.InlinePresentationSpec mInlinePresentationSpec\nprivate final  boolean mPinned\npublic @android.annotation.NonNull @android.annotation.Size(min=0L) java.lang.String[] getAutofillHints()\nclass InlinePresentation extends java.lang.Object implements [android.os.Parcelable]\n@com.android.internal.util.DataClass(genToString=true, genHiddenConstDefs=true, genEqualsHashCode=true)")
+0 −208
Original line number Diff line number Diff line
/*
 * Copyright (C) 2020 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package android.view.inline;

import android.annotation.NonNull;
import android.annotation.Nullable;
import android.content.Context;
import android.graphics.PixelFormat;
import android.util.AttributeSet;
import android.view.SurfaceControl;
import android.view.SurfaceControlViewHost;
import android.view.SurfaceHolder;
import android.view.SurfaceView;
import android.view.ViewGroup;

/**
 * This class represents a view that holds opaque content from another app that
 * you can inline in your UI.
 *
 * <p>Since the content presented by this view is from another security domain,it is
 * shown on a remote surface preventing the host application from accessing that content.
 * Also the host application cannot interact with the inlined content by injecting touch
 * events or clicking programmatically.
 *
 * <p>This view can be overlaid by other windows, i.e. redressed, but if this is the case
 * the inined UI would not be interactive. Sometimes this is desirable, e.g. animating
 * transitions.
 *
 * <p>By default the surface backing this view is shown on top of the hosting window such
 * that the inlined content is interactive. However, you can temporarily move the surface
 * under the hosting window which could be useful in some cases, e.g. animating transitions.
 * At this point the inlined content will not be interactive and the touch events would
 * be delivered to your app.
 *
 * @hide
 * @removed
 */
public class InlineContentView extends ViewGroup {

    /**
     * Callback for observing the lifecycle of the surface control
     * that manipulates the backing secure embedded UI surface.
     */
    public interface SurfaceControlCallback {
        /**
         * Called when the backing surface is being created.
         *
         * @param surfaceControl The surface control to manipulate the surface.
         */
        void onCreated(@NonNull SurfaceControl surfaceControl);

        /**
         * Called when the backing surface is being destroyed.
         *
         * @param surfaceControl The surface control to manipulate the surface.
         */
        void onDestroyed(@NonNull SurfaceControl surfaceControl);
    }

    private final @NonNull SurfaceHolder.Callback mSurfaceCallback = new SurfaceHolder.Callback() {
        @Override
        public void surfaceCreated(@NonNull SurfaceHolder holder) {
            mSurfaceControlCallback.onCreated(mSurfaceView.getSurfaceControl());
        }

        @Override
        public void surfaceChanged(@NonNull SurfaceHolder holder,
                int format, int width, int height) {
            /* do nothing */
        }

        @Override
        public void surfaceDestroyed(@NonNull SurfaceHolder holder) {
            mSurfaceControlCallback.onDestroyed(mSurfaceView.getSurfaceControl());
        }
    };

    private final @NonNull SurfaceView mSurfaceView;

    private @Nullable SurfaceControlCallback mSurfaceControlCallback;

    /**
     * @inheritDoc
     *
     * @hide
     */
    public InlineContentView(@NonNull Context context) {
        this(context, null);
    }

    /**
     * @inheritDoc
     *
     * @hide
     */
    public InlineContentView(@NonNull Context context, @Nullable AttributeSet attrs) {
        this(context, attrs, 0);
    }

    /**
     * @inheritDoc
     *
     * @hide
     */
    public InlineContentView(@NonNull Context context, @Nullable AttributeSet attrs,
            int defStyleAttr) {
        this(context, attrs, defStyleAttr, 0);
    }

    /**
     * Gets the surface control. If the surface is not created this method
     * returns {@code null}.
     *
     * @return The surface control.
     *
     * @see #setSurfaceControlCallback(SurfaceControlCallback) 
     */
    public @Nullable SurfaceControl getSurfaceControl() {
        return mSurfaceView.getSurfaceControl();
    }

    /**
     * @inheritDoc
     *
     * @hide
     */
    public InlineContentView(@NonNull Context context, @Nullable AttributeSet attrs,
            int defStyleAttr, int defStyleRes) {
        super(context, attrs, defStyleAttr, defStyleRes);
        mSurfaceView = new SurfaceView(context, attrs, defStyleAttr, defStyleRes);
        mSurfaceView.setZOrderOnTop(true);
        mSurfaceView.getHolder().setFormat(PixelFormat.TRANSPARENT);
        addView(mSurfaceView);
    }

    /**
     * Sets the embedded UI.
     * @param surfacePackage The embedded UI.
     *
     * @hide
     */
    public void setChildSurfacePackage(
            @Nullable SurfaceControlViewHost.SurfacePackage surfacePackage) {
        mSurfaceView.setChildSurfacePackage(surfacePackage);
    }

    @Override
    public void onLayout(boolean changed, int l, int t, int r, int b) {
        mSurfaceView.layout(0, 0, getMeasuredWidth(), getMeasuredHeight());
    }

    /**
     * Sets a callback to observe the lifecycle of the surface control for
     * managing the backing surface.
     *
     * @param callback The callback to set or {@code null} to clear.
     */
    public void setSurfaceControlCallback(@Nullable SurfaceControlCallback callback) {
        if (mSurfaceControlCallback != null) {
            mSurfaceView.getHolder().removeCallback(mSurfaceCallback);
        }
        mSurfaceControlCallback = callback;
        if (mSurfaceControlCallback != null) {
            mSurfaceView.getHolder().addCallback(mSurfaceCallback);
        }
    }

    /**
     * @return Whether the surface backing this view appears on top of its parent.
     *
     * @see #setZOrderedOnTop(boolean)
     */
    public boolean isZOrderedOnTop() {
        return mSurfaceView.isZOrderedOnTop();
    }

    /**
     * Controls whether the backing surface is placed on top of this view's window.
     * Normally, it is placed on top of the window, to allow interaction
     * with the inlined UI. Via this method, you can place the surface below the
     * window. This means that all of the contents of the window this view is in
     * will be visible on top of its surface.
     *
     * <p> The Z ordering can be changed dynamically if the backing surface is
     * created, otherwise the ordering would be applied at surface construction time.
     *
     * @param onTop Whether to show the surface on top of this view's window.
     *
     * @see #isZOrderedOnTop()
     */
    public boolean setZOrderedOnTop(boolean onTop) {
        return mSurfaceView.setZOrderedOnTop(onTop, /*allowDynamicChange*/ true);
    }
}
+0 −23
Original line number Diff line number Diff line
/*
 * Copyright (C) 2019 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package android.view.inline;

/**
 * @hide
 * @removed
 */
parcelable InlinePresentationSpec;
+0 −347
Original line number Diff line number Diff line
/*
 * Copyright (C) 2019 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package android.view.inline;

import android.annotation.NonNull;
import android.annotation.Nullable;
import android.compat.annotation.UnsupportedAppUsage;
import android.os.Bundle;
import android.os.Parcelable;
import android.util.Size;

import com.android.internal.util.DataClass;

import java.util.ArrayList;
import java.util.List;

/**
 * This class represents the presentation specification by which an inline suggestion
 * should abide when constructing its UI. Since suggestions are inlined in a
 * host application while provided by another source, they need to be consistent
 * with the host's look at feel to allow building smooth and integrated UIs.
 *
 * @hide
 * @removed
 */
@DataClass(genEqualsHashCode = true, genToString = true, genBuilder = true)
public final class InlinePresentationSpec implements Parcelable {

    /** The minimal size of the suggestion. */
    @NonNull
    private final Size mMinSize;
    /** The maximal size of the suggestion. */
    @NonNull
    private final Size mMaxSize;

    /**
     * The extras encoding the UI style information. Defaults to {@code Bundle.EMPTY} in which case
     * the default system UI style will be used.
     */
    @NonNull
    private final Bundle mStyle;

    private static Bundle defaultStyle() {
        return Bundle.EMPTY;
    }

    /** @hide */
    @DataClass.Suppress({"setMaxSize", "setMinSize"})
    abstract static class BaseBuilder {
    }

    /**
     * @hide
     */
    public android.widget.inline.InlinePresentationSpec toWidget() {
        final android.widget.inline.InlinePresentationSpec.Builder builder =
                new android.widget.inline.InlinePresentationSpec.Builder(
                        getMinSize(), getMaxSize());
        final Bundle style = getStyle();
        if (style != null) {
            builder.setStyle(style);
        }
        return builder.build();
    }

    /**
     * @hide
     */
    public static android.view.inline.InlinePresentationSpec fromWidget(
            android.widget.inline.InlinePresentationSpec widget) {
        final android.view.inline.InlinePresentationSpec.Builder builder =
                new android.view.inline.InlinePresentationSpec.Builder(
                        widget.getMinSize(), widget.getMaxSize());
        final Bundle style = widget.getStyle();
        if (style != null) {
            builder.setStyle(style);
        }
        return builder.build();
    }

    /**
     * @hide
     */
    public static List<android.view.inline.InlinePresentationSpec> fromWidgets(
            List<android.widget.inline.InlinePresentationSpec> widgets) {
        final ArrayList<android.view.inline.InlinePresentationSpec> convertedSpecs =
                new ArrayList<>();
        for (int i = 0; i < widgets.size(); i++) {
            convertedSpecs.add(fromWidget(widgets.get(i)));
        }
        return convertedSpecs;
    }



    // Code below generated by codegen v1.0.15.
    //
    // DO NOT MODIFY!
    // CHECKSTYLE:OFF Generated code
    //
    // To regenerate run:
    // $ codegen $ANDROID_BUILD_TOP/frameworks/base/core/java/android/view/inline/InlinePresentationSpec.java
    //
    // To exclude the generated code from IntelliJ auto-formatting enable (one-time):
    //   Settings > Editor > Code Style > Formatter Control
    //@formatter:off


    @DataClass.Generated.Member
    /* package-private */ InlinePresentationSpec(
            @NonNull Size minSize,
            @NonNull Size maxSize,
            @NonNull Bundle style) {
        this.mMinSize = minSize;
        com.android.internal.util.AnnotationValidations.validate(
                NonNull.class, null, mMinSize);
        this.mMaxSize = maxSize;
        com.android.internal.util.AnnotationValidations.validate(
                NonNull.class, null, mMaxSize);
        this.mStyle = style;
        com.android.internal.util.AnnotationValidations.validate(
                NonNull.class, null, mStyle);

        // onConstructed(); // You can define this method to get a callback
    }

    /**
     * The minimal size of the suggestion.
     */
    @UnsupportedAppUsage
    @DataClass.Generated.Member
    public @NonNull Size getMinSize() {
        return mMinSize;
    }

    /**
     * The maximal size of the suggestion.
     */
    @UnsupportedAppUsage
    @DataClass.Generated.Member
    public @NonNull Size getMaxSize() {
        return mMaxSize;
    }

    /**
     * The extras encoding the UI style information. Defaults to {@code Bundle.EMPTY} in which case
     * the default system UI style will be used.
     */
    @DataClass.Generated.Member
    public @NonNull Bundle getStyle() {
        return mStyle;
    }

    @Override
    @DataClass.Generated.Member
    public String toString() {
        // You can override field toString logic by defining methods like:
        // String fieldNameToString() { ... }

        return "InlinePresentationSpec { " +
                "minSize = " + mMinSize + ", " +
                "maxSize = " + mMaxSize + ", " +
                "style = " + mStyle +
        " }";
    }

    @Override
    @DataClass.Generated.Member
    public boolean equals(@Nullable Object o) {
        // You can override field equality logic by defining either of the methods like:
        // boolean fieldNameEquals(InlinePresentationSpec other) { ... }
        // boolean fieldNameEquals(FieldType otherValue) { ... }

        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        @SuppressWarnings("unchecked")
        InlinePresentationSpec that = (InlinePresentationSpec) o;
        //noinspection PointlessBooleanExpression
        return true
                && java.util.Objects.equals(mMinSize, that.mMinSize)
                && java.util.Objects.equals(mMaxSize, that.mMaxSize)
                && java.util.Objects.equals(mStyle, that.mStyle);
    }

    @Override
    @DataClass.Generated.Member
    public int hashCode() {
        // You can override field hashCode logic by defining methods like:
        // int fieldNameHashCode() { ... }

        int _hash = 1;
        _hash = 31 * _hash + java.util.Objects.hashCode(mMinSize);
        _hash = 31 * _hash + java.util.Objects.hashCode(mMaxSize);
        _hash = 31 * _hash + java.util.Objects.hashCode(mStyle);
        return _hash;
    }

    @Override
    @DataClass.Generated.Member
    public void writeToParcel(@NonNull android.os.Parcel dest, int flags) {
        // You can override field parcelling by defining methods like:
        // void parcelFieldName(Parcel dest, int flags) { ... }

        dest.writeSize(mMinSize);
        dest.writeSize(mMaxSize);
        dest.writeBundle(mStyle);
    }

    @Override
    @DataClass.Generated.Member
    public int describeContents() { return 0; }

    /** @hide */
    @SuppressWarnings({"unchecked", "RedundantCast"})
    @DataClass.Generated.Member
    /* package-private */ InlinePresentationSpec(@NonNull android.os.Parcel in) {
        // You can override field unparcelling by defining methods like:
        // static FieldType unparcelFieldName(Parcel in) { ... }

        Size minSize = (Size) in.readSize();
        Size maxSize = (Size) in.readSize();
        Bundle style = in.readBundle();

        this.mMinSize = minSize;
        com.android.internal.util.AnnotationValidations.validate(
                NonNull.class, null, mMinSize);
        this.mMaxSize = maxSize;
        com.android.internal.util.AnnotationValidations.validate(
                NonNull.class, null, mMaxSize);
        this.mStyle = style;
        com.android.internal.util.AnnotationValidations.validate(
                NonNull.class, null, mStyle);

        // onConstructed(); // You can define this method to get a callback
    }

    @DataClass.Generated.Member
    public static final @NonNull Parcelable.Creator<InlinePresentationSpec> CREATOR
            = new Parcelable.Creator<InlinePresentationSpec>() {
        @Override
        public InlinePresentationSpec[] newArray(int size) {
            return new InlinePresentationSpec[size];
        }

        @Override
        public InlinePresentationSpec createFromParcel(@NonNull android.os.Parcel in) {
            return new InlinePresentationSpec(in);
        }
    };

    /**
     * A builder for {@link InlinePresentationSpec}
     */
    @SuppressWarnings("WeakerAccess")
    @DataClass.Generated.Member
    public static final class Builder extends BaseBuilder {

        private @NonNull Size mMinSize;
        private @NonNull Size mMaxSize;
        private @NonNull Bundle mStyle;

        private long mBuilderFieldsSet = 0L;

        /**
         * Creates a new Builder.
         *
         * @param minSize
         *   The minimal size of the suggestion.
         * @param maxSize
         *   The maximal size of the suggestion.
         */
        @UnsupportedAppUsage
        public Builder(
                @NonNull Size minSize,
                @NonNull Size maxSize) {
            mMinSize = minSize;
            com.android.internal.util.AnnotationValidations.validate(
                    NonNull.class, null, mMinSize);
            mMaxSize = maxSize;
            com.android.internal.util.AnnotationValidations.validate(
                    NonNull.class, null, mMaxSize);
        }

        /**
         * The extras encoding the UI style information. Defaults to {@code Bundle.EMPTY} in which case
         * the default system UI style will be used.
         */
        @DataClass.Generated.Member
        public @NonNull Builder setStyle(@NonNull Bundle value) {
            checkNotUsed();
            mBuilderFieldsSet |= 0x4;
            mStyle = value;
            return this;
        }

        /** Builds the instance. This builder should not be touched after calling this! */
        @UnsupportedAppUsage
        @NonNull
        public InlinePresentationSpec build() {
            checkNotUsed();
            mBuilderFieldsSet |= 0x8; // Mark builder used

            if ((mBuilderFieldsSet & 0x4) == 0) {
                mStyle = defaultStyle();
            }
            InlinePresentationSpec o = new InlinePresentationSpec(
                    mMinSize,
                    mMaxSize,
                    mStyle);
            return o;
        }

        private void checkNotUsed() {
            if ((mBuilderFieldsSet & 0x8) != 0) {
                throw new IllegalStateException(
                        "This Builder should not be reused. Use a new Builder instance instead");
            }
        }
    }

    @DataClass.Generated(
            time = 1585691139012L,
            codegenVersion = "1.0.15",
            sourceFile = "frameworks/base/core/java/android/view/inline/InlinePresentationSpec.java",
            inputSignatures = "private final @android.annotation.NonNull android.util.Size mMinSize\nprivate final @android.annotation.NonNull android.util.Size mMaxSize\nprivate final @android.annotation.NonNull android.os.Bundle mStyle\nprivate static  android.os.Bundle defaultStyle()\npublic  android.widget.inline.InlinePresentationSpec toWidget()\npublic static  android.view.inline.InlinePresentationSpec fromWidget(android.widget.inline.InlinePresentationSpec)\npublic static  java.util.List<android.view.inline.InlinePresentationSpec> fromWidgets(java.util.List<android.widget.inline.InlinePresentationSpec>)\nclass InlinePresentationSpec extends java.lang.Object implements [android.os.Parcelable]\n@com.android.internal.util.DataClass(genEqualsHashCode=true, genToString=true, genBuilder=true)\nclass BaseBuilder extends java.lang.Object implements []")
    @Deprecated
    private void __metadata() {}


    //@formatter:on
    // End of generated code

}
+2 −14

File changed.

Preview size limit exceeded, changes collapsed.

Loading