Merge "Enable SC registry in the Shell" into udc-dev

This commit is contained in:
Winson Chung
2023-05-18 21:50:56 +00:00
committed by Android (Google) Code Review
7 changed files with 26 additions and 10 deletions

View File

@@ -732,10 +732,11 @@ public abstract class WMShellBaseModule {
@WMSingleton
@Provides
static ShellController provideShellController(ShellInit shellInit,
static ShellController provideShellController(Context context,
ShellInit shellInit,
ShellCommandHandler shellCommandHandler,
@ShellMainThread ShellExecutor mainExecutor) {
return new ShellController(shellInit, shellCommandHandler, mainExecutor);
return new ShellController(context, shellInit, shellCommandHandler, mainExecutor);
}
//

View File

@@ -32,6 +32,7 @@ import android.content.pm.UserInfo;
import android.content.res.Configuration;
import android.os.Bundle;
import android.util.ArrayMap;
import android.view.SurfaceControlRegistry;
import androidx.annotation.NonNull;
import androidx.annotation.VisibleForTesting;
@@ -52,6 +53,7 @@ import java.util.function.Supplier;
public class ShellController {
private static final String TAG = ShellController.class.getSimpleName();
private final Context mContext;
private final ShellInit mShellInit;
private final ShellCommandHandler mShellCommandHandler;
private final ShellExecutor mMainExecutor;
@@ -72,8 +74,11 @@ public class ShellController {
private Configuration mLastConfiguration;
public ShellController(ShellInit shellInit, ShellCommandHandler shellCommandHandler,
public ShellController(Context context,
ShellInit shellInit,
ShellCommandHandler shellCommandHandler,
ShellExecutor mainExecutor) {
mContext = context;
mShellInit = shellInit;
mShellCommandHandler = shellCommandHandler;
mMainExecutor = mainExecutor;
@@ -254,6 +259,16 @@ public class ShellController {
}
}
private void handleInit() {
SurfaceControlRegistry.createProcessInstance(mContext);
mShellInit.init();
}
private void handleDump(PrintWriter pw) {
mShellCommandHandler.dump(pw);
SurfaceControlRegistry.dump(100 /* limit */, false /* runGc */, pw);
}
public void dump(@NonNull PrintWriter pw, String prefix) {
final String innerPrefix = prefix + " ";
pw.println(prefix + TAG);
@@ -279,7 +294,7 @@ public class ShellController {
@Override
public void onInit() {
try {
mMainExecutor.executeBlocking(() -> mShellInit.init());
mMainExecutor.executeBlocking(() -> ShellController.this.handleInit());
} catch (InterruptedException e) {
throw new RuntimeException("Failed to initialize the Shell in 2s", e);
}
@@ -344,7 +359,7 @@ public class ShellController {
@Override
public void dump(PrintWriter pw) {
try {
mMainExecutor.executeBlocking(() -> mShellCommandHandler.dump(pw));
mMainExecutor.executeBlocking(() -> ShellController.this.handleDump(pw));
} catch (InterruptedException e) {
throw new RuntimeException("Failed to dump the Shell in 2s", e);
}

View File

@@ -129,7 +129,7 @@ public class PipControllerTest extends ShellTestCase {
return null;
}).when(mMockExecutor).execute(any());
mShellInit = spy(new ShellInit(mMockExecutor));
mShellController = spy(new ShellController(mShellInit, mMockShellCommandHandler,
mShellController = spy(new ShellController(mContext, mShellInit, mMockShellCommandHandler,
mMockExecutor));
mPipController = new PipController(mContext, mShellInit, mMockShellCommandHandler,
mShellController, mMockDisplayController, mMockPipAnimationController,

View File

@@ -107,7 +107,7 @@ public class RecentTasksControllerTest extends ShellTestCase {
mMainExecutor = new TestShellExecutor();
when(mContext.getPackageManager()).thenReturn(mock(PackageManager.class));
mShellInit = spy(new ShellInit(mMainExecutor));
mShellController = spy(new ShellController(mShellInit, mShellCommandHandler,
mShellController = spy(new ShellController(mContext, mShellInit, mShellCommandHandler,
mMainExecutor));
mRecentTasksControllerReal = new RecentTasksController(mContext, mShellInit,
mShellController, mShellCommandHandler, mTaskStackListener, mActivityTaskManager,

View File

@@ -111,7 +111,7 @@ public class SplitScreenControllerTests extends ShellTestCase {
public void setup() {
assumeTrue(ActivityTaskManager.supportsSplitScreenMultiWindow(mContext));
MockitoAnnotations.initMocks(this);
mShellController = spy(new ShellController(mShellInit, mShellCommandHandler,
mShellController = spy(new ShellController(mContext, mShellInit, mShellCommandHandler,
mMainExecutor));
mSplitScreenController = spy(new SplitScreenController(mContext, mShellInit,
mShellCommandHandler, mShellController, mTaskOrganizer, mSyncQueue,

View File

@@ -81,7 +81,7 @@ public class StartingWindowControllerTests extends ShellTestCase {
doReturn(mock(Display.class)).when(mDisplayManager).getDisplay(anyInt());
doReturn(mDisplayManager).when(mContext).getSystemService(eq(DisplayManager.class));
mShellInit = spy(new ShellInit(mMainExecutor));
mShellController = spy(new ShellController(mShellInit, mShellCommandHandler,
mShellController = spy(new ShellController(mContext, mShellInit, mShellCommandHandler,
mMainExecutor));
mController = new StartingWindowController(mContext, mShellInit, mShellController,
mTaskOrganizer, mMainExecutor, mTypeAlgorithm, mIconProvider, mTransactionPool);

View File

@@ -78,7 +78,7 @@ public class ShellControllerTest extends ShellTestCase {
mConfigChangeListener = new TestConfigurationChangeListener();
mUserChangeListener = new TestUserChangeListener();
mExecutor = new TestShellExecutor();
mController = new ShellController(mShellInit, mShellCommandHandler, mExecutor);
mController = new ShellController(mContext, mShellInit, mShellCommandHandler, mExecutor);
mController.onConfigurationChanged(getConfigurationCopy());
}