0
点赞
收藏
分享

微信扫一扫

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

大雁f 2022-04-21 阅读 60
android
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;           
         }
     }

举报

相关推荐

0 条评论