Search code examples
androidshelladbspyware

Find applications that use the microphone with ADB


Google's voice assistant hasn't worked for some time because my phone's microphone seems to be used by another application.

With ADB, how do I know which applications are using the microphone?

Thank you!

UPDATE:

The output of adb shell dumpsys audio is as follows

MediaFocusControl dump time: 09:01:00

Audio Focus stack entries (last is top of stack):
mFocusStack:

mFocusStackForExternal:

No external focus policy



 Notify on duck:  true

 In ring or call: false


Stream volumes (device: index)
- STREAM_VOICE_CALL:
   Muted: false
   Min: 1
   Max: 10
   Current: 1 (earpiece): 10, 2 (speaker): 10, 4 (headset): 8, 20 (bt_sco_hs): 8, 80 (bt_a2dp): 8, 40000000 (default): 8
   Devices: earpiece
- STREAM_SYSTEM:
   Muted: false
   Min: 0
   Max: 15
   Current: 1 (earpiece): 12, 2 (speaker): 15, 4 (headset): 15, 20 (bt_sco_hs): 15, 80 (bt_a2dp): 15, 40000000 (default): 15
   Devices: speaker
- STREAM_RING:
   Muted: false
   Min: 0
   Max: 15
   Current: 1 (earpiece): 12, 2 (speaker): 15, 4 (headset): 15, 20 (bt_sco_hs): 15, 80 (bt_a2dp): 15, 40000000 (default): 15
   Devices: speaker
- STREAM_MUSIC:
   Muted: false
   Min: 0
   Max: 15
   Current: 2 (speaker): 8, 4 (headset): 8, 8 (headphone): 8, 20 (bt_sco_hs): 11, 80 (bt_a2dp): 13, 4000 (usb_device): 8, 20000000 (usb_device): 8, 40000000 (default): 11
   Devices: speaker
- STREAM_ALARM:
   Muted: false
   Min: 0
   Max: 15
   Current: 2 (speaker): 15, 40000000 (default): 12
   Devices: speaker
- STREAM_NOTIFICATION:
   Muted: false
   Min: 0
   Max: 15
   Current: 1 (earpiece): 12, 2 (speaker): 15, 4 (headset): 15, 20 (bt_sco_hs): 15, 80 (bt_a2dp): 15, 40000000 (default): 15
   Devices: speaker
- STREAM_BLUETOOTH_SCO:
   Muted: false
   Min: 0
   Max: 15
   Current: 1 (earpiece): 10, 20 (bt_sco_hs): 10, 80 (bt_a2dp): 13, 40000000 (default): 7
   Devices: earpiece
- STREAM_SYSTEM_ENFORCED:
   Muted: false
   Min: 0
   Max: 15
   Current: 1 (earpiece): 12, 2 (speaker): 15, 4 (headset): 15, 20 (bt_sco_hs): 15, 80 (bt_a2dp): 15, 40000000 (default): 15
   Devices: speaker
- STREAM_DTMF:
   Muted: false
   Min: 0
   Max: 15
   Current: 1 (earpiece): 12, 2 (speaker): 15, 4 (headset): 15, 20 (bt_sco_hs): 15, 80 (bt_a2dp): 15, 40000000 (default): 15
   Devices: speaker
- STREAM_TTS:
   Muted: false
   Min: 0
   Max: 15
   Current: 2 (speaker): 8, 4 (headset): 8, 8 (headphone): 8, 20 (bt_sco_hs): 11, 80 (bt_a2dp): 13, 4000 (usb_device): 8, 20000000 (usb_device): 8, 40000000 (default): 11
   Devices: speaker
- STREAM_ACCESSIBILITY:
   Muted: false
   Min: 0
   Max: 15
   Current: 2 (speaker): 8, 4 (headset): 8, 8 (headphone): 8, 20 (bt_sco_hs): 11, 80 (bt_a2dp): 13, 4000 (usb_device): 8, 20000000 (usb_device): 8, 40000000 (default): 11
   Devices: speaker

- mute affected streams = 0x2e

