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

Commit 149e096e authored by Wei Sheng Shih's avatar Wei Sheng Shih Committed by Android (Google) Code Review
Browse files

Merge "Introduce Windowless starting window."

parents 5c16b5bc 8efcfd66
Loading
Loading
Loading
Loading
+1 −2
Original line number Diff line number Diff line
@@ -34,9 +34,8 @@ oneway interface ITaskOrganizer {
     * has create a starting window for the Task.
     *
     * @param info The information about the Task that's available
     * @param appToken Token of the application being started.
     */
    void addStartingWindow(in StartingWindowInfo info, IBinder appToken);
    void addStartingWindow(in StartingWindowInfo info);

    /**
     * Called when the Task want to remove the starting window.
+29 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2023 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.window;

import android.view.SurfaceControl;

/**
 * Interface to be invoked when a windowless starting surface added.
 *
 * @param addedSurface The starting surface.
 * {@hide}
 */
interface IWindowlessStartingSurfaceCallback {
    void onSurfaceAdded(in SurfaceControl addedSurface);
}
+17 −7
Original line number Diff line number Diff line
@@ -328,6 +328,21 @@ public class SnapshotDrawerUtils {
                        - ((float) frame.width() / frame.height())) <= 0.01f;
    }

    /**
     * Get or create a TaskDescription from a RunningTaskInfo.
     */
    public static ActivityManager.TaskDescription getOrCreateTaskDescription(
            ActivityManager.RunningTaskInfo runningTaskInfo) {
        final ActivityManager.TaskDescription taskDescription;
        if (runningTaskInfo.taskDescription != null) {
            taskDescription = runningTaskInfo.taskDescription;
        } else {
            taskDescription = new ActivityManager.TaskDescription();
            taskDescription.setBackgroundColor(WHITE);
        }
        return taskDescription;
    }

    /**
     * Help method to draw the snapshot on a surface.
     */
@@ -344,13 +359,8 @@ public class SnapshotDrawerUtils {

        final WindowManager.LayoutParams attrs = info.topOpaqueWindowLayoutParams;
        final ActivityManager.RunningTaskInfo runningTaskInfo = info.taskInfo;
        final ActivityManager.TaskDescription taskDescription;
        if (runningTaskInfo.taskDescription != null) {
            taskDescription = runningTaskInfo.taskDescription;
        } else {
            taskDescription = new ActivityManager.TaskDescription();
            taskDescription.setBackgroundColor(WHITE);
        }
        final ActivityManager.TaskDescription taskDescription =
                getOrCreateTaskDescription(runningTaskInfo);
        drawSurface.initiateSystemBarPainter(lp.flags, lp.privateFlags,
                attrs.insetsFlags.appearance, taskDescription, info.requestedVisibleTypes);
        final Rect systemBarInsets = getSystemBarInsets(windowBounds, topWindowInsetsState);
+48 −2
Original line number Diff line number Diff line
@@ -22,9 +22,12 @@ import android.annotation.Nullable;
import android.app.ActivityManager;
import android.app.TaskInfo;
import android.content.pm.ActivityInfo;
import android.os.IBinder;
import android.os.Parcel;
import android.os.Parcelable;
import android.os.RemoteException;
import android.view.InsetsState;
import android.view.SurfaceControl;
import android.view.WindowInsets;
import android.view.WindowInsets.Type.InsetsType;
import android.view.WindowManager;
@@ -59,6 +62,8 @@ public final class StartingWindowInfo implements Parcelable {
    /** @hide **/
    public static final int STARTING_WINDOW_TYPE_LEGACY_SPLASH_SCREEN = 4;

    public static final int STARTING_WINDOW_TYPE_WINDOWLESS = 5;

    /**
     * @hide
     */
@@ -67,7 +72,8 @@ public final class StartingWindowInfo implements Parcelable {
            STARTING_WINDOW_TYPE_SPLASH_SCREEN,
            STARTING_WINDOW_TYPE_SNAPSHOT,
            STARTING_WINDOW_TYPE_SOLID_COLOR_SPLASH_SCREEN,
            STARTING_WINDOW_TYPE_LEGACY_SPLASH_SCREEN
            STARTING_WINDOW_TYPE_LEGACY_SPLASH_SCREEN,
            STARTING_WINDOW_TYPE_WINDOWLESS
    })
    public @interface StartingWindowType {}

@@ -118,6 +124,7 @@ public final class StartingWindowInfo implements Parcelable {
            TYPE_PARAMETER_ACTIVITY_CREATED,
            TYPE_PARAMETER_USE_SOLID_COLOR_SPLASH_SCREEN,
            TYPE_PARAMETER_ALLOW_HANDLE_SOLID_COLOR_SCREEN,
            TYPE_PARAMETER_WINDOWLESS,
            TYPE_PARAMETER_LEGACY_SPLASH_SCREEN
    })
    public @interface StartingTypeParams {}
