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

Commit 85fe3c0a authored by Cyrus Boadway's avatar Cyrus Boadway Committed by Automerger Merge Worker
Browse files

Merge "Include splashscreen background color in new starting window listener"...

Merge "Include splashscreen background color in new starting window listener" into sc-dev am: 7deb3ba4

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/14881305

Change-Id: If063439e9e98dd28e1e7e134ea15ac956b27e0c3
parents 7de44b83 7deb3ba4
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@ interface IStartingWindowListener {
     * Notifies when Shell going to create a new starting window.
     * @param taskId The task Id
     * @param supportedType The starting window type
     * @param splashScreenBackgroundColor The splash screen's background color
     */
    oneway void onTaskLaunching(int taskId, int supportedType);
    oneway void onTaskLaunching(int taskId, int supportedType, int splashScreenBackgroundColor);
}
+7 −0
Original line number Diff line number Diff line
@@ -32,6 +32,7 @@ import android.content.res.Resources;
import android.content.res.TypedArray;
import android.graphics.PixelFormat;
import android.graphics.Rect;
import android.graphics.drawable.ColorDrawable;
import android.hardware.display.DisplayManager;
import android.os.IBinder;
import android.os.SystemProperties;
@@ -326,6 +327,12 @@ public class StartingSurfaceDrawer {
        }
    }

    int getStartingWindowBackgroundColorForTask(int taskId) {
        StartingWindowRecord startingWindowRecord = mStartingWindowRecords.get(taskId);
        if (startingWindowRecord == null || startingWindowRecord.mContentView == null) return 0;
        return ((ColorDrawable) startingWindowRecord.mContentView.getBackground()).getColor();
    }

    private static class SplashScreenViewSupplier implements Supplier<SplashScreenView> {
        private SplashScreenView mView;
        private boolean mIsViewSet;
+12 −10
Original line number Diff line number Diff line
@@ -36,12 +36,11 @@ import android.window.TaskSnapshot;

import androidx.annotation.BinderThread;

import com.android.internal.util.function.TriConsumer;
import com.android.wm.shell.common.RemoteCallable;
import com.android.wm.shell.common.ShellExecutor;
import com.android.wm.shell.common.TransactionPool;

import java.util.function.BiConsumer;

/**
 * Implementation to draw the starting window to an application, and remove the starting window
 * until the application displays its own window.
@@ -68,7 +67,7 @@ public class StartingWindowController implements RemoteCallable<StartingWindowCo
    private final StartingSurfaceDrawer mStartingSurfaceDrawer;
    private final StartingWindowTypeAlgorithm mStartingWindowTypeAlgorithm;

    private BiConsumer<Integer, Integer> mTaskLaunchingCallback;
    private TriConsumer<Integer, Integer, Integer> mTaskLaunchingCallback;
    private final StartingSurfaceImpl mImpl = new StartingSurfaceImpl();
    private final Context mContext;
    private final ShellExecutor mSplashScreenExecutor;
@@ -103,7 +102,7 @@ public class StartingWindowController implements RemoteCallable<StartingWindowCo
     *
     * @param listener The callback when need a starting window.
     */
    void setStartingWindowListener(BiConsumer<Integer, Integer> listener) {
    void setStartingWindowListener(TriConsumer<Integer, Integer, Integer> listener) {
        mTaskLaunchingCallback = listener;
    }

@@ -121,9 +120,6 @@ public class StartingWindowController implements RemoteCallable<StartingWindowCo
            final int suggestionType = mStartingWindowTypeAlgorithm.getSuggestedWindowType(
                    windowInfo);
            final RunningTaskInfo runningTaskInfo = windowInfo.taskInfo;
            if (mTaskLaunchingCallback != null && shouldSendToListener(suggestionType)) {
                mTaskLaunchingCallback.accept(runningTaskInfo.taskId, suggestionType);
            }
            if (suggestionType == STARTING_WINDOW_TYPE_SPLASH_SCREEN) {
                mStartingSurfaceDrawer.addSplashScreenStartingWindow(windowInfo, appToken,
                        false /* emptyView */);
@@ -137,6 +133,11 @@ public class StartingWindowController implements RemoteCallable<StartingWindowCo
            } else /* suggestionType == STARTING_WINDOW_TYPE_NONE */ {
                // Don't add a staring window.
            }
            if (mTaskLaunchingCallback != null && shouldSendToListener(suggestionType)) {
                int taskId = runningTaskInfo.taskId;
                int color = mStartingSurfaceDrawer.getStartingWindowBackgroundColorForTask(taskId);
                mTaskLaunchingCallback.accept(taskId, suggestionType, color);
            }

            Trace.traceEnd(TRACE_TAG_WINDOW_MANAGER);
        });
@@ -181,7 +182,7 @@ public class StartingWindowController implements RemoteCallable<StartingWindowCo
    private static class IStartingWindowImpl extends IStartingWindow.Stub {
        private StartingWindowController mController;
        private IStartingWindowListener mListener;
        private final BiConsumer<Integer, Integer> mStartingWindowListener =
        private final TriConsumer<Integer, Integer, Integer> mStartingWindowListener =
                this::notifyIStartingWindowListener;
        private final IBinder.DeathRecipient mListenerDeathRecipient =
                new IBinder.DeathRecipient() {
@@ -230,13 +231,14 @@ public class StartingWindowController implements RemoteCallable<StartingWindowCo
                    });
        }

        private void notifyIStartingWindowListener(int taskId, int supportedType) {
        private void notifyIStartingWindowListener(int taskId, int supportedType,
                int startingWindowBackgroundColor) {
            if (mListener == null) {
                return;
            }

            try {
                mListener.onTaskLaunching(taskId, supportedType);
                mListener.onTaskLaunching(taskId, supportedType, startingWindowBackgroundColor);
            } catch (RemoteException e) {
                Slog.e(TAG, "Failed to notify task launching", e);
            }