Introduce LauncherSearchCallback to handle search overlay status.

Bug: 20011047
Change-Id: I93cab4e0614b9658b4b657dd98dca68d42580e63
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java
index 16e4ce6..3d88906 100644
--- a/src/com/android/launcher3/Launcher.java
+++ b/src/com/android/launcher3/Launcher.java
@@ -546,6 +546,35 @@
                 }
             }
         });
+        mLauncherCallbacks.setLauncherSearchCallback(new Launcher.LauncherSearchCallbacks() {
+            private boolean mImportanceStored = false;
+            private int mWorkspaceImportanceForAccessibility =
+                View.IMPORTANT_FOR_ACCESSIBILITY_AUTO;
+            private int mHotseatImportanceForAccessibility = View.IMPORTANT_FOR_ACCESSIBILITY_AUTO;
+
+            @Override
+            public void onSearchOverlayOpened() {
+                if (mImportanceStored) {
+                    return;
+                }
+                // The underlying workspace and hotseat are temporarily suppressed by the search
+                // overlay. So they sholudn't be accessible.
+                mWorkspaceImportanceForAccessibility = mWorkspace.getImportantForAccessibility();
+                mHotseatImportanceForAccessibility = mHotseat.getImportantForAccessibility();
+                mWorkspace.setImportantForAccessibility(
+                    View.IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS);
+                mHotseat.setImportantForAccessibility(
+                    View.IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS);
+                mImportanceStored = true;
+            }
+
+            @Override
+            public void onSearchOverlayClosed() {
+                mWorkspace.setImportantForAccessibility(mWorkspaceImportanceForAccessibility);
+                mHotseat.setImportantForAccessibility(mHotseatImportanceForAccessibility);
+                mImportanceStored = false;
+            }
+        });
         return true;
     }
 
@@ -1192,6 +1221,18 @@
         public void dismissAllApps();
     }
 
+    public interface LauncherSearchCallbacks {
+        /**
+         * Called when the search overlay is shown.
+         */
+        public void onSearchOverlayOpened();
+
+        /**
+         * Called when the search overlay is dismissed.
+         */
+        public void onSearchOverlayClosed();
+    }
+
     public interface LauncherOverlayCallbacks {
         /**
          * This method indicates whether a call to {@link #enterFullImmersion()} will succeed,