Merge "Initialize color mode if set" into pi-dev
am: 5cb4117353
Change-Id: I136cd337d23c60465b18b4162ad4cdd7e6fc8652
This commit is contained in:
@@ -335,7 +335,7 @@ public final class ColorDisplayController {
|
||||
if (colorTemperature == -1) {
|
||||
if (DEBUG) {
|
||||
Slog.d(TAG, "Using default value for setting: "
|
||||
+ Secure.NIGHT_DISPLAY_COLOR_TEMPERATURE);
|
||||
+ Secure.NIGHT_DISPLAY_COLOR_TEMPERATURE);
|
||||
}
|
||||
colorTemperature = getDefaultColorTemperature();
|
||||
}
|
||||
@@ -358,7 +358,7 @@ public final class ColorDisplayController {
|
||||
*/
|
||||
public boolean setColorTemperature(int colorTemperature) {
|
||||
return Secure.putIntForUser(mContext.getContentResolver(),
|
||||
Secure.NIGHT_DISPLAY_COLOR_TEMPERATURE, colorTemperature, mUserId);
|
||||
Secure.NIGHT_DISPLAY_COLOR_TEMPERATURE, colorTemperature, mUserId);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -367,10 +367,10 @@ public final class ColorDisplayController {
|
||||
* See com.android.server.display.DisplayTransformManager.
|
||||
*/
|
||||
private @ColorMode int getCurrentColorModeFromSystemProperties() {
|
||||
int displayColorSetting = SystemProperties.getInt("persist.sys.sf.native_mode", 0);
|
||||
final int displayColorSetting = SystemProperties.getInt("persist.sys.sf.native_mode", 0);
|
||||
if (displayColorSetting == 0) {
|
||||
return "1.0".equals(SystemProperties.get("persist.sys.sf.color_saturation"))
|
||||
? COLOR_MODE_NATURAL : COLOR_MODE_BOOSTED;
|
||||
? COLOR_MODE_NATURAL : COLOR_MODE_BOOSTED;
|
||||
} else if (displayColorSetting == 1) {
|
||||
return COLOR_MODE_SATURATED;
|
||||
} else if (displayColorSetting == 2) {
|
||||
@@ -381,16 +381,13 @@ public final class ColorDisplayController {
|
||||
}
|
||||
|
||||
private boolean isColorModeAvailable(@ColorMode int colorMode) {
|
||||
// SATURATED is always allowed
|
||||
if (colorMode == COLOR_MODE_SATURATED) {
|
||||
return true;
|
||||
}
|
||||
|
||||
final int[] availableColorModes = mContext.getResources().getIntArray(
|
||||
R.array.config_availableColorModes);
|
||||
for (int mode : availableColorModes) {
|
||||
if (mode == colorMode) {
|
||||
return true;
|
||||
if (availableColorModes != null) {
|
||||
for (int mode : availableColorModes) {
|
||||
if (mode == colorMode) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
@@ -401,14 +398,18 @@ public final class ColorDisplayController {
|
||||
*/
|
||||
public int getColorMode() {
|
||||
if (getAccessibilityTransformActivated()) {
|
||||
return COLOR_MODE_SATURATED;
|
||||
if (isColorModeAvailable(COLOR_MODE_SATURATED)) {
|
||||
return COLOR_MODE_SATURATED;
|
||||
} else if (isColorModeAvailable(COLOR_MODE_AUTOMATIC)) {
|
||||
return COLOR_MODE_AUTOMATIC;
|
||||
}
|
||||
}
|
||||
|
||||
int colorMode = System.getIntForUser(mContext.getContentResolver(),
|
||||
System.DISPLAY_COLOR_MODE, -1, mUserId);
|
||||
System.DISPLAY_COLOR_MODE, -1, mUserId);
|
||||
if (colorMode == -1) {
|
||||
// There still might be a legacy system property controlling color mode that we need to
|
||||
// respect.
|
||||
// There might be a system property controlling color mode that we need to respect; if
|
||||
// not, this will set a suitable default.
|
||||
colorMode = getCurrentColorModeFromSystemProperties();
|
||||
}
|
||||
|
||||
@@ -418,10 +419,13 @@ public final class ColorDisplayController {
|
||||
if (colorMode == COLOR_MODE_BOOSTED && isColorModeAvailable(COLOR_MODE_NATURAL)) {
|
||||
colorMode = COLOR_MODE_NATURAL;
|
||||
} else if (colorMode == COLOR_MODE_SATURATED
|
||||
&& isColorModeAvailable(COLOR_MODE_AUTOMATIC)) {
|
||||
&& isColorModeAvailable(COLOR_MODE_AUTOMATIC)) {
|
||||
colorMode = COLOR_MODE_AUTOMATIC;
|
||||
} else {
|
||||
} else if (colorMode == COLOR_MODE_AUTOMATIC
|
||||
&& isColorModeAvailable(COLOR_MODE_SATURATED)) {
|
||||
colorMode = COLOR_MODE_SATURATED;
|
||||
} else {
|
||||
colorMode = -1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -189,6 +189,13 @@ public final class ColorDisplayService extends SystemService
|
||||
mController = new ColorDisplayController(getContext(), mCurrentUser);
|
||||
mController.setListener(this);
|
||||
|
||||
// Set the color mode, if valid, and immediately apply the updated tint matrix based on the
|
||||
// existing activated state. This ensures consistency of tint across the color mode change.
|
||||
onDisplayColorModeChanged(mController.getColorMode());
|
||||
|
||||
// Reset the activated state.
|
||||
mIsActivated = null;
|
||||
|
||||
setCoefficientMatrix(getContext(), DisplayTransformManager.needsLinearColorMatrix());
|
||||
|
||||
// Prepare color transformation matrix.
|
||||
@@ -201,9 +208,6 @@ public final class ColorDisplayService extends SystemService
|
||||
if (mIsActivated == null) {
|
||||
onActivated(mController.isActivated());
|
||||
}
|
||||
|
||||
// Transition the screen to the current temperature.
|
||||
applyTint(false);
|
||||
}
|
||||
|
||||
private void tearDown() {
|
||||
@@ -223,8 +227,6 @@ public final class ColorDisplayService extends SystemService
|
||||
mColorMatrixAnimator.end();
|
||||
mColorMatrixAnimator = null;
|
||||
}
|
||||
|
||||
mIsActivated = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -288,6 +290,10 @@ public final class ColorDisplayService extends SystemService
|
||||
|
||||
@Override
|
||||
public void onDisplayColorModeChanged(int mode) {
|
||||
if (mode == -1) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Cancel the night display tint animator if it's running.
|
||||
if (mColorMatrixAnimator != null) {
|
||||
mColorMatrixAnimator.cancel();
|
||||
@@ -297,7 +303,8 @@ public final class ColorDisplayService extends SystemService
|
||||
setMatrix(mController.getColorTemperature(), mMatrixNight);
|
||||
|
||||
final DisplayTransformManager dtm = getLocalService(DisplayTransformManager.class);
|
||||
dtm.setColorMode(mode, mIsActivated ? mMatrixNight : MATRIX_IDENTITY);
|
||||
dtm.setColorMode(mode, (mIsActivated != null && mIsActivated) ? mMatrixNight
|
||||
: MATRIX_IDENTITY);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.server;
|
||||
package com.android.server.display;
|
||||
|
||||
import android.annotation.NonNull;
|
||||
import android.app.ActivityManager;
|
||||
@@ -32,8 +32,8 @@ import android.test.mock.MockContentResolver;
|
||||
|
||||
import com.android.internal.app.ColorDisplayController;
|
||||
import com.android.internal.util.test.FakeSettingsProvider;
|
||||
import com.android.server.display.DisplayTransformManager;
|
||||
import com.android.server.display.ColorDisplayService;
|
||||
import com.android.server.LocalServices;
|
||||
import com.android.server.SystemService;
|
||||
import com.android.server.twilight.TwilightListener;
|
||||
import com.android.server.twilight.TwilightManager;
|
||||
import com.android.server.twilight.TwilightState;
|
||||
Reference in New Issue
Block a user