Allow color matrix to be controlled by secure setting

Change-Id: Ia5518ad79fae502e814034edd7ae8d7a57b3eaeb
This commit is contained in:
Jason Monk
2015-12-07 20:05:08 -05:00
parent 8dac23eafc
commit 08e7fa9b69
3 changed files with 31 additions and 0 deletions

View File

@@ -4911,6 +4911,15 @@ public final class Settings {
public static final String ACCESSIBILITY_DISPLAY_DALTONIZER =
"accessibility_display_daltonizer";
/**
* Float list that specifies the color matrix to apply to
* the display. Valid values are defined in AccessibilityManager.
*
* @hide
*/
public static final String ACCESSIBILITY_DISPLAY_COLOR_MATRIX =
"accessibility_display_color_matrix";
/**
* Setting that specifies whether automatic click when the mouse pointer stops moving is
* enabled.

View File

@@ -3987,6 +3987,9 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub {
private final Uri mDisplayDaltonizerUri = Settings.Secure.getUriFor(
Settings.Secure.ACCESSIBILITY_DISPLAY_DALTONIZER);
private final Uri mDisplayColorMatrixUri = Settings.Secure.getUriFor(
Settings.Secure.ACCESSIBILITY_DISPLAY_COLOR_MATRIX);
private final Uri mHighTextContrastUri = Settings.Secure.getUriFor(
Settings.Secure.ACCESSIBILITY_HIGH_TEXT_CONTRAST_ENABLED);
@@ -4016,6 +4019,8 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub {
mDisplayDaltonizerEnabledUri, false, this, UserHandle.USER_ALL);
contentResolver.registerContentObserver(
mDisplayDaltonizerUri, false, this, UserHandle.USER_ALL);
contentResolver.registerContentObserver(
mDisplayColorMatrixUri, false, this, UserHandle.USER_ALL);
contentResolver.registerContentObserver(
mHighTextContrastUri, false, this, UserHandle.USER_ALL);
}
@@ -4066,6 +4071,8 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub {
if (readDisplayColorAdjustmentSettingsLocked(userState)) {
updateDisplayColorAdjustmentSettingsLocked(userState);
}
} else if (mDisplayColorMatrixUri.equals(uri)) {
updateDisplayColorAdjustmentSettingsLocked(userState);
} else if (mHighTextContrastUri.equals(uri)) {
if (readHighTextContrastEnabledSettingLocked(userState)) {
onUserStateChangedLocked(userState);

View File

@@ -107,9 +107,24 @@ class DisplayAdjustmentUtils {
setDaltonizerMode(AccessibilityManager.DALTONIZER_DISABLED);
}
String matrix = Settings.Secure.getStringForUser(cr,
Settings.Secure.ACCESSIBILITY_DISPLAY_COLOR_MATRIX, userId);
if (matrix != null) {
colorMatrix = multiply(colorMatrix, getMatrix(matrix));
}
setColorTransform(colorMatrix);
}
private static float[] getMatrix(String matrix) {
String[] strValues = matrix.split(",");
float[] values = new float[strValues.length];
for (int i = 0; i < values.length; i++) {
values[i] = Float.parseFloat(strValues[i]);
}
return values;
}
private static float[] multiply(float[] matrix, float[] other) {
if (matrix == null) {
return other;