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

Commit bd848bef authored by Vishnu Nair's avatar Vishnu Nair Committed by Android (Google) Code Review
Browse files

Merge changes from topic "TrustedPresentationListener-API" into main

* changes:
  Expose TrustedPresentationListener for Window
  Reland Use WindowInfosListener for TPL
parents 9c08fe6a 99249ffe
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -53881,9 +53881,11 @@ package android.view {
    method @Deprecated public android.view.Display getDefaultDisplay();
    method @NonNull public default android.view.WindowMetrics getMaximumWindowMetrics();
    method public default boolean isCrossWindowBlurEnabled();
    method @FlaggedApi("com.android.window.flags.trusted_presentation_listener_for_window") public default void registerTrustedPresentationListener(@NonNull android.os.IBinder, @NonNull android.window.TrustedPresentationThresholds, @NonNull java.util.concurrent.Executor, @NonNull java.util.function.Consumer<java.lang.Boolean>);
    method public default void removeCrossWindowBlurEnabledListener(@NonNull java.util.function.Consumer<java.lang.Boolean>);
    method public default void removeProposedRotationListener(@NonNull java.util.function.IntConsumer);
    method public void removeViewImmediate(android.view.View);
    method @FlaggedApi("com.android.window.flags.trusted_presentation_listener_for_window") public default void unregisterTrustedPresentationListener(@NonNull java.util.function.Consumer<java.lang.Boolean>);
    field public static final String PROPERTY_ACTIVITY_EMBEDDING_ALLOW_SYSTEM_OVERRIDE = "android.window.PROPERTY_ACTIVITY_EMBEDDING_ALLOW_SYSTEM_OVERRIDE";
    field public static final String PROPERTY_ACTIVITY_EMBEDDING_SPLITS_ENABLED = "android.window.PROPERTY_ACTIVITY_EMBEDDING_SPLITS_ENABLED";
    field public static final String PROPERTY_CAMERA_COMPAT_ALLOW_FORCE_ROTATION = "android.window.PROPERTY_CAMERA_COMPAT_ALLOW_FORCE_ROTATION";
@@ -60864,6 +60866,16 @@ package android.window {
    method public void markSyncReady();
  }
  @FlaggedApi("com.android.window.flags.trusted_presentation_listener_for_window") public final class TrustedPresentationThresholds implements android.os.Parcelable {
    ctor @FlaggedApi("com.android.window.flags.trusted_presentation_listener_for_window") public TrustedPresentationThresholds(@FloatRange(from=0.0f, fromInclusive=false, to=1.0f) float, @FloatRange(from=0.0f, fromInclusive=false, to=1.0f) float, @IntRange(from=1) int);
    method @FlaggedApi("com.android.window.flags.trusted_presentation_listener_for_window") public int describeContents();
    method @FlaggedApi("com.android.window.flags.trusted_presentation_listener_for_window") public void writeToParcel(@NonNull android.os.Parcel, int);
    field @FlaggedApi("com.android.window.flags.trusted_presentation_listener_for_window") @NonNull public static final android.os.Parcelable.Creator<android.window.TrustedPresentationThresholds> CREATOR;
    field @FlaggedApi("com.android.window.flags.trusted_presentation_listener_for_window") @FloatRange(from=0.0f, fromInclusive=false, to=1.0f) public final float minAlpha;
    field @FlaggedApi("com.android.window.flags.trusted_presentation_listener_for_window") @FloatRange(from=0.0f, fromInclusive=false, to=1.0f) public final float minFractionRendered;
    field @FlaggedApi("com.android.window.flags.trusted_presentation_listener_for_window") @IntRange(from=1) public final int stabilityRequirementMs;
  }
}
package javax.microedition.khronos.egl {
+0 −39
Original line number Diff line number Diff line
@@ -27,9 +27,6 @@ import android.window.SurfaceSyncGroup;

import com.android.window.flags.Flags;

import java.util.concurrent.Executor;
import java.util.function.Consumer;

/**
 * Provides an interface to the root-Surface of a View Hierarchy or Window. This
 * is used in combination with the {@link android.view.SurfaceControl} API to enable
@@ -196,42 +193,6 @@ public interface AttachedSurfaceControl {
            + "implemented before making this call.");
    }

    /**
     * Add a trusted presentation listener on the SurfaceControl associated with this window.
     *
     * @param t          Transaction that the trusted presentation listener is added on. This should
     *                   be applied by the caller.
     * @param thresholds The {@link SurfaceControl.TrustedPresentationThresholds} that will specify
     *                   when the to invoke the callback.
     * @param executor   The {@link Executor} where the callback will be invoked on.
     * @param listener   The {@link Consumer} that will receive the callbacks when entered or
     *                   exited the threshold.
     *
     * @see SurfaceControl.Transaction#setTrustedPresentationCallback(SurfaceControl,
     * SurfaceControl.TrustedPresentationThresholds, Executor, Consumer)
     *
     * @hide b/287076178 un-hide with API bump
     */
    default void addTrustedPresentationCallback(@NonNull SurfaceControl.Transaction t,
            @NonNull SurfaceControl.TrustedPresentationThresholds thresholds,
            @NonNull Executor executor, @NonNull Consumer<Boolean> listener) {
    }

    /**
     * Remove a trusted presentation listener on the SurfaceControl associated with this window.
     *
     * @param t          Transaction that the trusted presentation listener removed on. This should
     *                   be applied by the caller.
     * @param listener   The {@link Consumer} that was previously registered with
     *                   addTrustedPresentationCallback that should be removed.
     *
     * @see SurfaceControl.Transaction#clearTrustedPresentationCallback(SurfaceControl)
     * @hide b/287076178 un-hide with API bump
     */
    default void removeTrustedPresentationCallback(@NonNull SurfaceControl.Transaction t,
            @NonNull Consumer<Boolean> listener) {
    }

    /**
     * Transfer the currently in progress touch gesture from the host to the requested
     * {@link SurfaceControlViewHost.SurfacePackage}. This requires that the
+8 −0
Original line number Diff line number Diff line
@@ -73,6 +73,8 @@ import android.window.ISurfaceSyncGroupCompletedListener;
import android.window.ITaskFpsCallback;
import android.window.ScreenCapture;
import android.window.WindowContextInfo;
import android.window.ITrustedPresentationListener;
import android.window.TrustedPresentationThresholds;

/**
 * System private interface to the window manager.
@@ -1075,4 +1077,10 @@ interface IWindowManager
    @JavaPassthrough(annotation = "@android.annotation.RequiresPermission(android.Manifest"
            + ".permission.MONITOR_INPUT)")
    void unregisterDecorViewGestureListener(IDecorViewGestureListener listener, int displayId);

    void registerTrustedPresentationListener(in IBinder window, in ITrustedPresentationListener listener,
            in TrustedPresentationThresholds thresholds, int id);


    void unregisterTrustedPresentationListener(in ITrustedPresentationListener listener, int id);
}
+0 −12
Original line number Diff line number Diff line
@@ -12016,18 +12016,6 @@ public final class ViewRootImpl implements ViewParent,
        scheduleTraversals();
    }

    @Override
    public void addTrustedPresentationCallback(@NonNull SurfaceControl.Transaction t,
            @NonNull SurfaceControl.TrustedPresentationThresholds thresholds,
            @NonNull Executor executor, @NonNull Consumer<Boolean> listener) {
        t.setTrustedPresentationCallback(getSurfaceControl(), thresholds, executor, listener);
    }

    @Override
    public void removeTrustedPresentationCallback(@NonNull SurfaceControl.Transaction t,
            @NonNull Consumer<Boolean> listener) {
        t.clearTrustedPresentationCallback(getSurfaceControl());
    }

    private void logAndTrace(String msg) {
        if (Trace.isTagEnabled(Trace.TRACE_TAG_VIEW)) {
+34 −0
Original line number Diff line number Diff line
@@ -122,7 +122,11 @@ import android.view.WindowInsets.Side.InsetsSide;
import android.view.WindowInsets.Type;
import android.view.WindowInsets.Type.InsetsType;
import android.view.accessibility.AccessibilityNodeInfo;
import android.window.ITrustedPresentationListener;
import android.window.TaskFpsCallback;
import android.window.TrustedPresentationThresholds;

import com.android.window.flags.Flags;

import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
@@ -5905,4 +5909,34 @@ public interface WindowManager extends ViewManager {
    default boolean replaceContentOnDisplayWithSc(int displayId, @NonNull SurfaceControl sc) {
        throw new UnsupportedOperationException();
    }

    /**
     * Add a trusted presentation listener associated with a window.
     *
     * <p> If this listener is already registered then the window and thresholds will be updated.
     *
     * @param window     The Window to add the trusted presentation listener for
     * @param thresholds The {@link TrustedPresentationThresholds} that will specify
     *                   when the to invoke the callback.
     * @param executor   The {@link Executor} where the callback will be invoked on.
     * @param listener   The {@link Consumer} that will receive the callbacks
     *                  when entered or exited trusted presentation per the thresholds.
     */
    @FlaggedApi(Flags.FLAG_TRUSTED_PRESENTATION_LISTENER_FOR_WINDOW)
    default void registerTrustedPresentationListener(@NonNull IBinder window,
            @NonNull TrustedPresentationThresholds thresholds,  @NonNull Executor executor,
            @NonNull Consumer<Boolean> listener) {
        throw new UnsupportedOperationException();
    }

    /**
     * Removes a presentation listener associated with a window. If the listener was not previously
     * registered, the call will be a noop.
     *
     * @see WindowManager#registerTrustedPresentationListener(IBinder, TrustedPresentationThresholds, Executor, Consumer)
     */
    @FlaggedApi(Flags.FLAG_TRUSTED_PRESENTATION_LISTENER_FOR_WINDOW)
    default void unregisterTrustedPresentationListener(@NonNull Consumer<Boolean> listener) {
        throw new UnsupportedOperationException();
    }
}
Loading