Dynamically show the menu button on the system bar.

Windows with FLAG_NEEDS_MENU_KEY (or windowNeedsMenuKey=true
in their theme) will cause the system bar to show a menu
icon. (Note that the phone's status bar currently ignores
this, but phones tend to have hardware menu keys anyway.)

Additionally, all windows whose package's SDK version is
pre-Honeycomb will have FLAG_NEEDS_MENU_KEY set by default.

Bug: 3003728

Change-Id: I2d983763a726ea4f32cd1af9b0390e30478b11d1
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/CommandQueue.java b/packages/SystemUI/src/com/android/systemui/statusbar/CommandQueue.java
index 81091e3..c164eb4 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/CommandQueue.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/CommandQueue.java
@@ -54,6 +54,8 @@
 
     private static final int MSG_SET_LIGHTS_ON = 0x00070000;
 
+    private static final int MSG_SHOW_MENU = 0x00080000;
+
     private StatusBarIconList mList;
     private Callbacks mCallbacks;
     private Handler mHandler = new H();
@@ -78,6 +80,7 @@
         public void animateExpand();
         public void animateCollapse();
         public void setLightsOn(boolean on);
+        public void setMenuKeyVisible(boolean visible);
     }
 
     public CommandQueue(Callbacks callbacks, StatusBarIconList list) {
@@ -153,6 +156,13 @@
         }
     }
 
+    public void setMenuKeyVisible(boolean visible) {
+        synchronized (mList) {
+            mHandler.removeMessages(MSG_SHOW_MENU);
+            mHandler.obtainMessage(MSG_SHOW_MENU, visible ? 1 : 0, 0, null).sendToTarget();
+        }
+    }
+
     private final class H extends Handler {
         public void handleMessage(Message msg) {
             final int what = msg.what & MSG_MASK;
@@ -210,6 +220,9 @@
                 case MSG_SET_LIGHTS_ON:
                     mCallbacks.setLightsOn(msg.arg1 != 0);
                     break;
+                case MSG_SHOW_MENU:
+                    mCallbacks.setMenuKeyVisible(msg.arg1 != 0);
+                    break;
             }
         }
     }