问题描述
Android go版本 在设置中打开锁屏音开关,息屏灭屏还是无声音
排查
vendor\mediatek\proprietary\packages\apps\SystemUI\src\com\android\systemui\keyguard\KeyguardViewMediator.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 所以在这里加上
$(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版本低配机器上,去掉了这部分来优化系统流畅度,所以相关资源没有拷贝过去。