Store the current IME's token in the system bar for changing the current IME to a shortcut IME from the system bar

Bug: 3212206
Bug: 3201828

- Added a shortcut IME button. This will be used for calling a shortcut IME (e.g. Voice input)
- Made the positions of IME buttons left aligned
- IME token is required to change IME because of the security reasons.

Change-Id: I48ba5e2509b3aa1bfd2394f9201427fa6b93c6d3
diff --git a/services/java/com/android/server/StatusBarManagerService.java b/services/java/com/android/server/StatusBarManagerService.java
index 596db57..cbfa4ee 100644
--- a/services/java/com/android/server/StatusBarManagerService.java
+++ b/services/java/com/android/server/StatusBarManagerService.java
@@ -73,6 +73,7 @@
     boolean mLightsOn = true;
     boolean mMenuVisible = false;
     boolean mIMEButtonVisible = false;
+    IBinder mIMEToken = null;
 
     private class DisableRecord implements IBinder.DeathRecipient {
         String pkg;
@@ -257,7 +258,7 @@
         }
     }
 
-    public void setIMEButtonVisible(final boolean visible) {
+    public void setIMEButtonVisible(final IBinder token, final boolean visible) {
         enforceStatusBar();
 
         if (SPEW) Slog.d(TAG, (visible?"showing":"hiding") + " IME Button");
@@ -267,11 +268,12 @@
             // mIMEButtonVisible because mIMEButtonVisible may not have been set to false when the
             // previous IME was destroyed.
             mIMEButtonVisible = visible;
+            mIMEToken = token;
             mHandler.post(new Runnable() {
                 public void run() {
                     if (mBar != null) {
                         try {
-                            mBar.setIMEButtonVisible(visible);
+                            mBar.setIMEButtonVisible(token, visible);
                         } catch (RemoteException ex) {
                         }
                     }
@@ -351,7 +353,7 @@
     // ================================================================================
     public void registerStatusBar(IStatusBar bar, StatusBarIconList iconList,
             List<IBinder> notificationKeys, List<StatusBarNotification> notifications,
-            int switches[]) {
+            int switches[], List<IBinder> binders) {
         enforceStatusBarService();
 
         Slog.i(TAG, "registerStatusBar bar=" + bar);
@@ -370,6 +372,7 @@
             switches[1] = mLightsOn ? 1 : 0;
             switches[2] = mMenuVisible ? 1 : 0;
             switches[3] = mIMEButtonVisible ? 1 : 0;
+            binders.add(mIMEToken);
         }
     }