Merge "WM: Handle primary display orientation when calculating the transform hint" am: 5fb9f63795
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1887653 Change-Id: I3d1ef99b82cb142f27015bd68a976e2d942a4fda
This commit is contained in:
@@ -157,6 +157,7 @@ public final class SurfaceControl implements Parcelable {
|
|||||||
private static native boolean nativeGetAnimationFrameStats(WindowAnimationFrameStats outStats);
|
private static native boolean nativeGetAnimationFrameStats(WindowAnimationFrameStats outStats);
|
||||||
|
|
||||||
private static native long[] nativeGetPhysicalDisplayIds();
|
private static native long[] nativeGetPhysicalDisplayIds();
|
||||||
|
private static native long nativeGetPrimaryPhysicalDisplayId();
|
||||||
private static native IBinder nativeGetPhysicalDisplayToken(long physicalDisplayId);
|
private static native IBinder nativeGetPhysicalDisplayToken(long physicalDisplayId);
|
||||||
private static native IBinder nativeCreateDisplay(String name, boolean secure);
|
private static native IBinder nativeCreateDisplay(String name, boolean secure);
|
||||||
private static native void nativeDestroyDisplay(IBinder displayToken);
|
private static native void nativeDestroyDisplay(IBinder displayToken);
|
||||||
@@ -2265,6 +2266,15 @@ public final class SurfaceControl implements Parcelable {
|
|||||||
return nativeGetPhysicalDisplayIds();
|
return nativeGetPhysicalDisplayIds();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Exposed to identify the correct display to apply the primary display orientation. Avoid using
|
||||||
|
* for any other purpose.
|
||||||
|
* @hide
|
||||||
|
*/
|
||||||
|
public static long getPrimaryPhysicalDisplayId() {
|
||||||
|
return nativeGetPrimaryPhysicalDisplayId();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @hide
|
* @hide
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -889,6 +889,12 @@ static jlongArray nativeGetPhysicalDisplayIds(JNIEnv* env, jclass clazz) {
|
|||||||
return array;
|
return array;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static jlong nativeGetPrimaryPhysicalDisplayId(JNIEnv* env, jclass clazz) {
|
||||||
|
PhysicalDisplayId displayId;
|
||||||
|
SurfaceComposerClient::getPrimaryPhysicalDisplayId(&displayId);
|
||||||
|
return static_cast<jlong>(displayId.value);
|
||||||
|
}
|
||||||
|
|
||||||
static jobject nativeGetPhysicalDisplayToken(JNIEnv* env, jclass clazz, jlong physicalDisplayId) {
|
static jobject nativeGetPhysicalDisplayToken(JNIEnv* env, jclass clazz, jlong physicalDisplayId) {
|
||||||
sp<IBinder> token =
|
sp<IBinder> token =
|
||||||
SurfaceComposerClient::getPhysicalDisplayToken(PhysicalDisplayId(physicalDisplayId));
|
SurfaceComposerClient::getPhysicalDisplayToken(PhysicalDisplayId(physicalDisplayId));
|
||||||
@@ -1879,6 +1885,8 @@ static const JNINativeMethod sSurfaceControlMethods[] = {
|
|||||||
(void*)nativeReleaseFrameRateFlexibilityToken },
|
(void*)nativeReleaseFrameRateFlexibilityToken },
|
||||||
{"nativeGetPhysicalDisplayIds", "()[J",
|
{"nativeGetPhysicalDisplayIds", "()[J",
|
||||||
(void*)nativeGetPhysicalDisplayIds },
|
(void*)nativeGetPhysicalDisplayIds },
|
||||||
|
{"nativeGetPrimaryPhysicalDisplayId", "()J",
|
||||||
|
(void*)nativeGetPrimaryPhysicalDisplayId },
|
||||||
{"nativeGetPhysicalDisplayToken", "(J)Landroid/os/IBinder;",
|
{"nativeGetPhysicalDisplayToken", "(J)Landroid/os/IBinder;",
|
||||||
(void*)nativeGetPhysicalDisplayToken },
|
(void*)nativeGetPhysicalDisplayToken },
|
||||||
{"nativeCreateDisplay", "(Ljava/lang/String;Z)Landroid/os/IBinder;",
|
{"nativeCreateDisplay", "(Ljava/lang/String;Z)Landroid/os/IBinder;",
|
||||||
|
|||||||
@@ -499,6 +499,12 @@
|
|||||||
"group": "WM_DEBUG_STATES",
|
"group": "WM_DEBUG_STATES",
|
||||||
"at": "com\/android\/server\/wm\/ActivityRecord.java"
|
"at": "com\/android\/server\/wm\/ActivityRecord.java"
|
||||||
},
|
},
|
||||||
|
"-1556507536": {
|
||||||
|
"message": "Passing transform hint %d for window %s%s",
|
||||||
|
"level": "VERBOSE",
|
||||||
|
"group": "WM_DEBUG_ORIENTATION",
|
||||||
|
"at": "com\/android\/server\/wm\/WindowManagerService.java"
|
||||||
|
},
|
||||||
"-1554521902": {
|
"-1554521902": {
|
||||||
"message": "showInsets(ime) was requested by different window: %s ",
|
"message": "showInsets(ime) was requested by different window: %s ",
|
||||||
"level": "WARN",
|
"level": "WARN",
|
||||||
|
|||||||
@@ -151,7 +151,7 @@ java_library_static {
|
|||||||
"android.hardware.biometrics.fingerprint-V2.3-java",
|
"android.hardware.biometrics.fingerprint-V2.3-java",
|
||||||
"android.hardware.biometrics.fingerprint-V1-java",
|
"android.hardware.biometrics.fingerprint-V1-java",
|
||||||
"android.hardware.oemlock-V1.0-java",
|
"android.hardware.oemlock-V1.0-java",
|
||||||
"android.hardware.configstore-V1.0-java",
|
"android.hardware.configstore-V1.1-java",
|
||||||
"android.hardware.contexthub-V1.0-java",
|
"android.hardware.contexthub-V1.0-java",
|
||||||
"android.hardware.rebootescrow-V1-java",
|
"android.hardware.rebootescrow-V1-java",
|
||||||
"android.hardware.soundtrigger-V2.3-java",
|
"android.hardware.soundtrigger-V2.3-java",
|
||||||
|
|||||||
@@ -167,8 +167,10 @@ import android.graphics.Point;
|
|||||||
import android.graphics.Rect;
|
import android.graphics.Rect;
|
||||||
import android.graphics.RectF;
|
import android.graphics.RectF;
|
||||||
import android.graphics.Region;
|
import android.graphics.Region;
|
||||||
import android.hardware.configstore.V1_0.ISurfaceFlingerConfigs;
|
|
||||||
import android.hardware.configstore.V1_0.OptionalBool;
|
import android.hardware.configstore.V1_0.OptionalBool;
|
||||||
|
import android.hardware.configstore.V1_1.DisplayOrientation;
|
||||||
|
import android.hardware.configstore.V1_1.ISurfaceFlingerConfigs;
|
||||||
|
import android.hardware.configstore.V1_1.OptionalDisplayOrientation;
|
||||||
import android.hardware.display.DisplayManager;
|
import android.hardware.display.DisplayManager;
|
||||||
import android.hardware.display.DisplayManagerInternal;
|
import android.hardware.display.DisplayManagerInternal;
|
||||||
import android.hardware.input.InputManager;
|
import android.hardware.input.InputManager;
|
||||||
@@ -220,6 +222,7 @@ import android.util.TypedValue;
|
|||||||
import android.util.proto.ProtoOutputStream;
|
import android.util.proto.ProtoOutputStream;
|
||||||
import android.view.Choreographer;
|
import android.view.Choreographer;
|
||||||
import android.view.Display;
|
import android.view.Display;
|
||||||
|
import android.view.DisplayAddress;
|
||||||
import android.view.DisplayInfo;
|
import android.view.DisplayInfo;
|
||||||
import android.view.Gravity;
|
import android.view.Gravity;
|
||||||
import android.view.IAppTransitionAnimationSpecsFuture;
|
import android.view.IAppTransitionAnimationSpecsFuture;
|
||||||
@@ -465,6 +468,8 @@ public class WindowManagerService extends IWindowManager.Stub
|
|||||||
*/
|
*/
|
||||||
static final boolean ENABLE_FIXED_ROTATION_TRANSFORM =
|
static final boolean ENABLE_FIXED_ROTATION_TRANSFORM =
|
||||||
SystemProperties.getBoolean("persist.wm.fixed_rotation_transform", true);
|
SystemProperties.getBoolean("persist.wm.fixed_rotation_transform", true);
|
||||||
|
private @Surface.Rotation int mPrimaryDisplayOrientation = Surface.ROTATION_0;
|
||||||
|
private DisplayAddress mPrimaryDisplayPhysicalAddress;
|
||||||
|
|
||||||
// Enums for animation scale update types.
|
// Enums for animation scale update types.
|
||||||
@Retention(RetentionPolicy.SOURCE)
|
@Retention(RetentionPolicy.SOURCE)
|
||||||
@@ -2461,16 +2466,21 @@ public class WindowManagerService extends IWindowManager.Stub
|
|||||||
configChanged = displayContent.updateOrientation();
|
configChanged = displayContent.updateOrientation();
|
||||||
Trace.traceEnd(TRACE_TAG_WINDOW_MANAGER);
|
Trace.traceEnd(TRACE_TAG_WINDOW_MANAGER);
|
||||||
|
|
||||||
final DisplayInfo rotatedDisplayInfo =
|
final DisplayInfo displayInfo = win.getDisplayInfo();
|
||||||
win.mToken.getFixedRotationTransformDisplayInfo();
|
int transformHint = displayInfo.rotation;
|
||||||
if (rotatedDisplayInfo != null) {
|
// If the window is on the primary display, use the panel orientation to adjust the
|
||||||
outSurfaceControl.setTransformHint(rotatedDisplayInfo.rotation);
|
// transform hint
|
||||||
} else {
|
final boolean isPrimaryDisplay = displayInfo.address != null &&
|
||||||
// We have to update the transform hint of display here, but we need to get if from
|
displayInfo.address.equals(mPrimaryDisplayPhysicalAddress);
|
||||||
// SurfaceFlinger, so set it as rotation of display for most cases, then
|
if (isPrimaryDisplay) {
|
||||||
// SurfaceFlinger would still update the transform hint of display in next frame.
|
transformHint = (transformHint + mPrimaryDisplayOrientation) % 4;
|
||||||
outSurfaceControl.setTransformHint(displayContent.getDisplayInfo().rotation);
|
|
||||||
}
|
}
|
||||||
|
outSurfaceControl.setTransformHint(transformHint);
|
||||||
|
ProtoLog.v(WM_DEBUG_ORIENTATION,
|
||||||
|
"Passing transform hint %d for window %s%s",
|
||||||
|
transformHint, win,
|
||||||
|
isPrimaryDisplay ? " on primary display with orientation "
|
||||||
|
+ mPrimaryDisplayOrientation : "");
|
||||||
|
|
||||||
if (toBeDisplayed && win.mIsWallpaper) {
|
if (toBeDisplayed && win.mIsWallpaper) {
|
||||||
displayContent.mWallpaperController.updateWallpaperOffset(win, false /* sync */);
|
displayContent.mWallpaperController.updateWallpaperOffset(win, false /* sync */);
|
||||||
@@ -4868,6 +4878,9 @@ public class WindowManagerService extends IWindowManager.Stub
|
|||||||
mTaskSnapshotController.systemReady();
|
mTaskSnapshotController.systemReady();
|
||||||
mHasWideColorGamutSupport = queryWideColorGamutSupport();
|
mHasWideColorGamutSupport = queryWideColorGamutSupport();
|
||||||
mHasHdrSupport = queryHdrSupport();
|
mHasHdrSupport = queryHdrSupport();
|
||||||
|
mPrimaryDisplayOrientation = queryPrimaryDisplayOrientation();
|
||||||
|
mPrimaryDisplayPhysicalAddress =
|
||||||
|
DisplayAddress.fromPhysicalDisplayId(SurfaceControl.getPrimaryPhysicalDisplayId());
|
||||||
UiThread.getHandler().post(mSettingsObserver::loadSettings);
|
UiThread.getHandler().post(mSettingsObserver::loadSettings);
|
||||||
IVrManager vrManager = IVrManager.Stub.asInterface(
|
IVrManager vrManager = IVrManager.Stub.asInterface(
|
||||||
ServiceManager.getService(Context.VR_SERVICE));
|
ServiceManager.getService(Context.VR_SERVICE));
|
||||||
@@ -4887,6 +4900,9 @@ public class WindowManagerService extends IWindowManager.Stub
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Keep logic in sync with SurfaceFlingerProperties.cpp
|
||||||
|
// Consider exposing properties via ISurfaceComposer instead.
|
||||||
private static boolean queryWideColorGamutSupport() {
|
private static boolean queryWideColorGamutSupport() {
|
||||||
boolean defaultValue = false;
|
boolean defaultValue = false;
|
||||||
Optional<Boolean> hasWideColorProp = SurfaceFlingerProperties.has_wide_color_display();
|
Optional<Boolean> hasWideColorProp = SurfaceFlingerProperties.has_wide_color_display();
|
||||||
@@ -4927,6 +4943,39 @@ public class WindowManagerService extends IWindowManager.Stub
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static @Surface.Rotation int queryPrimaryDisplayOrientation() {
|
||||||
|
Optional<SurfaceFlingerProperties.primary_display_orientation_values> prop =
|
||||||
|
SurfaceFlingerProperties.primary_display_orientation();
|
||||||
|
if (prop.isPresent()) {
|
||||||
|
switch (prop.get()) {
|
||||||
|
case ORIENTATION_90: return Surface.ROTATION_90;
|
||||||
|
case ORIENTATION_180: return Surface.ROTATION_180;
|
||||||
|
case ORIENTATION_270: return Surface.ROTATION_270;
|
||||||
|
case ORIENTATION_0:
|
||||||
|
default:
|
||||||
|
return Surface.ROTATION_0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
ISurfaceFlingerConfigs surfaceFlinger = ISurfaceFlingerConfigs.getService();
|
||||||
|
OptionalDisplayOrientation primaryDisplayOrientation =
|
||||||
|
surfaceFlinger.primaryDisplayOrientation();
|
||||||
|
if (primaryDisplayOrientation != null && primaryDisplayOrientation.specified) {
|
||||||
|
switch (primaryDisplayOrientation.value) {
|
||||||
|
case DisplayOrientation.ORIENTATION_90: return Surface.ROTATION_90;
|
||||||
|
case DisplayOrientation.ORIENTATION_180: return Surface.ROTATION_180;
|
||||||
|
case DisplayOrientation.ORIENTATION_270: return Surface.ROTATION_270;
|
||||||
|
case DisplayOrientation.ORIENTATION_0:
|
||||||
|
default:
|
||||||
|
return Surface.ROTATION_0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
// Use default value if we can't talk to config store.
|
||||||
|
}
|
||||||
|
return Surface.ROTATION_0;
|
||||||
|
}
|
||||||
|
|
||||||
void reportFocusChanged(IBinder oldToken, IBinder newToken) {
|
void reportFocusChanged(IBinder oldToken, IBinder newToken) {
|
||||||
WindowState lastFocus;
|
WindowState lastFocus;
|
||||||
WindowState newFocus;
|
WindowState newFocus;
|
||||||
|
|||||||
Reference in New Issue
Block a user