feat(ambient-brightness): add ambient light sensor based auto brightn… - #118
feat(ambient-brightness): add ambient light sensor based auto brightn…#118fly602 wants to merge 1 commit into
Conversation
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: fly602 The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
Reviewer's GuideAdd a new ambient-brightness plugin that exposes org.deepin.dde.AmbientBrightness1 on D-Bus, implements continuous ambient light based brightness recommendation with hysteresis/debounce and lifecycle handling, wires it into the Qt plugin build, and refactors existing power and shortcut code to rely on the new DBus state instead of the old DConfig toggle, preventing conflicts with power save brightness adjustments. Sequence diagram for ambient brightness recommendation and power-plan guardsequenceDiagram
participant SensorProxy as net_hadess_SensorProxy
participant AmbientBrightnessService
participant AmbientBrightnessModel
participant ContinuousAmbientLightPolicy
participant AmbientBrightness1 as org_deepin_dde_AmbientBrightness1
participant SessionDBusProxy
participant PowerManager
participant PowerSavePlan
SensorProxy->>AmbientBrightnessService: PropertiesChanged(LightLevel)
AmbientBrightnessService->>AmbientBrightnessModel: submitSample(lux, timestamp)
AmbientBrightnessModel->>ContinuousAmbientLightPolicy: update(SensorSample)
ContinuousAmbientLightPolicy-->>AmbientBrightnessModel: Recommendation
AmbientBrightnessModel-->>AmbientBrightnessService: recommendedBrightnessChanged(brightness)
AmbientBrightnessService-->>AmbientBrightness1: PropertiesChanged(State=Active, RecommendedBrightness)
PowerSavePlan->>PowerManager: isAmbientBrightnessActive()
PowerManager->>SessionDBusProxy: isAmbientBrightnessActive()
SessionDBusProxy->>AmbientBrightness1: get Property(State)
AmbientBrightness1-->>SessionDBusProxy: State
SessionDBusProxy-->>PowerManager: bool
alt ambient brightness active
PowerSavePlan-->>PowerSavePlan: [skip brightness change]
else inactive
PowerSavePlan-->>PowerSavePlan: applyBrightnessDrop()/resetBrightness()
end
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
f833acb to
8ae717f
Compare
1. Add an ambient brightness service backed by iio-sensor-proxy 2. Convert lux samples into stable brightness recommendations with filtering, hysteresis, and debounce 3. Coordinate sensor lifecycle with lid, sleep, session, service, and configuration state Influence: 1. Publish automatic brightness state and recommendations through org.deepin.dde.AmbientBrightness1 2. Prevent power-saving and manual brightness paths from conflicting with ambient brightness 3. Verify sensor lifecycle and brightness policy with unit tests fix: 支持环境光自动亮度调节 1. 新增基于iio-sensor-proxy的环境光亮度服务 2. 通过滤波、滞回和防抖将lux样本转换为稳定的亮度推荐值 3. 根据合盖、休眠、会话、传感器服务及配置状态管理光感生命周期 Influence: 1. 通过org.deepin.dde.AmbientBrightness1发布自动亮度状态及推荐值 2. 避免省电及手动亮度调节路径与环境光自动亮度冲突 3. 通过单元测试验证光感生命周期及亮度策略 PMS: BUG-372191
deepin pr auto review★ 总体评分:95分■ 【总体评价】
■ 【详细分析】
■ 【改进建议代码示例】 // src/plugin-qt/ambient-brightness/plugin.cpp
#include "ambientbrightnessservice.h"
#include <QDBusConnection>
#include <QMutex>
#include <QMutexLocker>
using dde::ambient_brightness::AmbientBrightnessService;
static AmbientBrightnessService *g_service = nullptr;
static QMutex g_serviceMutex;
extern "C" int DSMRegister(const char *, void *data)
{
QMutexLocker locker(&g_serviceMutex);
auto *connection = reinterpret_cast<QDBusConnection *>(data);
if (!connection)
return -1;
// 防御重复注册:先释放可能存在的旧实例,避免覆盖全局指针时泄漏。
delete g_service;
g_service = nullptr;
g_service = new AmbientBrightnessService(*connection);
if (!g_service->initialize()) {
delete g_service;
g_service = nullptr;
return -1;
}
return 0;
}
extern "C" int DSMUnRegister(const char *, void *)
{
QMutexLocker locker(&g_serviceMutex);
delete g_service;
g_service = nullptr;
return 0;
} |
|
TAG Bot New tag: 1.0.37 |
…ess plugin
Add a new ambient-brightness plugin that reads lux from iio-sensor-proxy, applies filtering, hysteresis, and debouncing, and publishes recommended brightness via DBus (org.deepin.dde.AmbientBrightness1). Refactor the power plugin to remove the old DConfig-based ambient brightness toggle, add isAmbientBrightnessActive() guard to PowerSavePlan so brightness save-plan operations don't conflict with ambient auto brightness. Remove redundant auto-brightness disable logic from dde-shortcut-tool since Display1.ChangeBrightness already calls prepareManualBrightnessChange() which disables ambient brightness via DBus.
新增环境光自动亮度插件,从 iio-sensor-proxy 读取 lux 值,经过滤波、滞回
和防抖处理后通过 DBus 发布推荐亮度。重构 power 插件,删除旧的 DConfig
自动亮度开关,在 PowerSavePlan 中添加 isAmbientBrightnessActive 守卫避免 省电计划与自动亮度冲突。移除 dde-shortcut-tool 中冗余的自动亮度关闭逻辑
(Display1.ChangeBrightness 已通过 prepareManualBrightnessChange 处理)。
Log: add ambient brightness plugin and refactor power/shortcut for auto brightness
Summary by Sourcery
Introduce a new ambient brightness plugin that exposes automatic brightness recommendations over DBus and integrates it with existing power and shortcut components.
New Features:
Enhancements:
Build:
Documentation:
Tests: