android添加micphone静音事件处理

软件版本:Android9

硬件平台:Mtk8175

需求:物理按键触发,底层上报静音事件,上层响应;

按键驱动层面的内容,在此不做记录分析,从驱动上报事件到系统层事件映射透传做起:

1、修改kl映射表:

diff --git a/data/keyboards/Generic.kl b/data/keyboards/Generic.kl

index 860aa9c118b..fd9773a5415 100644

--- a/data/keyboards/Generic.kl

+++ b/data/keyboards/Generic.kl

@@ -132,7 +132,7 @@ key 109   PAGE_DOWN

key 110   INSERT

key 111   FORWARD_DEL

# key 112 "KEY_MACRO"

-key 248   VOLUME_MUTE

+key 248   MUTE

key 114   VOLUME_DOWN

key 115   VOLUME_UP

key 116   POWER

248代表驱动上报的事件键值,由于内核和Framework层键值并未统一,因此在此做映射,后边的MUTE对应的是框架层的KEYCODE_MUTE键值,该按键在framework层代表mic静音。

2、Framework层改动,PhoneWindowManager对事件进行接收和派发,改动如下:

diff --git a/services/core/java/com/android/server/policy/PhoneWindowManager.java b/services/core/java/com/android/server/policy/PhoneWindowManager.java

index b74ae77729b..6ae526ec0ce 100644

--- a/services/core/java/com/android/server/policy/PhoneWindowManager.java

+++ b/services/core/java/com/android/server/policy/PhoneWindowManager.java

@@ -300,6 +300,7 @@ import java.io.File;

import java.io.FileReader;

import java.io.IOException;

import java.io.PrintWriter;

+import java.io.BufferedReader;

import java.util.List;

/**

@@ -460,6 +461,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {

     private final Object mLock = new Object();

     Context mContext;

+    AudioManager mAudioManager;

     IWindowManager mWindowManager;

     WindowManagerFuncs mWindowManagerFuncs;

     WindowManagerInternal mWindowManagerInternal;

@@ -499,6 +501,9 @@ public class PhoneWindowManager implements WindowManagerPolicy {

     /** If true, hitting shift & menu will broadcast Intent.ACTION_BUG_REPORT */

     boolean mEnableShiftMenuBugReports = false;

+    // Switch for micmute debug

+    private static boolean mMicmuteDebug = false;

+

     /** Controller that supports enabling an AccessibilityService by holding down the volume keys */

     private AccessibilityShortcutController mAccessibilityShortcutController;

@@ -506,6 +511,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {

     private final ArraySet<WindowState> mScreenDecorWindows = new ArraySet<>();

     WindowState mStatusBar = null;

     private final int[] mStatusBarHeightForRotation = new int[4];

+    private boolean mMicStatus = false;

     WindowState mNavigationBar = null;

     boolean mHasNavigationBar = false;

     boolean mNavigationBarCanMove = false; // can the navigation bar ever move to the side?

@@ -2022,6 +2028,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {

         mDreamManagerInternal = LocalServices.getService(DreamManagerInternal.class);

         mPowerManagerInternal = LocalServices.getService(PowerManagerInternal.class);

        

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值