android平台上耳机缓慢插入时图标显示后又消失的bug


在Android某些平台上,当耳机缓慢插入时,有可能会出现耳机图标在状态栏上出现一下,然后又消失的情况,出现这种情况的原因是:

耳机插入速度快时,上报如下键值:

/dev/input/event4: 0005 0002 00000001
/dev/input/event4: 0005 0004 00000001
/dev/input/event4: 0000 0000 00000000

插入速度慢时,先报headphone插入,再报MIC插入:

/dev/input/event4: 0005 0002 00000001
/dev/input/event4: 0000 0000 00000000
/dev/input/event4: 0005 0004 00000001
/dev/input/event4: 0000 0000 00000000

由于上报的键值不同,导致了该问题的出现,可以用如下patch来尝试解决:

--- a/services/Java/com/android/server/WiredAccessoryManager.java
+++ b/services/java/com/android/server/WiredAccessoryManager.java
@@ -55,8 +55,8 @@ final class WiredAccessoryManager implements WiredAccessoryCallbacks {
     private static final String TAG = WiredAccessoryManager.class.getSimpleName();
     private static final boolean LOG = true;
 
-    private static final int BIT_HEADSET = (1 << 0);
-    private static final int BIT_HEADSET_NO_MIC = (1 << 1);
+    private static final int BIT_HEADSET_NO_MIC = (1 << 0);
+    private static final int BIT_HEADSET = (1 << 1);
     private static final int BIT_USB_HEADSET_ANLG = (1 << 2);
     private static final int BIT_USB_HEADSET_DGTL = (1 << 3);
     private static final int BIT_HDMI_AUDIO = (1 << 4

当然,不同的版本可能处理方式不同,这个patch仅仅针对上述原因引起的问题。


你可能感兴趣的:(Android)