Updates shelf visibility from Launcher to SysUI

We used to set shelf visibility (and its height) from Launcher to WM and
with the PiP-SysUI migration, this function will be called from Launcher
to SysUI directly since SysUI will be the new source of truth for PiP
bounds.

Bug: 139016518
Test: atest PinnedStackTests
Test: Manual
Change-Id: Id0931333da76b52ccc6fa23877c72fbe2747203b
(cherry picked from commit 95a6dba0784161ed31ef5d3ddf8873c564e4c2b2)
diff --git a/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/RecentsUiFactory.java b/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/RecentsUiFactory.java
index e691566..8597f98 100644
--- a/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/RecentsUiFactory.java
+++ b/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/RecentsUiFactory.java
@@ -22,6 +22,8 @@
 
 import android.content.Context;
 import android.graphics.Rect;
+import android.os.RemoteException;
+import android.util.Log;
 import android.view.Gravity;
 
 import com.android.launcher3.DeviceProfile;
@@ -42,11 +44,12 @@
 import com.android.launcher3.util.TouchController;
 import com.android.launcher3.util.UiThreadHelper;
 import com.android.launcher3.util.UiThreadHelper.AsyncCommand;
+import com.android.quickstep.RecentsModel;
 import com.android.quickstep.SysUINavigationMode;
 import com.android.quickstep.SysUINavigationMode.Mode;
 import com.android.quickstep.TouchInteractionService;
 import com.android.quickstep.views.RecentsView;
-import com.android.systemui.shared.system.WindowManagerWrapper;
+import com.android.systemui.shared.recents.ISystemUiProxy;
 
 import java.util.ArrayList;
 
@@ -56,8 +59,20 @@
 public abstract class RecentsUiFactory {
 
     public static final boolean GO_LOW_RAM_RECENTS_ENABLED = false;
-    private static final AsyncCommand SET_SHELF_HEIGHT_CMD = (visible, height) ->
-            WindowManagerWrapper.getInstance().setShelfHeight(visible != 0, height);
+
+    private static final String TAG = RecentsUiFactory.class.getSimpleName();
+
+    private static AsyncCommand newSetShelfHeightCmd(Context context) {
+        return (visible, height) -> {
+            ISystemUiProxy sysUiProxy = RecentsModel.INSTANCE.get(context).getSystemUiProxy();
+            if (sysUiProxy == null) return;
+            try {
+                sysUiProxy.setShelfHeight(visible != 0, height);
+            } catch (RemoteException e) {
+                Log.e(TAG, "Error setShelfHeight", e);
+            }
+        };
+    }
 
     public static RotationMode ROTATION_LANDSCAPE = new RotationMode(-90) {
         @Override
@@ -197,7 +212,7 @@
         DeviceProfile profile = launcher.getDeviceProfile();
         boolean visible = (state == NORMAL || state == OVERVIEW) && launcher.isUserActive()
                 && !profile.isVerticalBarLayout();
-        UiThreadHelper.runAsyncCommand(launcher, SET_SHELF_HEIGHT_CMD,
+        UiThreadHelper.runAsyncCommand(launcher, newSetShelfHeightCmd(launcher),
                 visible ? 1 : 0, profile.hotseatBarSizePx);
 
         if (state == NORMAL) {