Include splashscreen background color in new starting window listener
Pass the starting window background color to starting window listeners. Bug: 187706750 Test: Manual Change-Id: I729df4afbf75540a60c6f2e288de80fc0b6d97dd
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user