Merge "Add more brightness config details to dumpsys"
This commit is contained in:
@@ -1118,9 +1118,9 @@ package android.hardware.display {
|
||||
}
|
||||
|
||||
public static class BrightnessConfiguration.Builder {
|
||||
ctor public BrightnessConfiguration.Builder();
|
||||
ctor public BrightnessConfiguration.Builder(float[], float[]);
|
||||
method public android.hardware.display.BrightnessConfiguration build();
|
||||
method public android.hardware.display.BrightnessConfiguration.Builder setCurve(float[], float[]);
|
||||
method public android.hardware.display.BrightnessConfiguration.Builder setDescription(java.lang.String);
|
||||
}
|
||||
|
||||
public final class DisplayManager {
|
||||
|
||||
@@ -320,9 +320,9 @@ package android.hardware.display {
|
||||
}
|
||||
|
||||
public static class BrightnessConfiguration.Builder {
|
||||
ctor public BrightnessConfiguration.Builder();
|
||||
ctor public BrightnessConfiguration.Builder(float[], float[]);
|
||||
method public android.hardware.display.BrightnessConfiguration build();
|
||||
method public android.hardware.display.BrightnessConfiguration.Builder setCurve(float[], float[]);
|
||||
method public android.hardware.display.BrightnessConfiguration.Builder setDescription(java.lang.String);
|
||||
}
|
||||
|
||||
public final class DisplayManager {
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
package android.hardware.display;
|
||||
|
||||
import android.annotation.Nullable;
|
||||
import android.annotation.SystemApi;
|
||||
import android.annotation.TestApi;
|
||||
import android.os.Parcel;
|
||||
@@ -25,6 +26,7 @@ import android.util.Pair;
|
||||
import com.android.internal.util.Preconditions;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Objects;
|
||||
|
||||
/** @hide */
|
||||
@SystemApi
|
||||
@@ -32,10 +34,12 @@ import java.util.Arrays;
|
||||
public final class BrightnessConfiguration implements Parcelable {
|
||||
private final float[] mLux;
|
||||
private final float[] mNits;
|
||||
private final String mDescription;
|
||||
|
||||
private BrightnessConfiguration(float[] lux, float[] nits) {
|
||||
private BrightnessConfiguration(float[] lux, float[] nits, String description) {
|
||||
mLux = lux;
|
||||
mNits = nits;
|
||||
mDescription = description;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -51,10 +55,19 @@ public final class BrightnessConfiguration implements Parcelable {
|
||||
return Pair.create(Arrays.copyOf(mLux, mLux.length), Arrays.copyOf(mNits, mNits.length));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns description string.
|
||||
* @hide
|
||||
*/
|
||||
public String getDescription() {
|
||||
return mDescription;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToParcel(Parcel dest, int flags) {
|
||||
dest.writeFloatArray(mLux);
|
||||
dest.writeFloatArray(mNits);
|
||||
dest.writeString(mDescription);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -72,7 +85,9 @@ public final class BrightnessConfiguration implements Parcelable {
|
||||
}
|
||||
sb.append("(").append(mLux[i]).append(", ").append(mNits[i]).append(")");
|
||||
}
|
||||
sb.append("]}");
|
||||
sb.append("], '");
|
||||
sb.append(mDescription);
|
||||
sb.append("'}");
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
@@ -81,6 +96,7 @@ public final class BrightnessConfiguration implements Parcelable {
|
||||
int result = 1;
|
||||
result = result * 31 + Arrays.hashCode(mLux);
|
||||
result = result * 31 + Arrays.hashCode(mNits);
|
||||
result = result * 31 + mDescription.hashCode();
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -93,16 +109,17 @@ public final class BrightnessConfiguration implements Parcelable {
|
||||
return false;
|
||||
}
|
||||
final BrightnessConfiguration other = (BrightnessConfiguration) o;
|
||||
return Arrays.equals(mLux, other.mLux) && Arrays.equals(mNits, other.mNits);
|
||||
return Arrays.equals(mLux, other.mLux) && Arrays.equals(mNits, other.mNits)
|
||||
&& Objects.equals(mDescription, other.mDescription);
|
||||
}
|
||||
|
||||
public static final Creator<BrightnessConfiguration> CREATOR =
|
||||
new Creator<BrightnessConfiguration>() {
|
||||
public BrightnessConfiguration createFromParcel(Parcel in) {
|
||||
Builder builder = new Builder();
|
||||
float[] lux = in.createFloatArray();
|
||||
float[] nits = in.createFloatArray();
|
||||
builder.setCurve(lux, nits);
|
||||
Builder builder = new Builder(lux, nits);
|
||||
builder.setDescription(in.readString());
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
@@ -117,6 +134,29 @@ public final class BrightnessConfiguration implements Parcelable {
|
||||
public static class Builder {
|
||||
private float[] mCurveLux;
|
||||
private float[] mCurveNits;
|
||||
private String mDescription;
|
||||
|
||||
/**
|
||||
* STOPSHIP remove when app has stopped using this.
|
||||
* @hide
|
||||
*/
|
||||
public Builder() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs the builder with the control points for the brightness curve.
|
||||
*
|
||||
* Brightness curves must have strictly increasing ambient brightness values in lux and
|
||||
* monotonically increasing display brightness values in nits. In addition, the initial
|
||||
* control point must be 0 lux.
|
||||
*
|
||||
* @throws IllegalArgumentException if the initial control point is not at 0 lux.
|
||||
* @throws IllegalArgumentException if the lux levels are not strictly increasing.
|
||||
* @throws IllegalArgumentException if the nit levels are not monotonically increasing.
|
||||
*/
|
||||
public Builder(float[] lux, float[] nits) {
|
||||
setCurve(lux, nits);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the control points for the brightness curve.
|
||||
@@ -128,6 +168,9 @@ public final class BrightnessConfiguration implements Parcelable {
|
||||
* @throws IllegalArgumentException if the initial control point is not at 0 lux.
|
||||
* @throws IllegalArgumentException if the lux levels are not strictly increasing.
|
||||
* @throws IllegalArgumentException if the nit levels are not monotonically increasing.
|
||||
*
|
||||
* STOPSHIP remove when app has stopped using this.
|
||||
* @hide
|
||||
*/
|
||||
public Builder setCurve(float[] lux, float[] nits) {
|
||||
Preconditions.checkNotNull(lux);
|
||||
@@ -150,6 +193,17 @@ public final class BrightnessConfiguration implements Parcelable {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set description of the brightness curve.
|
||||
*
|
||||
* @param description brief text describing the curve pushed. It maybe truncated
|
||||
* and will not be displayed in the UI
|
||||
*/
|
||||
public Builder setDescription(@Nullable String description) {
|
||||
mDescription = description;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds the {@link BrightnessConfiguration}.
|
||||
*
|
||||
@@ -159,7 +213,7 @@ public final class BrightnessConfiguration implements Parcelable {
|
||||
if (mCurveLux == null || mCurveNits == null) {
|
||||
throw new IllegalStateException("A curve must be set!");
|
||||
}
|
||||
return new BrightnessConfiguration(mCurveLux, mCurveNits);
|
||||
return new BrightnessConfiguration(mCurveLux, mCurveNits, mDescription);
|
||||
}
|
||||
|
||||
private static void checkMonotonic(float[] vals, boolean strictlyIncreasing, String name) {
|
||||
|
||||
@@ -639,7 +639,7 @@ public final class DisplayManager {
|
||||
@TestApi
|
||||
@RequiresPermission(Manifest.permission.CONFIGURE_DISPLAY_BRIGHTNESS)
|
||||
public void setBrightnessConfiguration(BrightnessConfiguration c) {
|
||||
setBrightnessConfigurationForUser(c, UserHandle.myUserId());
|
||||
setBrightnessConfigurationForUser(c, UserHandle.myUserId(), mContext.getPackageName());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -650,8 +650,9 @@ public final class DisplayManager {
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
public void setBrightnessConfigurationForUser(BrightnessConfiguration c, int userId) {
|
||||
mGlobal.setBrightnessConfigurationForUser(c, userId);
|
||||
public void setBrightnessConfigurationForUser(BrightnessConfiguration c, int userId,
|
||||
String packageName) {
|
||||
mGlobal.setBrightnessConfigurationForUser(c, userId, packageName);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -480,9 +480,10 @@ public final class DisplayManagerGlobal {
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
public void setBrightnessConfigurationForUser(BrightnessConfiguration c, int userId) {
|
||||
public void setBrightnessConfigurationForUser(BrightnessConfiguration c, int userId,
|
||||
String packageName) {
|
||||
try {
|
||||
mDm.setBrightnessConfigurationForUser(c, userId);
|
||||
mDm.setBrightnessConfigurationForUser(c, userId, packageName);
|
||||
} catch (RemoteException ex) {
|
||||
throw ex.rethrowFromSystemServer();
|
||||
}
|
||||
|
||||
@@ -90,5 +90,6 @@ interface IDisplayManager {
|
||||
// Sets the global brightness configuration for a given user. Requires
|
||||
// CONFIGURE_DISPLAY_BRIGHTNESS, and INTERACT_ACROSS_USER if the user being configured is not
|
||||
// the same as the calling user.
|
||||
void setBrightnessConfigurationForUser(in BrightnessConfiguration c, int userId);
|
||||
void setBrightnessConfigurationForUser(in BrightnessConfiguration c, int userId,
|
||||
String packageName);
|
||||
}
|
||||
|
||||
@@ -521,6 +521,7 @@ public class BrightnessTracker {
|
||||
public void dump(PrintWriter pw) {
|
||||
pw.println("BrightnessTracker state:");
|
||||
synchronized (mDataCollectionLock) {
|
||||
pw.println(" mStarted=" + mStarted);
|
||||
pw.println(" mLastSensorReadings.size=" + mLastSensorReadings.size());
|
||||
if (!mLastSensorReadings.isEmpty()) {
|
||||
pw.println(" mLastSensorReadings time span "
|
||||
|
||||
@@ -29,6 +29,7 @@ import com.android.internal.util.IndentingPrintWriter;
|
||||
|
||||
import android.Manifest;
|
||||
import android.annotation.NonNull;
|
||||
import android.annotation.Nullable;
|
||||
import android.annotation.UserIdInt;
|
||||
import android.app.AppOpsManager;
|
||||
import android.content.Context;
|
||||
@@ -1005,11 +1006,13 @@ public final class DisplayManagerService extends SystemService {
|
||||
}
|
||||
|
||||
private void setBrightnessConfigurationForUserInternal(
|
||||
@NonNull BrightnessConfiguration c, @UserIdInt int userId) {
|
||||
@NonNull BrightnessConfiguration c, @UserIdInt int userId,
|
||||
@Nullable String packageName) {
|
||||
final int userSerial = getUserManager().getUserSerialNumber(userId);
|
||||
synchronized (mSyncRoot) {
|
||||
try {
|
||||
mPersistentDataStore.setBrightnessConfigurationForUser(c, userSerial);
|
||||
mPersistentDataStore.setBrightnessConfigurationForUser(c, userSerial,
|
||||
packageName);
|
||||
} finally {
|
||||
mPersistentDataStore.saveIfNeeded();
|
||||
}
|
||||
@@ -1833,7 +1836,7 @@ public final class DisplayManagerService extends SystemService {
|
||||
|
||||
@Override // Binder call
|
||||
public void setBrightnessConfigurationForUser(
|
||||
BrightnessConfiguration c, @UserIdInt int userId) {
|
||||
BrightnessConfiguration c, @UserIdInt int userId, String packageName) {
|
||||
mContext.enforceCallingOrSelfPermission(
|
||||
Manifest.permission.CONFIGURE_DISPLAY_BRIGHTNESS,
|
||||
"Permission required to change the display's brightness configuration");
|
||||
@@ -1843,10 +1846,13 @@ public final class DisplayManagerService extends SystemService {
|
||||
"Permission required to change the display brightness"
|
||||
+ " configuration of another user");
|
||||
}
|
||||
if (packageName != null && !validatePackageName(getCallingUid(), packageName)) {
|
||||
packageName = null;
|
||||
}
|
||||
Preconditions.checkNotNull(c);
|
||||
final long token = Binder.clearCallingIdentity();
|
||||
try {
|
||||
setBrightnessConfigurationForUserInternal(c, userId);
|
||||
setBrightnessConfigurationForUserInternal(c, userId, packageName);
|
||||
} finally {
|
||||
Binder.restoreCallingIdentity(token);
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@ import org.xmlpull.v1.XmlPullParser;
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
import org.xmlpull.v1.XmlSerializer;
|
||||
|
||||
import android.annotation.Nullable;
|
||||
import android.graphics.Point;
|
||||
import android.hardware.display.BrightnessConfiguration;
|
||||
import android.hardware.display.WifiDisplay;
|
||||
@@ -30,6 +31,8 @@ import android.util.AtomicFile;
|
||||
import android.util.Slog;
|
||||
import android.util.SparseArray;
|
||||
import android.util.Pair;
|
||||
import android.util.SparseLongArray;
|
||||
import android.util.TimeUtils;
|
||||
import android.util.Xml;
|
||||
import android.view.Display;
|
||||
|
||||
@@ -73,8 +76,8 @@ import libcore.util.Objects;
|
||||
* <stable-display-width>1080</stable-display-width>
|
||||
* </stable-device-values>
|
||||
* <brightness-configurations>
|
||||
* <brightness-configuration user-id="0">
|
||||
* <brightness-curve>
|
||||
* <brightness-configuration user-serial="0" package-name="com.example" timestamp="1234">
|
||||
* <brightness-curve description="some text">
|
||||
* <brightness-point lux="0" nits="13.25"/>
|
||||
* <brightness-point lux="20" nits="35.94"/>
|
||||
* </brightness-curve>
|
||||
@@ -110,8 +113,11 @@ final class PersistentDataStore {
|
||||
private static final String TAG_BRIGHTNESS_CURVE = "brightness-curve";
|
||||
private static final String TAG_BRIGHTNESS_POINT = "brightness-point";
|
||||
private static final String ATTR_USER_SERIAL = "user-serial";
|
||||
private static final String ATTR_PACKAGE_NAME = "package-name";
|
||||
private static final String ATTR_TIME_STAMP = "timestamp";
|
||||
private static final String ATTR_LUX = "lux";
|
||||
private static final String ATTR_NITS = "nits";
|
||||
private static final String ATTR_DESCRIPTION = "description";
|
||||
|
||||
// Remembered Wifi display devices.
|
||||
private ArrayList<WifiDisplay> mRememberedWifiDisplays = new ArrayList<WifiDisplay>();
|
||||
@@ -273,9 +279,11 @@ final class PersistentDataStore {
|
||||
}
|
||||
}
|
||||
|
||||
public void setBrightnessConfigurationForUser(BrightnessConfiguration c, int userSerial) {
|
||||
public void setBrightnessConfigurationForUser(BrightnessConfiguration c, int userSerial,
|
||||
@Nullable String packageName) {
|
||||
loadIfNeeded();
|
||||
if (mBrightnessConfigurations.setBrightnessConfigurationForUser(c, userSerial)) {
|
||||
if (mBrightnessConfigurations.setBrightnessConfigurationForUser(c, userSerial,
|
||||
packageName)) {
|
||||
setDirty();
|
||||
}
|
||||
}
|
||||
@@ -576,15 +584,27 @@ final class PersistentDataStore {
|
||||
private static final class BrightnessConfigurations {
|
||||
// Maps from a user ID to the users' given brightness configuration
|
||||
private SparseArray<BrightnessConfiguration> mConfigurations;
|
||||
// Timestamp of time the configuration was set.
|
||||
private SparseLongArray mTimeStamps;
|
||||
// Package that set the configuration.
|
||||
private SparseArray<String> mPackageNames;
|
||||
|
||||
public BrightnessConfigurations() {
|
||||
mConfigurations = new SparseArray<>();
|
||||
mTimeStamps = new SparseLongArray();
|
||||
mPackageNames = new SparseArray<>();
|
||||
}
|
||||
|
||||
private boolean setBrightnessConfigurationForUser(BrightnessConfiguration c,
|
||||
int userSerial) {
|
||||
int userSerial, String packageName) {
|
||||
BrightnessConfiguration currentConfig = mConfigurations.get(userSerial);
|
||||
if (currentConfig == null || !currentConfig.equals(c)) {
|
||||
if (packageName == null) {
|
||||
mPackageNames.remove(userSerial);
|
||||
} else {
|
||||
mPackageNames.put(userSerial, packageName);
|
||||
}
|
||||
mTimeStamps.put(userSerial, System.currentTimeMillis());
|
||||
mConfigurations.put(userSerial, c);
|
||||
return true;
|
||||
}
|
||||
@@ -604,14 +624,31 @@ final class PersistentDataStore {
|
||||
userSerial = Integer.parseInt(
|
||||
parser.getAttributeValue(null, ATTR_USER_SERIAL));
|
||||
} catch (NumberFormatException nfe) {
|
||||
userSerial= -1;
|
||||
userSerial = -1;
|
||||
Slog.e(TAG, "Failed to read in brightness configuration", nfe);
|
||||
}
|
||||
|
||||
String packageName = parser.getAttributeValue(null, ATTR_PACKAGE_NAME);
|
||||
String timeStampString = parser.getAttributeValue(null, ATTR_TIME_STAMP);
|
||||
long timeStamp = -1;
|
||||
if (timeStampString != null) {
|
||||
try {
|
||||
timeStamp = Long.parseLong(timeStampString);
|
||||
} catch (NumberFormatException nfe) {
|
||||
// Ignore we will just not restore the timestamp.
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
BrightnessConfiguration config = loadConfigurationFromXml(parser);
|
||||
if (userSerial>= 0 && config != null) {
|
||||
if (userSerial >= 0 && config != null) {
|
||||
mConfigurations.put(userSerial, config);
|
||||
if (timeStamp != -1) {
|
||||
mTimeStamps.put(userSerial, timeStamp);
|
||||
}
|
||||
if (packageName != null) {
|
||||
mPackageNames.put(userSerial, packageName);
|
||||
}
|
||||
}
|
||||
} catch (IllegalArgumentException iae) {
|
||||
Slog.e(TAG, "Failed to load brightness configuration!", iae);
|
||||
@@ -623,18 +660,24 @@ final class PersistentDataStore {
|
||||
private static BrightnessConfiguration loadConfigurationFromXml(XmlPullParser parser)
|
||||
throws IOException, XmlPullParserException {
|
||||
final int outerDepth = parser.getDepth();
|
||||
final BrightnessConfiguration.Builder builder = new BrightnessConfiguration.Builder();
|
||||
String description = null;
|
||||
Pair<float[], float[]> curve = null;
|
||||
while (XmlUtils.nextElementWithin(parser, outerDepth)) {
|
||||
if (TAG_BRIGHTNESS_CURVE.equals(parser.getName())) {
|
||||
Pair<float[], float[]> curve = loadCurveFromXml(parser, builder);
|
||||
builder.setCurve(curve.first /*lux*/, curve.second /*nits*/);
|
||||
description = parser.getAttributeValue(null, ATTR_DESCRIPTION);
|
||||
curve = loadCurveFromXml(parser);
|
||||
}
|
||||
}
|
||||
if (curve == null) {
|
||||
return null;
|
||||
}
|
||||
final BrightnessConfiguration.Builder builder = new BrightnessConfiguration.Builder(
|
||||
curve.first, curve.second);
|
||||
builder.setDescription(description);
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
private static Pair<float[], float[]> loadCurveFromXml(XmlPullParser parser,
|
||||
BrightnessConfiguration.Builder builder)
|
||||
private static Pair<float[], float[]> loadCurveFromXml(XmlPullParser parser)
|
||||
throws IOException, XmlPullParserException {
|
||||
final int outerDepth = parser.getDepth();
|
||||
List<Float> luxLevels = new ArrayList<>();
|
||||
@@ -666,11 +709,19 @@ final class PersistentDataStore {
|
||||
|
||||
public void saveToXml(XmlSerializer serializer) throws IOException {
|
||||
for (int i = 0; i < mConfigurations.size(); i++) {
|
||||
final int userSerial= mConfigurations.keyAt(i);
|
||||
final int userSerial = mConfigurations.keyAt(i);
|
||||
final BrightnessConfiguration config = mConfigurations.valueAt(i);
|
||||
|
||||
serializer.startTag(null, TAG_BRIGHTNESS_CONFIGURATION);
|
||||
serializer.attribute(null, ATTR_USER_SERIAL, Integer.toString(userSerial));
|
||||
String packageName = mPackageNames.get(userSerial);
|
||||
if (packageName != null) {
|
||||
serializer.attribute(null, ATTR_PACKAGE_NAME, packageName);
|
||||
}
|
||||
long timestamp = mTimeStamps.get(userSerial, -1);
|
||||
if (timestamp != -1) {
|
||||
serializer.attribute(null, ATTR_TIME_STAMP, Long.toString(timestamp));
|
||||
}
|
||||
saveConfigurationToXml(serializer, config);
|
||||
serializer.endTag(null, TAG_BRIGHTNESS_CONFIGURATION);
|
||||
}
|
||||
@@ -679,6 +730,9 @@ final class PersistentDataStore {
|
||||
private static void saveConfigurationToXml(XmlSerializer serializer,
|
||||
BrightnessConfiguration config) throws IOException {
|
||||
serializer.startTag(null, TAG_BRIGHTNESS_CURVE);
|
||||
if (config.getDescription() != null) {
|
||||
serializer.attribute(null, ATTR_DESCRIPTION, config.getDescription());
|
||||
}
|
||||
final Pair<float[], float[]> curve = config.getCurve();
|
||||
for (int i = 0; i < curve.first.length; i++) {
|
||||
serializer.startTag(null, TAG_BRIGHTNESS_POINT);
|
||||
@@ -691,8 +745,16 @@ final class PersistentDataStore {
|
||||
|
||||
public void dump(final PrintWriter pw, final String prefix) {
|
||||
for (int i = 0; i < mConfigurations.size(); i++) {
|
||||
final int userSerial= mConfigurations.keyAt(i);
|
||||
final int userSerial = mConfigurations.keyAt(i);
|
||||
long time = mTimeStamps.get(userSerial, -1);
|
||||
String packageName = mPackageNames.get(userSerial);
|
||||
pw.println(prefix + "User " + userSerial + ":");
|
||||
if (time != -1) {
|
||||
pw.println(prefix + " set at: " + TimeUtils.formatForLogging(time));
|
||||
}
|
||||
if (packageName != null) {
|
||||
pw.println(prefix + " set by: " + packageName);
|
||||
}
|
||||
pw.println(prefix + " " + mConfigurations.valueAt(i));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -58,8 +58,11 @@ public class PersistentDataStoreTest {
|
||||
String contents = "<?xml version='1.0' encoding='utf-8' standalone='yes' ?>\n"
|
||||
+ "<display-manager-state>\n"
|
||||
+ " <brightness-configurations>\n"
|
||||
+ " <brightness-configuration user-serial=\"1\">\n"
|
||||
+ " <brightness-curve>\n"
|
||||
+ " <brightness-configuration"
|
||||
+ " user-serial=\"1\""
|
||||
+ " package-name=\"example.com\""
|
||||
+ " timestamp=\"123456\">\n"
|
||||
+ " <brightness-curve description=\"something\">\n"
|
||||
+ " <brightness-point lux=\"0\" nits=\"13.25\"/>\n"
|
||||
+ " <brightness-point lux=\"25\" nits=\"35.94\"/>\n"
|
||||
+ " </brightness-curve>\n"
|
||||
@@ -81,6 +84,7 @@ public class PersistentDataStoreTest {
|
||||
float[] expectedNits = { 13.25f, 35.94f };
|
||||
assertArrayEquals(expectedLux, curve.first, "lux");
|
||||
assertArrayEquals(expectedNits, curve.second, "nits");
|
||||
assertEquals("something", config.getDescription());
|
||||
|
||||
config = mDataStore.getBrightnessConfiguration(3 /*userSerial*/);
|
||||
curve = config.getCurve();
|
||||
@@ -88,6 +92,7 @@ public class PersistentDataStoreTest {
|
||||
expectedNits = new float[] { 13.25f, 15f };
|
||||
assertArrayEquals(expectedLux, curve.first, "lux");
|
||||
assertArrayEquals(expectedNits, curve.second, "nits");
|
||||
assertNull(config.getDescription());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -144,12 +149,12 @@ public class PersistentDataStoreTest {
|
||||
public void testStoreAndReloadOfBrightnessConfigurations() {
|
||||
final float[] lux = { 0f, 10f };
|
||||
final float[] nits = {1f, 100f };
|
||||
final BrightnessConfiguration config = new BrightnessConfiguration.Builder()
|
||||
.setCurve(lux, nits)
|
||||
final BrightnessConfiguration config = new BrightnessConfiguration.Builder(lux, nits)
|
||||
.setDescription("a description")
|
||||
.build();
|
||||
mDataStore.loadIfNeeded();
|
||||
assertNull(mDataStore.getBrightnessConfiguration(0 /*userSerial*/));
|
||||
mDataStore.setBrightnessConfigurationForUser(config, 0);
|
||||
mDataStore.setBrightnessConfigurationForUser(config, 0, "packagename");
|
||||
|
||||
final ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
mInjector.setWriteStream(baos);
|
||||
|
||||
Reference in New Issue
Block a user