@@ -151,6 +158,12 @@ public final class StartingWindowInfo implements Parcelable {
     * @hide
     */
    public static final int TYPE_PARAMETER_ALLOW_HANDLE_SOLID_COLOR_SCREEN = 0x00000080;

    /**
     * Windowless surface
     */
    public static final int TYPE_PARAMETER_WINDOWLESS = 0x00000100;

    /**
     * Application is allowed to use the legacy splash screen
     * @hide
@@ -182,7 +195,33 @@ public final class StartingWindowInfo implements Parcelable {
     */
    public TaskSnapshot taskSnapshot;

    public @InsetsType int requestedVisibleTypes = WindowInsets.Type.defaultVisible();
    @InsetsType public int requestedVisibleTypes = WindowInsets.Type.defaultVisible();

    /**
     * App token where the starting window should add to.
     */
    public IBinder appToken;

    public IWindowlessStartingSurfaceCallback windowlessStartingSurfaceCallback;

    /**
     * The root surface where windowless surface should attach on.
     */
    public SurfaceControl rootSurface;

    /**
     * Notify windowless surface is created.
     * @param addedSurface Created surface.
     */
    public void notifyAddComplete(SurfaceControl addedSurface) {
        if (windowlessStartingSurfaceCallback != null) {
            try {
                windowlessStartingSurfaceCallback.onSurfaceAdded(addedSurface);
            } catch (RemoteException e) {
                //
            }
        }
    }

    public StartingWindowInfo() {

@@ -216,6 +255,9 @@ public final class StartingWindowInfo implements Parcelable {
        dest.writeBoolean(isKeyguardOccluded);
        dest.writeTypedObject(taskSnapshot, flags);
        dest.writeInt(requestedVisibleTypes);
        dest.writeStrongBinder(appToken);
        dest.writeStrongInterface(windowlessStartingSurfaceCallback);
        dest.writeTypedObject(rootSurface, flags);
    }

    void readFromParcel(@NonNull Parcel source) {
@@ -230,6 +272,10 @@ public final class StartingWindowInfo implements Parcelable {
        isKeyguardOccluded = source.readBoolean();
        taskSnapshot = source.readTypedObject(TaskSnapshot.CREATOR);
        requestedVisibleTypes = source.readInt();
        appToken = source.readStrongBinder();
        windowlessStartingSurfaceCallback = IWindowlessStartingSurfaceCallback.Stub
                .asInterface(source.readStrongBinder());
        rootSurface = source.readTypedObject(SurfaceControl.CREATOR);
    }

    @Override
+17 −1
Original line number Diff line number Diff line
@@ -67,6 +67,16 @@ public final class StartingWindowRemovalInfo implements Parcelable {
     */
    public float roundedCornerRadius;

    /**
     * Remove windowless surface.
     */
    public boolean windowlessSurface;

    /**
     * Remove immediately.
     */
    public boolean removeImmediately;

    public StartingWindowRemovalInfo() {

    }
@@ -87,6 +97,8 @@ public final class StartingWindowRemovalInfo implements Parcelable {
        playRevealAnimation = source.readBoolean();
        deferRemoveForIme = source.readBoolean();
        roundedCornerRadius = source.readFloat();
        windowlessSurface = source.readBoolean();
        removeImmediately = source.readBoolean();
    }

    @Override
@@ -97,6 +109,8 @@ public final class StartingWindowRemovalInfo implements Parcelable {
        dest.writeBoolean(playRevealAnimation);
        dest.writeBoolean(deferRemoveForIme);
        dest.writeFloat(roundedCornerRadius);
        dest.writeBoolean(windowlessSurface);
        dest.writeBoolean(removeImmediately);
    }

    @Override
@@ -105,7 +119,9 @@ public final class StartingWindowRemovalInfo implements Parcelable {
                + " frame=" + mainFrame
                + " playRevealAnimation=" + playRevealAnimation
                + " roundedCornerRadius=" + roundedCornerRadius
                + " deferRemoveForIme=" + deferRemoveForIme + "}";
                + " deferRemoveForIme=" + deferRemoveForIme
                + " windowlessSurface=" + windowlessSurface
                + " removeImmediately=" + removeImmediately + "}";
    }

    public static final @android.annotation.NonNull Creator<StartingWindowRemovalInfo> CREATOR =
Loading