[flexiglass] Disable NPVC and NPV when flexiglass is on

When flexiglass is on, do not instantiate NPVC, and convert all logic in NPV to no-ops.

Bug: 303267342
Test: Manual
Flag: ACONFIG com.android.systemui.scene_container DEVELOPMENT
Change-Id: Ie1d213246bbf573e902651ab5735d5464a6f7452
diff --git a/packages/SystemUI/src/com/android/systemui/shade/NotificationPanelView.java b/packages/SystemUI/src/com/android/systemui/shade/NotificationPanelView.java
index c501d88..6bf5535 100644
--- a/packages/SystemUI/src/com/android/systemui/shade/NotificationPanelView.java
+++ b/packages/SystemUI/src/com/android/systemui/shade/NotificationPanelView.java
@@ -27,6 +27,8 @@
 import android.view.MotionEvent;
 import android.widget.FrameLayout;
 
+import com.android.systemui.scene.shared.flag.SceneContainerFlag;
+
 /** The shade view. */
 public final class NotificationPanelView extends FrameLayout {
     static final boolean DEBUG = false;
@@ -41,14 +43,20 @@
 
     public NotificationPanelView(Context context, AttributeSet attrs) {
         super(context, attrs);
-        setWillNotDraw(!DEBUG);
-        mAlphaPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.MULTIPLY));
+        if (!SceneContainerFlag.isEnabled()) {
+            setWillNotDraw(!DEBUG);
+            mAlphaPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.MULTIPLY));
 
-        setBackgroundColor(Color.TRANSPARENT);
+            setBackgroundColor(Color.TRANSPARENT);
+        }
     }
 
     @Override
     public void onRtlPropertiesChanged(int layoutDirection) {
+        if (SceneContainerFlag.isEnabled()) {
+            super.onRtlPropertiesChanged(layoutDirection);
+            return;
+        }
         if (mRtlChangeListener != null) {
             mRtlChangeListener.onRtlPropertielsChanged(layoutDirection);
         }
@@ -56,14 +64,19 @@
 
     @Override
     public boolean shouldDelayChildPressedState() {
+        if (SceneContainerFlag.isEnabled()) {
+            return super.shouldDelayChildPressedState();
+        }
         return true;
     }
 
     @Override
     protected void dispatchDraw(Canvas canvas) {
         super.dispatchDraw(canvas);
-        if (mCurrentPanelAlpha != 255) {
-            canvas.drawRect(0, 0, canvas.getWidth(), canvas.getHeight(), mAlphaPaint);
+        if (!SceneContainerFlag.isEnabled()) {
+            if (mCurrentPanelAlpha != 255) {
+                canvas.drawRect(0, 0, canvas.getWidth(), canvas.getHeight(), mAlphaPaint);
+            }
         }
     }
 
@@ -83,6 +96,9 @@
 
     @Override
     public boolean hasOverlappingRendering() {
+        if (SceneContainerFlag.isEnabled()) {
+            return super.hasOverlappingRendering();
+        }
         return !mDozing;
     }
 
@@ -102,6 +118,9 @@
 
     @Override
     public boolean onInterceptTouchEvent(MotionEvent event) {
+        if (SceneContainerFlag.isEnabled()) {
+            return super.onInterceptTouchEvent(event);
+        }
         return mTouchHandler.onInterceptTouchEvent(event);
     }
 
@@ -113,7 +132,9 @@
     @Override
     public void dispatchConfigurationChanged(Configuration newConfig) {
         super.dispatchConfigurationChanged(newConfig);
-        mOnConfigurationChangedListener.onConfigurationChanged(newConfig);
+        if (!SceneContainerFlag.isEnabled()) {
+            mOnConfigurationChangedListener.onConfigurationChanged(newConfig);
+        }
     }
 
     /** Callback for right-to-left setting changes. */
diff --git a/packages/SystemUI/src/com/android/systemui/shade/NotificationPanelViewController.java b/packages/SystemUI/src/com/android/systemui/shade/NotificationPanelViewController.java
index a135475..1d3e874 100644
--- a/packages/SystemUI/src/com/android/systemui/shade/NotificationPanelViewController.java
+++ b/packages/SystemUI/src/com/android/systemui/shade/NotificationPanelViewController.java
@@ -982,6 +982,7 @@
                 });
         mAlternateBouncerInteractor = alternateBouncerInteractor;
         dumpManager.registerDumpable(this);
