feat: pass launch_type when launching apps from launcher#757
feat: pass launch_type when launching apps from launcher#757Ivy233 merged 1 commit intolinuxdeepin:masterfrom
Conversation
Reviewer's guide (collapsed on small PRs)Reviewer's GuideAdds a launch_type parameter when the launcher starts apps so that downstream components can distinguish launcher-initiated launches for analytics/telemetry. Sequence diagram for launcher-initiated app start with launch_typesequenceDiagram
actor User
participant LauncherAppMgr as Launcher_AppMgr
participant QProcess
participant DdeAm as dde_am
User ->> LauncherAppMgr: launchApp(desktopId)
activate LauncherAppMgr
LauncherAppMgr ->> LauncherAppMgr: resolve amAppIface and path
LauncherAppMgr ->> QProcess: setProcessChannelMode(MergedChannels)
LauncherAppMgr ->> QProcess: start(dde-am, [--by-user, --launch-type, 1, path])
activate QProcess
QProcess ->> DdeAm: execute dde-am with args
DdeAm -->> QProcess: process launch result
QProcess -->> LauncherAppMgr: waitForFinished result
deactivate QProcess
LauncherAppMgr ->> LauncherAppMgr: check success and log if failed
deactivate LauncherAppMgr
Class diagram for AppMgr.launchApp change to include launch_typeclassDiagram
class AppMgr {
+bool launchApp(desktopId: QString)
}
class QProcess {
+setProcessChannelMode(mode: ProcessChannelMode) void
+start(program: QString, arguments: QStringList) void
+waitForFinished() bool
+errorString() QString
}
class AmAppIface {
+path() QString
}
AppMgr --> QProcess : uses
AppMgr --> AmAppIface : uses
note for AppMgr "launchApp now calls QProcess.start with arguments [--by-user, --launch-type, 1, path] to mark launcher-initiated launches"
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 left some high level feedback:
- Consider replacing the hardcoded "1" launch_type value with a named constant or enum to make the meaning clearer and reduce the chance of mistakes if additional launch types are added later.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Consider replacing the hardcoded "1" launch_type value with a named constant or enum to make the meaning clearer and reduce the chance of mistakes if additional launch types are added later.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
dd96b55 to
12eab7c
Compare
启动器启动应用时传入 launch_type 参数,用于应用启动埋点统计。 launch_type=1 表示从启动器点击启动。 Pass launch_type parameter when launching applications from launcher for application launch event reporting. launch_type=1 indicates the app was launched from the launcher. PMS: TASK-388657
12eab7c to
0c88e49
Compare
deepin pr auto review这段代码修改主要涉及对 1. 语法逻辑审查代码在语法上是正确的,使用了标准的 CMake 和 C++ 语法。逻辑上,通过 潜在问题:
2. 代码质量审查优点:
改进建议:
3. 代码性能审查
4. 代码安全审查
5. 改进后的代码示例以下是优化后的 bool AppMgr::launchApp(const QString &desktopId)
{
const auto path = amAppIface->path();
// 校验 path 合法性
if (path.isEmpty() || path.contains(QRegularExpression("[;|&`$]"))) {
qCWarning(logDdeIntegration) << "Invalid path for desktopId:" << desktopId;
return false;
}
QProcess process;
process.setProcessChannelMode(QProcess::MergedChannels);
#ifdef HAVE_DDE_API_EVENTLOGGER
process.start("dde-am", {"--by-user", "--launch-type", "dde-launchpad", path});
#else
process.start("dde-am", {"--by-user", path});
#endif
if (!process.waitForFinished(5000)) { // 设置超时时间
qCWarning(logDdeIntegration) << "Failed to launch the desktopId:" << desktopId
<< "Error:" << process.errorString();
process.kill(); // 确保进程终止
return false;
}
if (process.exitCode() != 0) {
qCWarning(logDdeIntegration) << "dde-am exited with error:" << process.exitCode()
<< "Output:" << process.readAll();
return false;
}
return true;
}6. 其他建议
总结整体代码逻辑清晰,但需加强错误处理和安全性检查,同时考虑性能优化(避免阻塞主线程)。建议在升级依赖版本后进行充分的测试,确保兼容性。 |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: BLumia, Ivy233 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 |
启动器启动应用时传入 launch_type 参数,用于应用启动埋点统计。
launch_type=1 表示从启动器点击启动。
Pass launch_type parameter when launching applications from launcher for application launch event reporting. launch_type=1 indicates the app was launched from the launcher.
PMS: TASK-388657
Summary by Sourcery
New Features: