Hide launcher when freeform tasks are visible

This CL introduces a new controller to manage the visibility of the
launcher workspace when desktop mode is active and freeform tasks
are visible.

This controller will be notified when the sysui state flag related
to freeform task visibility is changed.

The controller will modify the workspace visibility as well as
the flags on the activity indicating if it's been paused / resumed
based on freeform tasks being visible or not.

Bug: 245569277
Test: manual -  enable desktop mode and open some freeform tasks
             => observe that the contents of launcher is hidden and
                taskbar shows
             -  remove all of the freeform tasks
             => observe that the contents of launcher reappears along
                with the hotseat.
Change-Id: I378ab97b40cbb954a06f4e2426b195efddad905c
diff --git a/src/com/android/launcher3/BaseActivity.java b/src/com/android/launcher3/BaseActivity.java
index 83ff084..9bdc822 100644
--- a/src/com/android/launcher3/BaseActivity.java
+++ b/src/com/android/launcher3/BaseActivity.java
@@ -196,8 +196,7 @@
 
     @Override
     protected void onResume() {
-        addActivityFlags(ACTIVITY_STATE_RESUMED | ACTIVITY_STATE_USER_ACTIVE);
-        removeActivityFlags(ACTIVITY_STATE_USER_WILL_BE_ACTIVE);
+        setResumed();
         super.onResume();
     }
 
@@ -228,7 +227,7 @@
 
     @Override
     protected void onPause() {
-        removeActivityFlags(ACTIVITY_STATE_RESUMED | ACTIVITY_STATE_DEFERRED_RESUMED);
+        setPaused();
         super.onPause();
 
         // Reset the overridden sysui flags used for the task-swipe launch animation, we do this
@@ -260,6 +259,21 @@
         return (mActivityFlags & ACTIVITY_STATE_RESUMED) != 0;
     }
 
+    /**
+     * Sets the activity to appear as paused.
+     */
+    public void setPaused() {
+        removeActivityFlags(ACTIVITY_STATE_RESUMED | ACTIVITY_STATE_DEFERRED_RESUMED);
+    }
+
+    /**
+     * Sets the activity to appear as resumed.
+     */
+    public void setResumed() {
+        addActivityFlags(ACTIVITY_STATE_RESUMED | ACTIVITY_STATE_USER_ACTIVE);
+        removeActivityFlags(ACTIVITY_STATE_USER_WILL_BE_ACTIVE);
+    }
+
     public boolean isUserActive() {
         return (mActivityFlags & ACTIVITY_STATE_USER_ACTIVE) != 0;
     }