Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 58d9cefd authored by Jason Monk's avatar Jason Monk Committed by Android (Google) Code Review
Browse files

Merge "Allow color matrix to be controlled by secure setting"

parents 2945e95c 08e7fa9b
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -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.
+7 −0
Original line number Diff line number Diff line
@@ -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);
+15 −0
Original line number Diff line number Diff line
@@ -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;