summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Ziyang Cheng <ziyangch@google.com> 2023-07-25 00:16:54 +0000
committer Ziyang Cheng <ziyangch@google.com> 2023-07-25 00:18:49 +0000
commit0563f2971bb0c293e36519037119b8aec6eec6bf (patch)
treedcae3c8299667aab98689ccdf2a104d21a47655c
parent7382dcb32c3c82c37dd96165b27fbaa7dadab187 (diff)
Listen to ACTION_SCREEN_ON/OFF if DisplayManager is not available.
Test: Performing tilt/untilt gestures on Pixel watch and verify SetParameters is called when screen is on/off. Bug: 292477293 Change-Id: I9b1fd806a030ea5b5208256ea7eef32b5f12acad Signed-off-by: Ziyang Cheng <ziyangch@google.com>
-rw-r--r--services/core/java/com/android/server/audio/AudioService.java19
1 files changed, 18 insertions, 1 deletions
diff --git a/services/core/java/com/android/server/audio/AudioService.java b/services/core/java/com/android/server/audio/AudioService.java
index 9f958be84e98..1564f7d379d2 100644
--- a/services/core/java/com/android/server/audio/AudioService.java
+++ b/services/core/java/com/android/server/audio/AudioService.java
@@ -1386,6 +1386,10 @@ public class AudioService extends IAudioService.Stub
new IntentFilter(BluetoothHeadset.ACTION_AUDIO_STATE_CHANGED);
intentFilter.addAction(BluetoothHeadset.ACTION_ACTIVE_DEVICE_CHANGED);
intentFilter.addAction(Intent.ACTION_DOCK_EVENT);
+ if (mDisplayManager == null) {
+ intentFilter.addAction(Intent.ACTION_SCREEN_ON);
+ intentFilter.addAction(Intent.ACTION_SCREEN_OFF);
+ }
intentFilter.addAction(Intent.ACTION_USER_SWITCHED);
intentFilter.addAction(Intent.ACTION_USER_BACKGROUND);
intentFilter.addAction(Intent.ACTION_USER_FOREGROUND);
@@ -1416,7 +1420,9 @@ public class AudioService extends IAudioService.Stub
subscriptionManager.addOnSubscriptionsChangedListener(mSubscriptionChangedListener);
}
- mDisplayManager.registerDisplayListener(mDisplayListener, mAudioHandler);
+ if (mDisplayManager != null) {
+ mDisplayManager.registerDisplayListener(mDisplayListener, mAudioHandler);
+ }
}
public void systemReady() {
@@ -9587,6 +9593,17 @@ public class AudioService extends IAudioService.Stub
} else if (action.equals(BluetoothHeadset.ACTION_ACTIVE_DEVICE_CHANGED)
|| action.equals(BluetoothHeadset.ACTION_AUDIO_STATE_CHANGED)) {
mDeviceBroker.receiveBtEvent(intent);
+ } else if (action.equals(Intent.ACTION_SCREEN_ON)) {
+ if (mMonitorRotation) {
+ RotationHelper.enable();
+ }
+ AudioSystem.setParameters("screen_state=on");
+ } else if (action.equals(Intent.ACTION_SCREEN_OFF)) {
+ if (mMonitorRotation) {
+ //reduce wakeups (save current) by only listening when display is on
+ RotationHelper.disable();
+ }
+ AudioSystem.setParameters("screen_state=off");
} else if (action.equals(Intent.ACTION_CONFIGURATION_CHANGED)) {
sendMsg(mAudioHandler,
MSG_CONFIGURATION_CHANGED,