From e23a4c132897423f2b3fa5be3f57b49256bec8b3 Mon Sep 17 00:00:00 2001
From: Yohei Yukawa <yukawa@google.com>
Date: Wed, 19 Oct 2022 09:37:38 -0700
Subject: [PATCH] Stop using notification for IME switcher

InputMethodManagerService has had logic to show notifications when the
IME switcher icon cannot be shown on NavigationBar[1][2][3][4][5].

With this CL, such a fallback behavior is completely removed.  Devices
and form-factors that need a special handling need to come up with
their own solution rather than relying on this historical notification
mechanism.

 [1]: I2b9e955003c1f6703978824c947d5f322a039714
      7cfc0ed21a3fafabafb40b38a8589808ad1517af
 [2]: Id36c8c34159bea8b72557b40bcf024d401f580b6
      01065a5719414b0855da2820beb9bd4a6459ba1b
 [3]: I34a95732ef3e7c20d6549b57230c11f0c3db04d6
      d4b625994f7664666ac7b53bf6a7d79a6459b3f1
 [4]: I58421143bee25be459f4f744688b37614a750051
      f62c0b837a6d2f20b103db749c5cb46ada9f9e43
 [5]: I6ad818fc9ef08991e24c5020498243f1fc417998
      24ab9e18a74b052e4f5b8fb04c48d7f16ea071ae

Bug: 245989733
Test: atest CtsPermission2TestCases:ProtectedBroadcastsTest
Test: presubmit
Change-Id: I3b09d2b05ba9bde686b360b9f720b5d4258551c3
---
 .../SystemNotificationChannels.java           |  13 +--
 core/res/AndroidManifest.xml                  |   1 -
 .../ic_notification_ime_default.png           | Bin 755 -> 0 bytes
 .../ic_notification_ime_default.png           | Bin 642 -> 0 bytes
 .../ic_notification_ime_default.png           | Bin 1012 -> 0 bytes
 .../ic_notification_ime_default.png           | Bin 1183 -> 0 bytes
 core/res/res/values/strings.xml               |   3 -
 core/res/res/values/symbols.xml               |   1 -
 proto/src/system_messages.proto               |   2 +-
 .../InputMethodManagerService.java            |  86 ------------------
 .../server/inputmethod/InputMethodUtils.java  |  10 --
 .../server/wm/WindowManagerInternal.java      |   9 --
 .../server/wm/WindowManagerService.java       |   5 -
 13 files changed, 6 insertions(+), 124 deletions(-)
 delete mode 100644 core/res/res/drawable-hdpi/ic_notification_ime_default.png
 delete mode 100644 core/res/res/drawable-mdpi/ic_notification_ime_default.png
 delete mode 100644 core/res/res/drawable-xhdpi/ic_notification_ime_default.png
 delete mode 100644 core/res/res/drawable-xxhdpi/ic_notification_ime_default.png

