Move communal service classes out of SystemUI.

This change moves the communal service implementation
out of SystemUI. It also removes the Communal host
service, which is no longer in use.

Test: manual (code and tests refactored).
Bug: 198004715
Change-Id: Ie2c63a51d792dd77271e7748d7a0e1cc291f5713
diff --git a/packages/SystemUI/AndroidManifest.xml b/packages/SystemUI/AndroidManifest.xml
index a4b4680..eb0bb77 100644
--- a/packages/SystemUI/AndroidManifest.xml
+++ b/packages/SystemUI/AndroidManifest.xml
@@ -657,10 +657,6 @@
         </service>
 
         <service
-            android:name=".communal.service.CommunalService"
-            android:exported="@bool/config_communalServiceEnabled"/>
-
-        <service
             android:name=".keyguard.KeyguardService"
             android:exported="true" />
 
diff --git a/packages/SystemUI/src/com/android/systemui/communal/service/CommunalService.java b/packages/SystemUI/src/com/android/systemui/communal/service/CommunalService.java
deleted file mode 100644
index 1612670..0000000
--- a/packages/SystemUI/src/com/android/systemui/communal/service/CommunalService.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Copyright (C) 2021 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.systemui.communal.service;
-
-import android.app.Service;
-import android.content.Intent;
-import android.os.IBinder;
-
-import androidx.annotation.Nullable;
-
-import com.android.systemui.communal.CommunalSourceMonitor;
-import com.android.systemui.dagger.qualifiers.Main;
-import com.android.systemui.shared.communal.ICommunalHost;
-import com.android.systemui.shared.communal.ICommunalSource;
-
-import java.util.concurrent.Executor;
-
-import javax.inject.Inject;
-
-/**
- * CommunalService services requests to {@link ICommunalHost}, allowing clients to declare
- * themselves as the source of communal surfaces.
- */
-public class CommunalService extends Service {
-    final Executor mMainExecutor;
-    final CommunalSourceMonitor mMonitor;
-    private final CommunalSourceImpl.Factory mSourceFactory;
-
-    private ICommunalHost.Stub mBinder = new ICommunalHost.Stub() {
-        @Override
-        public void setSource(ICommunalSource source) {
-            mMonitor.setSource(
-                    source != null ? mSourceFactory.create(source) : null);
-        }
-    };
-
-    @Inject
-    CommunalService(@Main Executor mainExecutor, CommunalSourceImpl.Factory sourceFactory,
-            CommunalSourceMonitor monitor) {
-        mMainExecutor = mainExecutor;
-        mSourceFactory = sourceFactory;
-        mMonitor = monitor;
-    }
-
-    @Nullable
-    @Override
-    public IBinder onBind(Intent intent) {
-        // The service does not expect requests outside ICommunalHost.
-        return mBinder;
-    }
-}
diff --git a/packages/SystemUI/src/com/android/systemui/communal/service/CommunalSourceImpl.java b/packages/SystemUI/src/com/android/systemui/communal/service/CommunalSourceImpl.java
deleted file mode 100644
index b8070ab..0000000
--- a/packages/SystemUI/src/com/android/systemui/communal/service/CommunalSourceImpl.java
+++ /dev/null
@@ -1,225 +0,0 @@
-/*
- * Copyright (C) 2021 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.systemui.communal.service;
-
-import android.content.Context;
-import android.content.res.Resources;
-import android.os.IBinder;
-import android.os.RemoteException;
-import android.util.Log;
-import android.view.SurfaceControlViewHost;
-import android.view.SurfaceView;
-
-import androidx.concurrent.futures.CallbackToFutureAdapter;
-
-import com.android.systemui.communal.CommunalSource;
-import com.android.systemui.communal.CommunalStateController;
-import com.android.systemui.dagger.qualifiers.Main;
-import com.android.systemui.shared.communal.ICommunalSource;
-import com.android.systemui.shared.communal.ICommunalSurfaceCallback;
-import com.android.systemui.statusbar.NotificationShadeWindowController;
-
-import com.google.android.collect.Lists;
-import com.google.common.util.concurrent.ListenableFuture;
-
-import java.lang.ref.WeakReference;
-import java.util.ArrayList;
-import java.util.Objects;
-import java.util.concurrent.Executor;
-
-import javax.inject.Inject;
-
-/**
- * {@link CommunalSourceImpl} provides a wrapper around {@link ICommunalSource} proxies as an
- * implementation of {@link CommunalSource}. Requests and responses for communal surfaces are
- * translated into the proper binder calls.
- */
-public class CommunalSourceImpl implements CommunalSource {
-    private static final String TAG = "CommunalSourceImpl";
-    private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG);
-    private final ICommunalSource mSourceProxy;
-    private final Resources mResources;
-    private final Executor mMainExecutor;
-    private final NotificationShadeWindowController mNotificationShadeWindowController;
-    private final CommunalStateController mCommunalStateController;
-
-    static class Factory {
-        private final Executor mExecutor;
-        private final Resources mResources;
-        private final CommunalStateController mCommunalStateController;
-        private final NotificationShadeWindowController mNotificationShadeWindowController;
-
-        @Inject
-        Factory(@Main Executor executor, @Main Resources resources,
-                NotificationShadeWindowController notificationShadeWindowController,
-                CommunalStateController communalStateController) {
-            mExecutor = executor;
-            mResources = resources;
-            mNotificationShadeWindowController = notificationShadeWindowController;
-            mCommunalStateController = communalStateController;
-        }
-
-        public CommunalSource create(ICommunalSource source) {
-            return new CommunalSourceImpl(mExecutor, mResources, mCommunalStateController,
-                    mNotificationShadeWindowController, source);
-        }
-    }
-
-    static class Request {
-        private final int mWidth;
-        private final int mHeight;
-        private final int mDisplayId;
-        private final IBinder mHostToken;
-
-        Request(int width, int height, int displayId, IBinder hostToken) {
-            mWidth = width;
-            mHeight = height;
-            mDisplayId = displayId;
-            mHostToken = hostToken;
-        }
-
-        @Override
-        public boolean equals(Object o) {
-            if (this == o) return true;
-            if (!(o instanceof Request)) return false;
-            Request request = (Request) o;
-            return mWidth == request.mWidth && mHeight == request.mHeight
-                    && mDisplayId == request.mDisplayId && Objects.equals(mHostToken,
-                    request.mHostToken);
-        }
-
-        @Override
-        public int hashCode() {
-            return Objects.hash(mWidth, mHeight, mDisplayId, mHostToken);
-        }
-
-        @Override
-        public String toString() {
-            return "Request{"
-                    + "mWidth=" + mWidth
-                    + ", mHeight=" + mHeight
-                    + ", mDisplayId=" + mDisplayId
-                    + ", mHostToken=" + mHostToken
-                    + '}';
-        }
-    }
-
-    // mConnected is initialized to true as it is presumed instances are constructed with valid
-    // proxies. The source can never be reconnected once the proxy has died. Once this value
-    // becomes false, the source will always report disconnected to registering callbacks.
-    private boolean mConnected = true;
-
-    // A list of {@link Callback} that have registered to receive updates.
-    private final ArrayList<WeakReference<Callback>> mCallbacks = Lists.newArrayList();
-
-    public CommunalSourceImpl(Executor mainExecutor, Resources resources,
-            CommunalStateController communalStateController,
-            NotificationShadeWindowController notificationShadeWindowController,
-            ICommunalSource sourceProxy) {
-        mMainExecutor = mainExecutor;
-        mCommunalStateController = communalStateController;
-        mNotificationShadeWindowController = notificationShadeWindowController;
-        mResources = resources;
-        mSourceProxy = sourceProxy;
-
-        try {
-            // Track connection status based on proxy lifetime.
-            mSourceProxy.asBinder().linkToDeath(new IBinder.DeathRecipient() {
-                @Override
-                public void binderDied() {
-                    if (DEBUG) {
-                        Log.d(TAG, "Source lost. Clearing reporting disconnect.");
-                    }
-
-                    // Set connection state and inform callbacks.
-                    onDisconnected();
-                }
-            }, 0);
-        } catch (RemoteException e) {
-            Log.e(TAG, "Could not link to the source proxy death:" + e);
-        }
-    }
-
-    private void onDisconnected() {
-        mConnected = false;
-        for (WeakReference<Callback> cbRef : mCallbacks) {
-            final Callback cb = cbRef.get();
-            if (cb != null) {
-                cb.onDisconnected();
-            }
-        }
-
-        mCallbacks.clear();
-    }
-
-    @Override
-    public ListenableFuture<CommunalViewResult> requestCommunalView(Context context) {
-        if (DEBUG) {
-            Log.d(TAG, "Received request for communal view");
-        }
-        ListenableFuture<CommunalViewResult> packageFuture =
-                CallbackToFutureAdapter.getFuture(completer -> {
-                    final SurfaceView view = new SurfaceView(context);
-                    completer.set(new CommunalViewResult(view,
-                            new CommunalSurfaceViewController(view, mResources, mMainExecutor,
-                                    mCommunalStateController, mNotificationShadeWindowController,
-                                    this)));
-                    return "CommunalSourceImpl::requestCommunalSurface::getCommunalSurface";
-                });
-
-        return packageFuture;
-    }
-
-    /**
-     * Called internally to request a new {@link android.view.SurfaceControlViewHost.SurfacePackage}
-     * for showing communal content.
-     *
-     * @param request A request with the parameters for the new communal surface.
-     * @return A future that returns the resulting
-     * {@link android.view.SurfaceControlViewHost.SurfacePackage}.
-     */
-    protected ListenableFuture<SurfaceControlViewHost.SurfacePackage> requestCommunalSurface(
-            Request request) {
-        return CallbackToFutureAdapter.getFuture(completer -> {
-            mSourceProxy.getCommunalSurface(request.mHostToken, request.mWidth, request.mHeight,
-                    request.mDisplayId, new ICommunalSurfaceCallback.Stub() {
-                        @Override
-                        public void onSurface(
-                                SurfaceControlViewHost.SurfacePackage surfacePackage) {
-                            completer.set(surfacePackage);
-                        }
-                    });
-            return "CommunalSourceImpl::requestCommunalSurface::getCommunalSurface";
-        });
-
-    }
-
-    @Override
-    public void addCallback(Callback callback) {
-        mCallbacks.add(new WeakReference<>(callback));
-
-        // If not connected anymore, immediately inform new callback of disconnection and remove.
-        if (!mConnected) {
-            onDisconnected();
-        }
-    }
-
-    @Override
-    public void removeCallback(Callback callback) {
-        mCallbacks.removeIf(el -> el.get() == callback);
-    }
-}
diff --git a/packages/SystemUI/src/com/android/systemui/communal/service/CommunalSourcePrimer.java b/packages/SystemUI/src/com/android/systemui/communal/service/CommunalSourcePrimer.java
deleted file mode 100644
index 0f013ff..0000000
--- a/packages/SystemUI/src/com/android/systemui/communal/service/CommunalSourcePrimer.java
+++ /dev/null
@@ -1,235 +0,0 @@
-/*
- * Copyright (C) 2021 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.systemui.communal.service;
-
-import android.content.BroadcastReceiver;
-import android.content.ComponentName;
-import android.content.Context;
-import android.content.Intent;
-import android.content.IntentFilter;
-import android.content.ServiceConnection;
-import android.content.res.Resources;
-import android.os.IBinder;
-import android.os.PatternMatcher;
-import android.util.Log;
-
-import com.android.systemui.R;
-import com.android.systemui.SystemUI;
-import com.android.systemui.communal.CommunalSourceMonitor;
-import com.android.systemui.dagger.SysUISingleton;
-import com.android.systemui.dagger.qualifiers.Main;
-import com.android.systemui.shared.communal.ICommunalSource;
-import com.android.systemui.util.concurrency.DelayableExecutor;
-
-import javax.inject.Inject;
-
-/**
- * The {@link CommunalSourcePrimer} is responsible for priming SystemUI with a pre-configured
- * Communal source. The SystemUI service binds to the component to retrieve the
- * {@link com.android.systemui.communal.CommunalSource}. {@link CommunalSourcePrimer} has no effect
- * if there is no pre-defined value.
- */
-@SysUISingleton
-public class CommunalSourcePrimer extends SystemUI {
-    private static final String TAG = "CommunalSourcePrimer";
-    private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG);
-    private static final String ACTION_COMMUNAL_SOURCE = "android.intent.action.COMMUNAL_SOURCE";
-
-    private final Context mContext;
-    private final DelayableExecutor mMainExecutor;
-    private final CommunalSourceMonitor mMonitor;
-    private final CommunalSourceImpl.Factory mSourceFactory;
-    private final ComponentName mComponentName;
-    private final int mBaseReconnectDelayMs;
-    private final int mMaxReconnectAttempts;
-
-    private int mReconnectAttempts = 0;
-    private Runnable mCurrentReconnectCancelable;
-
-    private final Runnable mConnectRunnable = new Runnable() {
-        @Override
-        public void run() {
-            mCurrentReconnectCancelable = null;
-            bindToService();
-        }
-    };
-
-
-    private final BroadcastReceiver mReceiver = new BroadcastReceiver() {
-        @Override
-        public void onReceive(Context context, Intent intent) {
-            if (DEBUG) {
-                Log.d(TAG, "package added receiver - onReceive");
-            }
-
-            initiateConnectionAttempt();
-        }
-    };
-
-    private final ServiceConnection mConnection = new ServiceConnection() {
-        @Override
-        public void onServiceConnected(ComponentName className, IBinder service) {
-            final ICommunalSource source = ICommunalSource.Stub.asInterface(service);
-            if (DEBUG) {
-                Log.d(TAG, "onServiceConnected. source:" + source);
-            }
-
-            if (source == null) {
-                if (DEBUG) {
-                    Log.d(TAG, "onServiceConnected. invalid source");
-                    // Since the service could just repeatedly return null, the primer chooses
-                    // to schedule rather than initiate a new connection attempt sequence.
-                    scheduleConnectionAttempt();
-                }
-                return;
-            }
-
-            mMonitor.setSource(mSourceFactory.create(source));
-        }
-
-        @Override
-        public void onBindingDied(ComponentName name) {
-            if (DEBUG) {
-                Log.d(TAG, "onBindingDied. lost communal source. initiating reconnect");
-            }
-
-            initiateConnectionAttempt();
-        }
-
-        @Override
-        public void onServiceDisconnected(ComponentName className) {
-            if (DEBUG) {
-                Log.d(TAG,
-                        "onServiceDisconnected. lost communal source. initiating reconnect");
-            }
-
-            initiateConnectionAttempt();
-        }
-    };
-
-    @Inject
-    public CommunalSourcePrimer(Context context, @Main Resources resources,
-            DelayableExecutor mainExecutor,
-            CommunalSourceMonitor monitor,
-            CommunalSourceImpl.Factory sourceFactory) {
-        super(context);
-        mContext = context;
-        mMainExecutor = mainExecutor;
-        mMonitor = monitor;
-        mSourceFactory = sourceFactory;
-        mMaxReconnectAttempts = resources.getInteger(
-                R.integer.config_communalSourceMaxReconnectAttempts);
-        mBaseReconnectDelayMs = resources.getInteger(
-                R.integer.config_communalSourceReconnectBaseDelay);
-
-        final String component = resources.getString(R.string.config_communalSourceComponent);
-        mComponentName = component != null && !component.isEmpty()
-                ? ComponentName.unflattenFromString(component) : null;
-    }
-
-    @Override
-    public void start() {
-    }
-
-    private void initiateConnectionAttempt() {
-        // Reset attempts
-        mReconnectAttempts = 0;
-        mMonitor.setSource(null);
-
-        // The first attempt is always a direct invocation rather than delayed.
-        bindToService();
-    }
-
-    private void registerPackageListening() {
-        if (mComponentName == null) {
-            return;
-        }
-
-        final IntentFilter filter = new IntentFilter(Intent.ACTION_PACKAGE_ADDED);
-        filter.addDataScheme("package");
-        filter.addDataSchemeSpecificPart(mComponentName.getPackageName(),
-                PatternMatcher.PATTERN_LITERAL);
-        // Note that we directly register the receiver here as data schemes are not supported by
-        // BroadcastDispatcher.
-        mContext.registerReceiver(mReceiver, filter);
-    }
-
-    private void scheduleConnectionAttempt() {
-        // always clear cancelable if present.
-        if (mCurrentReconnectCancelable != null) {
-            mCurrentReconnectCancelable.run();
-            mCurrentReconnectCancelable = null;
-        }
-
-        if (mReconnectAttempts >= mMaxReconnectAttempts) {
-            if (DEBUG) {
-                Log.d(TAG, "exceeded max connection attempts.");
-            }
-            return;
-        }
-
-        final long reconnectDelayMs =
-                (long) Math.scalb(mBaseReconnectDelayMs, mReconnectAttempts);
-
-        if (DEBUG) {
-            Log.d(TAG,
-                    "scheduling connection attempt in " + reconnectDelayMs + "milliseconds");
-        }
-
-        mCurrentReconnectCancelable = mMainExecutor.executeDelayed(mConnectRunnable,
-                reconnectDelayMs);
-
-        mReconnectAttempts++;
-    }
-
-    @Override
-    protected void onBootCompleted() {
-        super.onBootCompleted();
-
-        if (DEBUG) {
-            Log.d(TAG, "onBootCompleted. communal source component:" + mComponentName);
-        }
-
-        registerPackageListening();
-        initiateConnectionAttempt();
-    }
-
-    private void bindToService() {
-        if (mComponentName == null) {
-            return;
-        }
-
-        if (DEBUG) {
-            Log.d(TAG, "attempting to bind to communal source");
-        }
-
-        final Intent intent = new Intent();
-        intent.setAction(ACTION_COMMUNAL_SOURCE);
-        intent.setComponent(mComponentName);
-
-        final boolean binding = mContext.bindService(intent, Context.BIND_AUTO_CREATE,
-                mMainExecutor, mConnection);
-
-        if (!binding) {
-            if (DEBUG) {
-                Log.d(TAG, "bindService failed, rescheduling");
-            }
-
-            scheduleConnectionAttempt();
-        }
-    }
-}
diff --git a/packages/SystemUI/src/com/android/systemui/communal/service/CommunalSurfaceViewController.java b/packages/SystemUI/src/com/android/systemui/communal/service/CommunalSurfaceViewController.java
deleted file mode 100644
index 0de5029..0000000
--- a/packages/SystemUI/src/com/android/systemui/communal/service/CommunalSurfaceViewController.java
+++ /dev/null
@@ -1,247 +0,0 @@
-/*
- * Copyright (C) 2021 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.systemui.communal.service;
-
-import android.annotation.IntDef;
-import android.content.res.Resources;
-import android.graphics.PixelFormat;
-import android.graphics.Region;
-import android.util.Log;
-import android.view.IWindow;
-import android.view.SurfaceControlViewHost;
-import android.view.SurfaceHolder;
-import android.view.SurfaceView;
-import android.view.View;
-
-import androidx.annotation.NonNull;
-
-import com.android.systemui.R;
-import com.android.systemui.communal.CommunalStateController;
-import com.android.systemui.statusbar.NotificationShadeWindowController;
-import com.android.systemui.util.Utils;
-import com.android.systemui.util.ViewController;
-
-import com.google.common.util.concurrent.ListenableFuture;
-
-import java.util.Optional;
-import java.util.concurrent.Executor;
-
-/**
- * {@link CommunalSurfaceViewController} coordinates requesting communal surfaces to populate a
- * {@link SurfaceView} with.
- */
-public class CommunalSurfaceViewController extends ViewController<SurfaceView> {
-    private static final String TAG = "CommunalSurfaceViewCtlr";
-    private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG);
-    private final Executor mMainExecutor;
-    private final CommunalStateController mCommunalStateController;
-    private final NotificationShadeWindowController mNotificationShadeWindowController;
-    private final CommunalSourceImpl mSource;
-    private final Resources mResources;
-    private final Region mSurfaceViewTouchableRegion;
-
-    @IntDef({STATE_SURFACE_CREATED, STATE_SURFACE_VIEW_ATTACHED})
-    private @interface State {}
-
-    private static final int STATE_SURFACE_CREATED = 1 << 0;
-    private static final int STATE_SURFACE_VIEW_ATTACHED = 1 << 1;
-
-    private static final int STATE_CAN_SHOW_SURFACE =
-            STATE_SURFACE_CREATED | STATE_SURFACE_VIEW_ATTACHED;
-
-    private int mCurrentState;
-
-    private Optional<CommunalSourceImpl.Request> mLastRequest = Optional.empty();
-
-    // The current in-flight request for a surface package.
-    private ListenableFuture<SurfaceControlViewHost.SurfacePackage> mCurrentSurfaceFuture;
-
-    private final SurfaceHolder.Callback mSurfaceHolderCallback = new SurfaceHolder.Callback() {
-        @Override
-        public void surfaceCreated(@NonNull SurfaceHolder holder) {
-            setState(STATE_SURFACE_CREATED, true);
-        }
-
-        @Override
-        public void surfaceChanged(@NonNull SurfaceHolder holder, int format, int width,
-                int height) {
-        }
-
-        @Override
-        public void surfaceDestroyed(@NonNull SurfaceHolder holder) {
-            setState(STATE_SURFACE_CREATED, false);
-        }
-    };
-
-    private final View.OnLayoutChangeListener mOnLayoutChangeListener =
-            new View.OnLayoutChangeListener() {
-        @Override
-        public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft,
-                int oldTop, int oldRight, int oldBottom) {
-            // The margin for the status bar and keyguard indication are excluded from the tap
-            // exclusion to preserve vertical swipes in this region.
-            final int topMargin = mResources.getDimensionPixelSize(
-                    Utils.shouldUseSplitNotificationShade(mResources)
-                            ? R.dimen.split_shade_header_height
-                            : R.dimen.notification_panel_margin_top);
-            final int bottomMargin = mResources.getDimensionPixelSize(
-                    R.dimen.keyguard_indication_bottom_padding);
-
-            mSurfaceViewTouchableRegion.set(left, top + topMargin, right, bottom - bottomMargin);
-            updateTouchExclusion();
-
-            // Trigger showing (or hiding) surface based on new dimensions.
-            showSurface();
-        }
-    };
-
-    private CommunalStateController.Callback mCommunalStateCallback =
-            new CommunalStateController.Callback() {
-        @Override
-        public void onCommunalViewOccludedChanged() {
-            updateTouchExclusion();
-        }
-    };
-
-    protected CommunalSurfaceViewController(SurfaceView view, Resources resources,
-            Executor executor, CommunalStateController communalStateController,
-            NotificationShadeWindowController notificationShadeWindowController,
-            CommunalSourceImpl source) {
-        super(view);
-        mCommunalStateController = communalStateController;
-        mSource = source;
-        mResources = resources;
-        mMainExecutor = executor;
-        mNotificationShadeWindowController = notificationShadeWindowController;
-        mSurfaceViewTouchableRegion = new Region();
-    }
-
-    @Override
-    protected void onInit() {
-        mView.getHolder().setFormat(PixelFormat.TRANSPARENT);
-        mView.getHolder().addCallback(mSurfaceHolderCallback);
-        mView.addOnLayoutChangeListener(mOnLayoutChangeListener);
-    }
-
-    private void setState(@State int state, boolean enabled) {
-        if (DEBUG) {
-            Log.d(TAG, "setState. state:" + state + " enable:" + enabled);
-        }
-
-        final int newState = enabled ? mCurrentState | state : mCurrentState & ~state;
-
-        // no new state is available
-        if (newState == mCurrentState) {
-            return;
-        }
-
-        if (DEBUG) {
-            Log.d(TAG, "setState. new state:" + mCurrentState);
-        }
-
-        mCurrentState = newState;
-
-        showSurface();
-
-        updateTouchExclusion();
-    }
-
-    private void updateTouchExclusion() {
-        final IWindow window = IWindow.Stub.asInterface(mView.getWindowToken());
-        final boolean excludeTouches = (mCurrentState & STATE_SURFACE_VIEW_ATTACHED) != 0
-                && !mCommunalStateController.getCommunalViewOccluded();
-        if (excludeTouches) {
-            mNotificationShadeWindowController.setTouchExclusionRegion(mSurfaceViewTouchableRegion);
-        } else {
-            final Region emptyRegion = Region.obtain();
-            mNotificationShadeWindowController.setTouchExclusionRegion(emptyRegion);
-            emptyRegion.recycle();
-        }
-    }
-
-    private void showSurface() {
-        mView.setWillNotDraw(false);
-
-        if (mCurrentState != STATE_CAN_SHOW_SURFACE) {
-            // If the surface is no longer showing, cancel any in-flight requests.
-            if (mCurrentSurfaceFuture != null) {
-                mCurrentSurfaceFuture.cancel(true);
-                mCurrentSurfaceFuture = null;
-            }
-
-            mLastRequest = Optional.empty();
-            mView.setWillNotDraw(true);
-            return;
-        }
-
-        final CommunalSourceImpl.Request request = new CommunalSourceImpl.Request(
-                mView.getMeasuredWidth(), mView.getMeasuredHeight(),
-                mView.getDisplay().getDisplayId(), mView.getHostToken());
-
-        if (mLastRequest.isPresent() && mLastRequest.get().equals(request)) {
-            return;
-        }
-
-        mLastRequest = Optional.of(request);
-
-        // Since this method is only called when the state has changed, mCurrentSurfaceFuture should
-        // be null here.
-        mCurrentSurfaceFuture = mSource.requestCommunalSurface(request);
-
-        mCurrentSurfaceFuture.addListener(new Runnable() {
-            @Override
-            public void run() {
-                try {
-                    // If the request is received after detached, ignore.
-                    if (!mView.isAttachedToWindow()) {
-                        return;
-                    }
-
-                    SurfaceControlViewHost.SurfacePackage surfacePackage =
-                            mCurrentSurfaceFuture.get();
-                    mCurrentSurfaceFuture = null;
-
-                    if (DEBUG) {
-                        Log.d(TAG, "Received surface package:" + surfacePackage);
-                    }
-
-                    if (surfacePackage != null) {
-                        mView.setChildSurfacePackage(surfacePackage);
-                        mView.postInvalidate();
-                        mCommunalStateController.setCommunalViewShowing(true);
-                    } else {
-                        Log.e(TAG, "couldn't get the surface package");
-                    }
-                } catch (Exception e) {
-                    Log.e(TAG, "An error occurred retrieving the future result:" + e);
-                }
-            }
-        }, mMainExecutor);
-    }
-
-    @Override
-    protected void onViewAttached() {
-        setState(STATE_SURFACE_VIEW_ATTACHED, true);
-        mCommunalStateController.addCallback(mCommunalStateCallback);
-    }
-
-    @Override
-    protected void onViewDetached() {
-        mCommunalStateController.removeCallback(mCommunalStateCallback);
-        setState(STATE_SURFACE_VIEW_ATTACHED, false);
-    }
-}
diff --git a/packages/SystemUI/src/com/android/systemui/dagger/DefaultServiceBinder.java b/packages/SystemUI/src/com/android/systemui/dagger/DefaultServiceBinder.java
index 17bd14c3..fe79110 100644
--- a/packages/SystemUI/src/com/android/systemui/dagger/DefaultServiceBinder.java
+++ b/packages/SystemUI/src/com/android/systemui/dagger/DefaultServiceBinder.java
@@ -20,7 +20,6 @@
 
 import com.android.systemui.ImageWallpaper;
 import com.android.systemui.SystemUIService;
