Skip to content

feat: optimize system application recognition and add power save#1151

Merged
xionglinlin merged 1 commit into
linuxdeepin:masterfrom
xionglinlin:fix/idle
Jun 17, 2026
Merged

feat: optimize system application recognition and add power save#1151
xionglinlin merged 1 commit into
linuxdeepin:masterfrom
xionglinlin:fix/idle

Conversation

@xionglinlin

Copy link
Copy Markdown
Contributor

services

Changed case sensitivity handling in third-party app detection to first match desktop names exactly, then apply lowercase fallback for system app identification. Added ssh, udcp-guard, appstore daemon, and serial- getty services to power save configuration, plus fcitx5-helper to autostart list.

Log: Optimized system app recognition logic

Influence:

  1. Verify system applications are correctly identified without case- sensitivity issues
  2. Test autostart behavior with Fcitx5-related applications
  3. Confirm new services (ssh, udcp-guard, appstore daemon, serial-getty) are properly managed during power save
  4. Validate short-idle blacklist applications still function as expected
  5. Ensure existing third-party applications continue to trigger power save correctly

feat: 优化系统应用识别逻辑并新增电源节电服务

修改了第三方应用检测中的大小写处理逻辑,先完全匹配desktop名称,再对系统
应用识别使用小写回退。将ssh、udcp-guard、应用商店守护进程和serial-getty
服务添加到电源节电配置中,同时将fcitx5-helper添加到自动启动列表。

Log: 优化系统应用识别逻辑

Influence:

  1. 验证系统应用能否在无大小写问题的情况下正确识别
  2. 测试与Fcitx5相关应用的自动启动行为
  3. 确认新增服务(ssh、udcp-guard、应用商店守护进程、serial-getty)在节电 期间能被正确管理
  4. 验证短空闲黑名单应用仍按预期运行
  5. 确保现有第三方应用继续正确触发电源节电

PMS: TASK-389737
Change-Id: Ic51334bb540d923cec79dc1cddb0c8928394745d

services

Changed case sensitivity handling in third-party app detection to first
match desktop names exactly, then apply lowercase fallback for system
app identification. Added ssh, udcp-guard, appstore daemon, and serial-
getty services to power save configuration, plus fcitx5-helper to
autostart list.

Log: Optimized system app recognition logic

Influence:
1. Verify system applications are correctly identified without case-
sensitivity issues
2. Test autostart behavior with Fcitx5-related applications
3. Confirm new services (ssh, udcp-guard, appstore daemon, serial-getty)
are properly managed during power save
4. Validate short-idle blacklist applications still function as expected
5. Ensure existing third-party applications continue to trigger power
save correctly

feat: 优化系统应用识别逻辑并新增电源节电服务

修改了第三方应用检测中的大小写处理逻辑,先完全匹配desktop名称,再对系统
应用识别使用小写回退。将ssh、udcp-guard、应用商店守护进程和serial-getty
服务添加到电源节电配置中,同时将fcitx5-helper添加到自动启动列表。

Log: 优化系统应用识别逻辑

Influence:
1. 验证系统应用能否在无大小写问题的情况下正确识别
2. 测试与Fcitx5相关应用的自动启动行为
3. 确认新增服务(ssh、udcp-guard、应用商店守护进程、serial-getty)在节电
期间能被正确管理
4. 验证短空闲黑名单应用仍按预期运行
5. 确保现有第三方应用继续正确触发电源节电

PMS: TASK-389737
Change-Id: Ic51334bb540d923cec79dc1cddb0c8928394745d

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry @xionglinlin, you have reached your weekly rate limit of 500000 diff characters.

Please try again later or upgrade to continue using Sourcery

@deepin-ci-robot

Copy link
Copy Markdown

deepin pr auto review

★ 总体评分:100分

■ 【总体评价】

代码精准修复了系统应用误判为第三方应用的逻辑缺陷,实现严谨且无副作用
逻辑完全正确且无安全漏洞,符合满分标准

■ 【详细分析】

  • 1.语法逻辑完全正确✓

修复了 isThirdPartyAppRunning 函数中因过早调用 strings.ToLower 导致的 Map 键值匹配失败问题。将大小写转换延后至确认非系统应用之后,确保在 shortIdleBlacklistApplicationsMapsystemApplicationsMap 中的查找使用原始大小写,与 Map 中保存的原始键值严格匹配。
建议:当前逻辑已完美解决上下文描述的 BUG,无需额外修改。

  • 2.代码质量良好✓

修改范围精准克制,仅调整了必要的变量赋值位置,保留了清晰的注释说明修复意图。JSON 配置文件的更新(新增 fcitx5-helper.desktop 及多项系统服务)规范合理,有效扩充了系统白名单,避免了新增系统组件触发误判。
建议:可考虑在后续迭代中将硬编码的特征字符串提取为常量数组,进一步提升可维护性。

  • 3.代码性能无性能问题✓

strings.ToLower 从循环每次必经路径移入 !exists 的条件分支内部,在应用被成功匹配为系统应用或黑名单应用时直接跳过了不必要的字符串转换与内存分配,属于正向的性能优化。
建议:保持当前实现。

  • 4.代码安全存在0个安全漏洞✓

漏洞对比统计:新增漏洞 0 个,减少漏洞 0 个,持平 0 个
代码仅涉及内部状态判断与字符串匹配,不涉及外部不可信输入处理、命令执行或权限变更,未引入任何安全风险。
建议:保持当前安全的代码实现。

■ 【改进建议代码示例】

func (psp *powerSavePlan) isThirdPartyAppRunning() (ret bool) {
	// 检查启动应用的desktop,是否在系统应用 systemApplicationsMap 中
	// 只要有一个运行中的desktop不存在于 systemApplicationsMap 中,说明就有第三方应用运行
	for _, app := range launchedApplications {
		desktop := psp.getDesktopName(app)
		// 如果存在短idle黑名单应用在运行,则返回true -> 不进短idle
		if _, exists := shortIdleBlacklistApplicationsMap[desktop]; exists {
			logger.Info("Found shortIdle blacklist application running: ", app, desktop)
			return true
		}

		if _, exists := systemApplicationsMap[desktop]; !exists {
			desktop = strings.ToLower(desktop)
			// 如果不存在的应用的desktop包含deepin、dde、uos说明也是系统应用,这个应用应该加到系统应用列表中
			if strings.Contains(desktop, "deepin") || strings.Contains(desktop, "dde") || strings.Contains(desktop, "uos") {
				logger.Warning("Need add systemApplicationsMap, Running app : ", app, desktop)
				continue
			}
			logger.Info("Found third party application running: ", app, desktop)
			return true
		}
	}
	return false
}

@deepin-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: mhduiy, xionglinlin

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@xionglinlin xionglinlin merged commit 506c931 into linuxdeepin:master Jun 17, 2026
17 of 18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants