kaputnikGo/PilferShushJammer

Detect microphone blockers. Turn on passive jammer if it is detected.

davidhedlund opened this issue · 4 comments

Please read this first: Microphone blockers

Suggestion

Run PilferShushJammer as a background service that detects if a physical microphone blocker is connected:

  • Immediately detect when a microphone is connected.
  • Record a few seconds and save the audio to a file.
  • If the file size is to small no recordings occurred, which means that a physical microphone blocker has been connected. Turn on passive jammer as a complement to the microphone blocker. I think that could be useful if a malware detects the microphone blocker and activates the external microphone.

Interesting idea.
However, I'm not keen on giving the Passive Jammer the ability to record any audio to file at all.

Currently the jammer works by creating a valid AudioRecord object that has its audio input source set to DEFAULT. The physical microphone that DEFAULT points to is determined by the OS. Tests on a device running LineageOS AOSP shows that the moment a headset is plugged in the DEFAULT input source is internally switched to the headset mic, as is expected. Tests also show that the jammer will block which ever input is routed at the time of starting the passive jamming.

And this is a problem because hotplugging a headset in or out after the passive jammer is running will currently not auto switch the hardware buffer and therefore not block that new input source. A manual Passive restart is required.

An AudioManager method was used in earlier versions of the jammer app but the method(s) have been deprecated and proved unreliable across the 1700 device types currently listed as being supported on Google Play. Quote the Android API docs: "This is not a valid indication that audio playback is actually over the wired headset as audio routing depends on other conditions."

Presently the minimum API for this app is 18 and the newer methods are targeting API 21+ but the better class is only in 23+ (AudioDeviceInfo) which will return an int for what seems like every audio device type (including USB).

I will be looking into this including the min API bump.

included a headphone listener to restart jammer if audio routing changed.

included a headphone listener to restart jammer if audio routing changed.

Thanks a lot! Can you please add the commit here?

5 march added headset receiver. warning i have had mixed results with this API...
90038f1#diff-c91bf661cf17875bfb846d2f278414f9