-import com.android.systemui.communal.service.CommunalService;
 import com.android.systemui.doze.DozeService;
 import com.android.systemui.dump.SystemUIAuxiliaryDumpService;
 import com.android.systemui.keyguard.KeyguardService;
@@ -39,12 +38,6 @@
     /** */
     @Binds
     @IntoMap
-    @ClassKey(CommunalService.class)
-    public abstract Service bindCommunalService(CommunalService service);
-
-    /** */
-    @Binds
-    @IntoMap
     @ClassKey(DozeService.class)
     public abstract Service bindDozeService(DozeService service);
 
diff --git a/packages/SystemUI/tests/src/com/android/systemui/communal/service/CommunalSourcePrimerTest.java b/packages/SystemUI/tests/src/com/android/systemui/communal/service/CommunalSourcePrimerTest.java
deleted file mode 100644
index 95ab5cb..0000000
--- a/packages/SystemUI/tests/src/com/android/systemui/communal/service/CommunalSourcePrimerTest.java
+++ /dev/null
@@ -1,223 +0,0 @@
-/*
- * Copyright (C) 2021 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.systemui.communal.service;
-
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.ArgumentMatchers.anyInt;
-import static org.mockito.Mockito.clearInvocations;
-import static org.mockito.Mockito.times;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
-import android.content.BroadcastReceiver;
-import android.content.ComponentName;
-import android.content.Context;
-import android.content.Intent;
-import android.content.IntentFilter;
-import android.content.ServiceConnection;
-import android.content.res.Resources;
-import android.os.IBinder;
-import android.testing.AndroidTestingRunner;
-
-import androidx.test.filters.SmallTest;
-
-import com.android.systemui.R;
-import com.android.systemui.SysuiTestCase;
-import com.android.systemui.communal.CommunalSourceMonitor;
-import com.android.systemui.shared.communal.ICommunalSource;
-import com.android.systemui.util.concurrency.FakeExecutor;
-import com.android.systemui.util.time.FakeSystemClock;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.ArgumentCaptor;
-import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
-
-import java.util.concurrent.Executor;
-
-@SmallTest
-@RunWith(AndroidTestingRunner.class)
-public class CommunalSourcePrimerTest extends SysuiTestCase {
-    private static final String TEST_COMPONENT_NAME = "com.google.tests/.CommualService";
-    private static final ComponentName TEST_COMPONENT =
-            ComponentName.unflattenFromString(TEST_COMPONENT_NAME);
-    private static final int MAX_RETRIES = 5;
-    private static final int RETRY_DELAY_MS = 1000;
-
-    @Mock
-    private Context mContext;
-
-    @Mock
-    private Resources mResources;
-
-    private FakeExecutor mFakeExecutor = new FakeExecutor(new FakeSystemClock());
-
-    @Mock
-    private CommunalSourceMonitor mCommunalSourceMonitor;
-
-    @Mock
-    private CommunalSourceImpl.Factory mCommunalSourceFactory;
-
-    @Mock
-    private CommunalSourceImpl mCommunalSourceImpl;
-
-    @Mock
-    private IBinder mServiceProxy;
-
-    private CommunalSourcePrimer mPrimer;
-
-    @Before
-    public void setup() {
-        MockitoAnnotations.initMocks(this);
-        when(mResources.getInteger(R.integer.config_communalSourceMaxReconnectAttempts))
-                .thenReturn(MAX_RETRIES);
-        when(mResources.getInteger(R.integer.config_communalSourceReconnectBaseDelay))
-                .thenReturn(RETRY_DELAY_MS);
-        when(mResources.getString(R.string.config_communalSourceComponent))
-                .thenReturn(TEST_COMPONENT_NAME);
-        when(mCommunalSourceFactory.create(any(ICommunalSource.class)))
-                .thenReturn(mCommunalSourceImpl);
-
-        mPrimer = new CommunalSourcePrimer(mContext, mResources, mFakeExecutor,
-                mCommunalSourceMonitor, mCommunalSourceFactory);
-    }
-
-    @Test
-    public void testNoConnectWithEmptyComponent() {
-        when(mResources.getString(R.string.config_communalSourceComponent)).thenReturn(null);
-        final CommunalSourcePrimer emptyComponentPrimer = new CommunalSourcePrimer(mContext,
-                mResources, mFakeExecutor, mCommunalSourceMonitor, mCommunalSourceFactory);
-
-        emptyComponentPrimer.onBootCompleted();
-        mFakeExecutor.runAllReady();
-        // When there is no component, we should not register any broadcast receives or bind to
-        // any service
-        verify(mContext, times(0))
-                .registerReceiver(any(BroadcastReceiver.class), any(IntentFilter.class));
-        verify(mContext, times(0)).bindService(any(Intent.class), anyInt(),
-                any(Executor.class), any(ServiceConnection.class));
-    }
-
-    private ServiceConnection givenOnBootCompleted(boolean bindSucceed) {
-        ArgumentCaptor<ServiceConnection> connectionCapture =
-                ArgumentCaptor.forClass(ServiceConnection.class);
-
-        when(mContext.bindService(any(Intent.class), anyInt(), any(Executor.class),
-                any(ServiceConnection.class))).thenReturn(bindSucceed);
-
-        mPrimer.onBootCompleted();
-        mFakeExecutor.runAllReady();
-
-        verify(mContext).bindService(any(Intent.class), anyInt(), any(Executor.class),
-                connectionCapture.capture());
-
-        // Simulate successful connection.
-        return connectionCapture.getValue();
-    }
-
-    @Test
-    public void testConnect() {
-        final ServiceConnection connection = givenOnBootCompleted(true);
-
-        // Simulate successful connection.
-        connection.onServiceConnected(TEST_COMPONENT, mServiceProxy);
-
-        // Verify source created and monitor informed.
-        verify(mCommunalSourceFactory).create(any(ICommunalSource.class));
-        verify(mCommunalSourceMonitor).setSource(mCommunalSourceImpl);
-    }
-
-    @Test
-    public void testRetryOnBindFailure() {
-        // Fail to bind on connection.
-        givenOnBootCompleted(false);
-
-        // Verify attempts happen. Note that we account for the retries plus initial attempt, which
-        // is not scheduled.
-        for (int attemptCount = 0; attemptCount < MAX_RETRIES + 1; attemptCount++) {
-            verify(mContext, times(1)).bindService(any(Intent.class),
-                    anyInt(), any(Executor.class), any(ServiceConnection.class));
-            clearInvocations(mContext);
-            mFakeExecutor.advanceClockToNext();
-            mFakeExecutor.runAllReady();
-        }
-
-        // Verify no more attempts occur.
-        verify(mContext, times(0)).bindService(any(Intent.class), anyInt(),
-                any(Executor.class), any(ServiceConnection.class));
-
-        // Verify source is not created and monitor is not informed.
-        verify(mCommunalSourceFactory, times(0))
-                .create(any(ICommunalSource.class));
-        verify(mCommunalSourceMonitor, times(0))
-                .setSource(any(CommunalSourceImpl.class));
-    }
-
-    @Test
-    public void testAttemptOnPackageChange() {
-        ArgumentCaptor<BroadcastReceiver> receiverCapture =
-                ArgumentCaptor.forClass(BroadcastReceiver.class);
-
-        // Fail to bind initially.
-        givenOnBootCompleted(false);
-
-        // Capture broadcast receiver.
-        verify(mContext).registerReceiver(receiverCapture.capture(), any(IntentFilter.class));
-
-        clearInvocations(mContext);
-
-        // Inform package has been added.
-        receiverCapture.getValue().onReceive(mContext, new Intent());
-
-        // Verify bind has been attempted.
-        verify(mContext, times(1)).bindService(any(Intent.class), anyInt(),
-                any(Executor.class), any(ServiceConnection.class));
-    }
-
-    @Test
-    public void testRetryOnServiceDisconnected() {
-        verifyConnectionFailureReconnect(v -> v.onServiceDisconnected(TEST_COMPONENT));
-    }
-
-    @Test
-    public void testRetryOnBindingDied() {
-        verifyConnectionFailureReconnect(v -> v.onBindingDied(TEST_COMPONENT));
-    }
-
-    private void verifyConnectionFailureReconnect(ConnectionHandler connectionHandler) {
-        // Fail to bind on connection.
-        final ServiceConnection connection = givenOnBootCompleted(false);
-
-        clearInvocations(mContext, mCommunalSourceMonitor);
-
-        connectionHandler.onConnectionMade(connection);
-
-        // Ensure source is cleared.
-        verify(mCommunalSourceMonitor).setSource(null);
-
-        // Ensure request made to bind. This is not a reattempt so it should happen in the same
-        // execution loop.
-        verify(mContext).bindService(any(Intent.class), anyInt(), any(Executor.class),
-                any(ServiceConnection.class));
-    }
-
-    interface ConnectionHandler {
-        void onConnectionMade(ServiceConnection connection);
-    }
-}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/communal/service/CommunalSurfaceViewControllerTest.java b/packages/SystemUI/tests/src/com/android/systemui/communal/service/CommunalSurfaceViewControllerTest.java
deleted file mode 100644
index cf2e029..0000000
--- a/packages/SystemUI/tests/src/com/android/systemui/communal/service/CommunalSurfaceViewControllerTest.java
+++ /dev/null
@@ -1,302 +0,0 @@
-/*
- * Copyright (C) 2021 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.systemui.communal.service;
-
-import static org.junit.Assert.assertTrue;
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.ArgumentMatchers.eq;
-import static org.mockito.Mockito.clearInvocations;
-import static org.mockito.Mockito.never;
-import static org.mockito.Mockito.times;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
-import android.content.res.Resources;
-import android.graphics.PixelFormat;
-import android.graphics.Region;
-import android.os.IBinder;
-import android.view.Display;
-import android.view.SurfaceControlViewHost;
-import android.view.SurfaceHolder;
-import android.view.SurfaceView;
-import android.view.View;
-
-import androidx.test.filters.SmallTest;
-
-import com.android.systemui.R;
-import com.android.systemui.SysuiTestCase;
-import com.android.systemui.communal.CommunalStateController;
-import com.android.systemui.statusbar.NotificationShadeWindowController;
-import com.android.systemui.util.concurrency.FakeExecutor;
-import com.android.systemui.util.time.FakeSystemClock;
-
-import com.google.common.util.concurrent.SettableFuture;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.mockito.ArgumentCaptor;
-import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
-
-@SmallTest
-public class CommunalSurfaceViewControllerTest extends SysuiTestCase {
-    private static final int MEASURED_HEIGHT = 200;
-    private static final int MEASURED_WIDTH = 500;
-    private static final int DISPLAY_ID = 3;
-    private static final int SPLIT_NOTIFICATION_STATUS_BAR_HEIGHT = 23;
-    private static final int NOTIFICATION_PANEL_MARGIN_TOP = 20;
-    private static final int KEYGUARD_INDICATION_BOTTOM_PADDING = 15;
-
-    @Mock
-    private Display mDisplay;
-
-    @Mock
-    private IBinder mHostToken;
-
-    @Mock
-    private SurfaceView mSurfaceView;
-
-    @Mock
-    private SurfaceHolder mSurfaceHolder;
-
-    @Mock
-    private CommunalSourceImpl mCommunalSource;
-
-    @Mock
-    private SurfaceControlViewHost.SurfacePackage mSurfacePackage;
-
-    @Mock
-    private CommunalStateController mCommunalStateController;
-
-    @Mock
-    private Resources mResources;
-
-    @Mock
-    private NotificationShadeWindowController mNotificationShadeWindowController;
-
-    @Mock
-    private IBinder mWindowToken;
-
-    private FakeExecutor mFakeExecutor = new FakeExecutor(new FakeSystemClock());
-
-    private SurfaceHolder.Callback mCallback;
-
-    private CommunalSurfaceViewController mController;
-
-    private SettableFuture<SurfaceControlViewHost.SurfacePackage> mPackageFuture;
-
-    private View.OnLayoutChangeListener mLayoutChangeListener;
-
-    @Before
-    public void setup() {
-        MockitoAnnotations.initMocks(this);
-        when(mSurfaceView.getHolder()).thenReturn(mSurfaceHolder);
-        when(mSurfaceView.getDisplay()).thenReturn(mDisplay);
-        when(mDisplay.getDisplayId()).thenReturn(DISPLAY_ID);
-        when(mSurfaceView.getHostToken()).thenReturn(mHostToken);
-        when(mSurfaceView.getWindowToken()).thenReturn(mWindowToken);
-        when(mSurfaceView.getMeasuredWidth()).thenReturn(MEASURED_WIDTH);
-        when(mSurfaceView.getMeasuredHeight()).thenReturn(MEASURED_HEIGHT);
-        when(mSurfaceView.isAttachedToWindow()).thenReturn(false);
-        when(mResources.getBoolean(R.bool.config_use_split_notification_shade)).thenReturn(true);
-        when(mResources.getDimensionPixelSize(R.dimen.split_shade_header_height))
-                .thenReturn(SPLIT_NOTIFICATION_STATUS_BAR_HEIGHT);
-        when(mResources.getDimensionPixelSize(R.dimen.notification_panel_margin_top))
-                .thenReturn(NOTIFICATION_PANEL_MARGIN_TOP);
-        when(mResources.getDimensionPixelSize(R.dimen.keyguard_indication_bottom_padding))
-                .thenReturn(KEYGUARD_INDICATION_BOTTOM_PADDING);
-        mController = new CommunalSurfaceViewController(mSurfaceView, mResources, mFakeExecutor,
-                mCommunalStateController, mNotificationShadeWindowController, mCommunalSource);
-        mController.init();
-
-        final ArgumentCaptor<SurfaceHolder.Callback> callbackCapture =
-                ArgumentCaptor.forClass(SurfaceHolder.Callback.class);
-        verify(mSurfaceHolder).addCallback(callbackCapture.capture());
-        verify(mSurfaceHolder).setFormat(PixelFormat.TRANSPARENT);
-        mCallback = callbackCapture.getValue();
-
-        final ArgumentCaptor<View.OnLayoutChangeListener> listenerCapture =
-                ArgumentCaptor.forClass(View.OnLayoutChangeListener.class);
-        verify(mSurfaceView).addOnLayoutChangeListener(listenerCapture.capture());
-        mLayoutChangeListener = listenerCapture.getValue();
-
-        mPackageFuture = SettableFuture.create();
-
-        when(mCommunalSource.requestCommunalSurface(any()))
-                .thenReturn(mPackageFuture);
-    }
-
-    @Test
-    public void testSetSurfacePackage() {
-        // There should be no requests without the proper state.
-        verify(mCommunalSource, times(0))
-                .requestCommunalSurface(any());
-
-        // The full state must be present to make a request.
-        mController.onViewAttached();
-        verify(mCommunalSource, times(0))
-                .requestCommunalSurface(any());
-
-        clearInvocations(mSurfaceView);
-
-        // Request surface view once all conditions are met.
-        mCallback.surfaceCreated(mSurfaceHolder);
-        final CommunalSourceImpl.Request expectedRequest = new CommunalSourceImpl.Request(
-                MEASURED_WIDTH, MEASURED_HEIGHT, DISPLAY_ID, mHostToken);
-        verify(mCommunalSource).requestCommunalSurface(eq(expectedRequest));
-
-        when(mSurfaceView.isAttachedToWindow()).thenReturn(true);
-
-        // Respond to request.
-        mPackageFuture.set(mSurfacePackage);
-        mFakeExecutor.runAllReady();
-
-
-        // Make sure SurfaceView is set.
-        verify(mSurfaceView).setChildSurfacePackage(mSurfacePackage);
-        verify(mSurfaceView).setWillNotDraw(false);
-    }
-
-    @Test
-    public void testCommunalStateControllerShowNotified() {
-        // Move CommunalSurfaceView to show
-        mController.onViewAttached();
-        mCallback.surfaceCreated(mSurfaceHolder);
-        when(mSurfaceView.isAttachedToWindow()).thenReturn(true);
-        mPackageFuture.set(mSurfacePackage);
-        mFakeExecutor.runAllReady();
-
-        // Ensure state controller is informed that the communal view is showing.
-        verify(mCommunalStateController).setCommunalViewShowing(true);
-    }
-
-    // Invoked to setup surface view package.
-    private void givenSurfacePresent() {
-        mController.onViewAttached();
-        mCallback.surfaceCreated(mSurfaceHolder);
-        when(mSurfaceView.isAttachedToWindow()).thenReturn(true);
-        mPackageFuture.set(mSurfacePackage);
-        mFakeExecutor.runAllReady();
-        clearInvocations(mSurfaceView);
-    }
-
-    @Test
-    public void testClearOnDetach() {
-        givenSurfacePresent();
-        when(mSurfaceView.isAttachedToWindow()).thenReturn(false);
-        mController.onViewDetached();
-        verify(mSurfaceView).setWillNotDraw(true);
-    }
-
-    @Test
-    public void testClearOnSurfaceDestroyed() {
-        givenSurfacePresent();
-        mCallback.surfaceDestroyed(mSurfaceHolder);
-        verify(mSurfaceView).setWillNotDraw(true);
-    }
-
-    @Test
-    public void testCancelRequest() {
-        mController.onViewAttached();
-        mCallback.surfaceCreated(mSurfaceHolder);
-        when(mSurfaceView.isAttachedToWindow()).thenReturn(true);
-        mFakeExecutor.runAllReady();
-        clearInvocations(mSurfaceView);
-
-        final CommunalSourceImpl.Request expectedRequest = new CommunalSourceImpl.Request(
-                MEASURED_WIDTH, MEASURED_HEIGHT, DISPLAY_ID, mHostToken);
-        verify(mCommunalSource, times(1)).requestCommunalSurface(eq(expectedRequest));
-
-        mController.onViewDetached();
-        assertTrue(mPackageFuture.isCancelled());
-        verify(mSurfaceView).setWillNotDraw(true);
-    }
-
-    @Test
-    public void testTapExclusion() {
-        final int left = 0;
-        final int top = 0;
-        final int right = 200;
-        final int bottom = 100;
-        final Region splitNotificationExclusionRegion = new Region(
-                left,
-                top + SPLIT_NOTIFICATION_STATUS_BAR_HEIGHT,
-                right,
-                bottom - KEYGUARD_INDICATION_BOTTOM_PADDING);
-
-        final Region notificationExclusionRegion = new Region(
-                left,
-                top + NOTIFICATION_PANEL_MARGIN_TOP,
-                right,
-                bottom - KEYGUARD_INDICATION_BOTTOM_PADDING);
-
-        // There should be no exclusion when communal isn't present.
-        mLayoutChangeListener.onLayoutChange(mSurfaceView, left, top, right, bottom, 0, 0, 0, 0);
-        verify(mNotificationShadeWindowController)
-                .setTouchExclusionRegion(eq(new Region()));
-
-
-        // Attach view
-        mController.onViewAttached();
-        clearInvocations(mNotificationShadeWindowController);
-        // Verify tap exclusion area matches proper dimensions.
-        mLayoutChangeListener.onLayoutChange(mSurfaceView, left, top, right, bottom, 0, 0, 0, 0);
-        verify(mNotificationShadeWindowController)
-                .setTouchExclusionRegion(eq(splitNotificationExclusionRegion));
-
-        // Switch to normal notification margin, verify padding changes.
-        clearInvocations(mNotificationShadeWindowController);
-        when(mResources.getBoolean(R.bool.config_use_split_notification_shade)).thenReturn(false);
-        mLayoutChangeListener.onLayoutChange(mSurfaceView, left, top, right, bottom, 0, 0, 0, 0);
-        verify(mNotificationShadeWindowController)
-                .setTouchExclusionRegion(eq(notificationExclusionRegion));
-
-        // Occlude, verify no exclude region.
-        clearInvocations(mNotificationShadeWindowController);
-        when(mCommunalStateController.getCommunalViewOccluded()).thenReturn(true);
-        mLayoutChangeListener.onLayoutChange(mSurfaceView, left, top, right, bottom, 0, 0, 0, 0);
-        verify(mNotificationShadeWindowController)
-                .setTouchExclusionRegion(eq(new Region()));
-    }
-
-    @Test
-    public void testLayoutChange() {
-        final int left = 0;
-        final int top = 0;
-        final int right = 200;
-        final int bottom = 100;
-
-        givenSurfacePresent();
-
-        // Layout change should trigger a request to get new communal surface.
-        mLayoutChangeListener.onLayoutChange(mSurfaceView, left, top, right, bottom, 0, 0, 0,
-                0);
-        // Note that the measured are preset and different than the layout input.
-        final CommunalSourceImpl.Request expectedRequest =
-                new CommunalSourceImpl.Request(MEASURED_WIDTH, MEASURED_HEIGHT, DISPLAY_ID,
-                        mHostToken);
-        verify(mCommunalSource)
-                .requestCommunalSurface(eq(expectedRequest));
-
-        clearInvocations(mCommunalSource);
-
-        // Subsequent matching layout change should not trigger any request.
-        mLayoutChangeListener.onLayoutChange(mSurfaceView, left, top, right, bottom, 0, 0, 0,
-                0);
-        verify(mCommunalSource, never()).requestCommunalSurface(any());
-    }
-}