DisplayManager: Add an API to query for DISPLAY_DECORATON

Tunnel through SurfaceControl to determine whether the HWC has this
capability. This allows clients (i.e. SystemUI) to know whether they can
use Composition.DISPLAY_DECORATON. If so, they may want to render
differently (i.e. in A8). See Ib948c38ee189877eda675a6342cb70099f66122b
for an example.

Bug: 193170859
Test: manual
Test: TODO
Change-Id: I9904452b6408199bb1f86de9e21132e4d4444e1a
This commit is contained in:
Leon Scroggins III
2021-12-29 11:21:39 -05:00
parent f02c47d86f
commit c66a2ac732
6 changed files with 73 additions and 0 deletions

View File

@@ -1205,6 +1205,17 @@ public final class DisplayManager {
mGlobal.setRefreshRateSwitchingType(newValue);
}
/**
* Returns whether the specified display supports DISPLAY_DECORATION.
*
* @param displayId The display to query support.
*
* @hide
*/
public boolean getDisplayDecorationSupport(int displayId) {
return mGlobal.getDisplayDecorationSupport(displayId);
}
/**
* Returns the user preference for "Match content frame rate".
* <p>

View File

@@ -811,6 +811,21 @@ public final class DisplayManagerGlobal {
}
}
/**
* Report whether the display supports DISPLAY_DECORATION.
*
* @param displayId The display whose support is being queried.
*
* @hide
*/
public boolean getDisplayDecorationSupport(int displayId) {
try {
return mDm.getDisplayDecorationSupport(displayId);
} catch (RemoteException ex) {
throw ex.rethrowFromSystemServer();
}
}
/**
* Gets the brightness of the display.
*

View File

@@ -180,4 +180,7 @@ interface IDisplayManager {
// Returns the refresh rate switching type.
int getRefreshRateSwitchingType();
// Query for DISPLAY_DECORATION support.
boolean getDisplayDecorationSupport(int displayId);
}

View File

@@ -231,6 +231,7 @@ public final class SurfaceControl implements Parcelable {
float shadowRadius);
private static native void nativeSetGlobalShadowSettings(@Size(4) float[] ambientColor,
@Size(4) float[] spotColor, float lightPosY, float lightPosZ, float lightRadius);
private static native boolean nativeGetDisplayDecorationSupport(IBinder displayToken);
private static native void nativeSetFrameRate(long transactionObj, long nativeObject,
float frameRate, int compatibility, int changeFrameRateStrategy);
@@ -2650,6 +2651,20 @@ public final class SurfaceControl implements Parcelable {
nativeSetGlobalShadowSettings(ambientColor, spotColor, lightPosY, lightPosZ, lightRadius);
}
/**
* Returns whether a display supports DISPLAY_DECORATION.
*
* @param displayToken
* The token for the display.
*
* @return Whether the display supports DISPLAY_DECORATION.
*
* @hide
*/
public static boolean getDisplayDecorationSupport(IBinder displayToken) {
return nativeGetDisplayDecorationSupport(displayToken);
}
/**
* Adds a callback to be informed about SF's jank classification for a specific surface.
* @hide

View File

@@ -1768,6 +1768,15 @@ static void nativeSetGlobalShadowSettings(JNIEnv* env, jclass clazz, jfloatArray
client->setGlobalShadowSettings(ambientColor, spotColor, lightPosY, lightPosZ, lightRadius);
}
static jboolean nativeGetDisplayDecorationSupport(JNIEnv* env, jclass clazz,
jobject displayTokenObject) {
sp<IBinder> displayToken(ibinderForJavaObject(env, displayTokenObject));
if (displayToken == nullptr) {
return JNI_FALSE;
}
return static_cast<jboolean>(SurfaceComposerClient::getDisplayDecorationSupport(displayToken));
}
static jlong nativeGetHandle(JNIEnv* env, jclass clazz, jlong nativeObject) {
SurfaceControl *surfaceControl = reinterpret_cast<SurfaceControl*>(nativeObject);
return reinterpret_cast<jlong>(surfaceControl->getHandle().get());
@@ -2092,6 +2101,8 @@ static const JNINativeMethod sSurfaceControlMethods[] = {
(void*)nativeMirrorSurface },
{"nativeSetGlobalShadowSettings", "([F[FFFF)V",
(void*)nativeSetGlobalShadowSettings },
{"nativeGetDisplayDecorationSupport", "(Landroid/os/IBinder;)Z",
(void*)nativeGetDisplayDecorationSupport},
{"nativeGetHandle", "(J)J",
(void*)nativeGetHandle },
{"nativeSetFixedTransformHint", "(JJI)V",

View File

@@ -1782,6 +1782,14 @@ public final class DisplayManagerService extends SystemService {
return mDisplayModeDirector.getModeSwitchingType();
}
private boolean getDisplayDecorationSupportInternal(int displayId) {
final IBinder displayToken = getDisplayToken(displayId);
if (null == displayToken) {
return false;
}
return SurfaceControl.getDisplayDecorationSupport(displayToken);
}
private void setBrightnessConfigurationForDisplayInternal(
@Nullable BrightnessConfiguration c, String uniqueId, @UserIdInt int userId,
String packageName) {
@@ -3442,6 +3450,16 @@ public final class DisplayManagerService extends SystemService {
Binder.restoreCallingIdentity(token);
}
}
@Override // Binder call
public boolean getDisplayDecorationSupport(int displayId) {
final long token = Binder.clearCallingIdentity();
try {
return getDisplayDecorationSupportInternal(displayId);
} finally {
Binder.restoreCallingIdentity(token);
}
}
}
private static boolean isValidBrightness(float brightness) {