我想更改我的 Android 9 LineageOS 设备的输出设备,因为我经常面临通过手机扬声器而不是蓝牙耳机播放音频的问题。我不知道为什么 Android 有时会决定不使用连接的音频设备,但我认为这是一个错误,因为它有时只会发生。
作为一种解决方法,我想使用终端来解决这个问题。
我的想法:找出管理音频输出的服务,找出我必须调用的方法以及需要的参数,然后从 shell 脚本或终端(具有 root 访问权限)使用服务实用程序。
我认为我的服务简称为“音频”(IAudioService)。在源代码中,第 35 个方法是“setBluetoothScoOn”,这听起来像是我正在寻找的。它接受一个参数(我希望为真的布尔值)。所以我在我的根终端中运行了这个:
service call audio 35 i32 1
#audio: service name
#35: setBluetoothScoOn is the 35th method in in the IAudioServicesource code
#i32: data type to be used for the first parameter (boolean)
#1: means true in this context
不幸的是,当我运行我的命令时没有任何反应。它只是返回:
Result: Parcel(00000000 '....')
任何想法我做错了什么?
编辑:
当我通过蓝牙耳机成功连接播放音乐(使用 VLC)并运行service call audio 38
时,我得到以下响应:
Result: Parcel(00000000 00000001 '........')
然后,当我运行service call audio 37 i32 0
手机时,会立即通过手机的扬声器而不是蓝牙耳机播放音频。
然后,当我运行时,service call audio 38
我得到以下响应:
Result: Parcel(00000000 00000000 '........')
一旦我播放下一首歌曲,音频就会再次通过蓝牙耳机播放。并service call audio 38
再次返回:
Result: Parcel(00000000 00000001 '........')
这让我想知道是否37
响应setBluetoothScoOn
和。38
isBluetoothScoOn
在另一种情况下,当我在service call audio 38
连接蓝牙耳机并且音乐通过扬声器播放并且拒绝通过蓝牙耳机播放的标准问题时跑步时,我仍然总是得到:
Result: Parcel(00000000 00000001 '........')
在我运行之前service call audio 37 i32 0
,它会暂时返回:
Result: Parcel(00000000 00000000 '........')
直到我播放下一首歌曲,但绝不会通过蓝牙耳机播放音频。
所以本质上
service call audio 37 i32 1
仅导致service call audio 38
暂时返回:
Result: Parcel(00000000 00000001 '........')
就像service call audio 37 i32 0
导致它返回一样:
Result: Parcel(00000000 00000000 '........')
但是在通过 Blurtooth 播放音乐时,service call audio 37 i32 0
也会通过扬声器暂时播放音频,直到我播放下一首歌曲。