Android 模拟器的 "virtual headset plug inserted" 是什么意思?

What does "virtual headset plug inserted" of Android emulator mean?

The official document 说:

The Android Emulator doesn't include virtual hardware for the following:

Bluetooth
NFC
SD card insert/eject
Device-attached headphones
USB

但是,模拟器有以下设置:

谁能解释一下这些设置的含义? 以下代码 returns 模拟器错误:

getPackageManager().hasSystemFeature(PackageManager.FEATURE_MICROPHONE)

顾名思义,在模拟器中开启"Virtual headset plug inserted"会发送广播"action=android.intent.action.HEADSET_PLUG"。 为 action.HEADSET_PLUG 设置广播接收器以检测 unplug/plug 有线耳机。

我正在寻找一种方法让 Android 认为我已经连接了耳机,但启用 Virtual headset plug inserted 是不够的。这样做你必须安装 Lesser AudioSwitchset input device to headset

只有getPackageManager().hasSystemFeature(PackageManager.FEATURE_MICROPHONE)才会returntrue