• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..16-Feb-2021-

java/H16-Feb-2021-421332

BUILD.gnH A D16-Feb-20211.3 KiB4034

OWNERSH A D16-Feb-202143 32

README.mdH A D16-Feb-20211.7 KiB5133

README.md

1## AudioFocusGrabber: a Tool for Testing Audio Focus Handling in Apps
2
3A simple app used to test audio focus handling in apps, especially
4MediaSession in Chrome. You can perform audio gain/abandon actions, in
5order to simulate a short ping from an SMS or email, or permanent
6audio focus gain from other media player apps.
7
8### Setup
9
10#### 1: Build and install the AudioFocusGrabber app
11
12	ninja -C out/Debug audio_focus_grabber_apk
13	adb install -r out/Debug/apks/AudioFocusGrabber.apk
14
15#### 2: Simulate audio focus actions
16
17You can simulate audio focus actions using the UI, the notification
18bar or through `adb` shell. There are three kinds of audio focus
19actions, corresponding to:
20
21* `AudioManager.AUDIOFOCUS_GAIN`
22* `AudioManager.AUDIOFOCUS_TRANSIENT`
23* `AudioManager.AUDIOFOCUS_TRANSIENT_MAY_DUCK`
24
25##### 2.1: Controlling from the UI
26
27From the UI, there are three buttons for the three actions. Just click
28it, and AudioFocusGrabber will perform the audio focus action, and play a ping
29sound.
30
31However in this way, the app must be in background.
32
33##### 2.2: Controlling from the notification
34
35You can also start a notification from the UI, and then you can make
36controls from the notification.
37
38In this way, the app must be in background or losed window focus.
39
40##### 2.3 Controlling from the `adb` shell
41
42From the `adb` shell, which you can do it even if the AudioFocusGrabber is not
43in foreground. You may use the following three commands:
44
45	adb shell am startservice -a AUDIO_FOCUS_GRABBER_GAIN
46	adb shell am startservice -a AUDIO_FOCUS_GRABBER_TRANSIENT_PAUSE
47	adb shell am startservice -a AUDIO_FOCUS_GRABBER_TRANSIENT_DUCK
48
49In this way, the app may be in the foreground, in the background or
50losed window focus.
51