Android GO 版本锁屏声音无效问题

问题描述

Android go版本 在设置中打开锁屏音开关,息屏灭屏还是无声音

排查

vendor\mediatek\proprietary\packages\apps\SystemUI\src\com\android\systemui\keyguard\KeyguardViewMediator.java

java 复制代码
private void setupLocked() {
        
        ...
        
        String soundPath = Settings.Global.getString(cr, Settings.Global.LOCK_SOUND);
		Log.d("TAG", "playSound soundPath = " + soundPath);
        if (soundPath != null) {
            mLockSoundId = mLockSounds.load(soundPath, 1);
        }
        if (soundPath == null || mLockSoundId == 0) {
            Log.w(TAG, "failed to load lock sound from " + soundPath);
        }
        soundPath = Settings.Global.getString(cr, Settings.Global.UNLOCK_SOUND);
        if (soundPath != null) {
            mUnlockSoundId = mLockSounds.load(soundPath, 1);
        }
        if (soundPath == null || mUnlockSoundId == 0) {
            Log.w(TAG, "failed to load unlock sound from " + soundPath);
        }
        soundPath = Settings.Global.getString(cr, Settings.Global.TRUSTED_SOUND);
        if (soundPath != null) {
            mTrustedSoundId = mLockSounds.load(soundPath, 1);
        }
        if (soundPath == null || mTrustedSoundId == 0) {
            Log.w(TAG, "failed to load trusted sound from " + soundPath);
        }

        ...
        
    }

追踪到锁屏声音相关类,获取锁屏音资源路径处打log,发现soundPath 是空的,说明没有获取到锁屏音资源文件

相关系统音频资源 通常会在编译时拷贝进product/media/audio/ui/ 目录

adb shell 进入 product/media/audio/ui/ 目录下,发现没有Lock.ogg文件,说明没有拷贝,mk文件没有执行拷贝动作

进入frameworks\base\data\sounds 路径下 查看相关资源文件和mk文件

AudioPackageGo.mk文件是GO版本编译到的mk文件,进入查看

确实没有复制Lock.ogg 所以在这里加上

java 复制代码
	$(LOCAL_PATH)/effects/Undock.ogg:$(TARGET_COPY_OUT_PRODUCT)/media/audio/ui/Undock.ogg \
	$(LOCAL_PATH)/effects/Lock.ogg:$(TARGET_COPY_OUT_PRODUCT)/media/audio/ui/Lock.ogg \

重编过后,设备目录中就会拷贝有锁屏和解锁音。

原因分析

锁屏解锁音 是在锁屏和解锁时播放一段音频,在GO版本低配机器上,去掉了这部分来优化系统流畅度,所以相关资源没有拷贝过去。

相关推荐
Whisper_Sy2 小时前
Flutter for OpenHarmony移动数据使用监管助手App实战 - 网络状态实现
android·java·开发语言·javascript·网络·flutter·php
乂爻yiyao3 小时前
1.1 JVM 内存区域划分
java·jvm
没有bug.的程序员4 小时前
Spring Cloud Eureka:注册中心高可用配置与故障转移实战
java·spring·spring cloud·eureka·注册中心
ujainu4 小时前
Flutter + OpenHarmony 网格布局:GridView 与 SliverGrid 在鸿蒙设备内容展示中的应用
android·flutter·组件
CryptoRzz4 小时前
如何高效接入日本股市实时数据?StockTV API 对接实战指南
java·python·kafka·区块链·状态模式·百度小程序
码农水水4 小时前
中国邮政Java面试被问:容器镜像的多阶段构建和优化
java·linux·开发语言·数据库·mysql·面试·php
若鱼19194 小时前
SpringBoot4.0新特性-BeanRegistrar
java·spring
龙之叶4 小时前
【Android Monkey源码解析五】- 异常处理
android·数据库
明道源码4 小时前
Android Studio AVD 模拟器的使用与配置
android·android studio
好好研究5 小时前
SpringBoot - yml配置文件
java·spring boot·spring