!18282 merge sendResultBackToCaller场景解除上报 into master

sendResultBackToCaller场景解除上报

Created-by: zhu-feimo
Commit-by: 朱菲墨
Merged-by: openharmony_ci
Description: **IssueNo**:
[#14430](https://gitcode.com/openharmony/ability_ability_runtime/issues/14430) 
**Description**:

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

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

**TDD Result**:
![image.png](https://raw.gitcode.com/user-images/assets/4421702/33244678-8bd2-4112-9eeb-3e3961d19fcc/image.png 'image.png')
**XTS Result**:
![image.png](https://raw.gitcode.com/user-images/assets/4421702/e5845e46-5acf-47ba-8036-b6d2f750719f/image.png 'image.png')
### 是否已执行L0用例
- [ ] 已验证
- [ ] 不涉及。如不涉及,请写明理由


See merge request: openharmony/ability_ability_runtime!18282
This commit is contained in:
openharmony_ci
2026-02-15 11:48:28 +08:00
4 changed files with 28 additions and 19 deletions
@@ -26,6 +26,9 @@
namespace OHOS {
namespace AAFwk {
class AbilityRecord;
namespace {
constexpr int32_t DEFAULT_REQUEST_CODE = -1;
}
/**
* @struct CallerAbilityInfo
@@ -144,6 +147,11 @@ public:
{
return requestCodeSet_;
}
bool HasForResultRequestCode()
{
return std::any_of(requestCodeSet_.begin(), requestCodeSet_.end(),
[](int32_t requestCode) { return requestCode != DEFAULT_REQUEST_CODE; });
}
private:
int32_t requestCode_ = -1; // requestCode of for-result start mode
@@ -334,7 +334,6 @@ constexpr const char* SCENEBOARD_BUNDLE_NAME = "com.ohos.sceneboard";
constexpr const char* SPECIFY_TOKEN_ID = "specifyTokenId";
constexpr const char* PROCESS_SUFFIX = "embeddable";
constexpr int32_t DEFAULT_DMS_MISSION_ID = -1;
constexpr int32_t DEFAULT_REQUEST_CODE = -1;
constexpr const char* PARAM_PREVENT_STARTABILITY = "persist.sys.abilityms.prevent_startability";
constexpr const char* SUSPEND_SERVICE_CONFIG_FILE = "/etc/efficiency_manager/prevent_startability_whitelist.json";
constexpr int32_t MAX_BUFFER = 2048;
@@ -9148,12 +9147,12 @@ void AbilityManagerService::RetrySubscribeUnlockedEvent(int32_t retryCount,
auto retrySubscribeScreenUnlockedEventTask = [aams = weak_from_this(), unlockedEventSubscriber = subscriber,
retryCount, isUserUnlock = isUserUnlockSubscriber]() {
CHECK_POINTER_LOG(unlockedEventSubscriber, "unlockedEventSubscriber nullptr");
bool subResult = EventFwk::CommonEventManager::SubscribeCommonEvent(unlockedEventSubscriber);
auto obj = aams.lock();
if (obj == nullptr) {
TAG_LOGE(AAFwkTag::ABILITYMGR, "retry subscribe screen unlocked event, obj null");
return;
}
bool subResult = EventFwk::CommonEventManager::SubscribeCommonEvent(unlockedEventSubscriber);
if (subResult) {
if (!isUserUnlock) {
obj->isSubscribed_ = true;
@@ -9165,9 +9164,7 @@ void AbilityManagerService::RetrySubscribeUnlockedEvent(int32_t retryCount,
obj->RetrySubscribeUnlockedEvent(retryCount - 1, unlockedEventSubscriber, isUserUnlock);
return;
}
if (!retryCount) {
TAG_LOGE(AAFwkTag::ABILITYMGR, "SU life, subscribe err:%{public}d", isUserUnlock);
}
TAG_LOGE(AAFwkTag::ABILITYMGR, "SU life, subscribe err:%{public}d", isUserUnlock);
};
constexpr int32_t delaytime = 200 * 1000; // us
ffrt::submit(std::move(retrySubscribeScreenUnlockedEventTask),
+18 -13
View File
@@ -113,7 +113,6 @@ const int32_t SHELL_ASSISTANT_DIETYPE = 0;
std::atomic<int64_t> AbilityRecord::abilityRecordId = 0;
const int32_t DEFAULT_USER_ID = 0;
const int32_t SEND_RESULT_CANCELED = -1;
const int32_t DEFAULT_REQUEST_CODE = -1;
const int VECTOR_SIZE = 2;
const int LOAD_TIMEOUT_ASANENABLED = 150;
const int TERMINATE_TIMEOUT_ASANENABLED = 150;
@@ -1319,10 +1318,6 @@ void AbilityRecord::SendResultByBackToCaller(const std::shared_ptr<AbilityResult
CHECK_POINTER(scheduler_);
CHECK_POINTER(result);
scheduler_->SendResult(result->requestCode_, result->resultCode_, result->resultWant_);
if (GetCallerInfo() != nullptr) {
DelayedSingleton<ForegroundAppConnectionManager>::GetInstance()->AbilityRemovePidConnection(
GetCallerInfo()->callerPid, GetPid(), GetAbilityRecordId());
}
}
void AbilityRecord::SendSandboxSavefileResult(const Want &want, int resultCode, int requestCode)
@@ -1551,17 +1546,27 @@ void AbilityRecord::RemoveCallerRequestCode(std::shared_ptr<AbilityRecord> calle
TAG_LOGI(AAFwkTag::ABILITYMGR, "null record");
return;
}
std::lock_guard guard(callerListLock_);
for (auto it = callerList_.begin(); it != callerList_.end(); it++) {
if ((*it)->GetCaller() == callerAbilityRecord) {
(*it)->RemoveHistoryRequestCode(requestCode);
if ((*it)->GetRequestCodeSet().empty()) {
callerList_.erase(it);
TAG_LOGI(AAFwkTag::ABILITYMGR, "remove callerRecord");
bool removePidConnection = false;
{
std::lock_guard guard(callerListLock_);
for (auto it = callerList_.begin(); it != callerList_.end(); it++) {
if ((*it) != nullptr && (*it)->GetCaller() == callerAbilityRecord) {
(*it)->RemoveHistoryRequestCode(requestCode);
if (!(*it)->HasForResultRequestCode()) {
removePidConnection = true;
}
if ((*it)->GetRequestCodeSet().empty()) {
callerList_.erase(it);
TAG_LOGI(AAFwkTag::ABILITYMGR, "remove callerRecord");
}
break;
}
return;
}
}
if (removePidConnection) {
DelayedSingleton<ForegroundAppConnectionManager>::GetInstance()->AbilityRemovePidConnection(
callerAbilityRecord->GetPid(), GetPid(), GetAbilityRecordId());
}
}
void AbilityRecord::AddCallerRecord(const sptr<IRemoteObject> &callerToken, int requestCode, const Want &want,
@@ -78,7 +78,6 @@ constexpr int32_t START_UI_ABILITY_PER_SECOND_UPPER_LIMIT = 20;
constexpr int32_t API20 = 20;
constexpr int32_t API_VERSION_MOD = 100;
constexpr int32_t REQUEST_LIST_ID_INIT = -1;
constexpr int32_t DEFAULT_REQUEST_CODE = -1;
constexpr const char* IS_CALLING_FROM_DMS = "supportCollaborativeCallingFromDmsInAAFwk";
constexpr int REMOVE_STARTING_BUNDLE_TIMEOUT_MICRO_SECONDS = 5000000; // 5s
constexpr int32_t BY_CALL_TIMEOUT = 10 * 1000 * 1000; // 10s