!19040 merge test_y0421 into master

provide dms interfaces

Created-by: renjh5496
Commit-by: renjh5496
Merged-by: openharmony_ci
Description: **IssueNo**:
https://gitcode.com/openharmony/ability_ability_runtime/issues/15028
**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        |    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**:

**XTS Result**:

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


See merge request: openharmony/ability_ability_runtime!19040
This commit is contained in:
openharmony_ci
2026-04-28 19:14:12 +08:00
21 changed files with 601 additions and 1 deletions
@@ -570,5 +570,50 @@ int32_t DistributedClient::OnCollaborateDone(
PARCEL_TRANSACT_SYNC_RET_INT(remote,
static_cast<uint32_t>(NOTIFY_ON_COLLABORATE_DONE), data, reply);
}
int32_t DistributedClient::StartRemoteIntent(const OHOS::AAFwk::Want& want,
const OHOS::AAFwk::IntentCallerInfo& callerInfo,
const sptr<IRemoteObject>& resultCallback)
{
sptr<IRemoteObject> remote = GetDmsProxy();
if (remote == nullptr) {
TAG_LOGE(AAFwkTag::DISTRIBUTED, "StartRemoteIntent null remote");
return INVALID_PARAMETERS_ERR;
}
MessageParcel data;
if (!data.WriteInterfaceToken(DMS_PROXY_INTERFACE_TOKEN)) {
return ERR_FLATTEN_OBJECT;
}
PARCEL_WRITE_HELPER(data, Parcelable, &want);
PARCEL_WRITE_HELPER(data, Int32, callerInfo.callerUid);
PARCEL_WRITE_HELPER(data, Uint64, callerInfo.requestCode);
PARCEL_WRITE_HELPER(data, Uint32, callerInfo.accessToken);
PARCEL_WRITE_HELPER(data, Uint32, callerInfo.specifyTokenId);
PARCEL_WRITE_HELPER(data, RemoteObject, resultCallback);
MessageParcel reply;
PARCEL_TRANSACT_SYNC_RET_INT(remote, START_REMOTE_INTENT, data, reply);
}
int32_t DistributedClient::SendIntentResult(const OHOS::AAFwk::Want& want,
const OHOS::AAFwk::IntentCallerInfo& callerInfo, const std::string& msg)
{
sptr<IRemoteObject> remote = GetDmsProxy();
if (remote == nullptr) {
TAG_LOGE(AAFwkTag::DISTRIBUTED, "SendIntentResult null remote");
return INVALID_PARAMETERS_ERR;
}
MessageParcel data;
if (!data.WriteInterfaceToken(DMS_PROXY_INTERFACE_TOKEN)) {
return ERR_FLATTEN_OBJECT;
}
PARCEL_WRITE_HELPER(data, Parcelable, &want);
PARCEL_WRITE_HELPER(data, Int32, callerInfo.callerUid);
PARCEL_WRITE_HELPER(data, Uint64, callerInfo.requestCode);
PARCEL_WRITE_HELPER(data, Uint32, callerInfo.accessToken);
PARCEL_WRITE_HELPER(data, Uint32, callerInfo.specifyTokenId);
PARCEL_WRITE_HELPER(data, String, msg);
MessageParcel reply;
PARCEL_TRANSACT_SYNC_RET_INT(remote, SEND_INTENT_RESULT, data, reply);
}
} // namespace AAFwk
} // namespace OHOS
@@ -1748,6 +1748,18 @@ public:
ErrCode ExecuteIntent(uint64_t key, sptr<IRemoteObject> callerToken,
const InsightIntentExecuteParam &param);
/**
* @brief Execute intent for distributed scenario.
*
* @param want The want containing intent execution information.
* @param srcDeviceId The source device id.
* @param requestCode The Intent id.
* @param specifiedFullTokenId The caller token id.
* @return Returns ERR_OK on success, others on failure.
*/
ErrCode ExecuteIntentForDistributed(const Want &want, const std::string &srcDeviceId,
uint64_t requestCode, uint64_t specifiedFullTokenId = 0);
/**
* @brief Query entity info.
* @param key The key of intent executing client.
@@ -2015,6 +2015,21 @@ public:
virtual int32_t ExecuteIntent(uint64_t key, const sptr<IRemoteObject> &callerToken,
const InsightIntentExecuteParam &param) = 0;
/**
* @brief Execute intent for distributed scenario.
*
* @param want The want containing intent execution information.
* @param srcDeviceId The source device id.
* @param requestCode The Intent id.
* @param specifiedFullTokenId The caller token id.
* @return Returns ERR_OK on success, others on failure.
*/
virtual int32_t ExecuteIntentForDistributed(const Want &want, const std::string &srcDeviceId,
uint64_t requestCode, uint64_t specifiedFullTokenId = 0)
{
return 0;
}
/**
* @brief Check if ability controller can start.
* @param want The want of ability to start.
@@ -491,6 +491,8 @@ enum class AbilityManagerInterfaceCode {
// ipc for request modal UIExtension with account
REQUEST_MODAL_UI_EXTENSION_WITH_ACCOUNT = 1144,
EXECUTE_INTENT_FOR_DISTRIBUTED = 1145,
// ipc id 2001-3000 for tools
// ipc id for dumping state (2001)
DUMP_STATE = 2001,
@@ -0,0 +1,31 @@
/*
* Copyright (c) 2026 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef OHOS_ABILITY_RUNTIME_DMS_INTENT_CALLER_INFO_H
#define OHOS_ABILITY_RUNTIME_DMS_INTENT_CALLER_INFO_H
#include <cstdint>
namespace OHOS {
namespace AAFwk {
struct IntentCallerInfo {
int32_t callerUid = 0;
uint64_t requestCode = 0;
uint32_t accessToken = 0;
uint32_t specifyTokenId = 0;
};
} // namespace AAFwk
} // namespace OHOS
#endif // OHOS_ABILITY_RUNTIME_DMS_INTENT_CALLER_INFO_H
@@ -0,0 +1,39 @@
/*
* Copyright (c) 2026 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef OHOS_ABILITY_RUNTIME_REMOTE_INTENT_RESULT_CALLBACK_INTERFACE_H
#define OHOS_ABILITY_RUNTIME_REMOTE_INTENT_RESULT_CALLBACK_INTERFACE_H
#include <string>
#include "iremote_broker.h"
namespace OHOS {
namespace AAFwk {
class IRemoteIntentResultCallback : public IRemoteBroker {
public:
DECLARE_INTERFACE_DESCRIPTOR(u"ohos.distributedschedule.IRemoteIntentResultCallback");
enum {
ON_INTENT_RESULT = 1,
ON_LINK_DISCONNECTED = 2,
};
virtual void OnIntentResult(uint64_t requestCode, int32_t resultCode, const std::string& resultMsg) = 0;
virtual void OnLinkDisconnected(uint64_t requestCode, int32_t reason) = 0;
};
} // namespace AAFwk
} // namespace OHOS
#endif // OHOS_ABILITY_RUNTIME_REMOTE_INTENT_RESULT_CALLBACK_INTERFACE_H
@@ -0,0 +1,43 @@
/*
* Copyright (c) 2026 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef OHOS_ABILITY_RUNTIME_REMOTE_INTENT_RESULT_CALLBACK_PROXY_H
#define OHOS_ABILITY_RUNTIME_REMOTE_INTENT_RESULT_CALLBACK_PROXY_H
#include <string>
#include "iremote_broker.h"
#include "iremote_object.h"
#include "iremote_proxy.h"
#include "remote_intent_result_callback_interface.h"
namespace OHOS {
namespace AAFwk {
class RemoteIntentResultCallbackProxy : public IRemoteProxy<IRemoteIntentResultCallback> {
public:
explicit RemoteIntentResultCallbackProxy(const sptr<IRemoteObject>& impl);
void OnIntentResult(uint64_t requestCode, int32_t resultCode, const std::string& resultMsg) override;
void OnLinkDisconnected(uint64_t requestCode, int32_t reason) override;
private:
int32_t SendTransactCmd(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option);
static inline BrokerDelegator<RemoteIntentResultCallbackProxy> delegator_;
};
} // namespace AAFwk
} // namespace OHOS
#endif // OHOS_ABILITY_RUNTIME_REMOTE_INTENT_RESULT_CALLBACK_PROXY_H
@@ -0,0 +1,42 @@
/*
* Copyright (c) 2026 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef OHOS_ABILITY_RUNTIME_REMOTE_INTENT_RESULT_CALLBACK_STUB_H
#define OHOS_ABILITY_RUNTIME_REMOTE_INTENT_RESULT_CALLBACK_STUB_H
#include <iremote_object.h>
#include <iremote_stub.h>
#include "nocopyable.h"
#include "remote_intent_result_callback_interface.h"
namespace OHOS {
namespace AAFwk {
class RemoteIntentResultCallbackStub : public IRemoteStub<IRemoteIntentResultCallback> {
public:
RemoteIntentResultCallbackStub();
virtual ~RemoteIntentResultCallbackStub() = default;
int OnRemoteRequest(
uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) override;
private:
DISALLOW_COPY_AND_MOVE(RemoteIntentResultCallbackStub);
int OnIntentResultInner(MessageParcel &data, MessageParcel &reply);
int OnLinkDisconnectedInner(MessageParcel &data, MessageParcel &reply);
};
} // namespace AAFwk
} // namespace OHOS
#endif // OHOS_ABILITY_RUNTIME_REMOTE_INTENT_RESULT_CALLBACK_STUB_H
@@ -20,6 +20,7 @@
#include <string>
#include "dms_continueInfo.h"
#include "dms_intent_caller_info.h"
#include "mission_info.h"
#include "mission_snapshot.h"
#include "want_params.h"
@@ -63,6 +64,11 @@ public:
int32_t SetMissionContinueState(int32_t missionId, const AAFwk::ContinueState &state, int32_t callingUid);
int32_t OnCollaborateDone(
const std::string &collabToken, int32_t result, int32_t pid, int32_t uid, int32_t accessTokenId);
int32_t StartRemoteIntent(const OHOS::AAFwk::Want& want,
const OHOS::AAFwk::IntentCallerInfo& callerInfo,
const sptr<IRemoteObject>& resultCallback);
int32_t SendIntentResult(const OHOS::AAFwk::Want& want, const OHOS::AAFwk::IntentCallerInfo& callerInfo,
const std::string& msg);
enum {
START_REMOTE_ABILITY = 1,
CONNECT_REMOTE_ABILITY = 6,
@@ -84,7 +90,9 @@ public:
REGISTER_ON_LISTENER = 260,
REGISTER_OFF_LISTENER = 261,
SET_MISSION_CONTINUE_STATE = 300,
NOTIFY_ON_COLLABORATE_DONE = 334
NOTIFY_ON_COLLABORATE_DONE = 334,
START_REMOTE_INTENT = 400,
SEND_INTENT_RESULT = 401
};
private:
sptr<IRemoteObject> GetDmsProxy();
+5
View File
@@ -116,6 +116,11 @@ abilityms_files = [
"src/free_install_manager.cpp",
"src/free_install_observer_manager.cpp",
#remote_intent
"src/remote_intent_result_callback.cpp",
"src/remote_intent_result_callback_proxy.cpp",
"src/remote_intent_result_callback_stub.cpp",
#erms
"src/query_erms_manager.cpp",
"src/query_erms_observer_manager.cpp",
@@ -1532,6 +1532,18 @@ public:
int32_t ExecuteIntent(uint64_t key, const sptr<IRemoteObject> &callerToken,
const InsightIntentExecuteParam &param) override;
/**
* @brief Execute intent for distributed scenario.
*
* @param want The want containing intent execution information.
* @param srcDeviceId The source device id.
* @param requestCode The Intent id.
* @param specifiedFullTokenId The caller token id.
* @return Returns ERR_OK on success, others on failure.
*/
int32_t ExecuteIntentForDistributed(const Want &want, const std::string &srcDeviceId,
uint64_t requestCode, uint64_t specifiedFullTokenId = 0) override;
/**
* @brief Query entity.
* @param key The key of intent executing client.
@@ -2181,6 +2181,8 @@ public:
int32_t StartAbilityByCallWithInsightIntent(const Want &want, const sptr<IRemoteObject> &callerToken,
const InsightIntentExecuteParam &param, int32_t userId = DEFAULT_INVAL_VALUE);
int32_t ExecuteIntentForDistributed(const Want &want, const std::string &srcDeviceId,
uint64_t requestCode, uint64_t specifiedFullTokenId = 0) override;
/**
* @brief Check if ability controller can start.
@@ -309,6 +309,7 @@ private:
int32_t AttachAppDebugInner(MessageParcel &data, MessageParcel &reply);
int32_t DetachAppDebugInner(MessageParcel &data, MessageParcel &reply);
int32_t ExecuteIntentInner(MessageParcel &data, MessageParcel &reply);
int32_t ExecuteIntentForDistributedInner(MessageParcel &data, MessageParcel &reply);
int32_t QueryEntityInner(MessageParcel &data, MessageParcel &reply);
@@ -0,0 +1,37 @@
/*
* Copyright (c) 2025 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef OHOS_ABILITY_RUNTIME_REMOTE_INTENT_RESULT_CALLBACK_H
#define OHOS_ABILITY_RUNTIME_REMOTE_INTENT_RESULT_CALLBACK_H
#include <iremote_object.h>
#include <iremote_stub.h>
#include "remote_intent_result_callback_stub.h"
namespace OHOS {
namespace AAFwk {
class RemoteIntentResultCallback : public RemoteIntentResultCallbackStub {
public:
RemoteIntentResultCallback() = default;
virtual ~RemoteIntentResultCallback() = default;
void OnIntentResult(uint64_t requestCode, int32_t resultCode, const std::string& resultMsg) override;
void OnLinkDisconnected(uint64_t requestCode, int32_t reason) override;
};
} // namespace AAFwk
} // namespace OHOS
#endif // OHOS_ABILITY_RUNTIME_REMOTE_INTENT_RESULT_CALLBACK_H
@@ -2136,6 +2136,15 @@ ErrCode AbilityManagerClient::ExecuteIntent(uint64_t key, sptr<IRemoteObject> ca
return abms->ExecuteIntent(key, callerToken, param);
}
ErrCode AbilityManagerClient::ExecuteIntentForDistributed(const Want &want, const std::string &srcDeviceId,
uint64_t requestCode, uint64_t specifiedFullTokenId)
{
TAG_LOGD(AAFwkTag::ABILITYMGR, "called");
auto abms = GetAbilityManager();
CHECK_POINTER_RETURN_NOT_CONNECTED(abms);
return abms->ExecuteIntentForDistributed(want, srcDeviceId, requestCode, specifiedFullTokenId);
}
ErrCode AbilityManagerClient::QueryEntityInfo(uint64_t key, sptr<IRemoteObject> callerToken,
const InsightIntentQueryParam &param)
{
@@ -5770,6 +5770,43 @@ int32_t AbilityManagerProxy::ExecuteIntent(uint64_t key, const sptr<IRemoteObje
return reply.ReadInt32();
}
int32_t AbilityManagerProxy::ExecuteIntentForDistributed(const Want &want, const std::string &srcDeviceId,
uint64_t requestCode, uint64_t specifiedFullTokenId)
{
TAG_LOGD(AAFwkTag::ABILITYMGR, "called");
MessageParcel data;
MessageParcel reply;
MessageOption option;
if (!WriteInterfaceToken(data)) {
TAG_LOGE(AAFwkTag::ABILITYMGR, "write token fail");
return INNER_ERR;
}
if (!data.WriteParcelable(&want)) {
TAG_LOGE(AAFwkTag::ABILITYMGR, "writeWantObject fail");
return INNER_ERR;
}
if (!data.WriteString(srcDeviceId)) {
TAG_LOGE(AAFwkTag::ABILITYMGR, "write srcDeviceId fail");
return INNER_ERR;
}
if (!data.WriteUint64(requestCode)) {
TAG_LOGE(AAFwkTag::ABILITYMGR, "write requestCode fail");
return INNER_ERR;
}
if (!data.WriteUint64(specifiedFullTokenId)) {
TAG_LOGE(AAFwkTag::ABILITYMGR, "write specifiedFullTokenId fail");
return INNER_ERR;
}
int32_t error = SendRequest(AbilityManagerInterfaceCode::EXECUTE_INTENT_FOR_DISTRIBUTED, data, reply, option);
if (error != NO_ERROR) {
TAG_LOGE(AAFwkTag::ABILITYMGR, "request err:%{public}d", error);
return error;
}
return reply.ReadInt32();
}
int32_t AbilityManagerProxy::QueryEntityInfo(uint64_t key, sptr<IRemoteObject> callerToken,
const InsightIntentQueryParam &param)
{
@@ -13985,6 +13985,32 @@ int32_t AbilityManagerService::StartAbilityWithServiceMatch(const InsightIntentE
}
int32_t AbilityManagerService::ExecuteIntentForDistributed(const Want &want, const std::string &srcDeviceId,
uint64_t requestCode, uint64_t specifiedFullTokenId)
{
AppExecFwk::InsightIntentExecuteParam param;
if (!AppExecFwk::InsightIntentExecuteParam::GenerateFromWant(want, param)) {
TAG_LOGE(AAFwkTag::INTENT, "GenerateFromWant failed, not a valid insight intent");
return ERR_INVALID_VALUE;
}
auto paramCopy = std::make_shared<InsightIntentExecuteParam>(param);
uint64_t key = requestCode;
auto callerBundlename = InsightIntentGetcallerBundleName();
if (callerBundlename.empty()) {
TAG_LOGD(AAFwkTag::INTENT, "callerBundlename is null");
}
AbilityRuntime::ExtractInsightIntentGenericInfo infos = GetInsightIntentGenericInfo(*paramCopy);
bool openLinkExecuteFlag = infos.decoratorType == AbilityRuntime::INSIGHT_INTENTS_DECORATOR_TYPE_LINK;
bool ignoreAbilityName = openLinkExecuteFlag ||
(infos.decoratorType == AbilityRuntime::INSIGHT_INTENTS_DECORATOR_TYPE_PAGE) ||
(infos.decoratorType == AbilityRuntime::INSIGHT_INTENTS_DECORATOR_TYPE_FUNCTION);
return ERR_OK;
}
int32_t AbilityManagerService::ExecuteIntent(uint64_t key, const sptr<IRemoteObject> &callerToken,
const InsightIntentExecuteParam &param)
{
@@ -345,6 +345,9 @@ int AbilityManagerStub::OnRemoteRequestInnerSeventh(uint32_t code, MessageParcel
if (interfaceCode == AbilityManagerInterfaceCode::START_SELF_UI_ABILITY_IN_CURRENT_PROCESS) {
return StartSelfUIAbilityInCurrentProcessInner(data, reply);
}
if (interfaceCode == AbilityManagerInterfaceCode::EXECUTE_INTENT_FOR_DISTRIBUTED) {
return ExecuteIntentForDistributedInner(data, reply);
}
return ERR_CODE_NOT_EXIST;
}
@@ -4266,6 +4269,31 @@ int AbilityManagerStub::QueryEntityInner(MessageParcel &data, MessageParcel &rep
return NO_ERROR;
}
int32_t AbilityManagerStub::ExecuteIntentForDistributedInner(MessageParcel &data, MessageParcel &reply)
{
std::unique_ptr<Want> want(data.ReadParcelable<Want>());
if (want == nullptr) {
TAG_LOGE(AAFwkTag::ABILITYMGR, "want null");
return ERR_INVALID_VALUE;
}
std::string srcDeviceId = data.ReadString();
if (srcDeviceId.empty()) {
TAG_LOGE(AAFwkTag::ABILITYMGR, "srcDeviceId empty");
return ERR_INVALID_VALUE;
}
uint64_t requestCode = data.ReadUint64();
uint64_t specifiedFullTokenId = data.ReadUint64();
auto result = ExecuteIntentForDistributed(*want, srcDeviceId, requestCode, specifiedFullTokenId);
if (!reply.WriteInt32(result)) {
TAG_LOGE(AAFwkTag::ABILITYMGR, "write result fail");
return ERR_INVALID_VALUE;
}
return NO_ERROR;
}
int AbilityManagerStub::StartAbilityForResultAsCallerInner(MessageParcel &data, MessageParcel &reply)
{
TAG_LOGD(AAFwkTag::ABILITYMGR, "called");
@@ -0,0 +1,37 @@
/*
* Copyright (c) 2026 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "remote_intent_result_callback.h"
#include "insight_intent_execute_manager.h"
#include "insight_intent_execute_result.h"
#include "hilog_tag_wrapper.h"
namespace OHOS {
namespace AAFwk {
void RemoteIntentResultCallback::OnIntentResult(uint64_t requestCode, int32_t resultCode,
const std::string& resultMsg)
{
TAG_LOGI(AAFwkTag::ABILITYMGR,
"OnIntentResult requestCode=%{public}" PRIu64 ", resultCode=%{public}d", requestCode, resultCode);
}
void RemoteIntentResultCallback::OnLinkDisconnected(uint64_t requestCode, int32_t reason)
{
TAG_LOGI(AAFwkTag::ABILITYMGR,
"OnLinkDisconnected requestCode=%{public}" PRIu64 ", reason=%{public}d", requestCode, reason);
}
} // namespace AAFwk
} // namespace OHOS
@@ -0,0 +1,106 @@
/*
* Copyright (c) 2026 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "remote_intent_result_callback_proxy.h"
#include "hilog_tag_wrapper.h"
namespace OHOS {
namespace AAFwk {
RemoteIntentResultCallbackProxy::RemoteIntentResultCallbackProxy(const sptr<IRemoteObject>& impl)
: IRemoteProxy<IRemoteIntentResultCallback>(impl)
{
}
void RemoteIntentResultCallbackProxy::OnIntentResult(uint64_t requestCode, int32_t resultCode,
const std::string& resultMsg)
{
MessageParcel data;
MessageParcel reply;
MessageOption option;
if (!data.WriteInterfaceToken(IRemoteIntentResultCallback::GetDescriptor())) {
TAG_LOGE(AAFwkTag::ABILITYMGR, "write interface token failed");
return;
}
if (!data.WriteUint64(requestCode)) {
TAG_LOGE(AAFwkTag::ABILITYMGR, "write requestCode failed");
return;
}
if (!data.WriteInt32(resultCode)) {
TAG_LOGE(AAFwkTag::ABILITYMGR, "write resultCode failed");
return;
}
if (!data.WriteString(resultMsg)) {
TAG_LOGE(AAFwkTag::ABILITYMGR, "write resultMsg failed");
return;
}
int32_t error = SendTransactCmd(IRemoteIntentResultCallback::ON_INTENT_RESULT, data, reply, option);
if (error != NO_ERROR) {
TAG_LOGE(AAFwkTag::ABILITYMGR, "OnIntentResult fail, error: %{public}d", error);
return;
}
}
void RemoteIntentResultCallbackProxy::OnLinkDisconnected(uint64_t requestCode, int32_t reason)
{
MessageParcel data;
MessageParcel reply;
MessageOption option;
if (!data.WriteInterfaceToken(IRemoteIntentResultCallback::GetDescriptor())) {
TAG_LOGE(AAFwkTag::ABILITYMGR, "write interface token failed");
return;
}
if (!data.WriteUint64(requestCode)) {
TAG_LOGE(AAFwkTag::ABILITYMGR, "write requestCode failed");
return;
}
if (!data.WriteInt32(reason)) {
TAG_LOGE(AAFwkTag::ABILITYMGR, "write reason failed");
return;
}
int32_t error = SendTransactCmd(IRemoteIntentResultCallback::ON_LINK_DISCONNECTED, data, reply, option);
if (error != NO_ERROR) {
TAG_LOGE(AAFwkTag::ABILITYMGR, "OnLinkDisconnected fail, error: %{public}d", error);
return;
}
}
int32_t RemoteIntentResultCallbackProxy::SendTransactCmd(uint32_t code, MessageParcel &data,
MessageParcel &reply, MessageOption &option)
{
sptr<IRemoteObject> remote = Remote();
if (remote == nullptr) {
TAG_LOGE(AAFwkTag::ABILITYMGR, "null remote");
return ERR_NULL_OBJECT;
}
int32_t ret = remote->SendRequest(code, data, reply, option);
if (ret != NO_ERROR) {
TAG_LOGE(AAFwkTag::ABILITYMGR, "sendRequest failed, code: %{public}d, ret: %{public}d", code, ret);
return ret;
}
return NO_ERROR;
}
} // namespace AAFwk
} // namespace OHOS
@@ -0,0 +1,63 @@
/*
* Copyright (c) 2026 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "remote_intent_result_callback_stub.h"
#include "hilog_tag_wrapper.h"
namespace OHOS {
namespace AAFwk {
RemoteIntentResultCallbackStub::RemoteIntentResultCallbackStub() {}
int RemoteIntentResultCallbackStub::OnIntentResultInner(MessageParcel &data, MessageParcel &reply)
{
auto requestCode = data.ReadUint64();
auto resultCode = data.ReadInt32();
std::string resultMsg = data.ReadString();
OnIntentResult(requestCode, resultCode, resultMsg);
return NO_ERROR;
}
int RemoteIntentResultCallbackStub::OnLinkDisconnectedInner(MessageParcel &data, MessageParcel &reply)
{
auto requestCode = data.ReadUint64();
auto reason = data.ReadInt32();
OnLinkDisconnected(requestCode, reason);
return NO_ERROR;
}
int RemoteIntentResultCallbackStub::OnRemoteRequest(
uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option)
{
std::u16string descriptor = RemoteIntentResultCallbackStub::GetDescriptor();
std::u16string remoteDescriptor = data.ReadInterfaceToken();
if (descriptor != remoteDescriptor) {
TAG_LOGE(AAFwkTag::ABILITYMGR, "descriptor not equal to remote");
return ERR_INVALID_STATE;
}
switch (code) {
case IRemoteIntentResultCallback::ON_INTENT_RESULT:
return OnIntentResultInner(data, reply);
case IRemoteIntentResultCallback::ON_LINK_DISCONNECTED:
return OnLinkDisconnectedInner(data, reply);
default:
break;
}
return IPCObjectStub::OnRemoteRequest(code, data, reply, option);
}
} // namespace AAFwk
} // namespace OHOS