Merge "Add Display.getPreferredWideGamutColorSpace()."
This commit is contained in:
@@ -48570,6 +48570,7 @@ package android.view {
|
||||
method public String getName();
|
||||
method @Deprecated public int getOrientation();
|
||||
method @Deprecated public int getPixelFormat();
|
||||
method @Nullable public android.graphics.ColorSpace getPreferredWideGamutColorSpace();
|
||||
method public long getPresentationDeadlineNanos();
|
||||
method public void getRealMetrics(android.util.DisplayMetrics);
|
||||
method public void getRealSize(android.graphics.Point);
|
||||
|
||||
@@ -20,6 +20,7 @@ import android.annotation.UnsupportedAppUsage;
|
||||
import android.content.Context;
|
||||
import android.content.pm.ParceledListSlice;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.ColorSpace;
|
||||
import android.graphics.Point;
|
||||
import android.hardware.display.DisplayManager.DisplayListener;
|
||||
import android.media.projection.IMediaProjection;
|
||||
@@ -80,12 +81,20 @@ public final class DisplayManagerGlobal {
|
||||
new ArrayList<DisplayListenerDelegate>();
|
||||
|
||||
private final SparseArray<DisplayInfo> mDisplayInfoCache = new SparseArray<DisplayInfo>();
|
||||
private final ColorSpace mWideColorSpace;
|
||||
private int[] mDisplayIdCache;
|
||||
|
||||
private int mWifiDisplayScanNestCount;
|
||||
|
||||
private DisplayManagerGlobal(IDisplayManager dm) {
|
||||
mDm = dm;
|
||||
try {
|
||||
mWideColorSpace =
|
||||
ColorSpace.get(
|
||||
ColorSpace.Named.values()[mDm.getPreferredWideGamutColorSpaceId()]);
|
||||
} catch (RemoteException ex) {
|
||||
throw ex.rethrowFromSystemServer();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -494,6 +503,17 @@ public final class DisplayManagerGlobal {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the preferred wide gamut color space for all displays.
|
||||
* The wide gamut color space is returned from composition pipeline
|
||||
* based on hardware capability.
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
public ColorSpace getPreferredWideGamutColorSpace() {
|
||||
return mWideColorSpace;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the global brightness configuration for a given user.
|
||||
*
|
||||
|
||||
@@ -116,4 +116,9 @@ interface IDisplayManager {
|
||||
|
||||
// Get the minimum brightness curve.
|
||||
Curve getMinimumBrightnessCurve();
|
||||
|
||||
// Gets the id of the preferred wide gamut color space for all displays.
|
||||
// The wide gamut color space is returned from composition pipeline
|
||||
// based on hardware capability.
|
||||
int getPreferredWideGamutColorSpaceId();
|
||||
}
|
||||
|
||||
@@ -26,6 +26,7 @@ import android.app.KeyguardManager;
|
||||
import android.content.res.CompatibilityInfo;
|
||||
import android.content.res.Configuration;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.ColorSpace;
|
||||
import android.graphics.PixelFormat;
|
||||
import android.graphics.Point;
|
||||
import android.graphics.Rect;
|
||||
@@ -952,6 +953,24 @@ public final class Display {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the preferred wide color space of the Display.
|
||||
* The returned wide gamut color space is based on hardware capability and
|
||||
* is preferred by the composition pipeline.
|
||||
* Returns null if the display doesn't support wide color gamut.
|
||||
* {@link Display#isWideColorGamut()}.
|
||||
*/
|
||||
@Nullable
|
||||
public ColorSpace getPreferredWideGamutColorSpace() {
|
||||
synchronized (this) {
|
||||
updateDisplayInfoLocked();
|
||||
if (mDisplayInfo.isWideColorGamut()) {
|
||||
return mGlobal.getPreferredWideGamutColorSpace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the supported color modes of this device.
|
||||
* @hide
|
||||
|
||||
@@ -36,6 +36,7 @@ import android.content.pm.PackageManager;
|
||||
import android.content.pm.ParceledListSlice;
|
||||
import android.content.res.Resources;
|
||||
import android.content.res.TypedArray;
|
||||
import android.graphics.ColorSpace;
|
||||
import android.graphics.Point;
|
||||
import android.hardware.SensorManager;
|
||||
import android.hardware.display.AmbientBrightnessDayStats;
|
||||
@@ -93,9 +94,9 @@ import com.android.server.DisplayThread;
|
||||
import com.android.server.LocalServices;
|
||||
import com.android.server.SystemService;
|
||||
import com.android.server.UiThread;
|
||||
import com.android.server.display.ColorDisplayService.ColorDisplayServiceInternal;
|
||||
import com.android.server.wm.SurfaceAnimationThread;
|
||||
import com.android.server.wm.WindowManagerInternal;
|
||||
import com.android.server.display.ColorDisplayService.ColorDisplayServiceInternal;
|
||||
|
||||
import java.io.FileDescriptor;
|
||||
import java.io.PrintWriter;
|
||||
@@ -294,6 +295,7 @@ public final class DisplayManagerService extends SystemService {
|
||||
// is rejected by the system.
|
||||
private final Curve mMinimumBrightnessCurve;
|
||||
private final Spline mMinimumBrightnessSpline;
|
||||
private final ColorSpace mWideColorSpace;
|
||||
|
||||
public DisplayManagerService(Context context) {
|
||||
this(context, new Injector());
|
||||
@@ -322,6 +324,8 @@ public final class DisplayManagerService extends SystemService {
|
||||
PowerManager pm = (PowerManager) mContext.getSystemService(Context.POWER_SERVICE);
|
||||
mGlobalDisplayBrightness = pm.getDefaultScreenBrightnessSetting();
|
||||
mCurrentUserId = UserHandle.USER_SYSTEM;
|
||||
ColorSpace[] colorSpaces = SurfaceControl.getCompositionColorSpaces();
|
||||
mWideColorSpace = colorSpaces[1];
|
||||
}
|
||||
|
||||
public void setupSchedulerPolicies() {
|
||||
@@ -1073,6 +1077,10 @@ public final class DisplayManagerService extends SystemService {
|
||||
return mMinimumBrightnessCurve;
|
||||
}
|
||||
|
||||
int getPreferredWideGamutColorSpaceIdInternal() {
|
||||
return mWideColorSpace.getId();
|
||||
}
|
||||
|
||||
private void setBrightnessConfigurationForUserInternal(
|
||||
@Nullable BrightnessConfiguration c, @UserIdInt int userId,
|
||||
@Nullable String packageName) {
|
||||
@@ -2128,6 +2136,16 @@ public final class DisplayManagerService extends SystemService {
|
||||
}
|
||||
}
|
||||
|
||||
@Override // Binder call
|
||||
public int getPreferredWideGamutColorSpaceId() {
|
||||
final long token = Binder.clearCallingIdentity();
|
||||
try {
|
||||
return getPreferredWideGamutColorSpaceIdInternal();
|
||||
} finally {
|
||||
Binder.restoreCallingIdentity(token);
|
||||
}
|
||||
}
|
||||
|
||||
void setBrightness(int brightness) {
|
||||
Settings.System.putIntForUser(mContext.getContentResolver(),
|
||||
Settings.System.SCREEN_BRIGHTNESS, brightness, UserHandle.USER_CURRENT);
|
||||
|
||||
Reference in New Issue
Block a user