overlay/sensors: Configure Doze brightness sensor

Oplus doze brightness sensors either reports 0 or 1

0.0 - Dark environment
1.0 - Bright environment

aod_light_mode value of 1 enables qcom,mdss-dsi-aod-low-mode-command
and any other value would enable qcom,mdss-dsi-aod-high-mode-command

Change-Id: I98e3ea6abe0375ca75dad1b82e0bc6a1551cbb0e
This commit is contained in:
pjgowtham
2024-10-03 10:53:29 +05:30
committed by TechPanelGM
parent ff08d01f05
commit 42d234e7b1
3 changed files with 34 additions and 0 deletions

View File

@@ -17,6 +17,7 @@
#include "HalProxyCallback.h"
#include <cinttypes>
#include <fstream>
namespace android {
namespace hardware {
@@ -66,6 +67,7 @@ std::vector<V2_1::Event> HalProxyCallbackBase::processEvents(const std::vector<V
size_t* numWakeupEvents) const {
*numWakeupEvents = 0;
std::vector<V2_1::Event> eventsOut;
const char* aodLightModeNode = "/sys/kernel/oplus_display/aod_light_mode_set";
for (V2_1::Event event : events) {
event.sensorHandle = setSubHalIndex(event.sensorHandle, mSubHalIndex);
if (event.sensorType == V2_1::SensorType::DYNAMIC_SENSOR_META) {
@@ -84,6 +86,14 @@ std::vector<V2_1::Event> HalProxyCallbackBase::processEvents(const std::vector<V
continue;
}
if (sensor.typeAsString == "qti.sensor.lux_aod") {
std::ofstream nodeFile(aodLightModeNode);
if (nodeFile.is_open()) {
nodeFile << !event.u.scalar;
nodeFile.close();
}
}
if ((sensor.flags & V1_0::SensorFlagBits::WAKE_UP) != 0) {
(*numWakeupEvents)++;
}

View File

@@ -1,3 +1,6 @@
on boot
chmod 666 /sys/kernel/oplus_display/aod_light_mode_set
service vendor.sensors-hal-multihal /vendor/bin/hw/android.hardware.sensors-service.oplus-multihal
class hal
user system

View File

@@ -5,9 +5,30 @@
-->
<resources>
<!-- Type of a sensor that provides a low-power estimate of the desired display
brightness, suitable to listen to while the device is asleep (e.g. during
always-on display) -->
<string name="doze_brightness_sensor_type" translatable="false">qti.sensor.lux_aod</string>
<!-- Doze: does this device support STATE_DOZE? -->
<bool name="doze_display_state_supported">true</bool>
<!-- Doze: Table that translates sensor values from the doze_brightness_sensor_type sensor
to brightness values; -1 means keeping the current brightness. -->
<integer-array name="config_doze_brightness_sensor_to_brightness">
<item>-1</item>
<item>-1</item>
</integer-array>
<!-- Doze: Table that translates sensor values from the doze_brightness_sensor_type sensor
to an opacity value for a black scrim that is overlayed in AOD1.
Valid range is from 0 (transparent) to 255 (opaque).
-1 means keeping the current opacity. -->
<integer-array name="config_doze_brightness_sensor_to_scrim_opacity">
<item>-1</item>
<item>-1</item>
</integer-array>
<!-- Tiles to auto add to Quick Settings upon first change of a given secure setting.
The syntax is setting-name:spec. If the tile is a TileService, the spec should be specified
as custom(package/class). Relative class name is supported. -->