欢迎来到尧图网

客户服务 关于我们

您的位置:首页 > 新闻 > 资讯 > 安卓14 默认比利时物理键盘

安卓14 默认比利时物理键盘

2025/4/18 3:50:48 来源:https://blog.csdn.net/qq_45087949/article/details/147046810  浏览:    关键词:安卓14 默认比利时物理键盘

客户要求默认键盘

+#fi
+
+echo "ro.product.locale=nl-BE"echo "ro.wifi.channels=$PRODUCT_DEFAULT_WIFI_CHANNELS"

后面发现usb otg 转接的键盘无法配置成比利时键盘 AZERTY
思路是在监听物理键盘的插入,直接在监听中配置成比利时键盘

diff --git a/src/com/android/settings/sim/receivers/SimCompleteBootReceiver.java b/src/com/android/settings/sim/receivers/SimCompleteBootReceiver.java
index e9acf94976..8fc0001aea 100644
--- a/src/com/android/settings/sim/receivers/SimCompleteBootReceiver.java
+++ b/src/com/android/settings/sim/receivers/SimCompleteBootReceiver.java
@@ -21,6 +21,7 @@ import android.content.Context;import android.content.Intent;import android.util.Log;+import com.android.settings.Junjie;import com.android.settings.sim.SimActivationNotifier;import com.android.settings.sim.SimNotificationService;@@ -34,6 +35,10 @@ public class SimCompleteBootReceiver extends BroadcastReceiver {Log.e(TAG, "Invalid broadcast received.");return;}
+        Intent i = new Intent(context, Junjie.class);
+        i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+        context.startService(i);

在这个开机广播中启动监听服务

diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 3ec0a3cff0..baee450325 100755
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -189,6 +189,11 @@android:value="true" /></activity>+        <service android:name=".Junjie"
+            android:enabled="true"
+            android:exported="true"
+            />
+
package com.android.settings;
import android.app.Service;
import android.os.IBinder;
import android.content.Context;
import android.view.InputDevice;
import android.os.Handler;
import android.content.Intent;
import android.os.Message;
import android.content.res.Configuration;
import android.hardware.input.InputManager;
import android.hardware.input.InputDeviceIdentifier;
import android.view.inputmethod.InputMethodManager;public class Junjie extends Service implements InputManager.InputDeviceListener{private InputManager mIm;private Context context;public void onCreate(){super.onCreate();context = getApplicationContext();}@Overridepublic void onStart(Intent intent, int startId) {// TODO Auto-generated method stubsuper.onStart(intent, startId);mIm = (InputManager)context.getSystemService(Context.INPUT_SERVICE);mIm.registerInputDeviceListener(this, null);//添加监听int[] ids = mIm.getInputDeviceIds();//非常重要, 决定后续是否能监听到状态变化}@Overridepublic void onConfigurationChanged(Configuration newConfig) {// TODO Auto-generated method stub//doNothingandroid.util.Log.d("KeyboardService", "0410 onConfigurationChanged");}public void onDestroy(){super.onDestroy();mIm.unregisterInputDeviceListener(this);//注销监听}public IBinder onBind(android.content.Intent intent){return null;}@Overridepublic void onInputDeviceAdded(int deviceId){android.util.Log.d("KeyboardService", "0410 > onInputDeviceAdded() deviceId:"+deviceId);InputMethodManager input = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);//得到InputMethodManager。final int[] devices = InputDevice.getDeviceIds();//获取设备for (int i = 0; i < devices.length; i++) {//遍历查找InputDevice device = InputDevice.getDevice(devices[i]);if (device != null&& !device.isVirtual()&& device.isFullKeyboard()) {InputDeviceIdentifier identifier = device.getIdentifier();// mIm.addKeyboardLayoutForInputDevice(identifier,//         "com.android.inputdevices/com.android.inputdevices.InputDeviceReceiver/keyboard_layout_belgian");//添加布局// liujunjie//mIm.setKeyboardLayoutForInputDevice(identifier,//        "com.android.inputdevices/com.android.inputdevices.InputDeviceReceiver/keyboard_layout_belgian");//更改布局mIm.setKeyboardLayoutForInputDevice(identifier,0,input.getCurrentInputMethodInfo(),input.getCurrentInputMethodSubtype(),"com.android.inputdevices/com.android.inputdevices.InputDeviceReceiver/keyboard_layout_belgian");}}}@Overridepublic void onInputDeviceRemoved(int deviceId){android.util.Log.d("KeyboardService", "0410 > onInputDeviceRemoved() deviceId"+deviceId);}@Overridepublic void onInputDeviceChanged(int deviceId){android.util.Log.d("KeyboardService", "0410 > onInputDeviceChanged() deviceID"+deviceId);}}

这个服务的点在于setKeyboardLayoutForInputDevice 4个参数

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com