Android:Mstar平台 HDMI OUT 静音流程
一、framework层
1. APP调用 AudioManager 的 adjustStreamVolume() 接口实现在: frameworks\base\services\core\java\com\android\server\audio\AudioService.java
在判断当前是系统静音操作时,调用 HdmiOutAudioMute Native接口:
if (isMuteAdjust) {
boolean state;
if (direction == AudioManager.ADJUST_TOGGLE_MUTE) {
state = !streamState.mIsMuted;
} else {
state = direction == AudioManager.ADJUST_MUTE;
}
if (streamTypeAlias == AudioSystem.STREAM_MUSIC) {
setSystemAudioMute(state);
/*lxl 20191206 add patch begin*/
PowerManagerService.nativeSetHdmiOutAudioMute(state);
/*lxl 20191130 add patch end*/
}
for (int stream = ; stream < mStreamStates.length; stream++) {
if (streamTypeAlias == mStreamVolumeAlias[stream]) {
if (!(readCameraSoundForced()
&& (mStreamStates[stream].getStreamType()
== AudioSystem.STREAM_SYSTEM_ENFORCED))) {
mStreamStates[stream].mute(state);
}
}
}
}
2. nativeSetHdmiOutAudioMute 接口声明在: frameworks\base\services\core\java\com\android\server\power\PowerManagerService.java
public static native boolean nativeSetHdmiOutAudioMute(boolean onOff);
二、Native层
1.frameworks\base\services\core\jni\com_android_server_power_PowerManagerService.cpp 中实现了 nativeSetHdmiOutAudioMute() 方法:
static jboolean nativeSetHdmiOutAudioMute(JNIEnv *env, jclass clazz, jboolean onOff){
std::lock_guard<std::mutex> lock(gPowerHalMutex);
if (getInputHal()) {
Return<bool> ret = gInputHal->setHdmiOutAudioMute(onOff);
if (!ret.isOk()) {
ALOGE("Failed to SetHdmiOutAudioMute.");
return false;
}
return ret;
}
ALOGE("Failed to SetHdmiOutAudioMute input hal is null.");
return false;
}
Native方法的声明和注册:
static const JNINativeMethod gPowerManagerServiceMethods[] = {
/* name, signature, funcPtr */
......
{"nativeSetHdmiOutAudioMute", "(Z)Z",
(void*) nativeSetHdmiOutAudioMute },
......
}
int register_android_server_PowerManagerService(JNIEnv* env) {
int res = jniRegisterNativeMethods(env, "com/android/server/power/PowerManagerService",
gPowerManagerServiceMethods, NELEM(gPowerManagerServiceMethods));
(void) res; // Faked use when LOG_NDEBUG.
LOG_FATAL_IF(res < , "Unable to register native methods."); // Callbacks jclass clazz;
FIND_CLASS(clazz, "com/android/server/power/PowerManagerService"); GET_METHOD_ID(gPowerManagerServiceClassInfo.userActivityFromNative, clazz,
"userActivityFromNative", "(JII)V"); // Initialize
for (int i = ; i <= USER_ACTIVITY_EVENT_LAST; i++) {
gLastEventTime[i] = LLONG_MIN;
}
gPowerManagerServiceObj = NULL;
return ;
}
2. 上面 gInputHal->setHdmiOutAudioMute(onOff); 调用是通过HIDL调用HAL层接口, Service的获取:
bool getInputHal(){
if (gInputHal == nullptr){
gInputHal = IMstarTvInput::getService();
if (gInputHal == nullptr) {
ALOGD("Load input HAL service fail");
return -;
}
} return gInputHal != nullptr;
}
三、HAL层
1 HIDL接口定义 vendor\mstar\hardware\interfaces\tv\input\1.0\IMstarTvInput.hal,继承于 TvInput :
interface IMstarTvInput
extends android.hardware.tv.input@1.0::ITvInput {
@callflow(next="*")
//EpgManager function(31/32)
...
setHdmiOutAudioMute(bool bEnable)
generates (bool result);
...
}
2. 接口的定义 vendor\mstar\hardware\interfaces\tv\input\1.0\default\TvInput.h, TvInput 又继承于 IMstarTvInput :
struct TvInput : public IMstarTvInput {
TvInput(mstar_tv_input_device_t* device);
~TvInput();
/*mstar tv interface*/
...
Return<bool> setHdmiOutAudioMute(bool bEnable);
...
}
3. 具体的方法实现在 vendor\mstar\hardware\interfaces\tv\input\1.0\default\TvInput_TvManager.cpp
Return<bool> TvInput::setHdmiOutAudioMute(bool bEnable){
return mDevice->TvManager_dev->setHdmiOutAudioMute(bEnable);
}
系统静音的方法实现便在另外文件:vendor\mstar\hardware\interfaces\tv\input\1.0\default\TvInput_AudioManager.cpp
4. 其中 mDevice->TvManager_dev->setHdmiOutAudioMute() 方法的定义在:vendor\mstar\hardware\interfaces\tv\input\1.0\default\mstarTvInput_TvManager_dev.h
#ifndef MSTAR_TV_INPUT_TvManager_H
#define MSTAR_TV_INPUT_TvManager_H
#include <mstar/hardware/tv/input/1.0/ITvManagerType.h>
#include "tvmanager/TvManager.h"
using ::mstar::hardware::tv::input::V1_0::ITvManagerType;
typedef struct mstar_TvManager_dev {
......
bool (*setHdmiOutAudioMute)(bool bEnable);
......
}
5. 其方法实现在 vendor\mstar\hardware\tv_input\mstar_tv_input_TvManager.cpp
bool mstar_tv_input_TvManager::setHdmiOutAudioMute(bool bEnable){
return g_pTvManagerImpl->setHdmiOutAudioMute(bEnable);
}
g_pTvManagerImpl 是通过 TvManager 转换所得:
void mstar_tv_input_TvManager::registerTvManagerInstance(sp<TvManager> &ptr) {
g_pTvManagerImpl=ptr;
}
6. TvManager 的接口定义在 vendor\mstar\common\libraries\tvapi\hidl_wrapper\tvmanager\TvManager.h
class TvManager : virtual public RefBase
{
public:
TvManager();
~TvManager(); static sp<TvManager> connect();
void HIDLconnect();
static void disconnect(); status_t setListener(const sp<TvManagerListener>& listener); ...
static bool setHdmiOutAudioMute(bool bEnable);
... }
7. 方法实现在 vendor\mstar\supernova\projects\tvos\tvmanager\libtvmanager\TvManager.cpp:
bool TvManager::setHdmiOutAudioMute(bool bOnOff)
{
ALOGV("TvManager setHdmiOutAudioMute\n");
return getITvManager()->setHdmiOutAudioMute(bOnOff);
}
后面就跳跃到 mstar 的 supernova 层。
四、Supernova层
1. TvManager 的 setHdmiOutAudioMute 实现在 vendor\mstar\supernova\projects\tvos\tvmanager\libtvmanagerservice\
bool TvManagerService::Client::setHdmiOutAudioMute(bool bOnOff){
TVOS_API_ESTIMATE_START()
TVOS_API_ESTIMATE_START(LOCK)
Mutex::Autolock lock(m_FuncLock);
TVOS_API_ESTIMATE_END(LOCK)
ALOGV("TvManagerService::Client::setHdmiOutAudioMute\n"); bool ret = FALSE; ret = MSrv_Control::GetInstance()->setHdmiOutAudioMute(bOnOff); TVOS_API_ESTIMATE_END()
return ret;
}
2. 最终方法实现在vendor\mstar\supernova\projects\tvos\tvmanager\libtvmanagerservice\TvManagerService.cpp,后面便是通过I2C接口对HDMI控制器的操作。
bool TvManagerService::Client::setHdmiOutAudioMute(bool bOnOff){
TVOS_API_ESTIMATE_START()
TVOS_API_ESTIMATE_START(LOCK)
Mutex::Autolock lock(m_FuncLock);
TVOS_API_ESTIMATE_END(LOCK)
ALOGV("TvManagerService::Client::setHdmiOutAudioMute\n"); bool ret = FALSE; ret = MSrv_Control::GetInstance()->setHdmiOutAudioMute(bOnOff); TVOS_API_ESTIMATE_END()
return ret;
}
Android:Mstar平台 HDMI OUT 静音流程的更多相关文章
- Android 4.4 Kitkat Phone工作流程浅析(六)__InCallActivity显示更新流程
本文来自http://blog.csdn.net/yihongyuelan 转载请务必注明出处 本文代码以MTK平台Android 4.4为分析对象,与Google原生AOSP有些许差异,请读者知悉. ...
- Android 7.0 Power 按键处理流程
Android 7.0 Power 按键处理流程 Power按键的处理逻辑由PhoneWindowManager来完成,本文只关注PhoneWindowManager中与Power键相关的内容,其他 ...
- Android 4.4 Kitkat Phone工作流程浅析(八)__Phone状态分析
本文来自http://blog.csdn.net/yihongyuelan 转载请务必注明出处 本文代码以MTK平台Android 4.4为分析对象.与Google原生AOSP有些许差异.请读者知悉. ...
- Android 4.4 Kitkat Phone工作流程浅析(七)__来电(MT)响铃流程
本文来自http://blog.csdn.net/yihongyuelan 转载请务必注明出处 本文代码以MTK平台Android 4.4为分析对象,与Google原生AOSP有些许差异,请读者知悉. ...
- unity3d-配置Android环境,打包发布Apk流程详解
31:unity3d-配置Android环境,打包发布Apk流程详解 作者 阿西纳尼 关注 2016.08.28 22:52 字数 498 阅读 1806评论 0喜欢 5 Unity配置Android ...
- mstar 平台I2C 配置
芯片的pin 脚可以用作不同的功能,总结一句就是外设进行状态和数据交换. 最常用的是作为GPIO,设置为输出模式时,通过高低电平来控制一些外围设置:// 如LED,屏的电源,背光的开关,功放的静音等等 ...
- 作业一:android开发平台的演变以及Android Studio设置
目录: ①. 从Eclipse到Android Studio ②. Android Studio的下载和安装 ③. 用户习惯设置以及快捷键 ④. SDK路径重新设置 ↓点此跳转到文 ...
- Android 开发平台的演变史
Android开发平台的发展(并不是很懂) Eclipse 首先是由IBM的一个项目小组花了两年时间开发完成的,当时主要解决IBM开发工具 Visual Age for Java 和 WebSpher ...
- 论文第5章:Android绘图平台的实现
面向移动设备的矢量绘图平台设计与实现 Design and Implementation of Mobile Device-oriented Vector Drawing Platform 引用本论文 ...
随机推荐
- thefuck安装和使用(ubuntu)
系统环境(已测试可用): ubuntu 18.04 lts (server或desktop),ubuntu 19.04(server或desktop) sudo apt update sudo apt ...
- C语言面试题目之指针和数组
说明:所有题目均摘录于网络以及我所见过的面试题目,欢迎补充! 无特殊说明情况下,下面所有题s目都是linux下的32位C程序. 先来几个简单的热热身. 1.计算以下sizeof的值. char str ...
- springboot 配置 中查找application.properties中对应的数据,添加对应的prefix前缀
@ConditionalOnProperty(prefix = "spring.redis", name = "enabled", havingValue = ...
- VS Code Monokai Pro验证
最新的VS Code Monokai Pro激活方式 需要vscode,并且安装了monokai pro插件 进入目录 Mac OS cd -/.vscode/extensions/monokai.t ...
- synchronized关键字所生成的字节码详细分析
在之前已经将如下这样的源文件对应的字节码文件完整的分析完了,如下: 这次再来写一个内容稍丰富一点的类,准备再来从头至尾的来分析一下,对其字节码的理解进一步巩固,如下: 然后用javap -verbos ...
- Dos命令获取当前时间
= = 这个真的折腾死我了.... 参考:http://bbs.bathome.net/thread-3328-1-1.html 操作系统不同,日期格式也可能不同: 星期二 2008-07-29 20 ...
- vue-loader was used without the corresponding plugin. Make sure to include VueLoaderPlugin in your webpack config.
默认,webpack无法打包.vue文件,需要安装 相关的loader: cnpm i vue-loader vue-template-compiler -D 提示以下错误信息: Module Err ...
- React Snippets 常用记录
官网 PropTypes ptar→ PropTypes.array.isRequired ptor→ PropTypes.object.isRequired ptsr→ PropTypes.stri ...
- vue init webpack-simple
vue init webpack-simple .. 将我们的项目更加方便,更有助于开发者快速开发. vue init webpack-simple的项目默认打包后之后一个html和一个js文件,而 ...
- [SCSS] SASS dynamic class properties
@mixin generateModifers($property) { #{$property}: $padding; &-large { #{$property}: $padding-la ...