Android11 插入实体键盘增加一个Dialog弹窗提示

a/frameworks/base/services/core/java/com/android/server/input/InputManagerService.java
+++ b/frameworks/base/services/core/java/com/android/server/input/InputManagerService.java
@@ -116,6 +116,14 @@ import java.util.List;
 import java.util.Locale;
 import java.util.Map;
 import java.util.Objects;
+
+// add yim
+import android.app.AlertDialog;
+import android.app.AlertDialog.Builder;
+import android.content.DialogInterface;
+import android.view.WindowManager;
+import android.view.Gravity;
+// add yim
 /*
  * Wraps the C++ InputManager and provides its callbacks.
  */
@@ -187,6 +195,10 @@ public class InputManagerService extends IInputManager.Stub
     final Object mInputFilterLock = new Object();
     IInputFilter mInputFilter; // guarded by mInputFilterLock
     InputFilterHost mInputFilterHost; // guarded by mInputFilterLock
+       
+       // add yim
+    private static AlertDialog mServiceDialog = null;
+    // add yim
 
     // The associations of input devices to displays by port. Maps from input device port (String)
     // to display id (int). Currently only accessed by InputReader.
@@ -1078,6 +1096,26 @@ public class InputManagerService extends IInputManager.Stub
                     intent, PendingIntent.FLAG_IMMUTABLE, null, UserHandle.CURRENT);
 
             Resources r = mContext.getResources();
+                               //yim add
+                    AlertDialog.Builder NewBuilder = new AlertDialog.Builder(mContext);
+                    NewBuilder.setTitle("System prompt");
+                    NewBuilder.setMessage("Please detach the Keyboard & Reconnect USB data cable to access files of this device on computer.");
+                    NewBuilder.setPositiveButton(mContext.getResources().getString(com.android.internal.R.string.ok), new DialogInterface.OnClickListener() {
+                            @Override
+                            public void onClick(DialogInterface dialog, int which) {
+                            }
+                    });
+                       mServiceDialog = NewBuilder.create();
+                       mServiceDialog.getWindow().setType(
+                                       WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY);
+                       mServiceDialog.getWindow().setGravity(Gravity.CENTER_HORIZONTAL);
+                       if (mServiceDialog != null && !mServiceDialog.isShowing()) {
+                               mServiceDialog.show();
+                       } 
+                       //yim 
             Notification notification =
                     new Notification.Builder(mContext, SystemNotificationChannels.PHYSICAL_KEYBOARD)
                             .setContentTitle(r.getString(
@@ -1093,6 +1131,7 @@ public class InputManagerService extends IInputManager.Stub
                     SystemMessage.NOTE_SELECT_KEYBOARD_LAYOUT,
                     notification, UserHandle.ALL);
             mKeyboardLayoutNotificationShown = true;           
         }
     }
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值