!19720 merge 29logCut into master

log cut

Created-by: wlh2624_DS
Commit-by: wlh2624_DS
Merged-by: openharmony_ci
Description: **IssueNo**:
https://gitcode.com/openharmony/ability_ability_runtime/issues/15549
**Description**:

**稳定性自检:**
| 自检项                                                       | 自检结果  |
| ------------------------------------------------------------ | -------- |
| 涉及跨进程调用的相关操作需要抛至主线程或加锁防止并发              |          |
| 成员变量进行赋值或创建需要排查并发                               |          |
| 谨慎在lambda表达式中使用引用捕获                                |          |
| 谨慎在未经拷贝的情况下使用外部传入的string、C字符串               |          |
| map\vector\list\set等stl模板类使用时需要排查并发                |          |
| 谨慎考虑加锁范围                                               |          |
| 在IPC通信中谨慎使用同步通信方式                                 |          |
| 禁止传递this指针至其他模块或线程(特别是eventhandler任务)        |          |
| 禁止将外部传入的裸指针在内部直接构造智能指针                      |          |
| 禁止多个独立创建的智能指针管理同一地址                           |          |
| 禁止在析构函数中抛异步任务                                      |          |
| 禁止js对象在非js线程(例如在IPC线程)创建、使用或销毁             |          |
| 禁止在对外接口中未经判空直接使用外部传入的指针                    |          |
| 禁止接口返回局部变量引用                                        |          |
| 禁止在信号函数中加锁                                            |          |
| 禁止在关键流程(SA启动、应用启动等主流程)执行耗时的操作           |          |
| 禁止将同一个cpp编译在不同的so中                                 |          |

**安全编码自检:**
| 自检项                                                          | 自检结果 |
| -------------------------------------------------------------- | -------- |
| 裸指针避免通过隐式转换构造为sptr                                 |          |
| json对象在取值之前必须先判断类型,避免类型不匹配                   |          |
| 序列化时必须对传入的数组大小进行校验,避免出现超大数组              |          |
| 避免使用未明确位宽的整型,选择使用int8_t、uint8_t等类型            |          |
| 外部传入的路径要做规范化校验,对路径中的.、..、../等特殊字符严格校验 |          |
| 指针变量、表示资源描述符的变量、bool变量必须赋初值                  |          |
| readParcelable获取的对象使用前需要判空                            |          |
| 分配和释放内存的函数需要成对出现                                   |          |
| 申请内存后异常退出前需要及时进行内存释放                            |          |
| 内存申请前必须对内存大小进行合法性校验                              |          |
| 内存分配后必须判断是否成功                                         |          |
| 禁止使用realloc、alloca函数                                       |          |
| 禁止打印文件路径、口令等敏感信息,如有需要,使用private修饰          |          |
| 禁止打印内存地址                                                  |          |
| 整数之间运算时必须严格检查,确保不会出现溢出、反转、除0               |          |
| 禁止对有符号整数进行位操作符运算                                    |          |
| 禁止对指针进行逻辑或位运算                                         |          |
| 循环次数如果收外部数据控制,需要检验其合法性                         |          |
| 禁止使用内存操作类危险函数,需要使用安全函数                         |          |
| 谨慎使用不可重入函数                                               |          |
| 必须检查安全函数的返回值,并进行正确处理                             |          |
| 禁止仅通过TokenType类型判断绕过权限校验                             |          |

**TDD Result**:

**XTS Result**:

### 是否已执行L0用例
- [ ] 已验证
- [ ] 不涉及。如不涉及,请写明理由