+        SceneContainerFlag.assertInLegacyMode();
     }
 
     private void unlockAnimationFinished() {
@@ -3555,9 +3556,9 @@
     }
 
     @Override
-    public ViewPropertyAnimator fadeOut(long startDelayMs, long durationMs, Runnable endAction) {
+    public void fadeOut(long startDelayMs, long durationMs, Runnable endAction) {
         mView.animate().cancel();
-        return mView.animate().alpha(0).setStartDelay(startDelayMs).setDuration(
+        mView.animate().alpha(0).setStartDelay(startDelayMs).setDuration(
                 durationMs).setInterpolator(Interpolators.ALPHA_OUT).withLayer().withEndAction(
                 endAction);
     }
diff --git a/packages/SystemUI/src/com/android/systemui/shade/ShadeModule.kt b/packages/SystemUI/src/com/android/systemui/shade/ShadeModule.kt
index 2d3833c..648d4b5 100644
--- a/packages/SystemUI/src/com/android/systemui/shade/ShadeModule.kt
+++ b/packages/SystemUI/src/com/android/systemui/shade/ShadeModule.kt
@@ -162,9 +162,7 @@
 
     @Binds
     @SysUISingleton
-    abstract fun bindsShadeViewController(
-        notificationPanelViewController: NotificationPanelViewController
-    ): ShadeViewController
+    abstract fun bindsShadeViewController(shadeSurface: ShadeSurface): ShadeViewController
 
     @Binds
     @SysUISingleton
diff --git a/packages/SystemUI/src/com/android/systemui/shade/ShadeSurface.kt b/packages/SystemUI/src/com/android/systemui/shade/ShadeSurface.kt
index d02c215..7346a28 100644
--- a/packages/SystemUI/src/com/android/systemui/shade/ShadeSurface.kt
+++ b/packages/SystemUI/src/com/android/systemui/shade/ShadeSurface.kt
@@ -15,7 +15,6 @@
  */
 package com.android.systemui.shade
 
-import android.view.ViewPropertyAnimator
 import com.android.systemui.shade.domain.interactor.PanelExpansionInteractor
 import com.android.systemui.shade.domain.interactor.ShadeBackActionInteractor
 import com.android.systemui.shade.domain.interactor.ShadeLockscreenInteractor
@@ -48,7 +47,7 @@
     fun cancelAnimation()
 
     /** Animates the view from its current alpha to zero then runs the runnable. */
-    fun fadeOut(startDelayMs: Long, durationMs: Long, endAction: Runnable): ViewPropertyAnimator
+    fun fadeOut(startDelayMs: Long, durationMs: Long, endAction: Runnable)
 
     /** Set whether the bouncer is showing. */
     fun setBouncerShowing(bouncerShowing: Boolean)
diff --git a/packages/SystemUI/src/com/android/systemui/shade/ShadeSurfaceImpl.kt b/packages/SystemUI/src/com/android/systemui/shade/ShadeSurfaceImpl.kt
new file mode 100644
index 0000000..adb2928
--- /dev/null
+++ b/packages/SystemUI/src/com/android/systemui/shade/ShadeSurfaceImpl.kt
@@ -0,0 +1,87 @@
+/*
+ * Copyright (C) 2024 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.shade
+
+import com.android.systemui.statusbar.GestureRecorder
+import com.android.systemui.statusbar.phone.CentralSurfaces
+import com.android.systemui.statusbar.policy.HeadsUpManager
+import javax.inject.Inject
+
+class ShadeSurfaceImpl @Inject constructor() : ShadeSurface, ShadeViewControllerEmptyImpl() {
+    override fun initDependencies(
+        centralSurfaces: CentralSurfaces,
+        recorder: GestureRecorder,
+        hideExpandedRunnable: Runnable,
+        headsUpManager: HeadsUpManager
+    ) {}
+
+    override fun cancelPendingCollapse() {
+        // Do nothing
+    }
+
+    override fun cancelAnimation() {
+        // Do nothing
+    }
+
+    override fun fadeOut(startDelayMs: Long, durationMs: Long, endAction: Runnable) {
+        // Do nothing
+    }
+
+    override fun setBouncerShowing(bouncerShowing: Boolean) {
+        // Do nothing
+    }
+
+    override fun setTouchAndAnimationDisabled(disabled: Boolean) {
+        // TODO(b/322197941): determine if still needed
+    }
+
+    override fun setWillPlayDelayedDozeAmountAnimation(willPlay: Boolean) {
+        // TODO(b/322494538): determine if still needed
+    }
+
+    override fun setDozing(dozing: Boolean, animate: Boolean) {
+        // Do nothing
+    }
+
+    override fun setImportantForAccessibility(mode: Int) {
+        // Do nothing
+    }
+
+    override fun resetTranslation() {
+        // Do nothing
+    }
+
+    override fun resetAlpha() {
+        // Do nothing
+    }
+
+    override fun onScreenTurningOn() {
+        // Do nothing
+    }
+
+    override fun onThemeChanged() {
+        // Do nothing
+    }
+
+    override fun updateExpansionAndVisibility() {
+        // Do nothing
+    }
+
+    override fun updateResources() {
+        // Do nothing
+    }
+}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/dagger/CentralSurfacesDependenciesModule.java b/packages/SystemUI/src/com/android/systemui/statusbar/dagger/CentralSurfacesDependenciesModule.java
index f960fca..e5b6497 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/dagger/CentralSurfacesDependenciesModule.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/dagger/CentralSurfacesDependenciesModule.java
@@ -35,9 +35,11 @@
 import com.android.systemui.dump.DumpManager;
 import com.android.systemui.media.controls.domain.pipeline.MediaDataManager;
 import com.android.systemui.power.domain.interactor.PowerInteractor;
+import com.android.systemui.scene.shared.flag.SceneContainerFlags;
 import com.android.systemui.settings.DisplayTracker;
 import com.android.systemui.shade.NotificationPanelViewController;
 import com.android.systemui.shade.ShadeSurface;
+import com.android.systemui.shade.ShadeSurfaceImpl;
 import com.android.systemui.shade.carrier.ShadeCarrierGroupController;
 import com.android.systemui.statusbar.CommandQueue;
 import com.android.systemui.statusbar.NotificationClickNotifier;
@@ -59,6 +61,8 @@
 import com.android.systemui.statusbar.phone.StatusBarRemoteInputCallback;
 import com.android.systemui.statusbar.policy.KeyguardStateController;
 
+import javax.inject.Provider;
+
 import dagger.Binds;
 import dagger.Lazy;
 import dagger.Module;
@@ -178,9 +182,20 @@
      * The {@link com.android.systemui.shade.ShadeViewController} interface is bound in
      * {@link com.android.systemui.shade.ShadeModule} so others can access it.
      */
-    @Binds
+    @Provides
     @SysUISingleton
-    ShadeSurface provideShadeSurface(NotificationPanelViewController impl);
+    static ShadeSurface provideShadeSurface(
+            SceneContainerFlags sceneContainerFlags,
+            Provider<ShadeSurfaceImpl> sceneContainerOn,
+            Provider<NotificationPanelViewController> sceneContainerOff) {
+        if (sceneContainerFlags.isEnabled()) {
+            return sceneContainerOn.get();
+        } else {
+            return sceneContainerOff.get();
+        }
+
+    }
+
 
     /** */
     @Binds
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfacesImpl.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfacesImpl.java
index b6f653f..2798dbf 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfacesImpl.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfacesImpl.java
@@ -164,6 +164,7 @@
 import com.android.systemui.qs.QSPanelController;
 import com.android.systemui.res.R;
 import com.android.systemui.scene.domain.interactor.WindowRootViewVisibilityInteractor;
+import com.android.systemui.scene.shared.flag.SceneContainerFlag;
 import com.android.systemui.scene.shared.flag.SceneContainerFlags;
 import com.android.systemui.scrim.ScrimView;
 import com.android.systemui.settings.UserTracker;
@@ -1256,11 +1257,13 @@
         mScreenOffAnimationController.initialize(this, mShadeSurface, mLightRevealScrim);
         updateLightRevealScrimVisibility();
 
-        mShadeSurface.initDependencies(
-                this,
-                mGestureRec,
-                mShadeController::makeExpandedInvisible,
-                mHeadsUpManager);
+        if (!SceneContainerFlag.isEnabled()) {
+            mShadeSurface.initDependencies(
+                    this,
+                    mGestureRec,
+                    mShadeController::makeExpandedInvisible,
+                    mHeadsUpManager);
+        }
 
         // Set up the quick settings tile panel
         final View container = getNotificationShadeWindowView().findViewById(R.id.qs_frame);