Merge "WM: Handle primary display orientation when calculating the transform hint" into sc-v2-dev
This commit is contained in:
@@ -159,6 +159,7 @@ public final class SurfaceControl implements Parcelable {
|
||||
private static native boolean nativeGetAnimationFrameStats(WindowAnimationFrameStats outStats);
|
||||
|
||||
private static native long[] nativeGetPhysicalDisplayIds();
|
||||
private static native long nativeGetPrimaryPhysicalDisplayId();
|
||||
private static native IBinder nativeGetPhysicalDisplayToken(long physicalDisplayId);
|
||||
private static native IBinder nativeCreateDisplay(String name, boolean secure);
|
||||
private static native void nativeDestroyDisplay(IBinder displayToken);
|
||||
@@ -2278,6 +2279,15 @@ public final class SurfaceControl implements Parcelable {
|
||||
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
|
||||
*/
|
||||
|
||||
@@ -898,6 +898,12 @@ static jlongArray nativeGetPhysicalDisplayIds(JNIEnv* env, jclass clazz) {
|
||||
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) {
|
||||
sp<IBinder> token =
|
||||
SurfaceComposerClient::getPhysicalDisplayToken(PhysicalDisplayId(physicalDisplayId));
|
||||
@@ -1899,6 +1905,8 @@ static const JNINativeMethod sSurfaceControlMethods[] = {
|
||||
(void*)nativeReleaseFrameRateFlexibilityToken },
|
||||
{"nativeGetPhysicalDisplayIds", "()[J",
|
||||
(void*)nativeGetPhysicalDisplayIds },
|
||||
{"nativeGetPrimaryPhysicalDisplayId", "()J",
|
||||
(void*)nativeGetPrimaryPhysicalDisplayId },
|
||||
{"nativeGetPhysicalDisplayToken", "(J)Landroid/os/IBinder;",
|
||||
(void*)nativeGetPhysicalDisplayToken },
|
||||
{"nativeCreateDisplay", "(Ljava/lang/String;Z)Landroid/os/IBinder;",
|
||||
|
||||
@@ -103,12 +103,6 @@
|
||||
"group": "WM_DEBUG_STATES",
|
||||
"at": "com\/android\/server\/wm\/TaskFragment.java"
|
||||
},
|
||||
"-2006946193": {
|
||||
"message": "setClientVisible: %s clientVisible=%b Callers=%s",
|
||||
"level": "VERBOSE",
|
||||
"group": "WM_DEBUG_APP_TRANSITIONS",
|
||||
"at": "com\/android\/server\/wm\/ActivityRecord.java"
|
||||
},
|
||||
"-2002500255": {
|
||||
"message": "Defer removing snapshot surface in %dms",
|
||||
"level": "VERBOSE",
|
||||
@@ -511,6 +505,12 @@
|
||||
"group": "WM_DEBUG_STATES",
|
||||
"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": {
|
||||
"message": "showInsets(ime) was requested by different window: %s ",
|
||||
"level": "WARN",
|
||||
|
||||
@@ -149,7 +149,7 @@ java_library_static {
|
||||
"android.hardware.biometrics.fingerprint-V2.3-java",
|
||||
"android.hardware.biometrics.fingerprint-V1-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.rebootescrow-V1-java",
|
||||
"android.hardware.soundtrigger-V2.3-java",
|
||||
|
||||
@@ -172,8 +172,10 @@ import android.graphics.Point;
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.RectF;
|
||||
import android.graphics.Region;
|
||||
import android.hardware.configstore.V1_0.ISurfaceFlingerConfigs;
|
||||
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.DisplayManagerInternal;
|
||||
import android.hardware.input.InputManager;
|
||||
@@ -225,6 +227,7 @@ import android.util.TypedValue;
|
||||
import android.util.proto.ProtoOutputStream;
|
||||
import android.view.Choreographer;
|
||||
import android.view.Display;
|
||||
import android.view.DisplayAddress;
|
||||
import android.view.DisplayInfo;
|
||||
import android.view.Gravity;
|
||||
import android.view.IAppTransitionAnimationSpecsFuture;
|
||||
@@ -450,6 +453,8 @@ public class WindowManagerService extends IWindowManager.Stub
|
||||
*/
|
||||
static final boolean ENABLE_FIXED_ROTATION_TRANSFORM =
|
||||
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.
|
||||
@Retention(RetentionPolicy.SOURCE)
|
||||
@@ -2459,16 +2464,21 @@ public class WindowManagerService extends IWindowManager.Stub
|
||||
configChanged = displayContent.updateOrientation();
|
||||
Trace.traceEnd(TRACE_TAG_WINDOW_MANAGER);
|
||||
|
||||
final DisplayInfo rotatedDisplayInfo =
|
||||
win.mToken.getFixedRotationTransformDisplayInfo();
|
||||
if (rotatedDisplayInfo != null) {
|
||||
outSurfaceControl.setTransformHint(rotatedDisplayInfo.rotation);
|
||||
} else {
|
||||
// We have to update the transform hint of display here, but we need to get if from
|
||||
// SurfaceFlinger, so set it as rotation of display for most cases, then
|
||||
// SurfaceFlinger would still update the transform hint of display in next frame.
|
||||
outSurfaceControl.setTransformHint(displayContent.getDisplayInfo().rotation);
|
||||
final DisplayInfo displayInfo = win.getDisplayInfo();
|
||||
int transformHint = displayInfo.rotation;
|
||||
// If the window is on the primary display, use the panel orientation to adjust the
|
||||
// transform hint
|
||||
final boolean isPrimaryDisplay = displayInfo.address != null &&
|
||||
displayInfo.address.equals(mPrimaryDisplayPhysicalAddress);
|
||||
if (isPrimaryDisplay) {
|
||||
transformHint = (transformHint + mPrimaryDisplayOrientation) % 4;
|
||||
}
|
||||
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) {
|
||||
displayContent.mWallpaperController.updateWallpaperOffset(win, false /* sync */);
|
||||
@@ -4874,6 +4884,9 @@ public class WindowManagerService extends IWindowManager.Stub
|
||||
mTaskSnapshotController.systemReady();
|
||||
mHasWideColorGamutSupport = queryWideColorGamutSupport();
|
||||
mHasHdrSupport = queryHdrSupport();
|
||||
mPrimaryDisplayOrientation = queryPrimaryDisplayOrientation();
|
||||
mPrimaryDisplayPhysicalAddress =
|
||||
DisplayAddress.fromPhysicalDisplayId(SurfaceControl.getPrimaryPhysicalDisplayId());
|
||||
UiThread.getHandler().post(mSettingsObserver::loadSettings);
|
||||
IVrManager vrManager = IVrManager.Stub.asInterface(
|
||||
ServiceManager.getService(Context.VR_SERVICE));
|
||||
@@ -4893,6 +4906,9 @@ public class WindowManagerService extends IWindowManager.Stub
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Keep logic in sync with SurfaceFlingerProperties.cpp
|
||||
// Consider exposing properties via ISurfaceComposer instead.
|
||||
private static boolean queryWideColorGamutSupport() {
|
||||
boolean defaultValue = false;
|
||||
Optional<Boolean> hasWideColorProp = SurfaceFlingerProperties.has_wide_color_display();
|
||||
@@ -4933,6 +4949,39 @@ public class WindowManagerService extends IWindowManager.Stub
|
||||
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) {
|
||||
WindowState lastFocus;
|
||||
WindowState newFocus;
|
||||
|
||||
Reference in New Issue
Block a user