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

Commit 23e27732 authored by Winson Chung's avatar Winson Chung Committed by Android (Google) Code Review
Browse files

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

parents aa7da10e dc09a78f
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -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);
    }

    //
+18 −3
Original line number Diff line number Diff line
@@ -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);
            }
+1 −1
Original line number Diff line number Diff line
@@ -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,
+1 −1
Original line number Diff line number Diff line
@@ -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,
+1 −1
Original line number Diff line number Diff line
@@ -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,
Loading