See merge request: openharmony/ability_ability_runtime!19720
This commit is contained in:
openharmony_ci
2026-06-29 21:12:45 +08:00
12 changed files with 30 additions and 24 deletions
@@ -24,12 +24,12 @@ class AppServiceExtensionContext extends ExtensionContext {
}
connectServiceExtensionAbility(want, options) {
hilog.sLogI(domainID, TAG, 'connectServiceExtensionAbility');
hilog.sLogI(domainID, TAG, 'conSrvEA');
return this.__context_impl__.connectServiceExtensionAbility(want, options);
}
disconnectServiceExtensionAbility(connection) {
hilog.sLogI(domainID, TAG, 'disconnectServiceExtensionAbility');
hilog.sLogI(domainID, TAG, 'disConSrvEA');
return this.__context_impl__.disconnectServiceExtensionAbility(connection);
}
@@ -55,7 +55,7 @@ class ServiceExtensionContext extends ExtensionContext {
}
connectServiceExtensionAbility(want, options) {
hilog.sLogI(domainID, TAG, 'connectServiceExtensionAbility');
hilog.sLogI(domainID, TAG, 'conSrvEA');
return this.__context_impl__.connectServiceExtensionAbility(want, options);
}
@@ -110,7 +110,7 @@ class ServiceExtensionContext extends ExtensionContext {
}
disconnectServiceExtensionAbility(connection, callback) {
hilog.sLogI(domainID, TAG, 'disconnectServiceExtensionAbility');
hilog.sLogI(domainID, TAG, 'disConSrvEA');
return this.__context_impl__.disconnectServiceExtensionAbility(connection, callback);
}
@@ -40,12 +40,12 @@ class UIServiceExtensionContext extends ExtensionContext {
}
connectServiceExtensionAbility(want, options) {
hilog.sLogI(domainID, TAG, 'connectServiceExtensionAbility');
hilog.sLogI(domainID, TAG, 'conSrvEA');
return this.__context_impl__.connectServiceExtensionAbility(want, options);
}
disconnectServiceExtensionAbility(connection, callback) {
hilog.sLogI(domainID, TAG, 'disconnectServiceExtensionAbility');
hilog.sLogI(domainID, TAG, 'disConSrvEA');
return this.__context_impl__.disconnectServiceExtensionAbility(connection, callback);
}
}
@@ -575,7 +575,7 @@ void JsWantAgent::SetOnGetBundleNameCallback(std::shared_ptr<WantAgent> wantAgen
auto retCode = std::make_shared<int32_t>(NO_ERROR);
auto bundleName = std::make_shared<std::string>();
execute = [wantAgent, retCode, bundleName] () {
TAG_LOGI(AAFwkTag::WANTAGENT, "get bundle name callback");
TAG_LOGD(AAFwkTag::WANTAGENT, "get bundle name callback");
*retCode = WantAgentHelper::GetBundleName(wantAgent, *bundleName);
};
complete = [retCode, bundleName](napi_env env, NapiAsyncTask &task, int32_t status) {
@@ -1122,7 +1122,7 @@ void ContextImpl::GetOverlayPath(std::shared_ptr<Global::Resource::ResourceManag
std::vector<AppExecFwk::OverlayModuleInfo> overlayModuleInfos;
auto res = GetOverlayModuleInfos(bundleName, moduleName, overlayModuleInfos);
if (res != ERR_OK) {
TAG_LOGE(AAFwkTag::APPKIT, "Get overlay paths from bms failed.");
TAG_LOGD(AAFwkTag::APPKIT, "Get overlay paths from bms failed.");
}
if (overlayModuleInfos.size() == 0) {
if (!resourceManager->AddResource(loadPath.c_str())) {
@@ -208,17 +208,17 @@ ErrCode ServiceExtensionContext::StopServiceExtensionAbility(const AAFwk::Want&
ErrCode ServiceExtensionContext::ConnectAbilityWithAccount(
const AAFwk::Want &want, int32_t accountId, const sptr<AbilityConnectCallback> &connectCallback) const
{
TAG_LOGI(AAFwkTag::APPKIT, "begin");
TAG_LOGD(AAFwkTag::APPKIT, "begin");
ErrCode ret =
ConnectionManager::GetInstance().ConnectAbilityWithAccount(token_, want, accountId, connectCallback);
TAG_LOGI(AAFwkTag::APPKIT, "ConnectAbilityWithAccount ErrorCode = %{public}d", ret);
TAG_LOGI(AAFwkTag::APPKIT, "ConAbiWithAcc:%{public}d", ret);
return ret;
}
ErrCode ServiceExtensionContext::DisconnectAbility(const AAFwk::Want &want,
const sptr<AbilityConnectCallback> &connectCallback, int32_t accountId) const
{
TAG_LOGI(AAFwkTag::APPKIT, "Disconnect c:%{public}s, t:%{public}s",
TAG_LOGI(AAFwkTag::APPKIT, "DisCon %{public}s,%{public}s",
GetAbilityInfo() == nullptr ? "" : GetAbilityInfo()->name.c_str(), want.GetElement().GetAbilityName().c_str());
ErrCode ret =
ConnectionManager::GetInstance().DisconnectAbility(token_, want, connectCallback, accountId);
+5 -5
View File
@@ -850,7 +850,7 @@ void MainThread::ScheduleLaunchAbility(const AbilityInfo &info, const sptr<IRemo
const std::shared_ptr<AAFwk::Want> &want, int32_t abilityRecordId, const std::shared_ptr<AppUpdateInfo> updateInfo)
{
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
TAG_LOGI(AAFwkTag::APPKIT, "%{public}s called, ability %{public}s, type is %{public}d.",
TAG_LOGI(AAFwkTag::APPKIT, "%{public}s called,ability %{public}s,%{public}d",
__func__, info.name.c_str(), info.type);
bool skipAbilityStageLifecycle = false;
@@ -1902,8 +1902,8 @@ void MainThread::HandleLaunchApplication(const AppLaunchData &appLaunchData, con
options.enableWarmStartupSmartGC =
(appLaunchData.GetAppPreloadMode() == AppExecFwk::PreloadMode::PRE_MAKE ||
appLaunchData.GetAppPreloadMode() == AppExecFwk::PreloadMode::PRELOAD_MODULE);
TAG_LOGI(AAFwkTag::APPKIT, "SmartGC: process is start. enable warm startup SmartGC: %{public}d"
" version:%{public}u", static_cast<int32_t>(options.enableWarmStartupSmartGC), bundleInfo.versionCode);
TAG_LOGI(AAFwkTag::APPKIT, "SmartGC:%{public}d version:%{public}u",
static_cast<int32_t>(options.enableWarmStartupSmartGC), bundleInfo.versionCode);
auto perfCmd = appLaunchData.GetPerfCmd();
auto findPos = perfCmd.find(BASE_LINE_PERFCMD);
if (findPos != std::string::npos && (appLaunchData.GetDebugFromLocal() || isDeveloperMode_)) {
@@ -2850,7 +2850,7 @@ void MainThread::HandleLaunchAbility(const std::shared_ptr<AbilityLocalRecord> &
UpdateWorkProcessInfo(updateInfo);
if (needNotifyApplicationPreAbilityCreate) {
TAG_LOGI(AAFwkTag::APPKIT, "NotifyApplicationPreAbilityCreate");
TAG_LOGI(AAFwkTag::APPKIT, "NtfyAppPreAbiCreate");
AppExecFwk::AppImageObserverManager::GetInstance().NotifyApplicationPreAbilityCreate();
}
@@ -2981,7 +2981,7 @@ void MainThread::HandleCleanAbility(const sptr<IRemoteObject> &token, bool isCac
TAG_LOGE(AAFwkTag::APPKIT, "null applicationInfo");
return;
}
TAG_LOGI(AAFwkTag::APPKIT, "Handle clean ability start, app is %{public}s.", applicationInfo_->name.c_str());
TAG_LOGD(AAFwkTag::APPKIT, "Handle clean ability start, app is %{public}s.", applicationInfo_->name.c_str());
if (!IsApplicationReady()) {
TAG_LOGE(AAFwkTag::APPKIT, "should launch application first");
@@ -159,7 +159,7 @@ void ConnectServerManager::StoreDebuggerInfo(int32_t tid, void* vm, const panda:
}
if (!isConnected_) {
TAG_LOGW(AAFwkTag::JSRUNTIME, "not Connected");
TAG_LOGW(AAFwkTag::JSRUNTIME, "disCon");
return;
}
@@ -308,7 +308,7 @@ void ConnectServerManager::RemoveInstance(int32_t instanceId)
}
if (!isConnected_) {
TAG_LOGW(AAFwkTag::JSRUNTIME, "not Connected");
TAG_LOGW(AAFwkTag::JSRUNTIME, "disCon");
return;
}
@@ -490,4 +490,4 @@ void ConnectServerManager::SendInstanceMessageAll(std::function<void(int32_t, co
}
}
}
} // namespace OHOS::AbilityRuntime
} // namespace OHOS::AbilityRuntime
@@ -7180,7 +7180,7 @@ std::string AbilityManagerService::GetPendingWantBundleName(const sptr<IWantSend
int AbilityManagerService::GetPendingWantCode(const sptr<IWantSender> &target)
{
TAG_LOGI(AAFwkTag::WANTAGENT, "%{public}s:begin", __func__);
TAG_LOGD(AAFwkTag::WANTAGENT, "%{public}s:begin", __func__);
if (target == nullptr) {
TAG_LOGE(AAFwkTag::WANTAGENT, "%s, target null", __func__);
return -1;
@@ -169,7 +169,7 @@ sptr<IWantSender> PendingWantManager::GetWantSenderLocked(const int32_t callingU
int32_t publisherUid)
{
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
TAG_LOGI(AAFwkTag::WANTAGENT, "begin");
TAG_LOGD(AAFwkTag::WANTAGENT, "begin");
bool needCreate = (static_cast<uint32_t>(wantSenderInfo.flags) &
static_cast<uint32_t>(Flags::NO_BUILD_FLAG)) == 0;
@@ -249,7 +249,7 @@ void PendingWantManager::MakeWantSenderCanceledLocked(PendingWantRecord &record)
sptr<PendingWantRecord> PendingWantManager::GetPendingWantRecordByKey(const std::shared_ptr<PendingWantKey> &key)
{
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
TAG_LOGI(AAFwkTag::WANTAGENT, "begin");
TAG_LOGD(AAFwkTag::WANTAGENT, "begin");
for (const auto &item : wantRecords_) {
const auto pendingKey = item.first;
const auto pendingRecord = item.second;
@@ -38,7 +38,7 @@ void PreLoadUIExtStateObserver::OnProcessDied(const AppExecFwk::ProcessData &pro
}
extensionRecord->UnloadUIExtensionAbility();
} else {
TAG_LOGW(AAFwkTag::UI_EXT, "extensionRecord null");
TAG_LOGW(AAFwkTag::UI_EXT, "null");
}
}
@@ -59,4 +59,4 @@ void PreLoadUIExtStateObserver::OnAppCacheStateChanged(const AppExecFwk::AppStat
}
}
} // namespace AAFwk
} // namespace OHOS
} // namespace OHOS
@@ -239,6 +239,12 @@ static bool ConvertFileName(const std::string& fileBaseName, std::string& abbrFi
abbrFileName = "AMSCHE";
} else if (fileBaseName == "base_extension_record") {
abbrFileName = "BER";
} else if (fileBaseName == "napi_want_agent") {
abbrFileName = "NWA";
} else if (fileBaseName == "pending_want_manager") {
abbrFileName = "PWM";
} else if (fileBaseName == "want_agent_helper") {
abbrFileName = "WAH";
} else if (fileBaseName == "connection_manager") {
abbrFileName = "CONM";
} else {