Loading services/core/java/com/android/server/audio/RotationHelper.java +22 −1 Original line number Diff line number Diff line Loading @@ -21,20 +21,26 @@ import android.hardware.display.DisplayManager; import android.media.AudioSystem; import android.os.Handler; import android.util.Log; import android.view.Display; import android.view.Surface; import android.view.WindowManager; /** * Class to handle device rotation events for AudioService, and forward device rotation * to the audio HALs through AudioSystem. * and current active ID to the audio HALs through AudioSystem. * * The role of this class is to monitor device orientation changes, and upon rotation, * verify the UI orientation. In case of a change, send the new orientation, in increments * of 90deg, through AudioSystem. * * Another role of this class is to track current active display ID changes. In case of a * change, send the new active display ID through AudioSystem. * * Note that even though we're responding to device orientation events, we always * query the display rotation so audio stays in sync with video/dialogs. This is * done with .getDefaultDisplay().getRotation() from WINDOW_SERVICE. * * We also monitor current display ID and audio is able to know which display is active. */ class RotationHelper { Loading @@ -43,7 +49,9 @@ class RotationHelper { private static AudioDisplayListener sDisplayListener; private static final Object sRotationLock = new Object(); private static final Object sActiveDisplayLock = new Object(); private static int sDeviceRotation = Surface.ROTATION_0; // R/W synchronized on sRotationLock private static int sDisplayId = Display.DEFAULT_DISPLAY; // synchronized on sActiveDisplayLock private static Context sContext; private static Handler sHandler; Loading Loading @@ -111,6 +119,18 @@ class RotationHelper { } } /** * Query current display active id and publish the change if any. */ static void updateActiveDisplayId(int displayId) { synchronized (sActiveDisplayLock) { if (displayId != Display.DEFAULT_DISPLAY && sDisplayId != displayId) { sDisplayId = displayId; AudioSystem.setParameters("active_displayId=" + sDisplayId); } } } /** * Uses android.hardware.display.DisplayManager.DisplayListener */ Loading @@ -126,6 +146,7 @@ class RotationHelper { @Override public void onDisplayChanged(int displayId) { updateActiveDisplayId(displayId); updateOrientation(); } } Loading Loading
services/core/java/com/android/server/audio/RotationHelper.java +22 −1 Original line number Diff line number Diff line Loading @@ -21,20 +21,26 @@ import android.hardware.display.DisplayManager; import android.media.AudioSystem; import android.os.Handler; import android.util.Log; import android.view.Display; import android.view.Surface; import android.view.WindowManager; /** * Class to handle device rotation events for AudioService, and forward device rotation * to the audio HALs through AudioSystem. * and current active ID to the audio HALs through AudioSystem. * * The role of this class is to monitor device orientation changes, and upon rotation, * verify the UI orientation. In case of a change, send the new orientation, in increments * of 90deg, through AudioSystem. * * Another role of this class is to track current active display ID changes. In case of a * change, send the new active display ID through AudioSystem. * * Note that even though we're responding to device orientation events, we always * query the display rotation so audio stays in sync with video/dialogs. This is * done with .getDefaultDisplay().getRotation() from WINDOW_SERVICE. * * We also monitor current display ID and audio is able to know which display is active. */ class RotationHelper { Loading @@ -43,7 +49,9 @@ class RotationHelper { private static AudioDisplayListener sDisplayListener; private static final Object sRotationLock = new Object(); private static final Object sActiveDisplayLock = new Object(); private static int sDeviceRotation = Surface.ROTATION_0; // R/W synchronized on sRotationLock private static int sDisplayId = Display.DEFAULT_DISPLAY; // synchronized on sActiveDisplayLock private static Context sContext; private static Handler sHandler; Loading Loading @@ -111,6 +119,18 @@ class RotationHelper { } } /** * Query current display active id and publish the change if any. */ static void updateActiveDisplayId(int displayId) { synchronized (sActiveDisplayLock) { if (displayId != Display.DEFAULT_DISPLAY && sDisplayId != displayId) { sDisplayId = displayId; AudioSystem.setParameters("active_displayId=" + sDisplayId); } } } /** * Uses android.hardware.display.DisplayManager.DisplayListener */ Loading @@ -126,6 +146,7 @@ class RotationHelper { @Override public void onDisplayChanged(int displayId) { updateActiveDisplayId(displayId); updateOrientation(); } } Loading