Skip to content

Commit 950e8cb

Browse files
author
Eric Laurent
committed
Indicate screen off condition to audio framework.
Add a mechanism for AudioService to notify audio framework and audio HAL that screen is turned on or off. This indication can be used by lower audio layers to trigger low power audio playback mode. Current implementaiton based on setParameters() method is experimental and will be replaced by a different interface when ready. Change-Id: Ie72ada0a8edec3d71b47681b9f51cb5bc839d45b
1 parent e6fee18 commit 950e8cb

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

media/java/android/media/AudioService.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -368,6 +368,8 @@ public AudioService(Context context) {
368368
intentFilter.addAction(Intent.ACTION_USB_DGTL_HEADSET_PLUG);
369369
intentFilter.addAction(Intent.ACTION_HDMI_AUDIO_PLUG);
370370
intentFilter.addAction(Intent.ACTION_BOOT_COMPLETED);
371+
intentFilter.addAction(Intent.ACTION_SCREEN_ON);
372+
intentFilter.addAction(Intent.ACTION_SCREEN_OFF);
371373
context.registerReceiver(mReceiver, intentFilter);
372374

373375
// Register for package removal intent broadcasts for media button receiver persistence
@@ -2565,6 +2567,10 @@ public void onReceive(Context context, Intent intent) {
25652567
removeMediaButtonReceiverForPackage(packageName);
25662568
}
25672569
}
2570+
} else if (action.equals(Intent.ACTION_SCREEN_ON)) {
2571+
AudioSystem.setParameters("screen_state=on");
2572+
} else if (action.equals(Intent.ACTION_SCREEN_OFF)) {
2573+
AudioSystem.setParameters("screen_state=off");
25682574
}
25692575
}
25702576
}

0 commit comments

Comments
 (0)