Merge "Add config.xml fallback in DisplayDeviceConfig"
This commit is contained in:
committed by
Android (Google) Code Review
commit
7adce7f6d9
@@ -686,6 +686,19 @@ public final class Display {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the default brightness configured for the display.
|
||||
*
|
||||
* @return Default brightness between 0.0-1.0
|
||||
* @hide
|
||||
*/
|
||||
public float getBrightnessDefault() {
|
||||
synchronized (this) {
|
||||
updateDisplayInfoLocked();
|
||||
return mDisplayInfo.brightnessDefault;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the size of the display, in pixels.
|
||||
* Value returned by this method does not necessarily represent the actual raw size
|
||||
|
||||
@@ -275,6 +275,27 @@ public final class DisplayInfo implements Parcelable {
|
||||
// TODO (b/114338689): Remove the flag and use IWindowManager#getRemoveContentMode
|
||||
public int removeMode = Display.REMOVE_MODE_MOVE_CONTENT_TO_PRIMARY;
|
||||
|
||||
/**
|
||||
* @hide
|
||||
* The current minimum brightness constraint of the display. Value between 0.0 and 1.0,
|
||||
* derived from the config constraints of the display device of this logical display.
|
||||
*/
|
||||
public float brightnessMinimum;
|
||||
|
||||
/**
|
||||
* @hide
|
||||
* The current maximum brightness constraint of the display. Value between 0.0 and 1.0,
|
||||
* derived from the config constraints of the display device of this logical display.
|
||||
*/
|
||||
public float brightnessMaximum;
|
||||
|
||||
/**
|
||||
* @hide
|
||||
* The current default brightness of the display. Value between 0.0 and 1.0,
|
||||
* derived from the configuration of the display device of this logical display.
|
||||
*/
|
||||
public float brightnessDefault;
|
||||
|
||||
public static final @android.annotation.NonNull Creator<DisplayInfo> CREATOR = new Creator<DisplayInfo>() {
|
||||
@Override
|
||||
public DisplayInfo createFromParcel(Parcel source) {
|
||||
@@ -339,7 +360,10 @@ public final class DisplayInfo implements Parcelable {
|
||||
&& ownerUid == other.ownerUid
|
||||
&& Objects.equals(ownerPackageName, other.ownerPackageName)
|
||||
&& removeMode == other.removeMode
|
||||
&& refreshRateOverride == other.refreshRateOverride;
|
||||
&& refreshRateOverride == other.refreshRateOverride
|
||||
&& brightnessMinimum == other.brightnessMinimum
|
||||
&& brightnessMaximum == other.brightnessMaximum
|
||||
&& brightnessDefault == other.brightnessDefault;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -384,6 +408,9 @@ public final class DisplayInfo implements Parcelable {
|
||||
ownerPackageName = other.ownerPackageName;
|
||||
removeMode = other.removeMode;
|
||||
refreshRateOverride = other.refreshRateOverride;
|
||||
brightnessMinimum = other.brightnessMinimum;
|
||||
brightnessMaximum = other.brightnessMaximum;
|
||||
brightnessDefault = other.brightnessDefault;
|
||||
}
|
||||
|
||||
public void readFromParcel(Parcel source) {
|
||||
@@ -430,6 +457,9 @@ public final class DisplayInfo implements Parcelable {
|
||||
uniqueId = source.readString8();
|
||||
removeMode = source.readInt();
|
||||
refreshRateOverride = source.readFloat();
|
||||
brightnessMinimum = source.readFloat();
|
||||
brightnessMaximum = source.readFloat();
|
||||
brightnessDefault = source.readFloat();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -475,6 +505,9 @@ public final class DisplayInfo implements Parcelable {
|
||||
dest.writeString8(uniqueId);
|
||||
dest.writeInt(removeMode);
|
||||
dest.writeFloat(refreshRateOverride);
|
||||
dest.writeFloat(brightnessMinimum);
|
||||
dest.writeFloat(brightnessMaximum);
|
||||
dest.writeFloat(brightnessDefault);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -698,7 +731,12 @@ public final class DisplayInfo implements Parcelable {
|
||||
sb.append(removeMode);
|
||||
sb.append(", refreshRateOverride ");
|
||||
sb.append(refreshRateOverride);
|
||||
|
||||
sb.append(", brightnessMinimum ");
|
||||
sb.append(brightnessMinimum);
|
||||
sb.append(", brightnessMaximum ");
|
||||
sb.append(brightnessMaximum);
|
||||
sb.append(", brightnessDefault ");
|
||||
sb.append(brightnessDefault);
|
||||
sb.append("}");
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
@@ -26,6 +26,7 @@ import android.content.res.TypedArray;
|
||||
import android.graphics.PixelFormat;
|
||||
import android.graphics.Point;
|
||||
import android.graphics.RectF;
|
||||
import android.hardware.display.DisplayManager;
|
||||
import android.hardware.fingerprint.FingerprintManager;
|
||||
import android.hardware.fingerprint.FingerprintSensorPropertiesInternal;
|
||||
import android.hardware.fingerprint.IUdfpsOverlayController;
|
||||
@@ -166,7 +167,7 @@ class UdfpsController implements DozeReceiver {
|
||||
@Main Resources resources,
|
||||
LayoutInflater inflater,
|
||||
@Nullable FingerprintManager fingerprintManager,
|
||||
PowerManager powerManager,
|
||||
DisplayManager displayManager,
|
||||
WindowManager windowManager,
|
||||
SystemSettings systemSettings,
|
||||
@NonNull StatusBarStateController statusBarStateController,
|
||||
@@ -246,7 +247,7 @@ class UdfpsController implements DozeReceiver {
|
||||
|
||||
mBacklightToNitsSpline = Spline.createSpline(normalizedBacklightRange, nitsRange);
|
||||
mNitsToHbmBacklightSpline = Spline.createSpline(hbmNitsRange, normalizedBacklightRange);
|
||||
mDefaultBrightness = obtainDefaultBrightness(powerManager);
|
||||
mDefaultBrightness = obtainDefaultBrightness(mContext);
|
||||
|
||||
// TODO(b/160025856): move to the "dump" method.
|
||||
Log.v(TAG, String.format("ctor | mNitsRange: [%f, %f]", nitsRange[0],
|
||||
@@ -450,14 +451,9 @@ class UdfpsController implements DozeReceiver {
|
||||
}
|
||||
}
|
||||
|
||||
private static float obtainDefaultBrightness(PowerManager powerManager) {
|
||||
if (powerManager == null) {
|
||||
Log.e(TAG, "PowerManager is unavailable. Can't obtain default brightness.");
|
||||
return 0f;
|
||||
}
|
||||
return MathUtils.constrain(powerManager.getBrightnessConstraint(
|
||||
PowerManager.BRIGHTNESS_CONSTRAINT_TYPE_DEFAULT), PowerManager.BRIGHTNESS_MIN,
|
||||
PowerManager.BRIGHTNESS_MAX);
|
||||
private static float obtainDefaultBrightness(Context context) {
|
||||
return MathUtils.constrain(context.getDisplay().getBrightnessDefault(),
|
||||
PowerManager.BRIGHTNESS_MIN, PowerManager.BRIGHTNESS_MAX);
|
||||
}
|
||||
|
||||
private static float[] toFloatArray(TypedArray array) {
|
||||
|
||||
@@ -316,8 +316,7 @@ public class BrightnessController implements ToggleSlider.Listener {
|
||||
PowerManager.BRIGHTNESS_CONSTRAINT_TYPE_MINIMUM);
|
||||
mMaximumBacklight = pm.getBrightnessConstraint(
|
||||
PowerManager.BRIGHTNESS_CONSTRAINT_TYPE_MAXIMUM);
|
||||
mDefaultBacklight = pm.getBrightnessConstraint(
|
||||
PowerManager.BRIGHTNESS_CONSTRAINT_TYPE_DEFAULT);
|
||||
mDefaultBacklight = mContext.getDisplay().getBrightnessDefault();
|
||||
mMinimumBacklightForVr = pm.getBrightnessConstraint(
|
||||
PowerManager.BRIGHTNESS_CONSTRAINT_TYPE_MINIMUM_VR);
|
||||
mMaximumBacklightForVr = pm.getBrightnessConstraint(
|
||||
|
||||
@@ -27,6 +27,7 @@ import static org.mockito.Mockito.when;
|
||||
import android.content.res.Resources;
|
||||
import android.content.res.TypedArray;
|
||||
import android.hardware.biometrics.SensorProperties;
|
||||
import android.hardware.display.DisplayManager;
|
||||
import android.hardware.fingerprint.FingerprintManager;
|
||||
import android.hardware.fingerprint.FingerprintSensorProperties;
|
||||
import android.hardware.fingerprint.FingerprintSensorPropertiesInternal;
|
||||
@@ -84,7 +85,7 @@ public class UdfpsControllerTest extends SysuiTestCase {
|
||||
@Mock
|
||||
private FingerprintManager mFingerprintManager;
|
||||
@Mock
|
||||
private PowerManager mPowerManager;
|
||||
private DisplayManager mDisplayManager;
|
||||
@Mock
|
||||
private WindowManager mWindowManager;
|
||||
@Mock
|
||||
@@ -124,7 +125,7 @@ public class UdfpsControllerTest extends SysuiTestCase {
|
||||
mResources,
|
||||
mLayoutInflater,
|
||||
mFingerprintManager,
|
||||
mPowerManager,
|
||||
mDisplayManager,
|
||||
mWindowManager,
|
||||
mSystemSettings,
|
||||
mStatusBarStateController,
|
||||
|
||||
@@ -16,10 +16,13 @@
|
||||
|
||||
package com.android.server.display;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Environment;
|
||||
import android.os.PowerManager;
|
||||
import android.util.Slog;
|
||||
import android.view.DisplayAddress;
|
||||
|
||||
import com.android.internal.BrightnessSynchronizer;
|
||||
import com.android.server.display.config.DisplayConfiguration;
|
||||
import com.android.server.display.config.DisplayQuirks;
|
||||
import com.android.server.display.config.NitsMap;
|
||||
@@ -33,6 +36,7 @@ import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
@@ -49,6 +53,7 @@ public class DisplayDeviceConfig {
|
||||
|
||||
public static final String QUIRK_CAN_SET_BRIGHTNESS_VIA_HWC = "canSetBrightnessViaHwc";
|
||||
|
||||
private static final float BRIGHTNESS_DEFAULT = 0.5f;
|
||||
private static final String ETC_DIR = "etc";
|
||||
private static final String DISPLAY_CONFIG_DIR = "displayconfig";
|
||||
private static final String CONFIG_FILE_FORMAT = "display_%s.xml";
|
||||
@@ -57,11 +62,21 @@ public class DisplayDeviceConfig {
|
||||
private static final String NO_SUFFIX_FORMAT = "%d";
|
||||
private static final long STABLE_FLAG = 1L << 62;
|
||||
|
||||
// Float.NaN (used as invalid for brightness) cannot be stored in config.xml
|
||||
// so -2 is used instead
|
||||
private static final float INVALID_BRIGHTNESS_IN_CONFIG = -2f;
|
||||
|
||||
private float[] mNits;
|
||||
private float[] mBrightness;
|
||||
private float mBrightnessMinimum = Float.NaN;
|
||||
private float mBrightnessMaximum = Float.NaN;
|
||||
private float mBrightnessDefault = Float.NaN;
|
||||
private List<String> mQuirks;
|
||||
|
||||
private DisplayDeviceConfig() {
|
||||
private final Context mContext;
|
||||
|
||||
private DisplayDeviceConfig(Context context) {
|
||||
mContext = context;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -72,37 +87,50 @@ public class DisplayDeviceConfig {
|
||||
* <li>physicalDisplayId without a stable flag (old system)</li>
|
||||
* <li>portId</li>
|
||||
* </ol>
|
||||
*
|
||||
* @param physicalDisplayId The display ID for which to load the configuration.
|
||||
* @return A configuration instance for the specified display.
|
||||
*/
|
||||
public static DisplayDeviceConfig create(long physicalDisplayId) {
|
||||
public static DisplayDeviceConfig create(Context context, long physicalDisplayId,
|
||||
boolean isDefaultDisplay) {
|
||||
DisplayDeviceConfig config;
|
||||
|
||||
config = loadConfigFromDirectory(Environment.getProductDirectory(), physicalDisplayId);
|
||||
config = loadConfigFromDirectory(context, Environment.getProductDirectory(),
|
||||
physicalDisplayId);
|
||||
if (config != null) {
|
||||
return config;
|
||||
}
|
||||
|
||||
config = loadConfigFromDirectory(Environment.getVendorDirectory(), physicalDisplayId);
|
||||
config = loadConfigFromDirectory(context, Environment.getVendorDirectory(),
|
||||
physicalDisplayId);
|
||||
if (config != null) {
|
||||
return config;
|
||||
}
|
||||
|
||||
return null;
|
||||
// If no config can be loaded from any ddc xml at all,
|
||||
// prepare a whole config using the global config.xml.
|
||||
// Guaranteed not null
|
||||
if (isDefaultDisplay) {
|
||||
config = getConfigFromGlobalXml(context);
|
||||
} else {
|
||||
config = getConfigFromPmValues(context);
|
||||
}
|
||||
return config;
|
||||
}
|
||||
|
||||
private static DisplayDeviceConfig loadConfigFromDirectory(
|
||||
private static DisplayDeviceConfig loadConfigFromDirectory(Context context,
|
||||
File baseDirectory, long physicalDisplayId) {
|
||||
DisplayDeviceConfig config;
|
||||
// Create config using filename from physical ID (including "stable" bit).
|
||||
config = getConfigFromSuffix(baseDirectory, STABLE_ID_SUFFIX_FORMAT, physicalDisplayId);
|
||||
config = getConfigFromSuffix(context, baseDirectory, STABLE_ID_SUFFIX_FORMAT,
|
||||
physicalDisplayId);
|
||||
if (config != null) {
|
||||
return config;
|
||||
}
|
||||
|
||||
// Create config using filename from physical ID (excluding "stable" bit).
|
||||
final long withoutStableFlag = physicalDisplayId & ~STABLE_FLAG;
|
||||
config = getConfigFromSuffix(baseDirectory, NO_SUFFIX_FORMAT, withoutStableFlag);
|
||||
config = getConfigFromSuffix(context, baseDirectory, NO_SUFFIX_FORMAT, withoutStableFlag);
|
||||
if (config != null) {
|
||||
return config;
|
||||
}
|
||||
@@ -111,14 +139,8 @@ public class DisplayDeviceConfig {
|
||||
final DisplayAddress.Physical physicalAddress =
|
||||
DisplayAddress.fromPhysicalDisplayId(physicalDisplayId);
|
||||
int port = physicalAddress.getPort();
|
||||
config = getConfigFromSuffix(baseDirectory, PORT_SUFFIX_FORMAT, port);
|
||||
if (config != null) {
|
||||
return config;
|
||||
}
|
||||
|
||||
// None of these files exist.
|
||||
return null;
|
||||
|
||||
config = getConfigFromSuffix(context, baseDirectory, PORT_SUFFIX_FORMAT, port);
|
||||
return config;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -139,6 +161,18 @@ public class DisplayDeviceConfig {
|
||||
return mBrightness;
|
||||
}
|
||||
|
||||
public float getBrightnessMinimum() {
|
||||
return mBrightnessMinimum;
|
||||
}
|
||||
|
||||
public float getBrightnessMaximum() {
|
||||
return mBrightnessMaximum;
|
||||
}
|
||||
|
||||
public float getBrightnessDefault() {
|
||||
return mBrightnessDefault;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param quirkValue The quirk to test.
|
||||
* @return {@code true} if the specified quirk is present in this configuration,
|
||||
@@ -153,12 +187,15 @@ public class DisplayDeviceConfig {
|
||||
String str = "DisplayDeviceConfig{"
|
||||
+ "mBrightness=" + Arrays.toString(mBrightness)
|
||||
+ ", mNits=" + Arrays.toString(mNits)
|
||||
+ ", mBrightnessMinimum=" + mBrightnessMinimum
|
||||
+ ", mBrightnessMaximum=" + mBrightnessMaximum
|
||||
+ ", mBrightnessDefault=" + mBrightnessDefault
|
||||
+ ", mQuirks=" + mQuirks
|
||||
+ "}";
|
||||
return str;
|
||||
}
|
||||
|
||||
private static DisplayDeviceConfig getConfigFromSuffix(File baseDirectory,
|
||||
private static DisplayDeviceConfig getConfigFromSuffix(Context context, File baseDirectory,
|
||||
String suffixFormat, long idNumber) {
|
||||
|
||||
final String suffix = String.format(suffixFormat, idNumber);
|
||||
@@ -167,13 +204,25 @@ public class DisplayDeviceConfig {
|
||||
baseDirectory, ETC_DIR, DISPLAY_CONFIG_DIR, filename);
|
||||
|
||||
if (filePath.exists()) {
|
||||
final DisplayDeviceConfig config = new DisplayDeviceConfig();
|
||||
final DisplayDeviceConfig config = new DisplayDeviceConfig(context);
|
||||
config.initFromFile(filePath);
|
||||
return config;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static DisplayDeviceConfig getConfigFromGlobalXml(Context context) {
|
||||
DisplayDeviceConfig config = new DisplayDeviceConfig(context);
|
||||
config.initFromGlobalXml();
|
||||
return config;
|
||||
}
|
||||
|
||||
private static DisplayDeviceConfig getConfigFromPmValues(Context context) {
|
||||
DisplayDeviceConfig config = new DisplayDeviceConfig(context);
|
||||
config.initFromPmValues();
|
||||
return config;
|
||||
}
|
||||
|
||||
private void initFromFile(File configFile) {
|
||||
if (!configFile.exists()) {
|
||||
// Display configuration files aren't required to exist.
|
||||
@@ -187,16 +236,87 @@ public class DisplayDeviceConfig {
|
||||
|
||||
try (InputStream in = new BufferedInputStream(new FileInputStream(configFile))) {
|
||||
final DisplayConfiguration config = XmlParser.read(in);
|
||||
loadBrightnessMap(config);
|
||||
loadQuirks(config);
|
||||
if (config != null) {
|
||||
loadBrightnessMap(config);
|
||||
loadBrightnessDefaultFromDdcXml(config);
|
||||
loadBrightnessConstraintsFromConfigXml();
|
||||
loadQuirks(config);
|
||||
} else {
|
||||
Slog.w(TAG, "DisplayDeviceConfig file is null");
|
||||
}
|
||||
} catch (IOException | DatatypeConfigurationException | XmlPullParserException e) {
|
||||
Slog.e(TAG, "Encountered an error while reading/parsing display config file: "
|
||||
+ configFile, e);
|
||||
}
|
||||
}
|
||||
|
||||
private void initFromGlobalXml() {
|
||||
// If no ddc exists, use config.xml
|
||||
loadBrightnessDefaultFromConfigXml();
|
||||
loadBrightnessConstraintsFromConfigXml();
|
||||
}
|
||||
|
||||
private void initFromPmValues() {
|
||||
mBrightnessMinimum = PowerManager.BRIGHTNESS_MIN;
|
||||
mBrightnessMaximum = PowerManager.BRIGHTNESS_MAX;
|
||||
mBrightnessDefault = BRIGHTNESS_DEFAULT;
|
||||
}
|
||||
|
||||
private void loadBrightnessDefaultFromDdcXml(DisplayConfiguration config) {
|
||||
// Default brightness values are stored in the displayDeviceConfig file,
|
||||
// Or we fallback standard values if not.
|
||||
// Priority 1: Value in the displayDeviceConfig
|
||||
// Priority 2: Value in the config.xml (float)
|
||||
// Priority 3: Value in the config.xml (int)
|
||||
if (config != null) {
|
||||
BigDecimal configBrightnessDefault = config.getScreenBrightnessDefault();
|
||||
if (configBrightnessDefault != null) {
|
||||
mBrightnessDefault = configBrightnessDefault.floatValue();
|
||||
} else {
|
||||
mBrightnessDefault = BRIGHTNESS_DEFAULT;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void loadBrightnessDefaultFromConfigXml() {
|
||||
// Priority 1: Value in the config.xml (float)
|
||||
// Priority 2: Value in the config.xml (int)
|
||||
final float def = mContext.getResources().getFloat(com.android.internal.R.dimen
|
||||
.config_screenBrightnessSettingDefaultFloat);
|
||||
if (def == INVALID_BRIGHTNESS_IN_CONFIG) {
|
||||
mBrightnessDefault = BrightnessSynchronizer.brightnessIntToFloat(
|
||||
mContext.getResources().getInteger(com.android.internal.R.integer
|
||||
.config_screenBrightnessSettingDefault));
|
||||
} else {
|
||||
mBrightnessDefault = def;
|
||||
}
|
||||
}
|
||||
|
||||
private void loadBrightnessConstraintsFromConfigXml() {
|
||||
// TODO(b/175373898) add constraints (min / max) to ddc.
|
||||
final float min = mContext.getResources().getFloat(com.android.internal.R.dimen
|
||||
.config_screenBrightnessSettingMinimumFloat);
|
||||
final float max = mContext.getResources().getFloat(com.android.internal.R.dimen
|
||||
.config_screenBrightnessSettingMaximumFloat);
|
||||
if (min == INVALID_BRIGHTNESS_IN_CONFIG || max == INVALID_BRIGHTNESS_IN_CONFIG) {
|
||||
mBrightnessMinimum = BrightnessSynchronizer.brightnessIntToFloat(
|
||||
mContext.getResources().getInteger(com.android.internal.R.integer
|
||||
.config_screenBrightnessSettingMinimum));
|
||||
mBrightnessMaximum = BrightnessSynchronizer.brightnessIntToFloat(
|
||||
mContext.getResources().getInteger(com.android.internal.R.integer
|
||||
.config_screenBrightnessSettingMaximum));
|
||||
} else {
|
||||
mBrightnessMinimum = min;
|
||||
mBrightnessMaximum = max;
|
||||
}
|
||||
}
|
||||
|
||||
private void loadBrightnessMap(DisplayConfiguration config) {
|
||||
final NitsMap map = config.getScreenBrightnessMap();
|
||||
// Map may not exist in config file
|
||||
if (map == null) {
|
||||
return;
|
||||
}
|
||||
final List<Point> points = map.getPoint();
|
||||
final int size = points.size();
|
||||
|
||||
|
||||
@@ -25,6 +25,8 @@ import android.view.DisplayCutout;
|
||||
import android.view.DisplayEventReceiver;
|
||||
import android.view.Surface;
|
||||
|
||||
import com.android.internal.BrightnessSynchronizer;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Objects;
|
||||
|
||||
@@ -337,6 +339,10 @@ final class DisplayDeviceInfo {
|
||||
public DisplayEventReceiver.FrameRateOverride[] frameRateOverrides =
|
||||
new DisplayEventReceiver.FrameRateOverride[0];
|
||||
|
||||
public float brightnessMinimum;
|
||||
public float brightnessMaximum;
|
||||
public float brightnessDefault;
|
||||
|
||||
public void setAssumedDensityForExternalDisplay(int width, int height) {
|
||||
densityDpi = Math.min(width, height) * DisplayMetrics.DENSITY_XHIGH / 1080;
|
||||
// Technically, these values should be smaller than the apparent density
|
||||
@@ -391,7 +397,11 @@ final class DisplayDeviceInfo {
|
||||
|| !Objects.equals(deviceProductInfo, other.deviceProductInfo)
|
||||
|| ownerUid != other.ownerUid
|
||||
|| !Objects.equals(ownerPackageName, other.ownerPackageName)
|
||||
|| !Objects.equals(frameRateOverrides, other.frameRateOverrides)) {
|
||||
|| !Objects.equals(frameRateOverrides, other.frameRateOverrides)
|
||||
|| !BrightnessSynchronizer.floatEquals(brightnessMinimum, other.brightnessMinimum)
|
||||
|| !BrightnessSynchronizer.floatEquals(brightnessMaximum, other.brightnessMaximum)
|
||||
|| !BrightnessSynchronizer.floatEquals(brightnessDefault,
|
||||
other.brightnessDefault)) {
|
||||
diff |= DIFF_OTHER;
|
||||
}
|
||||
return diff;
|
||||
@@ -431,6 +441,9 @@ final class DisplayDeviceInfo {
|
||||
ownerUid = other.ownerUid;
|
||||
ownerPackageName = other.ownerPackageName;
|
||||
frameRateOverrides = other.frameRateOverrides;
|
||||
brightnessMinimum = other.brightnessMinimum;
|
||||
brightnessMaximum = other.brightnessMaximum;
|
||||
brightnessDefault = other.brightnessDefault;
|
||||
}
|
||||
|
||||
// For debugging purposes
|
||||
@@ -471,6 +484,9 @@ final class DisplayDeviceInfo {
|
||||
for (DisplayEventReceiver.FrameRateOverride frameRateOverride : frameRateOverrides) {
|
||||
sb.append(frameRateOverride).append(" ");
|
||||
}
|
||||
sb.append(", brightnessMinimum ").append(brightnessMinimum);
|
||||
sb.append(", brightnessMaximum ").append(brightnessMaximum);
|
||||
sb.append(", brightnessDefault ").append(brightnessDefault);
|
||||
sb.append(flagsToString(flags));
|
||||
sb.append("}");
|
||||
return sb.toString();
|
||||
|
||||
@@ -288,9 +288,6 @@ public final class DisplayManagerService extends SystemService {
|
||||
@GuardedBy("mSyncRoot")
|
||||
private final SparseArray<Float> mDisplayBrightnesses = new SparseArray<>();
|
||||
|
||||
// The default brightness.
|
||||
private final float mDisplayDefaultBrightness;
|
||||
|
||||
// Set to true when there are pending display changes that have yet to be applied
|
||||
// to the surface flinger state.
|
||||
private boolean mPendingTraversal;
|
||||
@@ -416,9 +413,6 @@ public final class DisplayManagerService extends SystemService {
|
||||
mMinimumBrightnessCurve = new Curve(lux, nits);
|
||||
mMinimumBrightnessSpline = Spline.createSpline(lux, nits);
|
||||
|
||||
PowerManager pm = mContext.getSystemService(PowerManager.class);
|
||||
mDisplayDefaultBrightness = pm.getBrightnessConstraint(
|
||||
PowerManager.BRIGHTNESS_CONSTRAINT_TYPE_DEFAULT);
|
||||
mCurrentUserId = UserHandle.USER_SYSTEM;
|
||||
ColorSpace[] colorSpaces = SurfaceControl.getCompositionColorSpaces();
|
||||
mWideColorSpace = colorSpaces[1];
|
||||
@@ -1108,7 +1102,7 @@ public final class DisplayManagerService extends SystemService {
|
||||
}
|
||||
addDisplayPowerControllerLocked(displayId);
|
||||
mDisplayStates.append(displayId, Display.STATE_OFF);
|
||||
mDisplayBrightnesses.append(displayId, mDisplayDefaultBrightness);
|
||||
mDisplayBrightnesses.append(displayId, display.getDisplayInfoLocked().brightnessDefault);
|
||||
|
||||
DisplayManagerGlobal.invalidateLocalDisplayInfoCaches();
|
||||
|
||||
@@ -1876,7 +1870,7 @@ public final class DisplayManagerService extends SystemService {
|
||||
}
|
||||
final DisplayPowerController displayPowerController = new DisplayPowerController(
|
||||
mContext, mDisplayPowerCallbacks, mPowerHandler, mSensorManager,
|
||||
mDisplayBlanker, displayId);
|
||||
mDisplayBlanker, mLogicalDisplayMapper.getLocked(displayId));
|
||||
mDisplayPowerControllers.append(displayId, displayPowerController);
|
||||
}
|
||||
|
||||
|
||||
@@ -163,6 +163,9 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
|
||||
// The display blanker.
|
||||
private final DisplayBlanker mBlanker;
|
||||
|
||||
// The LogicalDisplay tied to this DisplayPowerController.
|
||||
private final LogicalDisplay mLogicalDisplay;
|
||||
|
||||
// The ID of the LogicalDisplay tied to this DisplayPowerController.
|
||||
private final int mDisplayId;
|
||||
|
||||
@@ -406,7 +409,7 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
|
||||
*/
|
||||
public DisplayPowerController(Context context,
|
||||
DisplayPowerCallbacks callbacks, Handler handler,
|
||||
SensorManager sensorManager, DisplayBlanker blanker, int displayId) {
|
||||
SensorManager sensorManager, DisplayBlanker blanker, LogicalDisplay logicalDisplay) {
|
||||
mHandler = new DisplayControllerHandler(handler.getLooper());
|
||||
mBrightnessTracker = new BrightnessTracker(context, null);
|
||||
mSettingsObserver = new SettingsObserver(mHandler);
|
||||
@@ -418,9 +421,10 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
|
||||
mContext = context;
|
||||
mBrightnessSynchronizer = new BrightnessSynchronizer(context);
|
||||
mBrightnessSynchronizer.startSynchronizing();
|
||||
mDisplayId = displayId;
|
||||
mLogicalDisplay = logicalDisplay;
|
||||
mDisplayId = mLogicalDisplay.getDisplayIdLocked();
|
||||
|
||||
PowerManager pm = context.getSystemService(PowerManager.class);
|
||||
PowerManager pm = context.getSystemService(PowerManager.class);
|
||||
|
||||
final Resources resources = context.getResources();
|
||||
|
||||
@@ -439,7 +443,7 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
|
||||
mScreenBrightnessRangeMaximum = clampAbsoluteBrightness(
|
||||
pm.getBrightnessConstraint(PowerManager.BRIGHTNESS_CONSTRAINT_TYPE_MAXIMUM));
|
||||
mScreenBrightnessDefault = clampAbsoluteBrightness(
|
||||
pm.getBrightnessConstraint(PowerManager.BRIGHTNESS_CONSTRAINT_TYPE_DEFAULT));
|
||||
mLogicalDisplay.getDisplayInfoLocked().brightnessDefault);
|
||||
|
||||
// VR SETTINGS
|
||||
mScreenBrightnessForVrDefault = clampAbsoluteBrightness(
|
||||
@@ -1833,6 +1837,9 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
|
||||
|
||||
pw.println();
|
||||
pw.println("Display Power Controller Configuration:");
|
||||
pw.println(" mScreenBrightnessRangeMinimum=" + mScreenBrightnessRangeMinimum);
|
||||
pw.println(" mScreenBrightnessRangeMaximum=" + mScreenBrightnessRangeMaximum);
|
||||
pw.println(" mScreenBrightnessRangeDefault=" + mScreenBrightnessDefault);
|
||||
pw.println(" mScreenBrightnessDozeConfig=" + mScreenBrightnessDozeConfig);
|
||||
pw.println(" mScreenBrightnessDimConfig=" + mScreenBrightnessDimConfig);
|
||||
pw.println(" mScreenBrightnessDefault=" + mScreenBrightnessDefault);
|
||||
|
||||
@@ -415,7 +415,9 @@ final class LocalDisplayAdapter extends DisplayAdapter {
|
||||
Spline sysToNits = null;
|
||||
|
||||
// Load the mapping from nits to HAL brightness range (display-device-config.xml)
|
||||
mDisplayDeviceConfig = DisplayDeviceConfig.create(mPhysicalDisplayId);
|
||||
final Context context = getOverlayContext();
|
||||
mDisplayDeviceConfig = DisplayDeviceConfig.create(context, mPhysicalDisplayId,
|
||||
mIsDefaultDisplay);
|
||||
if (mDisplayDeviceConfig == null) {
|
||||
return;
|
||||
}
|
||||
@@ -431,9 +433,9 @@ final class LocalDisplayAdapter extends DisplayAdapter {
|
||||
nitsToHal = Spline.createSpline(halNits, halBrightness);
|
||||
|
||||
// Load the mapping from system brightness range to nits (config.xml)
|
||||
final Resources res = getOverlayContext().getResources();
|
||||
final Resources res = context.getResources();
|
||||
final float[] sysNits = BrightnessMappingStrategy.getFloatArray(res.obtainTypedArray(
|
||||
com.android.internal.R.array.config_screenBrightnessNits));
|
||||
com.android.internal.R.array.config_screenBrightnessNits));
|
||||
final int[] sysBrightness = res.getIntArray(
|
||||
com.android.internal.R.array.config_screenBrightnessBacklight);
|
||||
if (sysNits.length == 0 || sysBrightness.length != sysNits.length) {
|
||||
@@ -630,6 +632,15 @@ final class LocalDisplayAdapter extends DisplayAdapter {
|
||||
|
||||
// The display is trusted since it is created by system.
|
||||
mInfo.flags |= DisplayDeviceInfo.FLAG_TRUSTED;
|
||||
if (mDisplayDeviceConfig != null) {
|
||||
mInfo.brightnessMinimum = mDisplayDeviceConfig.getBrightnessMinimum();
|
||||
mInfo.brightnessMaximum = mDisplayDeviceConfig.getBrightnessMaximum();
|
||||
mInfo.brightnessDefault = mDisplayDeviceConfig.getBrightnessDefault();
|
||||
} else {
|
||||
mInfo.brightnessMinimum = PowerManager.BRIGHTNESS_MIN;
|
||||
mInfo.brightnessMaximum = PowerManager.BRIGHTNESS_MAX;
|
||||
mInfo.brightnessDefault = 0.5f;
|
||||
}
|
||||
}
|
||||
return mInfo;
|
||||
}
|
||||
@@ -997,7 +1008,7 @@ final class LocalDisplayAdapter extends DisplayAdapter {
|
||||
pw.println(" " + mSupportedModes.valueAt(i));
|
||||
}
|
||||
pw.println("mSupportedColorModes=" + mSupportedColorModes.toString());
|
||||
pw.print("mDisplayDeviceConfig=" + mDisplayDeviceConfig);
|
||||
pw.println("mDisplayDeviceConfig=" + mDisplayDeviceConfig);
|
||||
}
|
||||
|
||||
private int findDisplayConfigIdLocked(int modeId, int configGroup) {
|
||||
|
||||
@@ -366,7 +366,9 @@ final class LogicalDisplay {
|
||||
mBaseDisplayInfo.displayCutout = maskCutout ? null : deviceInfo.displayCutout;
|
||||
mBaseDisplayInfo.displayId = mDisplayId;
|
||||
updateFrameRateOverrides(deviceInfo);
|
||||
|
||||
mBaseDisplayInfo.brightnessMinimum = deviceInfo.brightnessMinimum;
|
||||
mBaseDisplayInfo.brightnessMaximum = deviceInfo.brightnessMaximum;
|
||||
mBaseDisplayInfo.brightnessDefault = deviceInfo.brightnessDefault;
|
||||
mPrimaryDisplayDeviceInfo = deviceInfo;
|
||||
mInfo.set(null);
|
||||
}
|
||||
|
||||
@@ -2698,8 +2698,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
|
||||
float stepFloat = (maxFloat - minFloat) / BRIGHTNESS_STEPS * direction;
|
||||
float brightnessFloat = Settings.System.getFloatForUser(
|
||||
mContext.getContentResolver(), Settings.System.SCREEN_BRIGHTNESS_FLOAT,
|
||||
mPowerManager.getBrightnessConstraint(
|
||||
PowerManager.BRIGHTNESS_CONSTRAINT_TYPE_DEFAULT),
|
||||
mContext.getDisplay().getBrightnessDefault(),
|
||||
UserHandle.USER_CURRENT_OR_SELF);
|
||||
brightnessFloat += stepFloat;
|
||||
// Make sure we don't go beyond the limits.
|
||||
|
||||
@@ -29,6 +29,10 @@
|
||||
<xs:annotation name="nonnull"/>
|
||||
<xs:annotation name="final"/>
|
||||
</xs:element>
|
||||
<xs:element type="nonNegativeDecimal" name="screenBrightnessDefault">
|
||||
<xs:annotation name="nonnull"/>
|
||||
<xs:annotation name="final"/>
|
||||
</xs:element>
|
||||
<xs:element type="displayQuirks" name="quirks" minOccurs="0" maxOccurs="1" />
|
||||
</xs:sequence>
|
||||
</xs:complexType>
|
||||
|
||||
@@ -4,8 +4,10 @@ package com.android.server.display.config {
|
||||
public class DisplayConfiguration {
|
||||
ctor public DisplayConfiguration();
|
||||
method public com.android.server.display.config.DisplayQuirks getQuirks();
|
||||
method @NonNull public final java.math.BigDecimal getScreenBrightnessDefault();
|
||||
method @NonNull public final com.android.server.display.config.NitsMap getScreenBrightnessMap();
|
||||
method public void setQuirks(com.android.server.display.config.DisplayQuirks);
|
||||
method public final void setScreenBrightnessDefault(@NonNull java.math.BigDecimal);
|
||||
method public final void setScreenBrightnessMap(@NonNull com.android.server.display.config.NitsMap);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user