Fix: Cannot control ime_switcher and menu after resetting.

mButtonDispatchers contains ButtonDispatcher for ime_switcher and menu;
however, in #inflateButton, we tried to find ButtonDispatcher for
menu_ime, which is a FrameLayout containing ime_switcher and menu.
Therefore, after #clearViews and #inflateLayout, ime_switcher and menu
KeyButtonView are not in the corresponding ButtonDispatchers.
It means NavigationBarView#getImeSwitchButton and
NavigationBarView#getMenuButton returns empty ButtonDispatcher.
As a result, we can't control ime switch button and menu button via
NavigationBarView after then.  e.g. We can't control ime switch button
visibility.

This CL fixes that issue by calling #addToDispatchers recursively for
ViewGroup children if corresponding ButtonDispatcher is not found.  This
behavior is aligned with #addAll.

Bug: 28580774

Change-Id: Ibe724753390b7bbb395a6d53d00bc6d06d00aa9a
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarInflaterView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarInflaterView.java
index ec45d60..ee4a102 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarInflaterView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarInflaterView.java
@@ -282,6 +282,12 @@
             final int indexOfKey = mButtonDispatchers.indexOfKey(v.getId());
             if (indexOfKey >= 0) {
                 mButtonDispatchers.valueAt(indexOfKey).addView(v);
+            } else if (v instanceof ViewGroup) {
+                final ViewGroup viewGroup = (ViewGroup)v;
+                final int N = viewGroup.getChildCount();
+                for (int i = 0; i < N; i++) {
+                    addToDispatchers(viewGroup.getChildAt(i));
+                }
             }
         }
     }