Allow IMEs to opt out the opaque navigation guard view.

Previous CLs [1][2] introduced an opaque navigation guard view to
avoid the island effect (the real nav bar is transparent but the IME
shows its UI with assuming that the real nav bar is opaque).
 [1] I460912ee7c117480c57b947ed31eca330819f32c
 [2] I6a93f30aec83f1cecfb854073046cbc87ab4aa66
Although the current guard view works fine for that particular case,
there are two major situations where having an opaque navigation
guard view does not make much sense.
  1. The IME shows no software keyboard at all.
     Some IMEs automatically hide software keyboard when a hardware
     keyboard is attached.
  2. The IME relies on floating UI that is disjoint from the bottom of
     the screen.
The main goal of this CL is to address case 2 because unlike case 1
the system is not able to automatically detect the case 2.  Only IME
developers know when the opaque guard view should be opted out.
Of course, if IME developers can opt out the opaque guard view,
it means that they can also work around case 1 without relying on
the system, but again it is not the primary goal of this CL.
With this CL IMEs are now able to opt out the opaque navigation guard
view by calling Window#setNavigationBarColor(Color.TRANSPARENT) from
InputMethodService#onWindowShown().  Note that this API used to have
no effect for IME, hence reusing this here should have no compatibility
issues.
Note that any other color is currently ignored to minimize the impact
on UX.

Bug: 22564251
Change-Id: Iea77915ecc55eedaf19899e72c44f704ba9d852c
diff --git a/core/java/com/android/internal/policy/DecorView.java b/core/java/com/android/internal/policy/DecorView.java
index 27fe03c..c19190e 100644
--- a/core/java/com/android/internal/policy/DecorView.java
+++ b/core/java/com/android/internal/policy/DecorView.java
@@ -1138,6 +1138,17 @@
                 lp.height = insets.getSystemWindowInsetBottom();
                 mNavigationGuard.setLayoutParams(lp);
             }
+            updateNavigationGuardColor();
+        }
+    }
+
+    void updateNavigationGuardColor() {
+        if (mNavigationGuard != null) {
+            // Make navigation bar guard invisible if the transparent color is specified.
+            // Only TRANSPARENT is sufficient for hiding the navigation bar if the no software
+            // keyboard is shown by IMS.
+            mNavigationGuard.setVisibility(mWindow.getNavigationBarColor() == Color.TRANSPARENT ?
+                    View.INVISIBLE : View.VISIBLE);
         }
     }