feat: switch camera hotkey to daemon hardware privacy switch - #163
Conversation
Reviewer's GuideThe webcam hotkey is migrated from application/helper-script control to dde-shortcut-tool camera actions, which use org.deepin.dde.Daemon1 to query and apply hardware-level camera privacy, show corresponding OSD feedback, and remain silent when no switchable camera is available. Sequence diagram for hardware camera hotkey togglesequenceDiagram
actor User
participant Shortcut as dde-shortcut-tool
participant Daemon as org.deepin.dde.Daemon1
participant OSD as org.deepin.dde.Osd1
User->>Shortcut: camera toggle
Shortcut->>Daemon: GetCameraPrivacy()
Daemon-->>Shortcut: privacy, deviceKnown
alt switchable camera available
Shortcut->>Daemon: SetCameraPrivacy(!privacy)
Daemon-->>Shortcut: applied
alt hardware switch applied
Shortcut->>OSD: ShowOSD(CameraOn or CameraOff)
OSD-->>User: Matching camera OSD
else no switch applied
end
else no switchable camera
end
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've found 1 issue
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="src/plugin-qt/shortcut/tools/dde-shortcut-tool/cameracontroller.cpp" line_range="188" />
<code_context>
+ QDBusConnection::sessionBus()
+ );
+
+ if (osdInterface.isValid()) {
+ osdInterface.call("ShowOSD", signal);
+ } else {
+ qWarning() << "Failed to connect to OSD interface";
</code_context>
<issue_to_address>
**issue (bug_risk):** `ShowOSD` is called without checking the returned D-Bus message, so a camera switch can succeed while the OSD call fails and `execute` still reports success. The hotkey therefore does not guarantee the matching OSD described by the feature.
**Triggers:** When the OSD service is registered but rejects or fails the `ShowOSD` method call.
**Suggested fix:** Capture the returned `QDBusMessage` and log or propagate its error when the call is not a valid reply.
```suggestion
QDBusMessage reply = osdInterface.call("ShowOSD", signal);
if (reply.type() != QDBusMessage::ReplyMessage) {
qWarning() << "ShowOSD failed:" << reply.errorMessage();
}
```
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
469f119 to
902a9b6
Compare
yixinshark
left a comment
There was a problem hiding this comment.
看是否需要添加对dde-daemon版本的依赖。
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: fly602, yixinshark 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 |
1. Add CameraController to dde-shortcut-tool exposing camera toggle/on/off. It reads the real device state through org.deepin.dde.Daemon1.GetCameraPrivacy and switches it through SetCameraPrivacy, so the camera is disabled at the hardware level. 2. The hotkey only drives the hardware switch and shows the matching OSD; it never launches or closes the camera application. When the daemon reports no switchable camera, the hotkey stays silent. 3. Point the webcam shortcut config at dde-shortcut-tool camera toggle so the hotkey no longer needs the camera-switch helper script. Log: 摄像头热键改为仅通过系统接口硬件级开关摄像头,不关联相机应用 Influence: 1. Press the camera hotkey on a machine with a USB camera and confirm the camera toggles off/on with the OSD shown, and the built-in mic on the same device keeps working. 2. Press the camera hotkey on a machine without a switchable camera and confirm nothing happens (no application is launched). 3. Build dde-shortcut-tool and confirm camera toggle/on/off commands work without errors. feat: 摄像头热键改为仅通过系统接口硬件级开关摄像头 1. 在 dde-shortcut-tool 中新增 CameraController,提供 camera toggle/on/off,经 org.deepin.dde.Daemon1.GetCameraPrivacy 读取状态、 SetCameraPrivacy 开关,硬件级禁用摄像头。 2. 热键仅驱动硬件开关并显示 OSD,不启停相机应用;守护进程无可切换 摄像头时热键静默不动作。 3. 将 webcam 快捷键配置指向 dde-shortcut-tool camera toggle,热键不再 依赖 camera-switch 辅助脚本。 Log: 摄像头热键改为仅通过系统接口硬件级开关摄像头,不关联相机应用 Influence: 1. 有 USB 摄像头的机型按热键,确认开关且有 OSD,同设备内置麦克风 不受影响。 2. 无可切换摄像头的机型按热键,确认无动作(不启动相机应用)。 3. 构建 dde-shortcut-tool,确认 camera toggle/on/off 命令无报错。 PMS: BUG-375443
deepin pr auto review🤖 AI 代码审查报告📊 总体评价
🔍 详细分析1. 语法逻辑 ✅评价: 优秀 ✅ 通过 潜在问题: 建议: 代码语法正确,逻辑清晰,边界处理完善。CameraController 通过 D-Bus 与系统守护进程通信,toggle() 函数正确读取当前隐私状态并翻转,setPrivacy() 正确处理守护进程返回的 applied 标志,currentPrivacy() 和 requestPrivacy() 均检查接口有效性和返回参数数量,错误处理完整。 2. 代码质量 ✅评价: 优秀 ✅ 通过 潜在问题: 建议: 代码结构清晰,注释完整。SPDX 版权头声明齐全,头文件使用 #ifndef 保护,命名空间内常量定义规范,函数职责单一,每个方法都有明确的功能边界。cameracontroller.h 中类文档注释详细说明了设计意图(仅驱动硬件开关,不启停相机应用)。 3. 代码性能 ✅评价: 优秀 ✅ 通过 潜在问题: 建议: 性能良好,资源使用合理。QDBusInterface 在构造函数中创建一次并复用,避免重复连接开销。同步 D-Bus 调用对于一次性 CLI 工具是合理的,无性能瓶颈。showOSD() 中的 OSD 接口为栈上临时对象,符合使用场景。 4. 代码安全 🔒评价: 优秀 ✅ 通过
安全漏洞详情: 建议: 安全合规。action 参数仅与固定字符串(toggle/on/off)比较,无注入风险。D-Bus 通信目标为系统已知服务(org.deepin.dde.Daemon1、org.deepin.dde.Osd1),无用户输入直接传递到 D-Bus 调用。showOSD 的 signal 参数来自硬编码字符串(CameraOff/CameraOn)。相比删除的 camera-switch 脚本(使用 pgrep/pkill/exec),新方案通过 D-Bus 接口交互,安全性显著提升。 💡 改进建议代码示例// 当前实现已符合规范,无需额外修复
// CameraController 通过 D-Bus 安全地控制摄像头硬件隐私开关
bool CameraController::execute(const QString &action, const QStringList &args)
{
Q_UNUSED(args);
// action 仅与固定字符串比较,无注入风险
if (action == "toggle") {
return toggle();
} else if (action == "on") {
return setPrivacy(false);
} else if (action == "off") {
return setPrivacy(true);
}
qWarning() << "Unknown camera action:" << action;
return false;
}本报告由 AI 代码审查工具自动生成 |
|
/forcemerge |
|
This pr force merged! (status: blocked) |
Log: 摄像头热键改为仅通过系统接口硬件级开关摄像头,不关联相机应用
Influence:
feat: 摄像头热键改为仅通过系统接口硬件级开关摄像头
Log: 摄像头热键改为仅通过系统接口硬件级开关摄像头,不关联相机应用
Influence:
PMS: BUG-375443
Summary by Sourcery
Switch the webcam hotkey to control camera privacy through the system hardware interface without managing the camera application.
New Features:
Bug Fixes:
Enhancements: