import static android.hardware.display.ColorDisplayManager.COLOR_MODE_NATURAL;
import static android.hardware.display.ColorDisplayManager.COLOR_MODE_SATURATED;
-import static com.android.server.display.color.DisplayTransformManager.LEVEL_COLOR_MATRIX_DISPLAY_WHITE_BALANCE;
import static com.android.server.display.color.DisplayTransformManager.LEVEL_COLOR_MATRIX_NIGHT_DISPLAY;
import android.Manifest;
import android.content.pm.PackageManager;
import android.content.res.Resources;
import android.database.ContentObserver;
-import android.graphics.ColorSpace;
import android.hardware.display.ColorDisplayManager;
import android.hardware.display.ColorDisplayManager.AutoMode;
import android.hardware.display.ColorDisplayManager.ColorMode;
import android.opengl.Matrix;
import android.os.Binder;
import android.os.Handler;
-import android.os.IBinder;
import android.os.Looper;
import android.os.Message;
import android.os.SystemProperties;
import android.util.MathUtils;
import android.util.Slog;
import android.view.SurfaceControl;
-import android.view.SurfaceControl.DisplayPrimaries;
import android.view.accessibility.AccessibilityManager;
import android.view.animation.AnimationUtils;
/**
* The identity matrix, used if one of the given matrices is {@code null}.
*/
- private static final float[] MATRIX_IDENTITY = new float[16];
+ static final float[] MATRIX_IDENTITY = new float[16];
static {
Matrix.setIdentityM(MATRIX_IDENTITY, 0);
}
}
- final class DisplayWhiteBalanceTintController extends TintController {
-
- // Three chromaticity coordinates per color: X, Y, and Z
- private static final int NUM_VALUES_PER_PRIMARY = 3;
- // Four colors: red, green, blue, and white
- private static final int NUM_DISPLAY_PRIMARIES_VALS = 4 * NUM_VALUES_PER_PRIMARY;
-
- private final Object mLock = new Object();
- @VisibleForTesting
- int mTemperatureMin;
- @VisibleForTesting
- int mTemperatureMax;
- private int mTemperatureDefault;
- private float[] mDisplayNominalWhiteXYZ = new float[NUM_VALUES_PER_PRIMARY];
- @VisibleForTesting
- ColorSpace.Rgb mDisplayColorSpaceRGB;
- private float[] mChromaticAdaptationMatrix;
- @VisibleForTesting
- int mCurrentColorTemperature;
- private float[] mCurrentColorTemperatureXYZ;
- private boolean mSetUp = false;
- private float[] mMatrixDisplayWhiteBalance = new float[16];
- private Boolean mIsAvailable;
-
- @Override
- public void setUp(Context context, boolean needsLinear) {
- mSetUp = false;
- final Resources res = context.getResources();
-
- ColorSpace.Rgb displayColorSpaceRGB = getDisplayColorSpaceFromSurfaceControl();
- if (displayColorSpaceRGB == null) {
- Slog.w(TAG, "Failed to get display color space from SurfaceControl, trying res");
- displayColorSpaceRGB = getDisplayColorSpaceFromResources(res);
- if (displayColorSpaceRGB == null) {
- Slog.e(TAG, "Failed to get display color space from resources");
- return;
- }
- }
-
- final String[] nominalWhiteValues = res.getStringArray(
- R.array.config_displayWhiteBalanceDisplayNominalWhite);
- float[] displayNominalWhiteXYZ = new float[NUM_VALUES_PER_PRIMARY];
- for (int i = 0; i < nominalWhiteValues.length; i++) {
- displayNominalWhiteXYZ[i] = Float.parseFloat(nominalWhiteValues[i]);
- }
-
- final int colorTemperatureMin = res.getInteger(
- R.integer.config_displayWhiteBalanceColorTemperatureMin);
- if (colorTemperatureMin <= 0) {
- Slog.e(TAG, "Display white balance minimum temperature must be greater than 0");
- return;
- }
-
- final int colorTemperatureMax = res.getInteger(
- R.integer.config_displayWhiteBalanceColorTemperatureMax);
- if (colorTemperatureMax < colorTemperatureMin) {
- Slog.e(TAG, "Display white balance max temp must be greater or equal to min");
- return;
- }
-
- final int colorTemperature = res.getInteger(
- R.integer.config_displayWhiteBalanceColorTemperatureDefault);
-
- synchronized (mLock) {
- mDisplayColorSpaceRGB = displayColorSpaceRGB;
- mDisplayNominalWhiteXYZ = displayNominalWhiteXYZ;
- mTemperatureMin = colorTemperatureMin;
- mTemperatureMax = colorTemperatureMax;
- mTemperatureDefault = colorTemperature;
- mSetUp = true;
- }
-
- setMatrix(mTemperatureDefault);
- }
-
- @Override
- public float[] getMatrix() {
- return mSetUp && isActivated() ? mMatrixDisplayWhiteBalance : MATRIX_IDENTITY;
- }
-
- @Override
- public void setMatrix(int cct) {
- if (!mSetUp) {
- Slog.w(TAG, "Can't set display white balance temperature: uninitialized");
- return;
- }
-
- if (cct < mTemperatureMin) {
- Slog.w(TAG, "Requested display color temperature is below allowed minimum");
- cct = mTemperatureMin;
- } else if (cct > mTemperatureMax) {
- Slog.w(TAG, "Requested display color temperature is above allowed maximum");
- cct = mTemperatureMax;
- }
-
- Slog.d(TAG, "setDisplayWhiteBalanceTemperatureMatrix: cct = " + cct);
-
- synchronized (mLock) {
- mCurrentColorTemperature = cct;
-
- // Adapt the display's nominal white point to match the requested CCT value
- mCurrentColorTemperatureXYZ = ColorSpace.cctToXyz(cct);
-
- mChromaticAdaptationMatrix =
- ColorSpace.chromaticAdaptation(ColorSpace.Adaptation.BRADFORD,
- mDisplayNominalWhiteXYZ, mCurrentColorTemperatureXYZ);
-
- // Convert the adaptation matrix to RGB space
- float[] result = ColorSpace.mul3x3(mChromaticAdaptationMatrix,
- mDisplayColorSpaceRGB.getTransform());
- result = ColorSpace.mul3x3(mDisplayColorSpaceRGB.getInverseTransform(), result);
-
- // Normalize the transform matrix to peak white value in RGB space
- final float adaptedMaxR = result[0] + result[3] + result[6];
- final float adaptedMaxG = result[1] + result[4] + result[7];
- final float adaptedMaxB = result[2] + result[5] + result[8];
- final float denum = Math.max(Math.max(adaptedMaxR, adaptedMaxG), adaptedMaxB);
- for (int i = 0; i < result.length; i++) {
- result[i] /= denum;
- }
-
- Matrix.setIdentityM(mMatrixDisplayWhiteBalance, 0);
- java.lang.System.arraycopy(result, 0, mMatrixDisplayWhiteBalance, 0, 3);
- java.lang.System.arraycopy(result, 3, mMatrixDisplayWhiteBalance, 4, 3);
- java.lang.System.arraycopy(result, 6, mMatrixDisplayWhiteBalance, 8, 3);
- }
- }
-
- @Override
- public int getLevel() {
- return LEVEL_COLOR_MATRIX_DISPLAY_WHITE_BALANCE;
- }
-
- @Override
- public boolean isAvailable(Context context) {
- if (mIsAvailable == null) {
- mIsAvailable = ColorDisplayManager.isDisplayWhiteBalanceAvailable(context);
- }
- return mIsAvailable;
- }
-
- /**
- * Format a given matrix into a string.
- *
- * @param matrix the matrix to format
- * @param cols number of columns in the matrix
- */
- private String matrixToString(float[] matrix, int cols) {
- if (matrix == null || cols <= 0) {
- Slog.e(TAG, "Invalid arguments when formatting matrix to string");
- return "";
- }
-
- StringBuilder sb = new StringBuilder("");
- for (int i = 0; i < matrix.length; i++) {
- if (i % cols == 0) {
- sb.append("\n ");
- }
- sb.append(String.format("%9.6f ", matrix[i]));
- }
- return sb.toString();
- }
-
- @Override
- public void dump(PrintWriter pw) {
- synchronized (mLock) {
- pw.println(" mSetUp = " + mSetUp);
- if (!mSetUp) {
- return;
- }
-
- pw.println(" mTemperatureMin = " + mTemperatureMin);
- pw.println(" mTemperatureMax = " + mTemperatureMax);
- pw.println(" mTemperatureDefault = " + mTemperatureDefault);
- pw.println(" mCurrentColorTemperature = " + mCurrentColorTemperature);
- pw.println(" mCurrentColorTemperatureXYZ = "
- + matrixToString(mCurrentColorTemperatureXYZ, 3));
- pw.println(" mDisplayColorSpaceRGB RGB-to-XYZ = "
- + matrixToString(mDisplayColorSpaceRGB.getTransform(), 3));
- pw.println(" mChromaticAdaptationMatrix = "
- + matrixToString(mChromaticAdaptationMatrix, 3));
- pw.println(" mDisplayColorSpaceRGB XYZ-to-RGB = "
- + matrixToString(mDisplayColorSpaceRGB.getInverseTransform(), 3));
- pw.println(" mMatrixDisplayWhiteBalance = "
- + matrixToString(mMatrixDisplayWhiteBalance, 4));
- }
- }
-
- private ColorSpace.Rgb makeRgbColorSpaceFromXYZ(float[] redGreenBlueXYZ, float[] whiteXYZ) {
- return new ColorSpace.Rgb(
- "Display Color Space",
- redGreenBlueXYZ,
- whiteXYZ,
- 2.2f // gamma, unused for display white balance
- );
- }
-
- private ColorSpace.Rgb getDisplayColorSpaceFromSurfaceControl() {
- final IBinder displayToken = SurfaceControl.getInternalDisplayToken();
- if (displayToken == null) {
- return null;
- }
-
- DisplayPrimaries primaries = SurfaceControl.getDisplayNativePrimaries(displayToken);
- if (primaries == null || primaries.red == null || primaries.green == null
- || primaries.blue == null || primaries.white == null) {
- return null;
- }
-
- return makeRgbColorSpaceFromXYZ(
- new float[]{
- primaries.red.X, primaries.red.Y, primaries.red.Z,
- primaries.green.X, primaries.green.Y, primaries.green.Z,
- primaries.blue.X, primaries.blue.Y, primaries.blue.Z,
- },
- new float[]{primaries.white.X, primaries.white.Y, primaries.white.Z}
- );
- }
-
- private ColorSpace.Rgb getDisplayColorSpaceFromResources(Resources res) {
- final String[] displayPrimariesValues = res.getStringArray(
- R.array.config_displayWhiteBalanceDisplayPrimaries);
- float[] displayRedGreenBlueXYZ =
- new float[NUM_DISPLAY_PRIMARIES_VALS - NUM_VALUES_PER_PRIMARY];
- float[] displayWhiteXYZ = new float[NUM_VALUES_PER_PRIMARY];
-
- for (int i = 0; i < displayRedGreenBlueXYZ.length; i++) {
- displayRedGreenBlueXYZ[i] = Float.parseFloat(displayPrimariesValues[i]);
- }
-
- for (int i = 0; i < displayWhiteXYZ.length; i++) {
- displayWhiteXYZ[i] = Float.parseFloat(
- displayPrimariesValues[displayRedGreenBlueXYZ.length + i]);
- }
-
- return makeRgbColorSpaceFromXYZ(displayRedGreenBlueXYZ, displayWhiteXYZ);
- }
- }
-
/**
* Local service that allows color transforms to be enabled from other system services.
*/
--- /dev/null
+/*
+ * Copyright (C) 2019 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.server.display.color;
+
+import static com.android.server.display.color.DisplayTransformManager.LEVEL_COLOR_MATRIX_DISPLAY_WHITE_BALANCE;
+
+import android.content.Context;
+import android.content.res.Resources;
+import android.graphics.ColorSpace;
+import android.hardware.display.ColorDisplayManager;
+import android.opengl.Matrix;
+import android.os.IBinder;
+import android.util.Slog;
+import android.view.SurfaceControl;
+import android.view.SurfaceControl.DisplayPrimaries;
+
+import com.android.internal.R;
+import com.android.internal.annotations.VisibleForTesting;
+
+import java.io.PrintWriter;
+
+final class DisplayWhiteBalanceTintController extends TintController {
+
+ // Three chromaticity coordinates per color: X, Y, and Z
+ private static final int NUM_VALUES_PER_PRIMARY = 3;
+ // Four colors: red, green, blue, and white
+ private static final int NUM_DISPLAY_PRIMARIES_VALS = 4 * NUM_VALUES_PER_PRIMARY;
+
+ private final Object mLock = new Object();
+ @VisibleForTesting
+ int mTemperatureMin;
+ @VisibleForTesting
+ int mTemperatureMax;
+ private int mTemperatureDefault;
+ private float[] mDisplayNominalWhiteXYZ = new float[NUM_VALUES_PER_PRIMARY];
+ @VisibleForTesting
+ ColorSpace.Rgb mDisplayColorSpaceRGB;
+ private float[] mChromaticAdaptationMatrix;
+ @VisibleForTesting
+ int mCurrentColorTemperature;
+ private float[] mCurrentColorTemperatureXYZ;
+ private boolean mSetUp = false;
+ private float[] mMatrixDisplayWhiteBalance = new float[16];
+ private Boolean mIsAvailable;
+
+ @Override
+ public void setUp(Context context, boolean needsLinear) {
+ mSetUp = false;
+ final Resources res = context.getResources();
+
+ ColorSpace.Rgb displayColorSpaceRGB = getDisplayColorSpaceFromSurfaceControl();
+ if (displayColorSpaceRGB == null) {
+ Slog.w(ColorDisplayService.TAG,
+ "Failed to get display color space from SurfaceControl, trying res");
+ displayColorSpaceRGB = getDisplayColorSpaceFromResources(res);
+ if (displayColorSpaceRGB == null) {
+ Slog.e(ColorDisplayService.TAG, "Failed to get display color space from resources");
+ return;
+ }
+ }
+
+ final String[] nominalWhiteValues = res.getStringArray(
+ R.array.config_displayWhiteBalanceDisplayNominalWhite);
+ float[] displayNominalWhiteXYZ = new float[NUM_VALUES_PER_PRIMARY];
+ for (int i = 0; i < nominalWhiteValues.length; i++) {
+ displayNominalWhiteXYZ[i] = Float.parseFloat(nominalWhiteValues[i]);
+ }
+
+ final int colorTemperatureMin = res.getInteger(
+ R.integer.config_displayWhiteBalanceColorTemperatureMin);
+ if (colorTemperatureMin <= 0) {
+ Slog.e(ColorDisplayService.TAG,
+ "Display white balance minimum temperature must be greater than 0");
+ return;
+ }
+
+ final int colorTemperatureMax = res.getInteger(
+ R.integer.config_displayWhiteBalanceColorTemperatureMax);
+ if (colorTemperatureMax < colorTemperatureMin) {
+ Slog.e(ColorDisplayService.TAG,
+ "Display white balance max temp must be greater or equal to min");
+ return;
+ }
+
+ final int colorTemperature = res.getInteger(
+ R.integer.config_displayWhiteBalanceColorTemperatureDefault);
+
+ synchronized (mLock) {
+ mDisplayColorSpaceRGB = displayColorSpaceRGB;
+ mDisplayNominalWhiteXYZ = displayNominalWhiteXYZ;
+ mTemperatureMin = colorTemperatureMin;
+ mTemperatureMax = colorTemperatureMax;
+ mTemperatureDefault = colorTemperature;
+ mSetUp = true;
+ }
+
+ setMatrix(mTemperatureDefault);
+ }
+
+ @Override
+ public float[] getMatrix() {
+ return mSetUp && isActivated() ? mMatrixDisplayWhiteBalance
+ : ColorDisplayService.MATRIX_IDENTITY;
+ }
+
+ @Override
+ public void setMatrix(int cct) {
+ if (!mSetUp) {
+ Slog.w(ColorDisplayService.TAG,
+ "Can't set display white balance temperature: uninitialized");
+ return;
+ }
+
+ if (cct < mTemperatureMin) {
+ Slog.w(ColorDisplayService.TAG,
+ "Requested display color temperature is below allowed minimum");
+ cct = mTemperatureMin;
+ } else if (cct > mTemperatureMax) {
+ Slog.w(ColorDisplayService.TAG,
+ "Requested display color temperature is above allowed maximum");
+ cct = mTemperatureMax;
+ }
+
+ Slog.d(ColorDisplayService.TAG, "setDisplayWhiteBalanceTemperatureMatrix: cct = " + cct);
+
+ synchronized (mLock) {
+ mCurrentColorTemperature = cct;
+
+ // Adapt the display's nominal white point to match the requested CCT value
+ mCurrentColorTemperatureXYZ = ColorSpace.cctToXyz(cct);
+
+ mChromaticAdaptationMatrix =
+ ColorSpace.chromaticAdaptation(ColorSpace.Adaptation.BRADFORD,
+ mDisplayNominalWhiteXYZ, mCurrentColorTemperatureXYZ);
+
+ // Convert the adaptation matrix to RGB space
+ float[] result = ColorSpace.mul3x3(mChromaticAdaptationMatrix,
+ mDisplayColorSpaceRGB.getTransform());
+ result = ColorSpace.mul3x3(mDisplayColorSpaceRGB.getInverseTransform(), result);
+
+ // Normalize the transform matrix to peak white value in RGB space
+ final float adaptedMaxR = result[0] + result[3] + result[6];
+ final float adaptedMaxG = result[1] + result[4] + result[7];
+ final float adaptedMaxB = result[2] + result[5] + result[8];
+ final float denum = Math.max(Math.max(adaptedMaxR, adaptedMaxG), adaptedMaxB);
+ for (int i = 0; i < result.length; i++) {
+ result[i] /= denum;
+ }
+
+ Matrix.setIdentityM(mMatrixDisplayWhiteBalance, 0);
+ java.lang.System.arraycopy(result, 0, mMatrixDisplayWhiteBalance, 0, 3);
+ java.lang.System.arraycopy(result, 3, mMatrixDisplayWhiteBalance, 4, 3);
+ java.lang.System.arraycopy(result, 6, mMatrixDisplayWhiteBalance, 8, 3);
+ }
+ }
+
+ @Override
+ public int getLevel() {
+ return LEVEL_COLOR_MATRIX_DISPLAY_WHITE_BALANCE;
+ }
+
+ @Override
+ public boolean isAvailable(Context context) {
+ if (mIsAvailable == null) {
+ mIsAvailable = ColorDisplayManager.isDisplayWhiteBalanceAvailable(context);
+ }
+ return mIsAvailable;
+ }
+
+ @Override
+ public void dump(PrintWriter pw) {
+ synchronized (mLock) {
+ pw.println(" mSetUp = " + mSetUp);
+ if (!mSetUp) {
+ return;
+ }
+
+ pw.println(" mTemperatureMin = " + mTemperatureMin);
+ pw.println(" mTemperatureMax = " + mTemperatureMax);
+ pw.println(" mTemperatureDefault = " + mTemperatureDefault);
+ pw.println(" mCurrentColorTemperature = " + mCurrentColorTemperature);
+ pw.println(" mCurrentColorTemperatureXYZ = "
+ + matrixToString(mCurrentColorTemperatureXYZ, 3));
+ pw.println(" mDisplayColorSpaceRGB RGB-to-XYZ = "
+ + matrixToString(mDisplayColorSpaceRGB.getTransform(), 3));
+ pw.println(" mChromaticAdaptationMatrix = "
+ + matrixToString(mChromaticAdaptationMatrix, 3));
+ pw.println(" mDisplayColorSpaceRGB XYZ-to-RGB = "
+ + matrixToString(mDisplayColorSpaceRGB.getInverseTransform(), 3));
+ pw.println(" mMatrixDisplayWhiteBalance = "
+ + matrixToString(mMatrixDisplayWhiteBalance, 4));
+ }
+ }
+
+ /**
+ * Format a given matrix into a string.
+ *
+ * @param matrix the matrix to format
+ * @param columns number of columns in the matrix
+ */
+ private String matrixToString(float[] matrix, int columns) {
+ if (matrix == null || columns <= 0) {
+ Slog.e(ColorDisplayService.TAG, "Invalid arguments when formatting matrix to string");
+ return "";
+ }
+
+ final StringBuilder sb = new StringBuilder("");
+ for (int i = 0; i < matrix.length; i++) {
+ if (i % columns == 0) {
+ sb.append("\n ");
+ }
+ sb.append(String.format("%9.6f", matrix[i]));
+ }
+ return sb.toString();
+ }
+
+ private ColorSpace.Rgb makeRgbColorSpaceFromXYZ(float[] redGreenBlueXYZ, float[] whiteXYZ) {
+ return new ColorSpace.Rgb(
+ "Display Color Space",
+ redGreenBlueXYZ,
+ whiteXYZ,
+ 2.2f // gamma, unused for display white balance
+ );
+ }
+
+ private ColorSpace.Rgb getDisplayColorSpaceFromSurfaceControl() {
+ final IBinder displayToken = SurfaceControl.getInternalDisplayToken();
+ if (displayToken == null) {
+ return null;
+ }
+
+ DisplayPrimaries primaries = SurfaceControl.getDisplayNativePrimaries(displayToken);
+ if (primaries == null || primaries.red == null || primaries.green == null
+ || primaries.blue == null || primaries.white == null) {
+ return null;
+ }
+
+ return makeRgbColorSpaceFromXYZ(
+ new float[]{
+ primaries.red.X, primaries.red.Y, primaries.red.Z,
+ primaries.green.X, primaries.green.Y, primaries.green.Z,
+ primaries.blue.X, primaries.blue.Y, primaries.blue.Z,
+ },
+ new float[]{primaries.white.X, primaries.white.Y, primaries.white.Z}
+ );
+ }
+
+ private ColorSpace.Rgb getDisplayColorSpaceFromResources(Resources res) {
+ final String[] displayPrimariesValues = res.getStringArray(
+ R.array.config_displayWhiteBalanceDisplayPrimaries);
+ float[] displayRedGreenBlueXYZ =
+ new float[NUM_DISPLAY_PRIMARIES_VALS - NUM_VALUES_PER_PRIMARY];
+ float[] displayWhiteXYZ = new float[NUM_VALUES_PER_PRIMARY];
+
+ for (int i = 0; i < displayRedGreenBlueXYZ.length; i++) {
+ displayRedGreenBlueXYZ[i] = Float.parseFloat(displayPrimariesValues[i]);
+ }
+
+ for (int i = 0; i < displayWhiteXYZ.length; i++) {
+ displayWhiteXYZ[i] = Float.parseFloat(
+ displayPrimariesValues[displayRedGreenBlueXYZ.length + i]);
+ }
+
+ return makeRgbColorSpaceFromXYZ(displayRedGreenBlueXYZ, displayWhiteXYZ);
+ }
+}
@Test
public void customSchedule_whenStartedAfterNight_ifOffAfterNight_turnsOff() {
setAutoModeCustom(-120 /* startTimeOffset */, -60 /* endTimeOffset */);
- setActivated(false /* activated */, -30 /* lastActivatedTimeOffset */);
+ setNightDisplayActivated(false /* activated */, -30 /* lastActivatedTimeOffset */);
startService();
assertActivated(false /* activated */);
@Test
public void customSchedule_whenStartedAfterNight_ifOffBeforeNight_turnsOff() {
setAutoModeCustom(-120 /* startTimeOffset */, -60 /* endTimeOffset */);
- setActivated(false /* activated */, -180 /* lastActivatedTimeOffset */);
+ setNightDisplayActivated(false /* activated */, -180 /* lastActivatedTimeOffset */);
startService();
assertActivated(false /* activated */);
@Test
public void customSchedule_whenStartedAfterNight_ifOffDuringNight_turnsOff() {
setAutoModeCustom(-120 /* startTimeOffset */, -60 /* endTimeOffset */);
- setActivated(false /* activated */, -90 /* lastActivatedTimeOffset */);
+ setNightDisplayActivated(false /* activated */, -90 /* lastActivatedTimeOffset */);
startService();
assertActivated(false /* activated */);
@Test
public void customSchedule_whenStartedAfterNight_ifOffInFuture_turnsOff() {
setAutoModeCustom(-120 /* startTimeOffset */, -60 /* endTimeOffset */);
- setActivated(false /* activated */, 30 /* lastActivatedTimeOffset */);
+ setNightDisplayActivated(false /* activated */, 30 /* lastActivatedTimeOffset */);
startService();
assertActivated(false /* activated */);
@Test
public void customSchedule_whenStartedAfterNight_ifOnAfterNight_turnsOn() {
setAutoModeCustom(-120 /* startTimeOffset */, -60 /* endTimeOffset */);
- setActivated(true /* activated */, -30 /* lastActivatedTimeOffset */);
+ setNightDisplayActivated(true /* activated */, -30 /* lastActivatedTimeOffset */);
startService();
assertActivated(true /* activated */);
@Test
public void customSchedule_whenStartedAfterNight_ifOnBeforeNight_turnsOff() {
setAutoModeCustom(-120 /* startTimeOffset */, -60 /* endTimeOffset */);
- setActivated(true /* activated */, -180 /* lastActivatedTimeOffset */);
+ setNightDisplayActivated(true /* activated */, -180 /* lastActivatedTimeOffset */);
startService();
assertActivated(false /* activated */);
@Test
public void customSchedule_whenStartedAfterNight_ifOnDuringNight_turnsOff() {
setAutoModeCustom(-120 /* startTimeOffset */, -60 /* endTimeOffset */);
- setActivated(true /* activated */, -90 /* lastActivatedTimeOffset */);
+ setNightDisplayActivated(true /* activated */, -90 /* lastActivatedTimeOffset */);
startService();
assertActivated(false /* activated */);
@Test
public void customSchedule_whenStartedAfterNight_ifOnInFuture_turnsOff() {
setAutoModeCustom(-120 /* startTimeOffset */, -60 /* endTimeOffset */);
- setActivated(true /* activated */, 30 /* lastActivatedTimeOffset */);
+ setNightDisplayActivated(true /* activated */, 30 /* lastActivatedTimeOffset */);
startService();
assertActivated(false /* activated */);
@Test
public void customSchedule_whenStartedBeforeNight_ifOffAfterNight_turnsOff() {
setAutoModeCustom(60 /* startTimeOffset */, 120 /* endTimeOffset */);
- setActivated(false /* activated */, 180 /* lastActivatedTimeOffset */);
+ setNightDisplayActivated(false /* activated */, 180 /* lastActivatedTimeOffset */);
startService();
assertActivated(false /* activated */);
@Test
public void customSchedule_whenStartedBeforeNight_ifOffBeforeNight_turnsOff() {
setAutoModeCustom(60 /* startTimeOffset */, 120 /* endTimeOffset */);
- setActivated(false /* activated */, 30 /* lastActivatedTimeOffset */);
+ setNightDisplayActivated(false /* activated */, 30 /* lastActivatedTimeOffset */);
startService();
assertActivated(false /* activated */);
@Test
public void customSchedule_whenStartedBeforeNight_ifOffDuringNight_turnsOff() {
setAutoModeCustom(60 /* startTimeOffset */, 120 /* endTimeOffset */);
- setActivated(false /* activated */, 90 /* lastActivatedTimeOffset */);
+ setNightDisplayActivated(false /* activated */, 90 /* lastActivatedTimeOffset */);
startService();
assertActivated(false /* activated */);
@Test
public void customSchedule_whenStartedBeforeNight_ifOffInPast_turnsOff() {
setAutoModeCustom(60 /* startTimeOffset */, 120 /* endTimeOffset */);
- setActivated(false /* activated */, -30 /* lastActivatedTimeOffset */);
+ setNightDisplayActivated(false /* activated */, -30 /* lastActivatedTimeOffset */);
startService();
assertActivated(false /* activated */);
@Test
public void customSchedule_whenStartedBeforeNight_ifOnAfterNight_turnsOff() {
setAutoModeCustom(60 /* startTimeOffset */, 120 /* endTimeOffset */);
- setActivated(true /* activated */, 180 /* lastActivatedTimeOffset */);
+ setNightDisplayActivated(true /* activated */, 180 /* lastActivatedTimeOffset */);
startService();
assertActivated(false /* activated */);
@Test
public void customSchedule_whenStartedBeforeNight_ifOnBeforeNight_turnsOff() {
setAutoModeCustom(60 /* startTimeOffset */, 120 /* endTimeOffset */);
- setActivated(true /* activated */, 30 /* lastActivatedTimeOffset */);
+ setNightDisplayActivated(true /* activated */, 30 /* lastActivatedTimeOffset */);
startService();
assertActivated(false /* activated */);
@Test
public void customSchedule_whenStartedBeforeNight_ifOnDuringNight_turnsOff() {
setAutoModeCustom(60 /* startTimeOffset */, 120 /* endTimeOffset */);
- setActivated(true /* activated */, 90 /* lastActivatedTimeOffset */);
+ setNightDisplayActivated(true /* activated */, 90 /* lastActivatedTimeOffset */);
startService();
assertActivated(false /* activated */);
@Test
public void customSchedule_whenStartedBeforeNight_ifOnInPast_turnsOn() {
setAutoModeCustom(60 /* startTimeOffset */, 120 /* endTimeOffset */);
- setActivated(true /* activated */, -30 /* lastActivatedTimeOffset */);
+ setNightDisplayActivated(true /* activated */, -30 /* lastActivatedTimeOffset */);
startService();
assertActivated(true /* activated */);
@Test
public void customSchedule_whenStartedDuringNight_ifOffAfterNight_turnsOn() {
setAutoModeCustom(-60 /* startTimeOffset */, 60 /* endTimeOffset */);
- setActivated(false /* activated */, 90 /* lastActivatedTimeOffset */);
+ setNightDisplayActivated(false /* activated */, 90 /* lastActivatedTimeOffset */);
startService();
assertActivated(true /* activated */);
@Test
public void customSchedule_whenStartedDuringNight_ifOffBeforeNight_turnsOn() {
setAutoModeCustom(-60 /* startTimeOffset */, 60 /* endTimeOffset */);
- setActivated(false /* activated */, -90 /* lastActivatedTimeOffset */);
+ setNightDisplayActivated(false /* activated */, -90 /* lastActivatedTimeOffset */);
startService();
assertActivated(true /* activated */);
@Test
public void customSchedule_whenStartedDuringNight_ifOffDuringNightInFuture_turnsOn() {
setAutoModeCustom(-60 /* startTimeOffset */, 60 /* endTimeOffset */);
- setActivated(false /* activated */, 30 /* lastActivatedTimeOffset */);
+ setNightDisplayActivated(false /* activated */, 30 /* lastActivatedTimeOffset */);
startService();
assertActivated(true /* activated */);
@Test
public void customSchedule_whenStartedDuringNight_ifOffDuringNightInPast_turnsOff() {
setAutoModeCustom(-60 /* startTimeOffset */, 60 /* endTimeOffset */);
- setActivated(false /* activated */, -30 /* lastActivatedTimeOffset */);
+ setNightDisplayActivated(false /* activated */, -30 /* lastActivatedTimeOffset */);
startService();
assertActivated(false /* activated */);
@Test
public void customSchedule_whenStartedDuringNight_ifOnAfterNight_turnsOn() {
setAutoModeCustom(-60 /* startTimeOffset */, 60 /* endTimeOffset */);
- setActivated(true /* activated */, 90 /* lastActivatedTimeOffset */);
+ setNightDisplayActivated(true /* activated */, 90 /* lastActivatedTimeOffset */);
startService();
assertActivated(true /* activated */);
@Test
public void customSchedule_whenStartedDuringNight_ifOnBeforeNight_turnsOn() {
setAutoModeCustom(-60 /* startTimeOffset */, 60 /* endTimeOffset */);
- setActivated(true /* activated */, -90 /* lastActivatedTimeOffset */);
+ setNightDisplayActivated(true /* activated */, -90 /* lastActivatedTimeOffset */);
startService();
assertActivated(true /* activated */);
@Test
public void customSchedule_whenStartedDuringNight_ifOnDuringNightInFuture_turnsOn() {
setAutoModeCustom(-60 /* startTimeOffset */, 60 /* endTimeOffset */);
- setActivated(true /* activated */, 30 /* lastActivatedTimeOffset */);
+ setNightDisplayActivated(true /* activated */, 30 /* lastActivatedTimeOffset */);
startService();
assertActivated(true /* activated */);
@Test
public void customSchedule_whenStartedDuringNight_ifOnDuringNightInPast_turnsOn() {
setAutoModeCustom(-60 /* startTimeOffset */, 60 /* endTimeOffset */);
- setActivated(true /* activated */, -30 /* lastActivatedTimeOffset */);
+ setNightDisplayActivated(true /* activated */, -30 /* lastActivatedTimeOffset */);
startService();
assertActivated(true /* activated */);
@Test
public void twilightSchedule_whenStartedAfterNight_ifOffAfterNight_turnsOff() {
setAutoModeTwilight(-120 /* sunsetOffset */, -60 /* sunriseOffset */);
- setActivated(false /* activated */, -30 /* lastActivatedTimeOffset */);
+ setNightDisplayActivated(false /* activated */, -30 /* lastActivatedTimeOffset */);
startService();
assertActivated(false /* activated */);
@Test
public void twilightSchedule_whenStartedAfterNight_ifOffBeforeNight_turnsOff() {
setAutoModeTwilight(-120 /* sunsetOffset */, -60 /* sunriseOffset */);
- setActivated(false /* activated */, -180 /* lastActivatedTimeOffset */);
+ setNightDisplayActivated(false /* activated */, -180 /* lastActivatedTimeOffset */);
startService();
assertActivated(false /* activated */);
@Test
public void twilightSchedule_whenStartedAfterNight_ifOffDuringNight_turnsOff() {
setAutoModeTwilight(-120 /* sunsetOffset */, -60 /* sunriseOffset */);
- setActivated(false /* activated */, -90 /* lastActivatedTimeOffset */);
+ setNightDisplayActivated(false /* activated */, -90 /* lastActivatedTimeOffset */);
startService();
assertActivated(false /* activated */);
@Test
public void twilightSchedule_whenStartedAfterNight_ifOffInFuture_turnsOff() {
setAutoModeTwilight(-120 /* sunsetOffset */, -60 /* sunriseOffset */);
- setActivated(false /* activated */, 30 /* lastActivatedTimeOffset */);
+ setNightDisplayActivated(false /* activated */, 30 /* lastActivatedTimeOffset */);
startService();
assertActivated(false /* activated */);
@Test
public void twilightSchedule_whenStartedAfterNight_ifOnAfterNight_turnsOn() {
setAutoModeTwilight(-120 /* sunsetOffset */, -60 /* sunriseOffset */);
- setActivated(true /* activated */, -30 /* lastActivatedTimeOffset */);
+ setNightDisplayActivated(true /* activated */, -30 /* lastActivatedTimeOffset */);
startService();
assertActivated(true /* activated */);
@Test
public void twilightSchedule_whenStartedAfterNight_ifOnBeforeNight_turnsOff() {
setAutoModeTwilight(-120 /* sunsetOffset */, -60 /* sunriseOffset */);
- setActivated(true /* activated */, -180 /* lastActivatedTimeOffset */);
+ setNightDisplayActivated(true /* activated */, -180 /* lastActivatedTimeOffset */);
startService();
assertActivated(false /* activated */);
@Test
public void twilightSchedule_whenStartedAfterNight_ifOnDuringNight_turnsOff() {
setAutoModeTwilight(-120 /* sunsetOffset */, -60 /* sunriseOffset */);
- setActivated(true /* activated */, -90 /* lastActivatedTimeOffset */);
+ setNightDisplayActivated(true /* activated */, -90 /* lastActivatedTimeOffset */);
startService();
assertActivated(false /* activated */);
@Test
public void twilightSchedule_whenStartedAfterNight_ifOnInFuture_turnsOff() {
setAutoModeTwilight(-120 /* sunsetOffset */, -60 /* sunriseOffset */);
- setActivated(true /* activated */, 30 /* lastActivatedTimeOffset */);
+ setNightDisplayActivated(true /* activated */, 30 /* lastActivatedTimeOffset */);
startService();
assertActivated(false /* activated */);
@Test
public void twilightSchedule_whenStartedBeforeNight_ifOffAfterNight_turnsOff() {
setAutoModeTwilight(60 /* sunsetOffset */, 120 /* sunriseOffset */);
- setActivated(false /* activated */, 180 /* lastActivatedTimeOffset */);
+ setNightDisplayActivated(false /* activated */, 180 /* lastActivatedTimeOffset */);
startService();
assertActivated(false /* activated */);
@Test
public void twilightSchedule_whenStartedBeforeNight_ifOffBeforeNight_turnsOff() {
setAutoModeTwilight(60 /* sunsetOffset */, 120 /* sunriseOffset */);
- setActivated(false /* activated */, 30 /* lastActivatedTimeOffset */);
+ setNightDisplayActivated(false /* activated */, 30 /* lastActivatedTimeOffset */);
startService();
assertActivated(false /* activated */);
@Test
public void twilightSchedule_whenStartedBeforeNight_ifOffDuringNight_turnsOff() {
setAutoModeTwilight(60 /* sunsetOffset */, 120 /* sunriseOffset */);
- setActivated(false /* activated */, 90 /* lastActivatedTimeOffset */);
+ setNightDisplayActivated(false /* activated */, 90 /* lastActivatedTimeOffset */);
startService();
assertActivated(false /* activated */);
@Test
public void twilightSchedule_whenStartedBeforeNight_ifOffInPast_turnsOff() {
setAutoModeTwilight(60 /* sunsetOffset */, 120 /* sunriseOffset */);
- setActivated(false /* activated */, -30 /* lastActivatedTimeOffset */);
+ setNightDisplayActivated(false /* activated */, -30 /* lastActivatedTimeOffset */);
startService();
assertActivated(false /* activated */);
@Test
public void twilightSchedule_whenStartedBeforeNight_ifOnAfterNight_turnsOff() {
setAutoModeTwilight(60 /* sunsetOffset */, 120 /* sunriseOffset */);
- setActivated(true /* activated */, 180 /* lastActivatedTimeOffset */);
+ setNightDisplayActivated(true /* activated */, 180 /* lastActivatedTimeOffset */);
startService();
assertActivated(false /* activated */);
@Test
public void twilightSchedule_whenStartedBeforeNight_ifOnBeforeNight_turnsOff() {
setAutoModeTwilight(60 /* sunsetOffset */, 120 /* sunriseOffset */);
- setActivated(true /* activated */, 30 /* lastActivatedTimeOffset */);
+ setNightDisplayActivated(true /* activated */, 30 /* lastActivatedTimeOffset */);
startService();
assertActivated(false /* activated */);
@Test
public void twilightSchedule_whenStartedBeforeNight_ifOnDuringNight_turnsOff() {
setAutoModeTwilight(60 /* sunsetOffset */, 120 /* sunriseOffset */);
- setActivated(true /* activated */, 90 /* lastActivatedTimeOffset */);
+ setNightDisplayActivated(true /* activated */, 90 /* lastActivatedTimeOffset */);
startService();
assertActivated(false /* activated */);
@Test
public void twilightSchedule_whenStartedBeforeNight_ifOnInPast_turnsOn() {
setAutoModeTwilight(60 /* sunsetOffset */, 120 /* sunriseOffset */);
- setActivated(true /* activated */, -30 /* lastActivatedTimeOffset */);
+ setNightDisplayActivated(true /* activated */, -30 /* lastActivatedTimeOffset */);
startService();
assertActivated(true /* activated */);
@Test
public void twilightSchedule_whenStartedDuringNight_ifOffAfterNight_turnsOn() {
setAutoModeTwilight(-60 /* sunsetOffset */, 60 /* sunriseOffset */);
- setActivated(false /* activated */, 90 /* lastActivatedTimeOffset */);
+ setNightDisplayActivated(false /* activated */, 90 /* lastActivatedTimeOffset */);
startService();
assertActivated(true /* activated */);
@Test
public void twilightSchedule_whenStartedDuringNight_ifOffBeforeNight_turnsOn() {
setAutoModeTwilight(-60 /* sunsetOffset */, 60 /* sunriseOffset */);
- setActivated(false /* activated */, -90 /* lastActivatedTimeOffset */);
+ setNightDisplayActivated(false /* activated */, -90 /* lastActivatedTimeOffset */);
startService();
assertActivated(true /* activated */);
@Test
public void twilightSchedule_whenStartedDuringNight_ifOffDuringNightInFuture_turnsOn() {
setAutoModeTwilight(-60 /* sunsetOffset */, 60 /* sunriseOffset */);
- setActivated(false /* activated */, 30 /* lastActivatedTimeOffset */);
+ setNightDisplayActivated(false /* activated */, 30 /* lastActivatedTimeOffset */);
startService();
assertActivated(true /* activated */);
@Test
public void twilightSchedule_whenStartedDuringNight_ifOffDuringNightInPast_turnsOff() {
setAutoModeTwilight(-60 /* sunsetOffset */, 60 /* sunriseOffset */);
- setActivated(false /* activated */, -30 /* lastActivatedTimeOffset */);
+ setNightDisplayActivated(false /* activated */, -30 /* lastActivatedTimeOffset */);
startService();
assertActivated(false /* activated */);
@Test
public void twilightSchedule_whenStartedDuringNight_ifOnAfterNight_turnsOn() {
setAutoModeTwilight(-60 /* sunsetOffset */, 60 /* sunriseOffset */);
- setActivated(true /* activated */, 90 /* lastActivatedTimeOffset */);
+ setNightDisplayActivated(true /* activated */, 90 /* lastActivatedTimeOffset */);
startService();
assertActivated(true /* activated */);
@Test
public void twilightSchedule_whenStartedDuringNight_ifOnBeforeNight_turnsOn() {
setAutoModeTwilight(-60 /* sunsetOffset */, 60 /* sunriseOffset */);
- setActivated(true /* activated */, -90 /* lastActivatedTimeOffset */);
+ setNightDisplayActivated(true /* activated */, -90 /* lastActivatedTimeOffset */);
startService();
assertActivated(true /* activated */);
@Test
public void twilightSchedule_whenStartedDuringNight_ifOnDuringNightInFuture_turnsOn() {
setAutoModeTwilight(-60 /* sunsetOffset */, 60 /* sunriseOffset */);
- setActivated(true /* activated */, 30 /* lastActivatedTimeOffset */);
+ setNightDisplayActivated(true /* activated */, 30 /* lastActivatedTimeOffset */);
startService();
assertActivated(true /* activated */);
@Test
public void twilightSchedule_whenStartedDuringNight_ifOnDuringNightInPast_turnsOn() {
setAutoModeTwilight(-60 /* sunsetOffset */, 60 /* sunriseOffset */);
- setActivated(true /* activated */, -30 /* lastActivatedTimeOffset */);
+ setNightDisplayActivated(true /* activated */, -30 /* lastActivatedTimeOffset */);
startService();
assertActivated(true /* activated */);
@Test
public void twilightSchedule_whenRebootedAfterNight_ifOffAfterNight_turnsOff() {
setAutoModeTwilight(-120 /* sunsetOffset */, -60 /* sunriseOffset */);
- setActivated(false /* activated */, -30 /* lastActivatedTimeOffset */);
+ setNightDisplayActivated(false /* activated */, -30 /* lastActivatedTimeOffset */);
final TwilightState state = mTwilightManager.getLastTwilightState();
mTwilightManager.setTwilightState(null);
@Test
public void twilightSchedule_whenRebootedAfterNight_ifOffBeforeNight_turnsOff() {
setAutoModeTwilight(-120 /* sunsetOffset */, -60 /* sunriseOffset */);
- setActivated(false /* activated */, -180 /* lastActivatedTimeOffset */);
+ setNightDisplayActivated(false /* activated */, -180 /* lastActivatedTimeOffset */);
final TwilightState state = mTwilightManager.getLastTwilightState();
mTwilightManager.setTwilightState(null);
@Test
public void twilightSchedule_whenRebootedAfterNight_ifOffDuringNight_turnsOff() {
setAutoModeTwilight(-120 /* sunsetOffset */, -60 /* sunriseOffset */);
- setActivated(false /* activated */, -90 /* lastActivatedTimeOffset */);
+ setNightDisplayActivated(false /* activated */, -90 /* lastActivatedTimeOffset */);
final TwilightState state = mTwilightManager.getLastTwilightState();
mTwilightManager.setTwilightState(null);
@Test
public void twilightSchedule_whenRebootedAfterNight_ifOffInFuture_turnsOff() {
setAutoModeTwilight(-120 /* sunsetOffset */, -60 /* sunriseOffset */);
- setActivated(false /* activated */, 30 /* lastActivatedTimeOffset */);
+ setNightDisplayActivated(false /* activated */, 30 /* lastActivatedTimeOffset */);
final TwilightState state = mTwilightManager.getLastTwilightState();
mTwilightManager.setTwilightState(null);
@Test
public void twilightSchedule_whenRebootedAfterNight_ifOnAfterNight_turnsOn() {
setAutoModeTwilight(-120 /* sunsetOffset */, -60 /* sunriseOffset */);
- setActivated(true /* activated */, -30 /* lastActivatedTimeOffset */);
+ setNightDisplayActivated(true /* activated */, -30 /* lastActivatedTimeOffset */);
final TwilightState state = mTwilightManager.getLastTwilightState();
mTwilightManager.setTwilightState(null);
@Test
public void twilightSchedule_whenRebootedAfterNight_ifOnBeforeNight_turnsOff() {
setAutoModeTwilight(-120 /* sunsetOffset */, -60 /* sunriseOffset */);
- setActivated(true /* activated */, -180 /* lastActivatedTimeOffset */);
+ setNightDisplayActivated(true /* activated */, -180 /* lastActivatedTimeOffset */);
final TwilightState state = mTwilightManager.getLastTwilightState();
mTwilightManager.setTwilightState(null);
@Test
public void twilightSchedule_whenRebootedAfterNight_ifOnDuringNight_turnsOff() {
setAutoModeTwilight(-120 /* sunsetOffset */, -60 /* sunriseOffset */);
- setActivated(true /* activated */, -90 /* lastActivatedTimeOffset */);
+ setNightDisplayActivated(true /* activated */, -90 /* lastActivatedTimeOffset */);
final TwilightState state = mTwilightManager.getLastTwilightState();
mTwilightManager.setTwilightState(null);
@Test
public void twilightSchedule_whenRebootedAfterNight_ifOnInFuture_turnsOff() {
setAutoModeTwilight(-120 /* sunsetOffset */, -60 /* sunriseOffset */);
- setActivated(true /* activated */, 30 /* lastActivatedTimeOffset */);
+ setNightDisplayActivated(true /* activated */, 30 /* lastActivatedTimeOffset */);
final TwilightState state = mTwilightManager.getLastTwilightState();
mTwilightManager.setTwilightState(null);
@Test
public void twilightSchedule_whenRebootedBeforeNight_ifOffAfterNight_turnsOff() {
setAutoModeTwilight(60 /* sunsetOffset */, 120 /* sunriseOffset */);
- setActivated(false /* activated */, 180 /* lastActivatedTimeOffset */);
+ setNightDisplayActivated(false /* activated */, 180 /* lastActivatedTimeOffset */);
final TwilightState state = mTwilightManager.getLastTwilightState();
mTwilightManager.setTwilightState(null);
@Test
public void twilightSchedule_whenRebootedBeforeNight_ifOffBeforeNight_turnsOff() {
setAutoModeTwilight(60 /* sunsetOffset */, 120 /* sunriseOffset */);
- setActivated(false /* activated */, 30 /* lastActivatedTimeOffset */);
+ setNightDisplayActivated(false /* activated */, 30 /* lastActivatedTimeOffset */);
final TwilightState state = mTwilightManager.getLastTwilightState();
mTwilightManager.setTwilightState(null);
@Test
public void twilightSchedule_whenRebootedBeforeNight_ifOffDuringNight_turnsOff() {
setAutoModeTwilight(60 /* sunsetOffset */, 120 /* sunriseOffset */);
- setActivated(false /* activated */, 90 /* lastActivatedTimeOffset */);
+ setNightDisplayActivated(false /* activated */, 90 /* lastActivatedTimeOffset */);
final TwilightState state = mTwilightManager.getLastTwilightState();
mTwilightManager.setTwilightState(null);
@Test
public void twilightSchedule_whenRebootedBeforeNight_ifOffInPast_turnsOff() {
setAutoModeTwilight(60 /* sunsetOffset */, 120 /* sunriseOffset */);
- setActivated(false /* activated */, -30 /* lastActivatedTimeOffset */);
+ setNightDisplayActivated(false /* activated */, -30 /* lastActivatedTimeOffset */);
final TwilightState state = mTwilightManager.getLastTwilightState();
mTwilightManager.setTwilightState(null);
@Test
public void twilightSchedule_whenRebootedBeforeNight_ifOnAfterNight_turnsOff() {
setAutoModeTwilight(60 /* sunsetOffset */, 120 /* sunriseOffset */);
- setActivated(true /* activated */, 180 /* lastActivatedTimeOffset */);
+ setNightDisplayActivated(true /* activated */, 180 /* lastActivatedTimeOffset */);
final TwilightState state = mTwilightManager.getLastTwilightState();
mTwilightManager.setTwilightState(null);
@Test
public void twilightSchedule_whenRebootedBeforeNight_ifOnBeforeNight_turnsOff() {
setAutoModeTwilight(60 /* sunsetOffset */, 120 /* sunriseOffset */);
- setActivated(true /* activated */, 30 /* lastActivatedTimeOffset */);
+ setNightDisplayActivated(true /* activated */, 30 /* lastActivatedTimeOffset */);
final TwilightState state = mTwilightManager.getLastTwilightState();
mTwilightManager.setTwilightState(null);
@Test
public void twilightSchedule_whenRebootedBeforeNight_ifOnDuringNight_turnsOff() {
setAutoModeTwilight(60 /* sunsetOffset */, 120 /* sunriseOffset */);
- setActivated(true /* activated */, 90 /* lastActivatedTimeOffset */);
+ setNightDisplayActivated(true /* activated */, 90 /* lastActivatedTimeOffset */);
final TwilightState state = mTwilightManager.getLastTwilightState();
mTwilightManager.setTwilightState(null);
@Test
public void twilightSchedule_whenRebootedBeforeNight_ifOnInPast_turnsOn() {
setAutoModeTwilight(60 /* sunsetOffset */, 120 /* sunriseOffset */);
- setActivated(true /* activated */, -30 /* lastActivatedTimeOffset */);
+ setNightDisplayActivated(true /* activated */, -30 /* lastActivatedTimeOffset */);
final TwilightState state = mTwilightManager.getLastTwilightState();
mTwilightManager.setTwilightState(null);
@Test
public void twilightSchedule_whenRebootedDuringNight_ifOffAfterNight_turnsOn() {
setAutoModeTwilight(-60 /* sunsetOffset */, 60 /* sunriseOffset */);
- setActivated(false /* activated */, 90 /* lastActivatedTimeOffset */);
+ setNightDisplayActivated(false /* activated */, 90 /* lastActivatedTimeOffset */);
final TwilightState state = mTwilightManager.getLastTwilightState();
mTwilightManager.setTwilightState(null);
@Test
public void twilightSchedule_whenRebootedDuringNight_ifOffBeforeNight_turnsOn() {
setAutoModeTwilight(-60 /* sunsetOffset */, 60 /* sunriseOffset */);
- setActivated(false /* activated */, -90 /* lastActivatedTimeOffset */);
+ setNightDisplayActivated(false /* activated */, -90 /* lastActivatedTimeOffset */);
final TwilightState state = mTwilightManager.getLastTwilightState();
mTwilightManager.setTwilightState(null);
@Test
public void twilightSchedule_whenRebootedDuringNight_ifOffDuringNightInFuture_turnsOn() {
setAutoModeTwilight(-60 /* sunsetOffset */, 60 /* sunriseOffset */);
- setActivated(false /* activated */, 30 /* lastActivatedTimeOffset */);
+ setNightDisplayActivated(false /* activated */, 30 /* lastActivatedTimeOffset */);
final TwilightState state = mTwilightManager.getLastTwilightState();
mTwilightManager.setTwilightState(null);
@Test
public void twilightSchedule_whenRebootedDuringNight_ifOffDuringNightInPast_turnsOff() {
setAutoModeTwilight(-60 /* sunsetOffset */, 60 /* sunriseOffset */);
- setActivated(false /* activated */, -30 /* lastActivatedTimeOffset */);
+ setNightDisplayActivated(false /* activated */, -30 /* lastActivatedTimeOffset */);
final TwilightState state = mTwilightManager.getLastTwilightState();
mTwilightManager.setTwilightState(null);
@Test
public void twilightSchedule_whenRebootedDuringNight_ifOnAfterNight_turnsOn() {
setAutoModeTwilight(-60 /* sunsetOffset */, 60 /* sunriseOffset */);
- setActivated(true /* activated */, 90 /* lastActivatedTimeOffset */);
+ setNightDisplayActivated(true /* activated */, 90 /* lastActivatedTimeOffset */);
final TwilightState state = mTwilightManager.getLastTwilightState();
mTwilightManager.setTwilightState(null);
@Test
public void twilightSchedule_whenRebootedDuringNight_ifOnBeforeNight_turnsOn() {
setAutoModeTwilight(-60 /* sunsetOffset */, 60 /* sunriseOffset */);
- setActivated(true /* activated */, -90 /* lastActivatedTimeOffset */);
+ setNightDisplayActivated(true /* activated */, -90 /* lastActivatedTimeOffset */);
final TwilightState state = mTwilightManager.getLastTwilightState();
mTwilightManager.setTwilightState(null);
@Test
public void twilightSchedule_whenRebootedDuringNight_ifOnDuringNightInFuture_turnsOn() {
setAutoModeTwilight(-60 /* sunsetOffset */, 60 /* sunriseOffset */);
- setActivated(true /* activated */, 30 /* lastActivatedTimeOffset */);
+ setNightDisplayActivated(true /* activated */, 30 /* lastActivatedTimeOffset */);
final TwilightState state = mTwilightManager.getLastTwilightState();
mTwilightManager.setTwilightState(null);
@Test
public void twilightSchedule_whenRebootedDuringNight_ifOnDuringNightInPast_turnsOn() {
setAutoModeTwilight(-60 /* sunsetOffset */, 60 /* sunriseOffset */);
- setActivated(true /* activated */, -30 /* lastActivatedTimeOffset */);
+ setNightDisplayActivated(true /* activated */, -30 /* lastActivatedTimeOffset */);
final TwilightState state = mTwilightManager.getLastTwilightState();
mTwilightManager.setTwilightState(null);
}
@Test
- public void displayWhiteBalance_enable() {
- setWhiteBalance(true /* Enable DWB Setting */);
- setActivated(false /* activated */, -30 /* lastActivatedTimeOffset */);
+ public void displayWhiteBalance_enabled() {
+ setDisplayWhiteBalanceEnabled(true);
+ setNightDisplayActivated(false /* activated */, -30 /* lastActivatedTimeOffset */);
mBinderService.setColorMode(ColorDisplayManager.COLOR_MODE_NATURAL);
startService();
assertDwbActive(true);
}
@Test
- public void displayWhiteBalance_disableAfterNightDisplayEnable() {
- setWhiteBalance(true /* Enable DWB Setting */);
-
+ public void displayWhiteBalance_disabledAfterNightDisplayEnabled() {
+ setDisplayWhiteBalanceEnabled(true);
startService();
- /* Enable nightlight */
- setAutoModeTwilight(-120 /* sunsetOffset */, -60 /* sunriseOffset */);
- setActivated(true /* activated */, -30 /* lastActivatedTimeOffset */);
+ setNightDisplayActivated(true /* activated */, -30 /* lastActivatedTimeOffset */);
/* Since we are using FakeSettingsProvider which could not trigger observer change,
* force an update here.*/
}
@Test
- public void displayWhiteBalance_enableAfterNightDisplayDisable() {
- setWhiteBalance(true /* Enable DWB Setting */);
+ public void displayWhiteBalance_enabledAfterNightDisplayDisabled() {
+ setDisplayWhiteBalanceEnabled(true);
startService();
- /* Enable nightlight */
- setAutoModeTwilight(-120 /* sunsetOffset */, -60 /* sunriseOffset */);
- setActivated(true /* activated */, -30 /* lastActivatedTimeOffset */);
+ setNightDisplayActivated(true /* activated */, -30 /* lastActivatedTimeOffset */);
mCds.updateDisplayWhiteBalanceStatus();
assertDwbActive(false);
- /* Disable nightlight */
- setActivated(false /* activated */, -30 /* lastActivatedTimeOffset */);
+ setNightDisplayActivated(false /* activated */, -30 /* lastActivatedTimeOffset */);
mCds.updateDisplayWhiteBalanceStatus();
assertDwbActive(true);
}
@Test
- public void displayWhiteBalance_enableAfterLinearColorMode() {
- setWhiteBalance(true /* Enable DWB Setting */);
- setActivated(false /* activated */, -30 /* lastActivatedTimeOffset */);
+ public void displayWhiteBalance_enabledAfterLinearColorModeSelected() {
+ setDisplayWhiteBalanceEnabled(true);
+ setNightDisplayActivated(false /* activated */, -30 /* lastActivatedTimeOffset */);
startService();
mBinderService.setColorMode(ColorDisplayManager.COLOR_MODE_NATURAL);
assertDwbActive(true);
}
- @Test
- public void displayWhiteBalance_setTemperatureOverMax() {
- int max = mCds.mDisplayWhiteBalanceTintController.mTemperatureMax;
-
- ColorDisplayService.ColorDisplayServiceInternal cdsInternal = LocalServices.getService(
- ColorDisplayService.ColorDisplayServiceInternal.class);
- cdsInternal.setDisplayWhiteBalanceColorTemperature(max + 1);
-
- assertWithMessage("Unexpected temperature set")
- .that(mCds.mDisplayWhiteBalanceTintController.mCurrentColorTemperature)
- .isEqualTo(max);
- }
-
- @Test
- public void displayWhiteBalance_setTemperatureBelowMin() {
- int min = mCds.mDisplayWhiteBalanceTintController.mTemperatureMin;
-
- ColorDisplayService.ColorDisplayServiceInternal cdsInternal = LocalServices.getService(
- ColorDisplayService.ColorDisplayServiceInternal.class);
- cdsInternal.setDisplayWhiteBalanceColorTemperature(min - 1);
-
- assertWithMessage("Unexpected temperature set")
- .that(mCds.mDisplayWhiteBalanceTintController.mCurrentColorTemperature)
- .isEqualTo(min);
- }
-
- @Test
- public void displayWhiteBalance_setValidTemperature() {
- int min = mCds.mDisplayWhiteBalanceTintController.mTemperatureMin;
- int max = mCds.mDisplayWhiteBalanceTintController.mTemperatureMax;
- int valToSet = (min + max) / 2;
-
- ColorDisplayService.ColorDisplayServiceInternal cdsInternal = LocalServices.getService(
- ColorDisplayService.ColorDisplayServiceInternal.class);
- cdsInternal.setDisplayWhiteBalanceColorTemperature(valToSet);
-
- assertWithMessage("Unexpected temperature set")
- .that(mCds.mDisplayWhiteBalanceTintController.mCurrentColorTemperature)
- .isEqualTo(valToSet);
- }
-
/**
* Configures Night display to use a custom schedule.
*
* @param lastActivatedTimeOffset the offset relative to now to record that Night display was
* activated (in minutes)
*/
- private void setActivated(boolean activated, int lastActivatedTimeOffset) {
+ private void setNightDisplayActivated(boolean activated, int lastActivatedTimeOffset) {
mBinderService.setNightDisplayActivated(activated);
Secure.putStringForUser(mContext.getContentResolver(),
Secure.NIGHT_DISPLAY_LAST_ACTIVATED_TIME,
/**
* Configures the Display White Balance setting state.
*
- * @param state {@code true} if display white balance should be enabled
+ * @param enabled {@code true} if display white balance should be enabled
*/
- private void setWhiteBalance(boolean state) {
+ private void setDisplayWhiteBalanceEnabled(boolean enabled) {
Secure.putIntForUser(mContext.getContentResolver(),
- Secure.DISPLAY_WHITE_BALANCE_ENABLED, state ? 1 : 0, mUserId);
+ Secure.DISPLAY_WHITE_BALANCE_ENABLED, enabled ? 1 : 0, mUserId);
}
/**