Ringer mode: 
- mode (internal) = NORMAL
- mode (external) = NORMAL
- ringer mode affected streams = 0x1a6 (STREAM_SYSTEM,STREAM_RING,STREAM_NOTIFICATION,STREAM_SYSTEM_ENFORCED,STREAM_DTMF)
- ringer mode muted streams = 0x0
- delegate = ZenModeHelper

Audio routes:
  mMainType=0x0
  mBluetoothName=null

Other state:
  mVolumeController=VolumeController(android.os.BinderProxy@962b52,mVisible=false)
  mSafeMediaVolumeState=SAFE_MEDIA_VOLUME_ACTIVE
  mSafeMediaVolumeIndex=80
  sIndependentA11yVolume=false
  mPendingVolumeCommand=null
  mMusicActiveMs=0
  UNSAFE_VOLUME_MUSIC_ACTIVE_MS_MAX=72000000
  mMcc=222
  mCameraSoundForced=false
  mHasVibrator=true
  mVolumePolicy=VolumePolicy[volumeDownToEnterSilent=false,volumeUpToExitSilent=true,doNotDisturbWhenSilent=true,vibrateToSilentDebounce=400]
  mAvrcpAbsVolSupported=false

Audio policies:

PlaybackActivityMonitor dump time: 09:01:00
  ID:23 -- type:android.media.SoundPool -- u/pid:1000/1431 -- state:idle -- attr:AudioAttributes: usage=6 content=4 flags=0x0 tags= bundle=null
  ID:39 -- type:android.media.SoundPool -- u/pid:10028/2089 -- state:idle -- attr:AudioAttributes: usage=13 content=4 flags=0x0 tags= bundle=null
  ID:31015 -- type:android.media.MediaPlayer -- u/pid:10028/2089 -- state:stopped -- attr:AudioAttributes: usage=5 content=4 flags=0x0 tags= bundle=null
  ID:15 -- type:android.media.SoundPool -- u/pid:1000/1431 -- state:idle -- attr:AudioAttributes: usage=13 content=4 flags=0x0 tags= bundle=null
  ID:31 -- type:android.media.SoundPool -- u/pid:10028/2089 -- state:idle -- attr:AudioAttributes: usage=13 content=4 flags=0x0 tags= bundle=null
  ID:31007 -- type:android.media.MediaPlayer -- u/pid:1000/1431 -- state:stopped -- attr:AudioAttributes: usage=13 content=4 flags=0x0 tags= bundle=null

  ducked players:

  muted player piids:

RecordActivityMonitor dump time: 09:01:00
  session:5065 -- source:VOICE_COMMUNICATION -- uid:10132 -- patch:9 -- pack:com.whatsapp -- format client=1ch 16000Hz ENCODING_PCM_16BIT, dev=1ch 16000Hz ENCODING_PCM_16BIT

Audio Mode:
HwAudioService:DEBUG =false
mIsHuaweiSafeMediaConfig =true
mSecurityVolumeIndex =8
LOUD_VOICE_MODE_SUPPORT=false
Lound Voice State:
HW_SOUND_TRIGGER_SUPPORT=false
mSoundTriggerStatus=0
mad=on:
wakeup=on:
HW_KARAOKE_EFFECT_ENABLED=true
DTS_SOUND_EFFECTS_SUPPORT=false
mDtsStatus=0
Dts State:
DTS_MODE_PRESTATE:unknown
HS_NO_CHARGE_ON:
isCallForeground=true
DUAL_SMARTPA_SUPPORT=false
SPK_RCV_STEREO_SUPPORT=false
mSpkRcvStereoStatus=-1
mLowlatencyUidsMap={}
mVoipOptimizeInGameMode =false

I don't know, but it seems that the microphone is not in use by any application, or maybe I am wrong?


Solution

  • You can try using this command :

    adb shell dumpsys audio
    

    In the output look under Audio Focus stack entries (last is top of stack).It will show the the package name of the app using microphone

    Example (When I am using microphone in whatsapp) the output was:

     source:android.os.BinderProxy@829ac54 -- pack: com.whatsapp -- client: [email protected]@e5a922d -- gain: GAIN_TRANSIENT -- flags:  -- loss: none -- notified: true -- uid: 10165 -- attr: AudioAttributes: usage=USAGE_MEDIA content=CONTENT_TYPE_MUSIC flags=0x800 tags= bundle=null -- sdk:30