Closed
GetAppUid回退分支平台宏精确化:default实现中CROSS_PLATFORM收窄为ANDROID_PLATFORM #2571
jizaiyiAdd on  1 day agoClosed at  9 hours ago
jizaiyi
jizaiyi
1 day ago Create

问题描述

platform/default/process_helper.cpp 中 GetAppUid() 的回退分支以 #if defined(CROSS_PLATFORM) || defined(ETS_UTILS_HOST_UT) 守卫,注释称 AppUid 在 ArkUI-X 跨平台不存在。但对照 js_sys_module/process/BUILD.gn 的平台源选择逻辑:

  • iOS ArkUI-X 构建编译的是 platform/ios/process_helper.cpp(target_os == "ios" 分支),不经过 default 版本文件;
  • 实际编译 default 版 process_helper.cpp 的 ArkUI-X 形态只有 Android(该构建同时定义 ANDROID_PLATFORM 与 CROSS_PLATFORM);
  • OHOS 标准构建两宏均未定义,走 getappuid 主路径;Linux host UT 由 ETS_UTILS_HOST_UT 覆盖。

因此 default 实现中的 CROSS_PLATFORM 守卫宽于实际需要,且暗示 iOS 会经本文件走回退(实际不会),语义不精确。

修改方案

将该 #if 守卫中的 CROSS_PLATFORM 收窄为 ANDROID_PLATFORM,使守卫宏与真正编译本文件的平台精确对齐。

行为影响分析(对现有构建矩阵):

构建形态 编译文件 修改前 修改后
OHOS 标准构建 default 版 getappuid+缓存 不变
Android ArkUI-X default 版 getuid 回退 不变(ANDROID_PLATFORM 亦定义)
iOS ArkUI-X ios 版 getuid 回退 不变(不编译本文件)
Linux host UT default 版 getuid 回退 不变(ETS_UTILS_HOST_UT)

现有构建矩阵内行为完全保持,属守卫宏精确化。

likedislike
openharmony_ci
openharmony_ciCollaborators
1 day ago Comments:

感谢提交Issue!关于Issue的交互操作,请访问OpenHarmony社区支持命令清单。如果有问题,请联系 [@weng-changcheng](https://gitcode.com/weng-changcheng) [@xliu-huanwei](https://gitcode.com/xliu-huanwei) [@gong_19901](https://gitcode.com/gong_19901) 。如果需要调整订阅PR、Issue的变更状态,请访问链接。


Thanks for submitting the issue. For more commands, please visit OpenHarmony Command List. If you have any questions, please refer to committer gitcode for help. If you need to change the subscription of a Pull Request or Issue, please visit the link.

likedislike
openharmony_ciopenharmony_ciCollaborators
1 day ago Added label: waiting_for_assign
jizaiyijizaiyi
1 day ago Associated pull request
openharmony_ciopenharmony_ciCollaborators
9 hours ago Close issue
openharmony_ciopenharmony_ciCollaborators
9 hours ago changed custom state from 待办的 to 已完成