diff --git a/core/java/com/android/internal/notification/SystemNotificationChannels.java b/core/java/com/android/internal/notification/SystemNotificationChannels.java
index 681b46a01c8d..0489dc812ab6 100644
--- a/core/java/com/android/internal/notification/SystemNotificationChannels.java
+++ b/core/java/com/android/internal/notification/SystemNotificationChannels.java
@@ -35,7 +35,10 @@ import java.util.List;
 
 // Manages the NotificationChannels used by the frameworks itself.
 public class SystemNotificationChannels {
-    public static String VIRTUAL_KEYBOARD  = "VIRTUAL_KEYBOARD";
+    /**
+     * @deprecated Legacy system channel, which is no longer used,
+     */
+    @Deprecated public static String VIRTUAL_KEYBOARD  = "VIRTUAL_KEYBOARD";
     public static String PHYSICAL_KEYBOARD = "PHYSICAL_KEYBOARD";
     public static String SECURITY = "SECURITY";
     public static String CAR_MODE = "CAR_MODE";
@@ -72,13 +75,6 @@ public class SystemNotificationChannels {
     public static void createAll(Context context) {
         final NotificationManager nm = context.getSystemService(NotificationManager.class);
         List<NotificationChannel> channelsList = new ArrayList<NotificationChannel>();
-        final NotificationChannel keyboard = new NotificationChannel(
-                VIRTUAL_KEYBOARD,
-                context.getString(R.string.notification_channel_virtual_keyboard),
-                NotificationManager.IMPORTANCE_LOW);
-        keyboard.setBlockable(true);
-        channelsList.add(keyboard);
-
         final NotificationChannel physicalKeyboardChannel = new NotificationChannel(
                 PHYSICAL_KEYBOARD,
                 context.getString(R.string.notification_channel_physical_keyboard),
@@ -237,6 +233,7 @@ public class SystemNotificationChannels {
     /** Remove notification channels which are no longer used */
     public static void removeDeprecated(Context context) {
         final NotificationManager nm = context.getSystemService(NotificationManager.class);
+        nm.deleteNotificationChannel(VIRTUAL_KEYBOARD);
         nm.deleteNotificationChannel(DEVICE_ADMIN_DEPRECATED);
         nm.deleteNotificationChannel(SYSTEM_CHANGES_DEPRECATED);
     }
diff --git a/core/res/AndroidManifest.xml b/core/res/AndroidManifest.xml
index 1f23eb6a86d6..6ce31fc13f85 100644
--- a/core/res/AndroidManifest.xml
+++ b/core/res/AndroidManifest.xml
@@ -668,7 +668,6 @@
     <protected-broadcast android:name="android.media.tv.action.PREVIEW_PROGRAM_BROWSABLE_DISABLED" />
     <protected-broadcast android:name="android.media.tv.action.WATCH_NEXT_PROGRAM_BROWSABLE_DISABLED" />
     <protected-broadcast android:name="android.media.tv.action.CHANNEL_BROWSABLE_REQUESTED" />
-    <protected-broadcast android:name="com.android.server.inputmethod.InputMethodManagerService.SHOW_INPUT_METHOD_PICKER" />
 
     <!-- Time zone rules update intents fired by the system server -->
     <protected-broadcast android:name="com.android.intent.action.timezone.RULES_UPDATE_OPERATION" />
diff --git a/core/res/res/drawable-hdpi/ic_notification_ime_default.png b/core/res/res/drawable-hdpi/ic_notification_ime_default.png
deleted file mode 100644
index 369c88d317077da652b1bfe3414e97c0ef5114c4..0000000000000000000000000000000000000000
GIT binary patch
literal 0
HcmV?d00001

literal 755
zcmeAS@N?(olHy`uVBq!ia0vp^Dj>|k0wldT1B8JTQ<As43&a2R{xkc5JkA1-$YLPv
z0mg18v+Y2FWd)AuKpL!<p@LnypMin#x2KC^h{y4_Q||f+JIc79zwkD1VUD1|N6#Ah
z_o`V*CUq)ZLd_p<Ee|w&ku34lDbVSM&f0*?n~zy1x7M{JJlV8=wx#vS`e*yo)7g(n
zKL0O#V3I-K^yLw9dRuSWmx|0tYf|nz$=Nb#iR&p9C0(Pe=PMKxa(iSYkK9@RD)-~`
z+hTeh_PIZuV>T2VH~qM8*V|n`BJOT@DgHXCVab~uu^Ea6?p_@s$xJ)k5~g`32+df`
z?8Epur18{CCeJHh+rwkhStFGuxO!Q#*cthD^L?0UZt{{*-s9$Cui1Q0zju8)dge|Y
zm)RM&fUJ1a=Q3+=e>-6MapJD<pzF&YE%W7mKV#R^eZK<!yxVxcP4?-P$E(#2@I?L$
zVJ^yIDcbd9iG!5vS$^xNMQ#raW?6Lj#a(_Z`(e_QDWXqULyf{3(|s<>6p82t&azm1
zrA={G_7pzl-l8wJms!7JF1%d(wR2|lyQqrutD@hnDqp+%apUcG)h}*oxCeXipI9Wk
z;-a#;YCu0rsb9u~BmZ+-7N=&3h&-ub67yW~d7kjR;KVLbotHCQSBW^N&Rf55@_`AH
zYc8C;8B;&0Xr~r~sMVcEy17~`ei|MRWDc@O-&x|iNFY_f<J9gY+zSrygnqhoFX42f
zw1=a)#f89lu7s(neH_a9+WH@gOeJqz4d$N8o$aOnxTpB)Pj3IkNxyBr2Hppz3DpwU
zh?11Vl2ohYqEsNoU}RuusB2)UYh)f`Xl7+>U}a>YYhZ3=U~t$v52zkVLvDUbW?Cgw
zgN3fKL5Pu|m65TPfdxdv#;^Xfff^)1HU#IVm6RtIr7}3C<R_&nc;+Uirv{}arc@T5
ROtk?S>*?y}vd$@?2>>xVF*X1I

diff --git a/core/res/res/drawable-mdpi/ic_notification_ime_default.png b/core/res/res/drawable-mdpi/ic_notification_ime_default.png
deleted file mode 100644
index 7d97eb575f2a88418617eb47307ef45621f9dc2c..0000000000000000000000000000000000000000
GIT binary patch
literal 0
HcmV?d00001

literal 642
zcmeAS@N?(olHy`uVBq!ia0vp^5+KaM0wlfaz7_*1rX+877l!}s{b%+Ad7K3vkswhI
zFm^kcZ3hx8D{xE)(qO#|6+TOsF)%Q8dAc};Se$-3$u@g(qDb5N<?o&EU3sx!>$C?d
zbvkTPng<)4UEf}CEZp$_fa8_@5BUXRwOGtQiiZd&>R#(l3zTuWaL~&%z-!{ISGW7k
zr#mYLia45olsi{+f6i-}bB+H492*>*{1)`{O)6RaM5SdNv*kbDLoRE6AL*K&TX}Jn
zu72dk%)^fP*2z~_-}^qV)UcCffzRB#AuA0}+n7e}d8ESrB7Ke`o5e8+1J0JWvR!W;
z8cR=UFbz`57SY(`wcv=A^q1g-nLGwv!mH+eT2^&9@aweXS554>tC#OxH%~Zu3G<$(
zdK(US&$4-<+&^QX@8st?#zzI-&rI$rcTks@;MjKZ#_{AbgEKby5~|6w9#5$}5T~_f
z(&r{sr~D;8vgJX!6>+)MS6siYDc|+3MPfVWZ_9&LuFGy76^z^L(knX8(5cgsuW&}s
zlt?=Pr}uJCVjl8zPtn-ml%hWW#*#Cp^Dc>7-EZnRn4x8M#drVpX;qFsy=)WZ7!{U&
zxV)cb-v(FxAII<iVt#l%w=Vhb>|b1|Gaj4wUlB<FMv-cXYeY#(Vo9o1a#1RfVlXl=
zG}JY))HN~>F*LI>Hn1`>(KRr)GB7x7od;Bpq#-vyB{QuOs=-3n*dWBn(8|cz%D@7m
zVdGc-*+31FARB`7(@M${i&7aJQ}UBi6+Ckj(^G>|6H_V+Po~;{jP-Q&b6Mw<&;$UG
CmHdzZ

diff --git a/core/res/res/drawable-xhdpi/ic_notification_ime_default.png b/core/res/res/drawable-xhdpi/ic_notification_ime_default.png
deleted file mode 100644
index 900801a4d3d70770be92a21c71f59d0534d14790..0000000000000000000000000000000000000000
GIT binary patch
literal 0
HcmV?d00001

literal 1012
zcmeAS@N?(olHy`uVBq!ia0vp^1|ZDA0wn)(8}a}trX+877l!}s{b%+Ad7K3vk;OpT
z1B~5HX4`=T%L*LRfizez!?|}o;XrMFJY5_^A`ZX3X5Sy}D#H5V{+a4;R+=3Qu3a1*
z=NlXX7rhk}acExA(B*N#(e<GFf`&dO#Xv<?)`=d9u3Zij7V$QIU|iv`iHnu%R&T+z
z?B8dXeu!SbxBieABUg>o{F%Sc*_J=Ei=WLZ7Lm~SUoP{L;G`8QE?G*abN6^&e0RS1
z*otVo^)uJpW>4o`HqS8J@y*HdYm&RKO}-LsnsU_hc;W3*|7yR9D%$TN%6t}oY7SMm
zS$e`O_K0_uYuRzH)hD~&Op`CKaBJToA}A={u|1i4y<m9sKefU{sh4i~r}Ty2A2B=U
zYviYO|JbfY5yu@2O@eZgd<*wK{Vw8s^!<YS>#l9Q_-W#!du5lZjwPft1gi8lPFxeD
zBq=4aAoFKLu5gaWv8=-@mn{yI+*s<k+4tRvjGk26g$cs3Ta|c@PVrZ2zxd`-z@?1!
z+cT0Tq$E4*D0-W<M5%hSbw#y$-N=|f>-rhVGiE=#UmUMm<8E))FS6dv{@SCsFOQ#k
zd`$iFIPc5jUXMbxUmL~#?hu_@Ve$?ryI4M5>8SR_e)~o8^98@YlPmesqdGOOYsHt4
zO<q%#tg2qD3~~wgU%FWR!e!&I*ULKAs7GG9xo>u4v+^dr3Ks98>IX~B$|TyO_O&by
z+I{=z#IWKOSKmvBT277lw!~r6t6h)hxvK7b)+gMzu<Wq!a+%N)-rB|AlA>SahuJ(_
zqO^PFI#<8c`GFq|HdKd%NWHgSdP1%FO&h;%wf|xdyTYUF^9(25DZiyS|CPk5H9u}}
z-!pQ{b3ZC7ztY6|{-SQfZto+nFJH}kw0l~<o4VX=w|#2&dMoGLtq%F4d}G(5rql1X
zhlixtyT0A_St_Ki_ty4nCR+8Ux;9&Ny~(;#_c3(!oQ(bX#{Xvf&NHz(e?)$}&dOVJ
z-ERE8zD6VLuT6O3%<K<&F1|MM?8kS$UH0yJvn-!P-rYy{7X+R?_rF=vr_VBD|8@Rj
z5xFPobngV;`*%FT>H_Bi&)FOORewv%So~HwTgUd5Ih6hA;hMwZpv0*Bk4a?i$5}64
z|KJB^3e^(Vh?11Vl2ohYqEsNoU}RuusB2)UYh)f`Xl7+>U}a>YYhZ3=U~t$v52zkV
zLvDUbW?CgwgN3fKL5Pu|m65TPfdxdv#;^Xfff^)1HU#IVm6RtIr7}3C<R_&nc;+Ui
Zrv{}arc@T5Otk?S>*?y}vd$@?2>_4ry$ApR

diff --git a/core/res/res/drawable-xxhdpi/ic_notification_ime_default.png b/core/res/res/drawable-xxhdpi/ic_notification_ime_default.png
deleted file mode 100644
index 6c8222ec50b7273ad4902efa914af497c28203cc..0000000000000000000000000000000000000000
GIT binary patch
literal 0
HcmV?d00001

literal 1183
zcmbVMO=uKJ6z*u&O<V$^B5aUQcJ>E<X8Lbtdb-JMoSCk62AvotBSu(%I^8vyHt8R`
zYwSrR?yLyw9v1erpe*i1PZAY!@F19r7ri9HVu%L?abXWx7eTLT_58#fLJl@`RlTbB
zzW2RX@71rvLx*~{_HLypswbaQie%1(f7cc=9{X?Z5ShNla1@U?WgKW8qSA&lhCtrZ
z#!(Sz#?-k-Xn>+Nm(9{B9xWV^b;pWop-!}Bxx|{H1_o=crcWRY#?ZKFr|AFh&(pv(
zQuOh7fi1XMR55eY9vYb*D(TY`x@6FUKY)RnOaLr|HBhrAZC|dX=mxG#*5NiogN6#8
zNYPDFqlICRbvy*(Q8uEp2^J){C?~{3Q9J;6mSY)~XE;8>iL$`UEDKs6O}u$VSuQGS
z%NLPSbOmEqW|$xdqJa=~ym5w;Bq_w;`3TX7_)|94Y7yJ-ZzCwk*FDq4relK;Q5$or
zI7Jht%@8cNP*?@F{Z^t#%9xtwGF+5pEGvwwq3z=$`b1-0ZND_-BBqFZr|RkCKFa-V
zW0Jd#9fgX7jeOKI$)#wMilbL8WaGS&qRC0rFb!EuvT;5m!c3Ou5=oAe;wn_tbOI`p
z0-?aQG1jw<39KTfGio-IRyYo_lE}x@xRQw_pa5gM)V9srKGtj<wf&mJZ_5^LXe(zu
zq+!P^InHFe0){INcKnLtg6v2f6g1tmLpi*jX0!_O%=5@lJ;wr#{L1D!{?j}QAxvah
zwHbF(<kYmFN>CAmWDF+hmaXwQIb#SJCM=FM#nRp)6&Nm8OP>g<&4X;xF&=4+%ejAh
zNn0)Cm2|20Y-RaLcOC5fV)5+HiOPqmYY%%)&2KmNUEKNSS2N%4`sMo{&;E7=K3?8N
zZR+gW1`gJ#?r`WJ((mEc;!pLL=Wnh&fA7u*C$Il~cd59%zxS^b&z3r+u{t%g@7C#s
z@46P3rWbRA=E-}(>vvD9&*eY*UR~+fbmPmb1WLUyJR2z47gyh;_MQ&#gF9=^%Kxma
z?3ue`T-wbYtiJ_2zG*rRX>>NY5E?nE<J$GZ^$zOto7pNH=+na|BM*m^+nF<$J_2(!
BdbI!m

diff --git a/core/res/res/values/strings.xml b/core/res/res/values/strings.xml
index 5f9911358921..d0fca8b0a7bb 100644
--- a/core/res/res/values/strings.xml
+++ b/core/res/res/values/strings.xml
@@ -741,9 +741,6 @@
     <!-- Text shown in place of notification contents when the notification is hidden on a secure lockscreen -->
     <string name="notification_hidden_text">New notification</string>
 
-    <!-- Text shown when viewing channel settings for notifications related to the virtual keyboard -->
-    <string name="notification_channel_virtual_keyboard">Virtual keyboard</string>
-
     <!-- Text shown when viewing channel settings for notifications related to the hardware keyboard -->
     <string name="notification_channel_physical_keyboard">Physical keyboard</string>
 
diff --git a/core/res/res/values/symbols.xml b/core/res/res/values/symbols.xml
index b94d7990b394..fc55ed2fe443 100644
--- a/core/res/res/values/symbols.xml
+++ b/core/res/res/values/symbols.xml
@@ -1992,7 +1992,6 @@
   <java-symbol type="color" name="config_defaultNotificationColor" />
   <java-symbol type="color" name="decor_view_status_guard" />
   <java-symbol type="color" name="decor_view_status_guard_light" />
-  <java-symbol type="drawable" name="ic_notification_ime_default" />
   <java-symbol type="drawable" name="ic_menu_refresh" />
   <java-symbol type="drawable" name="ic_settings" />
   <java-symbol type="drawable" name="ic_voice_search" />
diff --git a/proto/src/system_messages.proto b/proto/src/system_messages.proto
index a94bfe281be1..12e722601e25 100644
--- a/proto/src/system_messages.proto
+++ b/proto/src/system_messages.proto
@@ -61,7 +61,7 @@ message SystemMessage {
 
     // Notify the user that they should select an input method
     // Package: android
-    NOTE_SELECT_INPUT_METHOD = 8;
+    NOTE_SELECT_INPUT_METHOD = 8 [deprecated = true];
 
     // Notify the user about limited functionality before decryption
     // Package: android
diff --git a/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java b/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java
index 76331fd6089c..76495b17c984 100644
--- a/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java
+++ b/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java
@@ -58,7 +58,6 @@ import android.Manifest;
 import android.accessibilityservice.AccessibilityService;
 import android.annotation.AnyThread;
 import android.annotation.BinderThread;
-import android.annotation.ColorInt;
 import android.annotation.DrawableRes;
 import android.annotation.DurationMillisLong;
 import android.annotation.EnforcePermission;
@@ -69,9 +68,6 @@ import android.annotation.UiThread;
 import android.annotation.UserIdInt;
 import android.app.ActivityManager;
 import android.app.ActivityManagerInternal;
-import android.app.Notification;
-import android.app.NotificationManager;
-import android.app.PendingIntent;
 import android.content.BroadcastReceiver;
 import android.content.ComponentName;
 import android.content.ContentProvider;
@@ -94,7 +90,6 @@ import android.inputmethodservice.InputMethodService;
 import android.media.AudioManagerInternal;
 import android.net.Uri;
 import android.os.Binder;
-import android.os.Bundle;
 import android.os.Debug;
 import android.os.Handler;
 import android.os.IBinder;
@@ -170,8 +165,6 @@ import com.android.internal.inputmethod.SoftInputShowHideReason;
 import com.android.internal.inputmethod.StartInputFlags;
 import com.android.internal.inputmethod.StartInputReason;
 import com.android.internal.inputmethod.UnbindReason;
-import com.android.internal.messages.nano.SystemMessageProto.SystemMessage;
-import com.android.internal.notification.SystemNotificationChannels;
 import com.android.internal.os.TransferPipe;
 import com.android.internal.util.ArrayUtils;
 import com.android.internal.util.ConcurrentUtils;
@@ -254,13 +247,6 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub
     private static final String TAG_TRY_SUPPRESSING_IME_SWITCHER = "TrySuppressingImeSwitcher";
     private static final String HANDLER_THREAD_NAME = "android.imms";
 
-    /**
-     * A protected broadcast intent action for internal use for {@link PendingIntent} in
-     * the notification.
-     */
-    private static final String ACTION_SHOW_INPUT_METHOD_PICKER =
-            "com.android.server.inputmethod.InputMethodManagerService.SHOW_INPUT_METHOD_PICKER";
-
     /**
      * When set, {@link #startInputUncheckedLocked} will return
      * {@link InputBindResult#NO_EDITOR} instead of starting an IME connection
@@ -334,13 +320,8 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub
     @GuardedBy("ImfLock.class")
     private int mDisplayIdToShowIme = INVALID_DISPLAY;
 
-    // Ongoing notification
-    private NotificationManager mNotificationManager;
     @Nullable private StatusBarManagerInternal mStatusBarManagerInternal;
-    private final Notification.Builder mImeSwitcherNotification;
-    private final PendingIntent mImeSwitchPendingIntent;
     private boolean mShowOngoingImeSwitcherForPhones;
-    private boolean mNotificationShown;
     @GuardedBy("ImfLock.class")
     private final HandwritingModeController mHwController;
     @GuardedBy("ImfLock.class")
@@ -1253,17 +1234,6 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub
                 return;
             } else if (Intent.ACTION_LOCALE_CHANGED.equals(action)) {
                 onActionLocaleChanged();
-            } else if (ACTION_SHOW_INPUT_METHOD_PICKER.equals(action)) {
-                // ACTION_SHOW_INPUT_METHOD_PICKER action is a protected-broadcast and it is
-                // guaranteed to be send only from the system, so that there is no need for extra
-                // security check such as
-                // {@link #canShowInputMethodPickerLocked(IInputMethodClient)}.
-                mHandler.obtainMessage(
-                        MSG_SHOW_IM_SUBTYPE_PICKER,
-                        // TODO(b/120076400): Design and implement IME switcher for heterogeneous
-                        // navbar configuration.
-                        InputMethodManager.SHOW_IM_PICKER_MODE_INCLUDE_AUXILIARY_SUBTYPES,
-                        DEFAULT_DISPLAY).sendToTarget();
             } else {
                 Slog.w(TAG, "Unexpected intent " + intent);
             }
@@ -1720,27 +1690,8 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub
 
         mSlotIme = mContext.getString(com.android.internal.R.string.status_bar_ime);
 
-        Bundle extras = new Bundle();
-        extras.putBoolean(Notification.EXTRA_ALLOW_DURING_SETUP, true);
-        @ColorInt final int accentColor = mContext.getColor(
-                com.android.internal.R.color.system_notification_accent_color);
-        mImeSwitcherNotification =
-                new Notification.Builder(mContext, SystemNotificationChannels.VIRTUAL_KEYBOARD)
-                        .setSmallIcon(com.android.internal.R.drawable.ic_notification_ime_default)
-                        .setWhen(0)
-                        .setOngoing(true)
-                        .addExtras(extras)
-                        .setCategory(Notification.CATEGORY_SYSTEM)
-                        .setColor(accentColor);
-
-        Intent intent = new Intent(ACTION_SHOW_INPUT_METHOD_PICKER)
-                .setPackage(mContext.getPackageName());
-        mImeSwitchPendingIntent = PendingIntent.getBroadcast(mContext, 0, intent,
-                PendingIntent.FLAG_IMMUTABLE);
-
         mShowOngoingImeSwitcherForPhones = false;
 
-        mNotificationShown = false;
         final int userId = mActivityManagerInternal.getCurrentUserId();
 
         mLastSwitchUserId = userId;
@@ -1939,7 +1890,6 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub
                 final int currentUserId = mSettings.getCurrentUserId();
                 mSettings.switchCurrentUser(currentUserId,
                         !mUserManagerInternal.isUserUnlockingOrUnlocked(currentUserId));
-                mNotificationManager = mContext.getSystemService(NotificationManager.class);
                 mStatusBarManagerInternal =
                         LocalServices.getService(StatusBarManagerInternal.class);
                 hideStatusBarIconLocked();
@@ -1977,7 +1927,6 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub
                 broadcastFilterForSystemUser.addAction(Intent.ACTION_USER_ADDED);
                 broadcastFilterForSystemUser.addAction(Intent.ACTION_USER_REMOVED);
                 broadcastFilterForSystemUser.addAction(Intent.ACTION_LOCALE_CHANGED);
-                broadcastFilterForSystemUser.addAction(ACTION_SHOW_INPUT_METHOD_PICKER);
                 mContext.registerReceiver(new ImmsBroadcastReceiverForSystemUser(),
                         broadcastFilterForSystemUser);
 
@@ -3159,41 +3108,6 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub
                 mStatusBarManagerInternal.setImeWindowStatus(mCurTokenDisplayId,
                         getCurTokenLocked(), vis, backDisposition, needsToShowImeSwitcher);
             }
-            final InputMethodInfo imi = mMethodMap.get(getSelectedMethodIdLocked());
-            if (imi != null && needsToShowImeSwitcher) {
-                // Used to load label
-                final CharSequence title = mRes.getText(
-                        com.android.internal.R.string.select_input_method);
-                final int currentUserId = mSettings.getCurrentUserId();
-                final Context userAwareContext = mContext.getUserId() == currentUserId
-                        ? mContext
-                        : mContext.createContextAsUser(UserHandle.of(currentUserId), 0 /* flags */);
-                final CharSequence summary = InputMethodUtils.getImeAndSubtypeDisplayName(
-                        userAwareContext, imi, mCurrentSubtype);
-                mImeSwitcherNotification.setContentTitle(title)
-                        .setContentText(summary)
-                        .setContentIntent(mImeSwitchPendingIntent);
-                // TODO(b/120076400): Figure out what is the best behavior
-                if ((mNotificationManager != null)
-                        && !mWindowManagerInternal.hasNavigationBar(DEFAULT_DISPLAY)) {
-                    if (DEBUG) {
-                        Slog.d(TAG, "--- show notification: label =  " + summary);
-                    }
-                    mNotificationManager.notifyAsUser(null,
-                            SystemMessage.NOTE_SELECT_INPUT_METHOD,
-                            mImeSwitcherNotification.build(), UserHandle.ALL);
-                    mNotificationShown = true;
-                }
-            } else {
-                if (mNotificationShown && mNotificationManager != null) {
-                    if (DEBUG) {
-                        Slog.d(TAG, "--- hide notification");
-                    }
-                    mNotificationManager.cancelAsUser(null,
-                            SystemMessage.NOTE_SELECT_INPUT_METHOD, UserHandle.ALL);
-                    mNotificationShown = false;
-                }
-            }
         } finally {
             Binder.restoreCallingIdentity(ident);
         }
diff --git a/services/core/java/com/android/server/inputmethod/InputMethodUtils.java b/services/core/java/com/android/server/inputmethod/InputMethodUtils.java
index c7ff8caf176b..ebf9237d61ea 100644
--- a/services/core/java/com/android/server/inputmethod/InputMethodUtils.java
+++ b/services/core/java/com/android/server/inputmethod/InputMethodUtils.java
@@ -179,16 +179,6 @@ final class InputMethodUtils {
         }
     }
 
-    static CharSequence getImeAndSubtypeDisplayName(Context context, InputMethodInfo imi,
-            InputMethodSubtype subtype) {
-        final CharSequence imiLabel = imi.loadLabel(context.getPackageManager());
-        return subtype != null
-                ? TextUtils.concat(subtype.getDisplayName(context,
-                        imi.getPackageName(), imi.getServiceInfo().applicationInfo),
-                                (TextUtils.isEmpty(imiLabel) ? "" : " - " + imiLabel))
-                : imiLabel;
-    }
-
     /**
      * Returns true if a package name belongs to a UID.
      *
diff --git a/services/core/java/com/android/server/wm/WindowManagerInternal.java b/services/core/java/com/android/server/wm/WindowManagerInternal.java
index 32feb6c98b24..c206a15503de 100644
--- a/services/core/java/com/android/server/wm/WindowManagerInternal.java
+++ b/services/core/java/com/android/server/wm/WindowManagerInternal.java
@@ -612,15 +612,6 @@ public abstract class WindowManagerInternal {
     public abstract void updateInputMethodTargetWindow(@NonNull IBinder imeToken,
             @NonNull IBinder imeTargetWindowToken);
 
-    /**
-     * Returns the presence of a software navigation bar on the specified display.
-     *
-     * @param displayId the id of display to check if there is a software navigation bar.
-     * @return {@code true} if there is a software navigation. {@code false} otherwise, including
-     *         the case when the specified display does not exist.
-     */
-    public abstract boolean hasNavigationBar(int displayId);
-
     /**
       * Returns true when the hardware keyboard is available.
       */
diff --git a/services/core/java/com/android/server/wm/WindowManagerService.java b/services/core/java/com/android/server/wm/WindowManagerService.java
index c17af3093e51..a5cd8a92003c 100644
--- a/services/core/java/com/android/server/wm/WindowManagerService.java
+++ b/services/core/java/com/android/server/wm/WindowManagerService.java
@@ -7916,11 +7916,6 @@ public class WindowManagerService extends IWindowManager.Stub
             }
         }
 
-        @Override
-        public boolean hasNavigationBar(int displayId) {
-            return WindowManagerService.this.hasNavigationBar(displayId);
-        }
-
         @Override
         public boolean isHardKeyboardAvailable() {
             synchronized (mGlobalLock) {
-- 
GitLab