Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 6fbd04e3 authored by Jean-Michel Trivi's avatar Jean-Michel Trivi Committed by Automerger Merge Worker
Browse files

Merge "AudioService: update display rotation monitoring" into tm-dev am:...

Merge "AudioService: update display rotation monitoring" into tm-dev am: abcff90b am: 3cc075c0 am: 06160619

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/18806553



Change-Id: Ic004b40682cd4284cf1d7067b9dd86e56775febf
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents 93a784cf 06160619
Loading
Loading
Loading
Loading
+12 −4
Original line number Original line Diff line number Diff line
@@ -20,12 +20,13 @@ import android.content.Context;
import android.hardware.devicestate.DeviceStateManager;
import android.hardware.devicestate.DeviceStateManager;
import android.hardware.devicestate.DeviceStateManager.FoldStateListener;
import android.hardware.devicestate.DeviceStateManager.FoldStateListener;
import android.hardware.display.DisplayManager;
import android.hardware.display.DisplayManager;
import android.hardware.display.DisplayManagerGlobal;
import android.media.AudioSystem;
import android.media.AudioSystem;
import android.os.Handler;
import android.os.Handler;
import android.os.HandlerExecutor;
import android.os.HandlerExecutor;
import android.util.Log;
import android.util.Log;
import android.view.Display;
import android.view.Surface;
import android.view.Surface;
import android.view.WindowManager;


/**
/**
 * Class to handle device rotation events for AudioService, and forward device rotation
 * Class to handle device rotation events for AudioService, and forward device rotation
@@ -48,6 +49,8 @@ class RotationHelper {


    private static final String TAG = "AudioService.RotationHelper";
    private static final String TAG = "AudioService.RotationHelper";


    private static final boolean DEBUG_ROTATION = false;

    private static AudioDisplayListener sDisplayListener;
    private static AudioDisplayListener sDisplayListener;
    private static FoldStateListener sFoldStateListener;
    private static FoldStateListener sFoldStateListener;


@@ -98,8 +101,8 @@ class RotationHelper {
        // Even though we're responding to device orientation events,
        // Even though we're responding to device orientation events,
        // use display rotation so audio stays in sync with video/dialogs
        // use display rotation so audio stays in sync with video/dialogs
        // TODO(b/148458001): Support multi-display
        // TODO(b/148458001): Support multi-display
        int newRotation = ((WindowManager) sContext.getSystemService(
        int newRotation = DisplayManagerGlobal.getInstance()
                Context.WINDOW_SERVICE)).getDefaultDisplay().getRotation();
                .getDisplayInfo(Display.DEFAULT_DISPLAY).rotation;
        synchronized(sRotationLock) {
        synchronized(sRotationLock) {
            if (newRotation != sDeviceRotation) {
            if (newRotation != sDeviceRotation) {
                sDeviceRotation = newRotation;
                sDeviceRotation = newRotation;
@@ -109,7 +112,9 @@ class RotationHelper {
    }
    }


    private static void publishRotation(int rotation) {
    private static void publishRotation(int rotation) {
        Log.v(TAG, "publishing device rotation =" + rotation + " (x90deg)");
        if (DEBUG_ROTATION) {
            Log.i(TAG, "publishing device rotation =" + rotation + " (x90deg)");
        }
        switch (rotation) {
        switch (rotation) {
            case Surface.ROTATION_0:
            case Surface.ROTATION_0:
                AudioSystem.setParameters("rotation=0");
                AudioSystem.setParameters("rotation=0");
@@ -159,6 +164,9 @@ class RotationHelper {


        @Override
        @Override
        public void onDisplayChanged(int displayId) {
        public void onDisplayChanged(int displayId) {
            if (DEBUG_ROTATION) {
                Log.i(TAG, "onDisplayChanged diplayId:" + displayId);
            }
            updateOrientation();
            updateOrientation();
        }
        }
    }
    }