Merge "DisplayManager: Add an API to query for DISPLAY_DECORATON"

This commit is contained in:
Leon Scroggins
2022-01-07 17:11:47 +00:00
committed by Android (Google) Code Review
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

@@ -1781,6 +1781,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) {
@@ -3441,6 +3449,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) {