lineage-sdk: Add backend for reading enhancement
Change-Id: Ibd1c9e057ddf8e9d21657aef0ebeeaa9a253e92d
This commit is contained in:
committed by
Joey Rizzoli
parent
ff242a26c1
commit
18fd692bbd
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Copyright (C) 2015-2016 The CyanogenMod Project
|
||||
* 2017 The LineageOS Project
|
||||
* 2017-2018 The LineageOS Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -51,6 +51,7 @@ import org.lineageos.hardware.HighTouchSensitivity;
|
||||
import org.lineageos.hardware.KeyDisabler;
|
||||
import org.lineageos.hardware.LongTermOrbits;
|
||||
import org.lineageos.hardware.PictureAdjustment;
|
||||
import org.lineageos.hardware.ReadingEnhancement;
|
||||
import org.lineageos.hardware.SerialNumber;
|
||||
import org.lineageos.hardware.SunlightEnhancement;
|
||||
import org.lineageos.hardware.TouchscreenGestures;
|
||||
@@ -111,6 +112,8 @@ public class LineageHardwareService extends LineageSystemService {
|
||||
|
||||
public TouchscreenGesture[] getTouchscreenGestures();
|
||||
public boolean setTouchscreenGestureEnabled(TouchscreenGesture gesture, boolean state);
|
||||
|
||||
public boolean setGrayscale(boolean state);
|
||||
}
|
||||
|
||||
private class LegacyLineageHardware implements LineageHardwareInterface {
|
||||
@@ -132,6 +135,8 @@ public class LineageHardwareService extends LineageSystemService {
|
||||
mSupportedFeatures |= LineageHardwareManager.FEATURE_KEY_DISABLE;
|
||||
if (LongTermOrbits.isSupported())
|
||||
mSupportedFeatures |= LineageHardwareManager.FEATURE_LONG_TERM_ORBITS;
|
||||
if (ReadingEnhancement.isSupported())
|
||||
mSupportedFeatures |= LineageHardwareManager.FEATURE_READING_ENHANCEMENT;
|
||||
if (SerialNumber.isSupported())
|
||||
mSupportedFeatures |= LineageHardwareManager.FEATURE_SERIAL_NUMBER;
|
||||
if (SunlightEnhancement.isSupported())
|
||||
@@ -368,6 +373,10 @@ public class LineageHardwareService extends LineageSystemService {
|
||||
public boolean setTouchscreenGestureEnabled(TouchscreenGesture gesture, boolean state) {
|
||||
return TouchscreenGestures.setGestureEnabled(gesture, state);
|
||||
}
|
||||
|
||||
public boolean setGrayscale(boolean state) {
|
||||
return ReadingEnhancement.setGrayscale(state);
|
||||
}
|
||||
}
|
||||
|
||||
private LineageHardwareInterface getImpl(Context context) {
|
||||
@@ -770,5 +779,16 @@ public class LineageHardwareService extends LineageSystemService {
|
||||
}
|
||||
return mLineageHwImpl.setTouchscreenGestureEnabled(gesture, state);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setGrayscale(boolean state) {
|
||||
mContext.enforceCallingOrSelfPermission(
|
||||
lineageos.platform.Manifest.permission.HARDWARE_ABSTRACTION_ACCESS, null);
|
||||
if (!isSupported(LineageHardwareManager.FEATURE_READING_ENHANCEMENT)) {
|
||||
Log.e(TAG, "Reading enhancement not supported");
|
||||
return false;
|
||||
}
|
||||
return mLineageHwImpl.setGrayscale(state);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
/*
|
||||
* Copyright (C) 2016 The CyanogenMod Project
|
||||
* 2018 The LineageOS Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -47,6 +48,7 @@ public class DisplayHardwareController extends LiveDisplayFeature {
|
||||
private final boolean mUseColorAdjustment;
|
||||
private final boolean mUseColorEnhancement;
|
||||
private final boolean mUseCABC;
|
||||
private final boolean mUseReaderMode;
|
||||
private final boolean mUseDisplayModes;
|
||||
|
||||
// default values
|
||||
@@ -71,6 +73,8 @@ public class DisplayHardwareController extends LiveDisplayFeature {
|
||||
LineageSettings.System.getUriFor(LineageSettings.System.DISPLAY_COLOR_ENHANCE);
|
||||
private static final Uri DISPLAY_CABC =
|
||||
LineageSettings.System.getUriFor(LineageSettings.System.DISPLAY_CABC);
|
||||
private static final Uri DISPLAY_READING_MODE =
|
||||
LineageSettings.System.getUriFor(LineageSettings.System.DISPLAY_READING_MODE);
|
||||
|
||||
public DisplayHardwareController(Context context, Handler handler) {
|
||||
super(context, handler);
|
||||
@@ -97,6 +101,9 @@ public class DisplayHardwareController extends LiveDisplayFeature {
|
||||
mUseDisplayModes = mHardware
|
||||
.isSupported(LineageHardwareManager.FEATURE_DISPLAY_MODES);
|
||||
|
||||
mUseReaderMode = mHardware
|
||||
.isSupported(LineageHardwareManager.FEATURE_READING_ENHANCEMENT);
|
||||
|
||||
if (mUseColorAdjustment) {
|
||||
mMaxColor = mHardware.getDisplayColorCalibrationMax();
|
||||
copyColors(getColorAdjustment(), mColorAdjustment);
|
||||
@@ -121,6 +128,9 @@ public class DisplayHardwareController extends LiveDisplayFeature {
|
||||
if (mUseColorAdjustment) {
|
||||
settings.add(DISPLAY_COLOR_ADJUSTMENT);
|
||||
}
|
||||
if (mUseReaderMode) {
|
||||
settings.add(DISPLAY_READING_MODE);
|
||||
}
|
||||
|
||||
if (settings.size() == 0) {
|
||||
return;
|
||||
@@ -146,8 +156,11 @@ public class DisplayHardwareController extends LiveDisplayFeature {
|
||||
if (mUseDisplayModes) {
|
||||
caps.set(LiveDisplayManager.FEATURE_DISPLAY_MODES);
|
||||
}
|
||||
if (mUseReaderMode) {
|
||||
caps.set(LiveDisplayManager.FEATURE_READING_ENHANCEMENT);
|
||||
}
|
||||
return mUseAutoContrast || mUseColorEnhancement || mUseCABC || mUseColorAdjustment ||
|
||||
mUseDisplayModes;
|
||||
mUseDisplayModes || mUseReaderMode;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -200,6 +213,7 @@ public class DisplayHardwareController extends LiveDisplayFeature {
|
||||
pw.println(" mUseColorEnhancement=" + mUseColorEnhancement);
|
||||
pw.println(" mUseCABC=" + mUseCABC);
|
||||
pw.println(" mUseDisplayModes=" + mUseDisplayModes);
|
||||
pw.println(" mUseReaderMode=" + mUseReaderMode);
|
||||
pw.println();
|
||||
pw.println(" DisplayHardwareController State:");
|
||||
pw.println(" mAutoContrast=" + isAutoContrastEnabled());
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/**
|
||||
* Copyright (c) 2015, The CyanogenMod Project
|
||||
* 2017 The LineageOS Project
|
||||
* Copyright (c) 2015-2016 The CyanogenMod Project
|
||||
* 2017-2018 The LineageOS Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -65,4 +65,6 @@ interface ILineageHardwareService {
|
||||
|
||||
TouchscreenGesture[] getTouchscreenGestures();
|
||||
boolean setTouchscreenGestureEnabled(in TouchscreenGesture gesture, boolean state);
|
||||
|
||||
boolean setGrayscale(boolean state);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Copyright (C) 2015-2016 The CyanogenMod Project
|
||||
* 2017 The LineageOS Project
|
||||
* 2017-2018 The LineageOS Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -134,6 +134,12 @@ public final class LineageHardwareManager {
|
||||
@VisibleForTesting
|
||||
public static final int FEATURE_DISPLAY_MODES = 0x2000;
|
||||
|
||||
/**
|
||||
* Reading mode
|
||||
*/
|
||||
@VisibleForTesting
|
||||
public static final int FEATURE_READING_ENHANCEMENT = 0x4000;
|
||||
|
||||
/**
|
||||
* Color balance
|
||||
*/
|
||||
@@ -868,4 +874,19 @@ public final class LineageHardwareManager {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Enables or disables reading mode
|
||||
*
|
||||
* @return true if success
|
||||
*/
|
||||
public boolean setGrayscale(boolean state) {
|
||||
try {
|
||||
if (checkService()) {
|
||||
return sService.setGrayscale(state);
|
||||
}
|
||||
} catch (RemoteException e) {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
/*
|
||||
* Copyright (C) 2016 The CyanogenMod Project
|
||||
* 2018 The LineageOS Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -120,6 +121,11 @@ public class LiveDisplayManager {
|
||||
*/
|
||||
public static final int FEATURE_PICTURE_ADJUSTMENT = 17;
|
||||
|
||||
/**
|
||||
* System supports grayscale matrix overlay
|
||||
*/
|
||||
public static final int FEATURE_READING_ENHANCEMENT = 18;
|
||||
|
||||
public static final int ADJUSTMENT_HUE = 0;
|
||||
public static final int ADJUSTMENT_SATURATION = 1;
|
||||
public static final int ADJUSTMENT_INTENSITY = 2;
|
||||
|
||||
@@ -1449,6 +1449,16 @@ public final class LineageSettings {
|
||||
public static final Validator DISPLAY_AUTO_OUTDOOR_MODE_VALIDATOR =
|
||||
sBooleanValidator;
|
||||
|
||||
/**
|
||||
* Reader mode
|
||||
* 0 = 0ff, 1 = on
|
||||
*/
|
||||
public static final String DISPLAY_READING_MODE = "display_reading_mode";
|
||||
|
||||
/** @hide */
|
||||
public static final Validator DISPLAY_READING_MODE_VALIDATOR =
|
||||
sBooleanValidator;
|
||||
|
||||
/**
|
||||
* Use display power saving features such as CABC or CABL
|
||||
* 0 = 0ff, 1 = on
|
||||
@@ -2058,6 +2068,7 @@ public final class LineageSettings {
|
||||
LineageSettings.System.DISPLAY_TEMPERATURE_NIGHT,
|
||||
LineageSettings.System.DISPLAY_TEMPERATURE_MODE,
|
||||
LineageSettings.System.DISPLAY_AUTO_OUTDOOR_MODE,
|
||||
LineageSettings.System.DISPLAY_READING_MODE,
|
||||
LineageSettings.System.DISPLAY_CABC,
|
||||
LineageSettings.System.DISPLAY_COLOR_ENHANCE,
|
||||
LineageSettings.System.DISPLAY_COLOR_ADJUSTMENT,
|
||||
@@ -2216,6 +2227,7 @@ public final class LineageSettings {
|
||||
VALIDATORS.put(DISPLAY_TEMPERATURE_MODE, DISPLAY_TEMPERATURE_MODE_VALIDATOR);
|
||||
VALIDATORS.put(DISPLAY_AUTO_CONTRAST, DISPLAY_AUTO_CONTRAST_VALIDATOR);
|
||||
VALIDATORS.put(DISPLAY_AUTO_OUTDOOR_MODE, DISPLAY_AUTO_OUTDOOR_MODE_VALIDATOR);
|
||||
VALIDATORS.put(DISPLAY_READING_MODE, DISPLAY_READING_MODE_VALIDATOR);
|
||||
VALIDATORS.put(DISPLAY_CABC, DISPLAY_CABC_VALIDATOR);
|
||||
VALIDATORS.put(DISPLAY_COLOR_ENHANCE, DISPLAY_COLOR_ENHANCE_VALIDATOR);
|
||||
VALIDATORS.put(DISPLAY_COLOR_ADJUSTMENT, DISPLAY_COLOR_ADJUSTMENT_VALIDATOR);
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
/**
|
||||
* Copyright (c) 2016, The CyanogenMod Project
|
||||
* Copyright (c) 2016 The CyanogenMod Project
|
||||
* 2018 The LineageOS Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -69,4 +70,5 @@ public class LineageMetricsLogger extends MetricsLogger {
|
||||
public static final int WEATHER_SETTINGS = BASE + 42;
|
||||
public static final int TILE_THEMES = BASE + 43;
|
||||
public static final int TILE_LOCATION_DETAIL = BASE + 44;
|
||||
public static final int TILE_READING_MODE = BASE + 45;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user