Merge "Ensure no starting window leak in WMShell before adding." into sc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
a1195c85c7
@@ -347,8 +347,13 @@ public class StartingSurfaceDrawer {
|
|||||||
void makeTaskSnapshotWindow(StartingWindowInfo startingWindowInfo, IBinder appToken,
|
void makeTaskSnapshotWindow(StartingWindowInfo startingWindowInfo, IBinder appToken,
|
||||||
TaskSnapshot snapshot) {
|
TaskSnapshot snapshot) {
|
||||||
final int taskId = startingWindowInfo.taskInfo.taskId;
|
final int taskId = startingWindowInfo.taskInfo.taskId;
|
||||||
|
// Remove any existing starting window for this task before adding.
|
||||||
|
removeWindowNoAnimate(taskId);
|
||||||
final TaskSnapshotWindow surface = TaskSnapshotWindow.create(startingWindowInfo, appToken,
|
final TaskSnapshotWindow surface = TaskSnapshotWindow.create(startingWindowInfo, appToken,
|
||||||
snapshot, mSplashScreenExecutor, () -> removeWindowNoAnimate(taskId));
|
snapshot, mSplashScreenExecutor, () -> removeWindowNoAnimate(taskId));
|
||||||
|
if (surface == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
final StartingWindowRecord tView = new StartingWindowRecord(appToken,
|
final StartingWindowRecord tView = new StartingWindowRecord(appToken,
|
||||||
null/* decorView */, surface);
|
null/* decorView */, surface);
|
||||||
mStartingWindowRecords.put(taskId, tView);
|
mStartingWindowRecords.put(taskId, tView);
|
||||||
|
|||||||
@@ -45,6 +45,7 @@ import static com.android.internal.policy.DecorView.STATUS_BAR_COLOR_VIEW_ATTRIB
|
|||||||
import static com.android.internal.policy.DecorView.getNavigationBarRect;
|
import static com.android.internal.policy.DecorView.getNavigationBarRect;
|
||||||
|
|
||||||
import android.annotation.BinderThread;
|
import android.annotation.BinderThread;
|
||||||
|
import android.annotation.NonNull;
|
||||||
import android.annotation.Nullable;
|
import android.annotation.Nullable;
|
||||||
import android.app.ActivityManager;
|
import android.app.ActivityManager;
|
||||||
import android.app.ActivityManager.TaskDescription;
|
import android.app.ActivityManager.TaskDescription;
|
||||||
@@ -141,7 +142,8 @@ public class TaskSnapshotWindow {
|
|||||||
private final float[] mTmpFloat9 = new float[9];
|
private final float[] mTmpFloat9 = new float[9];
|
||||||
|
|
||||||
static TaskSnapshotWindow create(StartingWindowInfo info, IBinder appToken,
|
static TaskSnapshotWindow create(StartingWindowInfo info, IBinder appToken,
|
||||||
TaskSnapshot snapshot, ShellExecutor mainExecutor, Runnable clearWindowHandler) {
|
TaskSnapshot snapshot, ShellExecutor splashScreenExecutor,
|
||||||
|
@NonNull Runnable clearWindowHandler) {
|
||||||
final ActivityManager.RunningTaskInfo runningTaskInfo = info.taskInfo;
|
final ActivityManager.RunningTaskInfo runningTaskInfo = info.taskInfo;
|
||||||
final int taskId = runningTaskInfo.taskId;
|
final int taskId = runningTaskInfo.taskId;
|
||||||
if (DEBUG) {
|
if (DEBUG) {
|
||||||
@@ -208,39 +210,38 @@ public class TaskSnapshotWindow {
|
|||||||
final TaskSnapshotWindow snapshotSurface = new TaskSnapshotWindow(
|
final TaskSnapshotWindow snapshotSurface = new TaskSnapshotWindow(
|
||||||
surfaceControl, snapshot, layoutParams.getTitle(), taskDescription, appearance,
|
surfaceControl, snapshot, layoutParams.getTitle(), taskDescription, appearance,
|
||||||
windowFlags, windowPrivateFlags, taskBounds, orientation,
|
windowFlags, windowPrivateFlags, taskBounds, orientation,
|
||||||
topWindowInsetsState, clearWindowHandler, mainExecutor);
|
topWindowInsetsState, clearWindowHandler, splashScreenExecutor);
|
||||||
final Window window = snapshotSurface.mWindow;
|
final Window window = snapshotSurface.mWindow;
|
||||||
|
|
||||||
final InsetsState mTmpInsetsState = new InsetsState();
|
final InsetsState mTmpInsetsState = new InsetsState();
|
||||||
final InputChannel tmpInputChannel = new InputChannel();
|
final InputChannel tmpInputChannel = new InputChannel();
|
||||||
mainExecutor.execute(() -> {
|
|
||||||
try {
|
|
||||||
Trace.traceBegin(TRACE_TAG_WINDOW_MANAGER, "TaskSnapshot#addToDisplay");
|
|
||||||
final int res = session.addToDisplay(window, layoutParams, View.GONE, displayId,
|
|
||||||
mTmpInsetsState, tmpInputChannel, mTmpInsetsState, mTempControls);
|
|
||||||
Trace.traceEnd(TRACE_TAG_WINDOW_MANAGER);
|
|
||||||
if (res < 0) {
|
|
||||||
Slog.w(TAG, "Failed to add snapshot starting window res=" + res);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
} catch (RemoteException e) {
|
|
||||||
snapshotSurface.clearWindowSynced();
|
|
||||||
}
|
|
||||||
window.setOuter(snapshotSurface);
|
|
||||||
try {
|
|
||||||
Trace.traceBegin(TRACE_TAG_WINDOW_MANAGER, "TaskSnapshot#relayout");
|
|
||||||
session.relayout(window, layoutParams, -1, -1, View.VISIBLE, 0, -1,
|
|
||||||
tmpFrames, tmpMergedConfiguration, surfaceControl, mTmpInsetsState,
|
|
||||||
mTempControls, TMP_SURFACE_SIZE);
|
|
||||||
Trace.traceEnd(TRACE_TAG_WINDOW_MANAGER);
|
|
||||||
} catch (RemoteException e) {
|
|
||||||
snapshotSurface.clearWindowSynced();
|
|
||||||
}
|
|
||||||
|
|
||||||
final Rect systemBarInsets = getSystemBarInsets(tmpFrames.frame, topWindowInsetsState);
|
try {
|
||||||
snapshotSurface.setFrames(tmpFrames.frame, systemBarInsets);
|
Trace.traceBegin(TRACE_TAG_WINDOW_MANAGER, "TaskSnapshot#addToDisplay");
|
||||||
snapshotSurface.drawSnapshot();
|
final int res = session.addToDisplay(window, layoutParams, View.GONE, displayId,
|
||||||
});
|
mTmpInsetsState, tmpInputChannel, mTmpInsetsState, mTempControls);
|
||||||
|
Trace.traceEnd(TRACE_TAG_WINDOW_MANAGER);
|
||||||
|
if (res < 0) {
|
||||||
|
Slog.w(TAG, "Failed to add snapshot starting window res=" + res);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
} catch (RemoteException e) {
|
||||||
|
snapshotSurface.clearWindowSynced();
|
||||||
|
}
|
||||||
|
window.setOuter(snapshotSurface);
|
||||||
|
try {
|
||||||
|
Trace.traceBegin(TRACE_TAG_WINDOW_MANAGER, "TaskSnapshot#relayout");
|
||||||
|
session.relayout(window, layoutParams, -1, -1, View.VISIBLE, 0, -1,
|
||||||
|
tmpFrames, tmpMergedConfiguration, surfaceControl, mTmpInsetsState,
|
||||||
|
mTempControls, TMP_SURFACE_SIZE);
|
||||||
|
Trace.traceEnd(TRACE_TAG_WINDOW_MANAGER);
|
||||||
|
} catch (RemoteException e) {
|
||||||
|
snapshotSurface.clearWindowSynced();
|
||||||
|
}
|
||||||
|
|
||||||
|
final Rect systemBarInsets = getSystemBarInsets(tmpFrames.frame, topWindowInsetsState);
|
||||||
|
snapshotSurface.setFrames(tmpFrames.frame, systemBarInsets);
|
||||||
|
snapshotSurface.drawSnapshot();
|
||||||
return snapshotSurface;
|
return snapshotSurface;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -469,9 +470,7 @@ public class TaskSnapshotWindow {
|
|||||||
* Clear window from drawer, must be post on main executor.
|
* Clear window from drawer, must be post on main executor.
|
||||||
*/
|
*/
|
||||||
private void clearWindowSynced() {
|
private void clearWindowSynced() {
|
||||||
if (mClearWindowHandler != null) {
|
mSplashScreenExecutor.executeDelayed(mClearWindowHandler, 0);
|
||||||
mClearWindowHandler.run();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void reportDrawn() {
|
private void reportDrawn() {
|
||||||
|
|||||||
Reference in New Issue
Block a user