Merge "Include splashscreen background color in new starting window listener" into sc-dev am: 7deb3ba4d4
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/14881305 Change-Id: If063439e9e98dd28e1e7e134ea15ac956b27e0c3
This commit is contained in:
@@ -25,6 +25,7 @@ interface IStartingWindowListener {
|
|||||||
* Notifies when Shell going to create a new starting window.
|
* Notifies when Shell going to create a new starting window.
|
||||||
* @param taskId The task Id
|
* @param taskId The task Id
|
||||||
* @param supportedType The starting window type
|
* @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.content.res.TypedArray;
|
||||||
import android.graphics.PixelFormat;
|
import android.graphics.PixelFormat;
|
||||||
import android.graphics.Rect;
|
import android.graphics.Rect;
|
||||||
|
import android.graphics.drawable.ColorDrawable;
|
||||||
import android.hardware.display.DisplayManager;
|
import android.hardware.display.DisplayManager;
|
||||||
import android.os.IBinder;
|
import android.os.IBinder;
|
||||||
import android.os.SystemProperties;
|
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 static class SplashScreenViewSupplier implements Supplier<SplashScreenView> {
|
||||||
private SplashScreenView mView;
|
private SplashScreenView mView;
|
||||||
private boolean mIsViewSet;
|
private boolean mIsViewSet;
|
||||||
|
|||||||
@@ -36,12 +36,11 @@ import android.window.TaskSnapshot;
|
|||||||
|
|
||||||
import androidx.annotation.BinderThread;
|
import androidx.annotation.BinderThread;
|
||||||
|
|
||||||
|
import com.android.internal.util.function.TriConsumer;
|
||||||
import com.android.wm.shell.common.RemoteCallable;
|
import com.android.wm.shell.common.RemoteCallable;
|
||||||
import com.android.wm.shell.common.ShellExecutor;
|
import com.android.wm.shell.common.ShellExecutor;
|
||||||
import com.android.wm.shell.common.TransactionPool;
|
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
|
* Implementation to draw the starting window to an application, and remove the starting window
|
||||||
* until the application displays its own window.
|
* until the application displays its own window.
|
||||||
@@ -68,7 +67,7 @@ public class StartingWindowController implements RemoteCallable<StartingWindowCo
|
|||||||
private final StartingSurfaceDrawer mStartingSurfaceDrawer;
|
private final StartingSurfaceDrawer mStartingSurfaceDrawer;
|
||||||
private final StartingWindowTypeAlgorithm mStartingWindowTypeAlgorithm;
|
private final StartingWindowTypeAlgorithm mStartingWindowTypeAlgorithm;
|
||||||
|
|
||||||
private BiConsumer<Integer, Integer> mTaskLaunchingCallback;
|
private TriConsumer<Integer, Integer, Integer> mTaskLaunchingCallback;
|
||||||
private final StartingSurfaceImpl mImpl = new StartingSurfaceImpl();
|
private final StartingSurfaceImpl mImpl = new StartingSurfaceImpl();
|
||||||
private final Context mContext;
|
private final Context mContext;
|
||||||
private final ShellExecutor mSplashScreenExecutor;
|
private final ShellExecutor mSplashScreenExecutor;
|
||||||
@@ -103,7 +102,7 @@ public class StartingWindowController implements RemoteCallable<StartingWindowCo
|
|||||||
*
|
*
|
||||||
* @param listener The callback when need a starting window.
|
* @param listener The callback when need a starting window.
|
||||||
*/
|
*/
|
||||||
void setStartingWindowListener(BiConsumer<Integer, Integer> listener) {
|
void setStartingWindowListener(TriConsumer<Integer, Integer, Integer> listener) {
|
||||||
mTaskLaunchingCallback = listener;
|
mTaskLaunchingCallback = listener;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -121,9 +120,6 @@ public class StartingWindowController implements RemoteCallable<StartingWindowCo
|
|||||||
final int suggestionType = mStartingWindowTypeAlgorithm.getSuggestedWindowType(
|
final int suggestionType = mStartingWindowTypeAlgorithm.getSuggestedWindowType(
|
||||||
windowInfo);
|
windowInfo);
|
||||||
final RunningTaskInfo runningTaskInfo = windowInfo.taskInfo;
|
final RunningTaskInfo runningTaskInfo = windowInfo.taskInfo;
|
||||||
if (mTaskLaunchingCallback != null && shouldSendToListener(suggestionType)) {
|
|
||||||
mTaskLaunchingCallback.accept(runningTaskInfo.taskId, suggestionType);
|
|
||||||
}
|
|
||||||
if (suggestionType == STARTING_WINDOW_TYPE_SPLASH_SCREEN) {
|
if (suggestionType == STARTING_WINDOW_TYPE_SPLASH_SCREEN) {
|
||||||
mStartingSurfaceDrawer.addSplashScreenStartingWindow(windowInfo, appToken,
|
mStartingSurfaceDrawer.addSplashScreenStartingWindow(windowInfo, appToken,
|
||||||
false /* emptyView */);
|
false /* emptyView */);
|
||||||
@@ -137,6 +133,11 @@ public class StartingWindowController implements RemoteCallable<StartingWindowCo
|
|||||||
} else /* suggestionType == STARTING_WINDOW_TYPE_NONE */ {
|
} else /* suggestionType == STARTING_WINDOW_TYPE_NONE */ {
|
||||||
// Don't add a staring window.
|
// 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);
|
Trace.traceEnd(TRACE_TAG_WINDOW_MANAGER);
|
||||||
});
|
});
|
||||||
@@ -181,7 +182,7 @@ public class StartingWindowController implements RemoteCallable<StartingWindowCo
|
|||||||
private static class IStartingWindowImpl extends IStartingWindow.Stub {
|
private static class IStartingWindowImpl extends IStartingWindow.Stub {
|
||||||
private StartingWindowController mController;
|
private StartingWindowController mController;
|
||||||
private IStartingWindowListener mListener;
|
private IStartingWindowListener mListener;
|
||||||
private final BiConsumer<Integer, Integer> mStartingWindowListener =
|
private final TriConsumer<Integer, Integer, Integer> mStartingWindowListener =
|
||||||
this::notifyIStartingWindowListener;
|
this::notifyIStartingWindowListener;
|
||||||
private final IBinder.DeathRecipient mListenerDeathRecipient =
|
private final IBinder.DeathRecipient mListenerDeathRecipient =
|
||||||
new IBinder.DeathRecipient() {
|
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) {
|
if (mListener == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
mListener.onTaskLaunching(taskId, supportedType);
|
mListener.onTaskLaunching(taskId, supportedType, startingWindowBackgroundColor);
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
Slog.e(TAG, "Failed to notify task launching", e);
|
Slog.e(TAG, "Failed to notify task launching", e);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user