add share form code

Signed-off-by: xuchenghua09 <xuchenghua09@huawei.com>
This commit is contained in:
xuchenghua09 2022-08-03 14:52:21 +08:00
parent 9734a880c2
commit 601c4ec8c7
13 changed files with 555 additions and 296 deletions

View File

@ -16,6 +16,7 @@
"subsystem": "ability",
"adapted_system_type": [ "standard" ],
"features" : [
"dmsfwk_standard_form_share",
"dmsfwk_mission_manager"
],
"hisysevent_config": [
@ -33,6 +34,7 @@
"distributeddatamgr",
"dsoftbus",
"eventhandler",
"form_fwk",
"hisysevent_native",
"hitrace_native",
"hiviewdfx_hilog_native",

View File

@ -12,6 +12,7 @@
# limitations under the License.
declare_args() {
dmsfwk_standard_form_share = true
dmsfwk_mission_manager = true
if (defined(global_parts_info) &&
!defined(global_parts_info.multimedia_multimedia_image_standard)) {

View File

@ -29,6 +29,9 @@ config("distributed_sched_config") {
if (dmsfwk_mission_manager) {
defines = [ "SUPPORT_DISTRIBUTED_MISSION_MANAGER" ]
}
if (dmsfwk_standard_form_share) {
defines += [ "SUPPORT_DISTRIBUTED_FORM_SHARE" ]
}
}
ohos_shared_library("distributedschedsvr") {
@ -81,6 +84,10 @@ ohos_shared_library("distributedschedsvr") {
deps = [ "//foundation/ability/dmsfwk/services/base:dmsbaseinner" ]
if (dmsfwk_standard_form_share) {
external_deps += [ "form_fwk:form_manager" ]
}
if (dmsfwk_mission_manager) {
defines = [ "SUPPORT_DISTRIBUTED_MISSION_MANAGER" ]
sources += [

View File

@ -20,6 +20,9 @@
#include "ability_info.h"
#include "ability_manager_interface.h"
#include "caller_info.h"
#ifdef SUPPORT_DISTRIBUTED_FORM_SHARE
#include "form_share_info.h"
#endif
#include "iremote_broker.h"
#ifdef SUPPORT_DISTRIBUTED_MISSION_MANAGER
#include "mission_info.h"
@ -115,6 +118,12 @@ public:
{
return 0;
}
#ifdef SUPPORT_DISTRIBUTED_FORM_SHARE
virtual int32_t StartRemoteShareForm(const std::string &remoteDeviceId,
const OHOS::AppExecFwk::FormShareInfo &formShareInfo) = 0;
virtual int32_t StartShareFormFromRemote(
const std::string &remoteDeviceId, const OHOS::AppExecFwk::FormShareInfo &formShareInfo) = 0;
#endif
virtual int32_t RegisterDistributedComponentListener(const sptr<IRemoteObject>& callback) = 0;
virtual int32_t GetDistributedComponentList(std::vector<std::string>& distributedComponents) = 0;
enum {
@ -170,6 +179,10 @@ public:
// request code for upload distributed component info
REGISTER_DISTRIBUTED_COMPONENT_LISTENER = 160,
GET_DISTRIBUTED_COMPONENT_LIST = 161,
// form share
START_REMOTE_SHARE_FORM = 220,
START_SHARE_FORM_FROM_REMOTE = 221,
};
};
} // namespace DistributedSchedule

View File

@ -79,7 +79,12 @@ public:
int32_t callerUid, int32_t requestCode, uint32_t accessToken, const sptr<IRemoteObject>& callback) override;
int32_t StartFreeInstallFromRemote(const FreeInstallInfo& info, int64_t taskId) override;
int32_t NotifyCompleteFreeInstallFromRemote(int64_t taskId, int32_t resultCode) override;
#ifdef SUPPORT_DISTRIBUTED_FORM_SHARE
int32_t StartRemoteShareForm(const std::string &remoteDeviceId,
const AppExecFwk::FormShareInfo &formShareInfo) override;
int32_t StartShareFormFromRemote(
const std::string &remoteDeviceId, const AppExecFwk::FormShareInfo &formShareInfo) override;
#endif
int32_t RegisterDistributedComponentListener(const sptr<IRemoteObject>& callback) override;
int32_t GetDistributedComponentList(std::vector<std::string>& distributedComponents) override;
private:

View File

@ -121,6 +121,12 @@ public:
const CallerInfo& callerInfo, const AccountInfo& accountInfo) override;
int32_t ReleaseAbilityFromRemote(const sptr<IRemoteObject>& connect, const AppExecFwk::ElementName &element,
const CallerInfo& callerInfo) override;
#ifdef SUPPORT_DISTRIBUTED_FORM_SHARE
int32_t StartRemoteShareForm(const std::string &remoteDeviceId,
const AppExecFwk::FormShareInfo &formShareInfo) override;
int32_t StartShareFormFromRemote(
const std::string &remoteDeviceId, const AppExecFwk::FormShareInfo &formShareInfo) override;
#endif
void ProcessCallerDied(const sptr<IRemoteObject>& connect, int32_t deviceType);
void ProcessCalleeDied(const sptr<IRemoteObject>& connect);
int32_t StartRemoteFreeInstall(const OHOS::AAFwk::Want& want, int32_t callerUid, int32_t requestCode,
@ -160,6 +166,9 @@ private:
static int32_t GetUidLocked(const std::list<ConnectAbilitySession>& sessionList);
int32_t TryConnectRemoteAbility(const OHOS::AAFwk::Want& want,
const sptr<IRemoteObject>& connect, const CallerInfo& callerInfo);
#ifdef SUPPORT_DISTRIBUTED_FORM_SHARE
sptr<IRemoteObject> GetFormMgrProxy();
#endif
int32_t CleanMission(int32_t missionId);
int32_t SetCallerInfo(int32_t callerUid, std::string localDeviceId, uint32_t accessToken, CallerInfo& callerInfo);
int32_t SetWantForContinuation(AAFwk::Want& newWant, int32_t missionId);
@ -193,6 +202,9 @@ private:
std::mutex distributedLock_;
std::mutex connectLock_;
sptr<IRemoteObject::DeathRecipient> connectDeathRecipient_;
#ifdef SUPPORT_DISTRIBUTED_FORM_SHARE
sptr<IRemoteObject> formMgrProxy_;
#endif
std::mutex calleeLock_;
std::map<sptr<IRemoteObject>, ConnectInfo> calleeMap_;
sptr<IRemoteObject::DeathRecipient> callerDeathRecipient_;

View File

@ -62,6 +62,10 @@ private:
int32_t StartRemoteFreeInstallInner(MessageParcel& data, MessageParcel& reply);
int32_t StartFreeInstallFromRemoteInner(MessageParcel& data, MessageParcel& reply);
int32_t NotifyCompleteFreeInstallFromRemoteInner(MessageParcel& data, MessageParcel& reply);
#ifdef SUPPORT_DISTRIBUTED_FORM_SHARE
int32_t StartRemoteShareFormInner(MessageParcel &data, MessageParcel &reply);
int32_t StartShareFormFromRemoteInner(MessageParcel &data, MessageParcel &reply);
#endif
int32_t RegisterDistributedComponentListenerInner(MessageParcel& data, MessageParcel& reply);
int32_t GetDistributedComponentListInner(MessageParcel& data, MessageParcel& reply);
bool CheckDmsRequestPermission();

View File

@ -769,6 +769,64 @@ int32_t DistributedSchedProxy::NotifyCompleteFreeInstallFromRemote(int64_t taskI
PARCEL_TRANSACT_SYNC_RET_INT(remote, NOTIFY_COMPLETE_FREE_INSTALL_FROM_REMOTE, data, reply);
}
#ifdef SUPPORT_DISTRIBUTED_FORM_SHARE
int32_t DistributedSchedProxy::StartRemoteShareForm(
const std::string &remoteDeviceId, const AppExecFwk::FormShareInfo &formShareInfo)
{
HILOGD("SHAREFORM:: func call");
if (remoteDeviceId.empty()) {
HILOGE("input params deviceId is nullptr.");
return INVALID_PARAMETERS_ERR;
}
auto remote = Remote();
if (remote == nullptr) {
HILOGE("fail to get dms remote.");
return DMSPROXY_SERVICE_ERR;
}
MessageParcel data;
MessageParcel reply;
if (!data.WriteInterfaceToken(DMS_PROXY_INTERFACE_TOKEN)) {
HILOGE("WriteInterfaceToken failed");
return ERR_FLATTEN_OBJECT;
}
PARCEL_WRITE_HELPER(data, String, remoteDeviceId);
PARCEL_WRITE_HELPER(data, Parcelable, &formShareInfo);
PARCEL_TRANSACT_SYNC_RET_INT(remote, START_REMOTE_SHARE_FORM, data, reply);
}
int32_t DistributedSchedProxy::StartShareFormFromRemote(
const std::string &remoteDeviceId, const AppExecFwk::FormShareInfo &formShareInfo)
{
HILOGD("SHAREFORM:: func call");
if (remoteDeviceId.empty()) {
HILOGE("input params deviceId is nullptr.");
return INVALID_PARAMETERS_ERR;
}
auto remote = Remote();
if (remote == nullptr) {
HILOGE("fail to get dms remote.");
return DMSPROXY_SERVICE_ERR;
}
MessageParcel data;
MessageParcel reply;
if (!data.WriteInterfaceToken(DMS_PROXY_INTERFACE_TOKEN)) {
HILOGE("WriteInterfaceToken failed");
return ERR_FLATTEN_OBJECT;
}
PARCEL_WRITE_HELPER(data, String, remoteDeviceId);
PARCEL_WRITE_HELPER(data, Parcelable, &formShareInfo);
PARCEL_TRANSACT_SYNC_RET_INT(remote, START_SHARE_FORM_FROM_REMOTE, data, reply);
}
#endif
int32_t DistributedSchedProxy::RegisterDistributedComponentListener(const sptr<IRemoteObject>& callback)
{
if (callback == nullptr) {

View File

@ -36,6 +36,9 @@
#include "dtbschedmgr_log.h"
#include "element_name.h"
#include "file_ex.h"
#ifdef SUPPORT_DISTRIBUTED_FORM_SHARE
#include "form_mgr_interface.h"
#endif
#include "ipc_skeleton.h"
#include "iservice_registry.h"
#ifdef SUPPORT_DISTRIBUTED_MISSION_MANAGER
@ -488,6 +491,29 @@ int32_t DistributedSchedService::NotifyContinuationResultFromRemote(int32_t sess
return ERR_OK;
}
#ifdef SUPPORT_DISTRIBUTED_FORM_SHARE
sptr<IRemoteObject> DistributedSchedService::GetFormMgrProxy()
{
HILOGD("%{public}s begin.", __func__);
if (formMgrProxy_ != nullptr) {
HILOGD("%{public}s fms proxy get success.", __func__);
return formMgrProxy_;
}
auto sm = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
if (sm == nullptr) {
HILOGE("GetAbilityManagerProxy sm is nullptr");
return nullptr;
}
formMgrProxy_ = sm->GetSystemAbility(FORM_MGR_SERVICE_ID);
if (formMgrProxy_ == nullptr) {
HILOGE("failed to get ability manager service");
return nullptr;
}
return formMgrProxy_;
}
#endif
void DistributedSchedService::NotifyContinuationCallbackResult(int32_t missionId, int32_t isSuccess)
{
HILOGD("Continuation result is: %{public}d", isSuccess);
@ -967,6 +993,63 @@ int32_t DistributedSchedService::ReleaseAbilityFromRemote(const sptr<IRemoteObje
return result;
}
#ifdef SUPPORT_DISTRIBUTED_FORM_SHARE
int32_t DistributedSchedService::StartRemoteShareForm(const std::string &remoteDeviceId,
const OHOS::AppExecFwk::FormShareInfo &formShareInfo)
{
HILOGD("SHAREFORM:: func call");
if (remoteDeviceId.empty()) {
HILOGE("StartRemoteShareForm input params error");
return INVALID_PARAMETERS_ERR;
}
sptr<IDistributedSched> remoteDms = GetRemoteDms(remoteDeviceId);
if (remoteDms == nullptr) {
HILOGE("StartRemoteShareForm get remote DMS failed, remoteDeviceId : %{public}s",
DnetworkAdapter::AnonymizeDeviceId(remoteDeviceId).c_str());
return GET_REMOTE_DMS_FAIL;
}
int32_t result = remoteDms->StartShareFormFromRemote(remoteDeviceId, formShareInfo);
HILOGD("[PerformanceTest] StartRemoteShareForm RPC end");
if (result != ERR_OK) {
HILOGE("StartRemoteShareForm failed, result : %{public}d", result);
}
return result;
}
int32_t DistributedSchedService::StartShareFormFromRemote(
const std::string &remoteDeviceId, const OHOS::AppExecFwk::FormShareInfo &formShareInfo)
{
HILOGD("SHAREFORM:: func call begin");
std::string localDeviceId = "";
GetLocalDeviceId(localDeviceId);
if (CheckDeviceId(localDeviceId, remoteDeviceId)) {
HILOGE("localId is %{public}s != %{public}s",
DnetworkAdapter::AnonymizeDeviceId(localDeviceId).c_str(),
DnetworkAdapter::AnonymizeDeviceId(remoteDeviceId).c_str());
return INVALID_REMOTE_PARAMETERS_ERR;
}
auto remote = GetFormMgrProxy();
if (remote == nullptr) {
HILOGE("Get remote proxy failed");
return NOT_FIND_SERVICE_PROXY;
}
auto formMgr = iface_cast<IFormMgr>(remote);
if (formMgr == nullptr) {
HILOGE("FormMgr type conversion failed");
return NOT_FIND_SERVICE_PROXY;
}
auto result = formMgr->RecvFormShareInfoFromRemote(formShareInfo);
HILOGD("SHAREFORM:: func call end");
return result;
}
#endif
int32_t DistributedSchedService::RegisterDistributedComponentListener(const sptr<IRemoteObject>& callback)
{
if (callback == nullptr) {

View File

@ -92,6 +92,10 @@ DistributedSchedStub::DistributedSchedStub()
localFuncsMap_[RELEASE_REMOTE_ABILITY] = &DistributedSchedStub::ReleaseRemoteAbilityInner;
remoteFuncsMap_[START_ABILITY_BY_CALL_FROM_REMOTE] = &DistributedSchedStub::StartAbilityByCallFromRemoteInner;
remoteFuncsMap_[RELEASE_ABILITY_FROM_REMOTE] = &DistributedSchedStub::ReleaseAbilityFromRemoteInner;
#ifdef SUPPORT_DISTRIBUTED_FORM_SHARE
localFuncsMap_[START_REMOTE_SHARE_FORM] = &DistributedSchedStub::StartRemoteShareFormInner;
remoteFuncsMap_[START_SHARE_FORM_FROM_REMOTE] = &DistributedSchedStub::StartShareFormFromRemoteInner;
#endif
localFuncsMap_[REGISTER_DISTRIBUTED_COMPONENT_LISTENER] =
&DistributedSchedStub::RegisterDistributedComponentListenerInner;
localFuncsMap_[GET_DISTRIBUTED_COMPONENT_LIST] = &DistributedSchedStub::GetDistributedComponentListInner;
@ -859,6 +863,48 @@ int32_t DistributedSchedStub::ReleaseAbilityFromRemoteInner(MessageParcel& data,
PARCEL_WRITE_REPLY_NOERROR(reply, Int32, result);
}
#ifdef SUPPORT_DISTRIBUTED_FORM_SHARE
int32_t DistributedSchedStub::StartRemoteShareFormInner(MessageParcel &data, MessageParcel &reply)
{
HILOGD("SHAREFORM:: func call");
std::string deviceId = "";
PARCEL_READ_HELPER(data, String, deviceId);
shared_ptr<AppExecFwk::FormShareInfo> formShareInfo(data.ReadParcelable<AppExecFwk::FormShareInfo>());
if (formShareInfo == nullptr) {
HILOGW("SHARE_FORM readParcelable failed!");
PARCEL_WRITE_REPLY_NOERROR(reply, Int32, static_cast<int32_t>(ERR_FLATTEN_OBJECT));
return ERR_FLATTEN_OBJECT;
}
int32_t result = StartRemoteShareForm(deviceId, *formShareInfo);
HILOGI("result = %{public}d", result);
PARCEL_WRITE_REPLY_NOERROR(reply, Int32, result);
}
int32_t DistributedSchedStub::StartShareFormFromRemoteInner(MessageParcel &data, MessageParcel &reply)
{
HILOGD("SHAREFORM:: func call");
if (!CheckCallingUid()) {
HILOGW("request DENIED!");
PARCEL_WRITE_REPLY_NOERROR(reply, Int32, static_cast<int32_t>(DMS_PERMISSION_DENIED));
return DMS_PERMISSION_DENIED;
}
std::string deviceId = "";
PARCEL_READ_HELPER(data, String, deviceId);
shared_ptr<AppExecFwk::FormShareInfo> formShareInfo(data.ReadParcelable<AppExecFwk::FormShareInfo>());
if (formShareInfo == nullptr) {
HILOGW("SHARE_FORM readParcelable failed!");
PARCEL_WRITE_REPLY_NOERROR(reply, Int32, static_cast<int32_t>(ERR_FLATTEN_OBJECT));
return ERR_FLATTEN_OBJECT;
}
int32_t result = StartShareFormFromRemote(deviceId, *formShareInfo);
HILOGI("result = %{public}d", result);
PARCEL_WRITE_REPLY_NOERROR(reply, Int32, result);
}
#endif
int32_t DistributedSchedStub::RegisterDistributedComponentListenerInner(MessageParcel& data, MessageParcel& reply)
{
if (!CheckCallingUid()) {

View File

@ -54,6 +54,10 @@ dsched_external_deps = [
"utils_base:utils",
]
if (dmsfwk_standard_form_share) {
dsched_external_deps += [ "form_fwk:form_manager" ]
}
if (dmsfwk_mission_manager) {
dsched_external_deps += [ "multimedia_image_standard:image_native" ]
}
@ -153,6 +157,10 @@ ohos_unittest("dschedcontinuetest") {
defines = [ "SUPPORT_DISTRIBUTED_MISSION_MANAGER" ]
}
if (dmsfwk_standard_form_share) {
defines += [ "SUPPORT_DISTRIBUTED_FORM_SHARE" ]
}
part_name = "dmsfwk"
subsystem_name = "ability"
}

View File

@ -1,207 +1,221 @@
/*
* Copyright (c) 2021-2022 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 "mock_distributed_sched.h"
#include "dtbschedmgr_log.h"
#include "string_ex.h"
using namespace std;
using namespace OHOS::AAFwk;
using namespace OHOS::AppExecFwk;
namespace OHOS {
namespace DistributedSchedule {
int32_t MockDistributedSched::StartRemoteAbility(const OHOS::AAFwk::Want& want,
int32_t callerUid, int32_t requestCode, uint32_t accessToken)
{
return 0;
}
int32_t MockDistributedSched::StartAbilityFromRemote(const OHOS::AAFwk::Want& want,
const OHOS::AppExecFwk::AbilityInfo& abilityInfo, int32_t requestCode, const CallerInfo& callerInfo,
const AccountInfo& accountInfo)
{
return 0;
}
int32_t MockDistributedSched::SendResultFromRemote(OHOS::AAFwk::Want& want, int32_t requestCode,
const CallerInfo& callerInfo, const AccountInfo& accountInfo, int32_t resultCode)
{
return 0;
}
int32_t MockDistributedSched::ContinueMission(const std::string& srcDeviceId, const std::string& dstDeviceId,
int32_t missionId, const sptr<IRemoteObject>& callback, const OHOS::AAFwk::WantParams& wantParams)
{
return 0;
}
int32_t MockDistributedSched::StartContinuation(const OHOS::AAFwk::Want& want, int32_t missionId,
int32_t callerUid, int32_t status, uint32_t accessToken)
{
return 0;
}
void MockDistributedSched::NotifyCompleteContinuation(const std::u16string& devId, int32_t sessionId, bool isSuccess)
{
(void)isSuccess;
}
int32_t MockDistributedSched::NotifyContinuationResultFromRemote(int32_t sessionId, bool isSuccess)
{
(void)isSuccess;
return 0;
}
int32_t MockDistributedSched::ConnectRemoteAbility(const OHOS::AAFwk::Want& want, const sptr<IRemoteObject>& connect,
int32_t callerUid, int32_t callerPid, uint32_t accessToken)
{
return 0;
}
int32_t MockDistributedSched::DisconnectRemoteAbility(const sptr<IRemoteObject>& connect, int32_t callerUid,
uint32_t accessToken)
{
return 0;
}
int32_t MockDistributedSched::ConnectAbilityFromRemote(const OHOS::AAFwk::Want& want,
const AppExecFwk::AbilityInfo& abilityInfo, const sptr<IRemoteObject>& connect,
const CallerInfo& callerInfo, const AccountInfo& accountInfo)
{
return 0;
}
int32_t MockDistributedSched::DisconnectAbilityFromRemote(const sptr<IRemoteObject>& connect,
int32_t uid, const std::string& sourceDeviceId)
{
return 0;
}
int32_t MockDistributedSched::NotifyProcessDiedFromRemote(const CallerInfo& callerInfo)
{
return 0;
}
#ifdef SUPPORT_DISTRIBUTED_MISSION_MANAGER
int32_t MockDistributedSched::StartSyncRemoteMissions(const std::string& devId, bool fixConflict, int64_t tag)
{
return ERR_NONE;
}
int32_t MockDistributedSched::RegisterMissionListener(const std::u16string& devId, const sptr<IRemoteObject>& obj)
{
return ERR_NONE;
}
int32_t MockDistributedSched::UnRegisterMissionListener(const std::u16string& devId,
const sptr<IRemoteObject>& obj)
{
return ERR_NONE;
}
int32_t MockDistributedSched::GetRemoteMissionSnapshotInfo(const std::string& networkId, int32_t missionId,
std::unique_ptr<MissionSnapshot>& missionSnapshot)
{
return ERR_NONE;
}
int32_t MockDistributedSched::NotifyMissionsChangedFromRemote(const std::vector<DstbMissionInfo>& missionInfos,
const CallerInfo& callerInfo)
{
expectedTrue_ = false;
return ERR_NONE;
}
int32_t MockDistributedSched::GetMissionInfos(const std::string& deviceId, int32_t numMissions,
std::vector<MissionInfo>& missionInfos)
{
return ERR_NONE;
}
int32_t MockDistributedSched::StartSyncMissionsFromRemote(const CallerInfo& callerInfo,
std::vector<DstbMissionInfo>& missionInfos)
{
return ERR_NONE;
}
int32_t MockDistributedSched::StopSyncMissionsFromRemote(const CallerInfo& callerInfo)
{
return ERR_NONE;
}
int32_t MockDistributedSched::StopSyncRemoteMissions(const std::string& devId)
{
return ERR_NONE;
}
#endif
int32_t MockDistributedSched::StartRemoteAbilityByCall(const OHOS::AAFwk::Want& want,
const sptr<IRemoteObject>& connect, int32_t callerUid, int32_t callerPid, uint32_t accessToken)
{
return ERR_NONE;
}
int32_t MockDistributedSched::ReleaseRemoteAbility(const sptr<IRemoteObject>& connect,
const AppExecFwk::ElementName &element)
{
return ERR_NONE;
}
int32_t MockDistributedSched::StartAbilityByCallFromRemote(const OHOS::AAFwk::Want& want,
const sptr<IRemoteObject>& connect, const CallerInfo& callerInfo, const AccountInfo& accountInfo)
{
return ERR_NONE;
}
int32_t MockDistributedSched::ReleaseAbilityFromRemote(const sptr<IRemoteObject>& connect,
const AppExecFwk::ElementName &element, const CallerInfo& callerInfo)
{
return ERR_NONE;
}
int32_t MockDistributedSched::RegisterDistributedComponentListener(const sptr<IRemoteObject>& callback)
{
return ERR_NONE;
}
int32_t MockDistributedSched::GetDistributedComponentList(std::vector<std::string>& distributedComponents)
{
return ERR_NONE;
}
int32_t MockDistributedSched::StartRemoteFreeInstall(const OHOS::AAFwk::Want &want, int32_t callerUid,
int32_t requestCode, uint32_t accessToken, const sptr<IRemoteObject> &callback)
{
return ERR_NONE;
}
int32_t MockDistributedSched::StartFreeInstallFromRemote(const IDistributedSched::FreeInstallInfo &info, int64_t taskId)
{
return ERR_NONE;
}
int32_t MockDistributedSched::NotifyCompleteFreeInstallFromRemote(int64_t taskId, int32_t resultCode)
{
return ERR_NONE;
}
int32_t MockDistributedSched::NotifyCompleteFreeInstall(
const IDistributedSched::FreeInstallInfo &info, int64_t taskId, int32_t resultCode)
{
return ERR_NONE;
}
} // namespace DistributedSchedule
/*
* Copyright (c) 2021-2022 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 "mock_distributed_sched.h"
#include "dtbschedmgr_log.h"
#include "string_ex.h"
using namespace std;
using namespace OHOS::AAFwk;
using namespace OHOS::AppExecFwk;
namespace OHOS {
namespace DistributedSchedule {
int32_t MockDistributedSched::StartRemoteAbility(const OHOS::AAFwk::Want& want,
int32_t callerUid, int32_t requestCode, uint32_t accessToken)
{
return 0;
}
int32_t MockDistributedSched::StartAbilityFromRemote(const OHOS::AAFwk::Want& want,
const OHOS::AppExecFwk::AbilityInfo& abilityInfo, int32_t requestCode, const CallerInfo& callerInfo,
const AccountInfo& accountInfo)
{
return 0;
}
int32_t MockDistributedSched::SendResultFromRemote(OHOS::AAFwk::Want& want, int32_t requestCode,
const CallerInfo& callerInfo, const AccountInfo& accountInfo, int32_t resultCode)
{
return 0;
}
int32_t MockDistributedSched::ContinueMission(const std::string& srcDeviceId, const std::string& dstDeviceId,
int32_t missionId, const sptr<IRemoteObject>& callback, const OHOS::AAFwk::WantParams& wantParams)
{
return 0;
}
int32_t MockDistributedSched::StartContinuation(const OHOS::AAFwk::Want& want, int32_t missionId,
int32_t callerUid, int32_t status, uint32_t accessToken)
{
return 0;
}
void MockDistributedSched::NotifyCompleteContinuation(const std::u16string& devId, int32_t sessionId, bool isSuccess)
{
(void)isSuccess;
}
int32_t MockDistributedSched::NotifyContinuationResultFromRemote(int32_t sessionId, bool isSuccess)
{
(void)isSuccess;
return 0;
}
int32_t MockDistributedSched::ConnectRemoteAbility(const OHOS::AAFwk::Want& want, const sptr<IRemoteObject>& connect,
int32_t callerUid, int32_t callerPid, uint32_t accessToken)
{
return 0;
}
int32_t MockDistributedSched::DisconnectRemoteAbility(const sptr<IRemoteObject>& connect, int32_t callerUid,
uint32_t accessToken)
{
return 0;
}
int32_t MockDistributedSched::ConnectAbilityFromRemote(const OHOS::AAFwk::Want& want,
const AppExecFwk::AbilityInfo& abilityInfo, const sptr<IRemoteObject>& connect,
const CallerInfo& callerInfo, const AccountInfo& accountInfo)
{
return 0;
}
int32_t MockDistributedSched::DisconnectAbilityFromRemote(const sptr<IRemoteObject>& connect,
int32_t uid, const std::string& sourceDeviceId)
{
return 0;
}
int32_t MockDistributedSched::NotifyProcessDiedFromRemote(const CallerInfo& callerInfo)
{
return 0;
}
#ifdef SUPPORT_DISTRIBUTED_MISSION_MANAGER
int32_t MockDistributedSched::StartSyncRemoteMissions(const std::string& devId, bool fixConflict, int64_t tag)
{
return ERR_NONE;
}
int32_t MockDistributedSched::RegisterMissionListener(const std::u16string& devId, const sptr<IRemoteObject>& obj)
{
return ERR_NONE;
}
int32_t MockDistributedSched::UnRegisterMissionListener(const std::u16string& devId,
const sptr<IRemoteObject>& obj)
{
return ERR_NONE;
}
int32_t MockDistributedSched::GetRemoteMissionSnapshotInfo(const std::string& networkId, int32_t missionId,
std::unique_ptr<MissionSnapshot>& missionSnapshot)
{
return ERR_NONE;
}
int32_t MockDistributedSched::NotifyMissionsChangedFromRemote(const std::vector<DstbMissionInfo>& missionInfos,
const CallerInfo& callerInfo)
{
expectedTrue_ = false;
return ERR_NONE;
}
int32_t MockDistributedSched::GetMissionInfos(const std::string& deviceId, int32_t numMissions,
std::vector<MissionInfo>& missionInfos)
{
return ERR_NONE;
}
int32_t MockDistributedSched::StartSyncMissionsFromRemote(const CallerInfo& callerInfo,
std::vector<DstbMissionInfo>& missionInfos)
{
return ERR_NONE;
}
int32_t MockDistributedSched::StopSyncMissionsFromRemote(const CallerInfo& callerInfo)
{
return ERR_NONE;
}
int32_t MockDistributedSched::StopSyncRemoteMissions(const std::string& devId)
{
return ERR_NONE;
}
#endif
int32_t MockDistributedSched::StartRemoteAbilityByCall(const OHOS::AAFwk::Want& want,
const sptr<IRemoteObject>& connect, int32_t callerUid, int32_t callerPid, uint32_t accessToken)
{
return ERR_NONE;
}
int32_t MockDistributedSched::ReleaseRemoteAbility(const sptr<IRemoteObject>& connect,
const AppExecFwk::ElementName &element)
{
return ERR_NONE;
}
int32_t MockDistributedSched::StartAbilityByCallFromRemote(const OHOS::AAFwk::Want& want,
const sptr<IRemoteObject>& connect, const CallerInfo& callerInfo, const AccountInfo& accountInfo)
{
return ERR_NONE;
}
int32_t MockDistributedSched::ReleaseAbilityFromRemote(const sptr<IRemoteObject>& connect,
const AppExecFwk::ElementName &element, const CallerInfo& callerInfo)
{
return ERR_NONE;
}
int32_t MockDistributedSched::RegisterDistributedComponentListener(const sptr<IRemoteObject>& callback)
{
return ERR_NONE;
}
int32_t MockDistributedSched::GetDistributedComponentList(std::vector<std::string>& distributedComponents)
{
return ERR_NONE;
}
int32_t MockDistributedSched::StartRemoteFreeInstall(const OHOS::AAFwk::Want &want, int32_t callerUid,
int32_t requestCode, uint32_t accessToken, const sptr<IRemoteObject> &callback)
{
return ERR_NONE;
}
int32_t MockDistributedSched::StartFreeInstallFromRemote(const IDistributedSched::FreeInstallInfo &info, int64_t taskId)
{
return ERR_NONE;
}
int32_t MockDistributedSched::NotifyCompleteFreeInstallFromRemote(int64_t taskId, int32_t resultCode)
{
return ERR_NONE;
}
int32_t MockDistributedSched::NotifyCompleteFreeInstall(
const IDistributedSched::FreeInstallInfo &info, int64_t taskId, int32_t resultCode)
{
return ERR_NONE;
}
#ifdef SUPPORT_DISTRIBUTED_FORM_SHARE
int32_t MockDistributedSched::StartRemoteShareForm(const std::string &remoteDeviceId,
const OHOS::AppExecFwk::FormShareInfo &formShareInfo)
{
return ERR_NONE;
}
int32_t MockDistributedSched::StartShareFormFromRemote(
const std::string &remoteDeviceId, const OHOS::AppExecFwk::FormShareInfo &formShareInfo)
{
return ERR_NONE;
}
#endif
} // namespace DistributedSchedule
} // namespace OHOS

View File

@ -1,89 +1,95 @@
/*
* Copyright (c) 2021-2022 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 MOCK_DISTRIBUTED_SCHED_H
#define MOCK_DISTRIBUTED_SCHED_H
#include "distributed_sched_stub.h"
namespace OHOS {
namespace DistributedSchedule {
class MockDistributedSched : public DistributedSchedStub {
public:
explicit MockDistributedSched(bool expectedTrue = false)
{
expectedTrue_ = expectedTrue;
}
~MockDistributedSched() = default;
int32_t StartRemoteAbility(const OHOS::AAFwk::Want& want, int32_t callerUid, int32_t requestCode,
uint32_t accessToken) override;
int32_t StartAbilityFromRemote(const OHOS::AAFwk::Want& want,
const OHOS::AppExecFwk::AbilityInfo& abilityInfo, int32_t requestCode, const CallerInfo& callerInfo,
const AccountInfo& accountInfo) override;
int32_t SendResultFromRemote(OHOS::AAFwk::Want& want, int32_t requestCode, const CallerInfo& callerInfo,
const AccountInfo& accountInfo, int32_t resultCode) override;
int32_t ContinueMission(const std::string& srcDeviceId, const std::string& dstDeviceId,
int32_t missionId, const sptr<IRemoteObject>& callback, const OHOS::AAFwk::WantParams& wantParams) override;
int32_t StartContinuation(const OHOS::AAFwk::Want& want, int32_t missionId, int32_t callerUid,
int32_t status, uint32_t accessToken) override;
void NotifyCompleteContinuation(const std::u16string& devId, int32_t sessionId, bool isSuccess) override;
int32_t NotifyContinuationResultFromRemote(int32_t sessionId, bool isSuccess) override;
int32_t ConnectRemoteAbility(const OHOS::AAFwk::Want& want, const sptr<IRemoteObject>& connect,
int32_t callerUid, int32_t callerPid, uint32_t accessToken) override;
int32_t DisconnectRemoteAbility(const sptr<IRemoteObject>& connect, int32_t callerUid,
uint32_t accessToken) override;
int32_t ConnectAbilityFromRemote(const OHOS::AAFwk::Want& want, const AppExecFwk::AbilityInfo& abilityInfo,
const sptr<IRemoteObject>& connect, const CallerInfo& callerInfo, const AccountInfo& accountInfo) override;
int32_t DisconnectAbilityFromRemote(const sptr<IRemoteObject>& connect,
int32_t uid, const std::string& sourceDeviceId) override;
int32_t NotifyProcessDiedFromRemote(const CallerInfo& callerInfo) override;
#ifdef SUPPORT_DISTRIBUTED_MISSION_MANAGER
int32_t StartSyncRemoteMissions(const std::string& devId, bool fixConflict, int64_t tag) override;
int32_t RegisterMissionListener(const std::u16string& devId, const sptr<IRemoteObject>& obj) override;
int32_t UnRegisterMissionListener(const std::u16string& devId, const sptr<IRemoteObject>& obj) override;
int32_t GetMissionInfos(const std::string& deviceId, int32_t numMissions,
std::vector<AAFwk::MissionInfo>& missionInfos) override;
int32_t GetRemoteMissionSnapshotInfo(const std::string& networkId, int32_t missionId,
std::unique_ptr<AAFwk::MissionSnapshot>& missionSnapshot) override;
int32_t NotifyMissionsChangedFromRemote(const std::vector<DstbMissionInfo>& missionInfos,
const CallerInfo& callerInfo) override;
int32_t StartSyncMissionsFromRemote(const CallerInfo& callerInfo,
std::vector<DstbMissionInfo>& missionInfos) override;
int32_t StopSyncMissionsFromRemote(const CallerInfo& callerInfo) override;
int32_t StopSyncRemoteMissions(const std::string& devId) override;
#endif
int32_t StartRemoteAbilityByCall(const OHOS::AAFwk::Want& want, const sptr<IRemoteObject>& connect,
int32_t callerUid, int32_t callerPid, uint32_t accessToken) override;
int32_t ReleaseRemoteAbility(const sptr<IRemoteObject>& connect,
const AppExecFwk::ElementName &element) override;
int32_t StartAbilityByCallFromRemote(const OHOS::AAFwk::Want& want, const sptr<IRemoteObject>& connect,
const CallerInfo& callerInfo, const AccountInfo& accountInfo) override;
int32_t ReleaseAbilityFromRemote(const sptr<IRemoteObject>& connect, const AppExecFwk::ElementName &element,
const CallerInfo& callerInfo) override;
int32_t RegisterDistributedComponentListener(const sptr<IRemoteObject>& callback) override;
int32_t GetDistributedComponentList(std::vector<std::string>& distributedComponents) override;
int32_t StartRemoteFreeInstall(const OHOS::AAFwk::Want& want, int32_t callerUid, int32_t requestCode,
uint32_t accessToken, const sptr<IRemoteObject>& callback) override;
int32_t StartFreeInstallFromRemote(const FreeInstallInfo& info, int64_t taskId) override;
int32_t NotifyCompleteFreeInstallFromRemote(int64_t taskId, int32_t resultCode) override;
int32_t NotifyCompleteFreeInstall(const FreeInstallInfo& info, int64_t taskId, int32_t resultCode);
private:
bool expectedTrue_ = false;
};
} // namespace DistributedSchedule
} // namespace OHOS
#endif // MOCK_DISTRIBUTED_SCHED_H
/*
* Copyright (c) 2021-2022 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 MOCK_DISTRIBUTED_SCHED_H
#define MOCK_DISTRIBUTED_SCHED_H
#include "distributed_sched_stub.h"
namespace OHOS {
namespace DistributedSchedule {
class MockDistributedSched : public DistributedSchedStub {
public:
explicit MockDistributedSched(bool expectedTrue = false)
{
expectedTrue_ = expectedTrue;
}
~MockDistributedSched() = default;
int32_t StartRemoteAbility(const OHOS::AAFwk::Want& want, int32_t callerUid, int32_t requestCode,
uint32_t accessToken) override;
int32_t StartAbilityFromRemote(const OHOS::AAFwk::Want& want,
const OHOS::AppExecFwk::AbilityInfo& abilityInfo, int32_t requestCode, const CallerInfo& callerInfo,
const AccountInfo& accountInfo) override;
int32_t SendResultFromRemote(OHOS::AAFwk::Want& want, int32_t requestCode, const CallerInfo& callerInfo,
const AccountInfo& accountInfo, int32_t resultCode) override;
int32_t ContinueMission(const std::string& srcDeviceId, const std::string& dstDeviceId,
int32_t missionId, const sptr<IRemoteObject>& callback, const OHOS::AAFwk::WantParams& wantParams) override;
int32_t StartContinuation(const OHOS::AAFwk::Want& want, int32_t missionId, int32_t callerUid,
int32_t status, uint32_t accessToken) override;
void NotifyCompleteContinuation(const std::u16string& devId, int32_t sessionId, bool isSuccess) override;
int32_t NotifyContinuationResultFromRemote(int32_t sessionId, bool isSuccess) override;
int32_t ConnectRemoteAbility(const OHOS::AAFwk::Want& want, const sptr<IRemoteObject>& connect,
int32_t callerUid, int32_t callerPid, uint32_t accessToken) override;
int32_t DisconnectRemoteAbility(const sptr<IRemoteObject>& connect, int32_t callerUid,
uint32_t accessToken) override;
int32_t ConnectAbilityFromRemote(const OHOS::AAFwk::Want& want, const AppExecFwk::AbilityInfo& abilityInfo,
const sptr<IRemoteObject>& connect, const CallerInfo& callerInfo, const AccountInfo& accountInfo) override;
int32_t DisconnectAbilityFromRemote(const sptr<IRemoteObject>& connect,
int32_t uid, const std::string& sourceDeviceId) override;
int32_t NotifyProcessDiedFromRemote(const CallerInfo& callerInfo) override;
#ifdef SUPPORT_DISTRIBUTED_MISSION_MANAGER
int32_t StartSyncRemoteMissions(const std::string& devId, bool fixConflict, int64_t tag) override;
int32_t RegisterMissionListener(const std::u16string& devId, const sptr<IRemoteObject>& obj) override;
int32_t UnRegisterMissionListener(const std::u16string& devId, const sptr<IRemoteObject>& obj) override;
int32_t GetMissionInfos(const std::string& deviceId, int32_t numMissions,
std::vector<AAFwk::MissionInfo>& missionInfos) override;
int32_t GetRemoteMissionSnapshotInfo(const std::string& networkId, int32_t missionId,
std::unique_ptr<AAFwk::MissionSnapshot>& missionSnapshot) override;
int32_t NotifyMissionsChangedFromRemote(const std::vector<DstbMissionInfo>& missionInfos,
const CallerInfo& callerInfo) override;
int32_t StartSyncMissionsFromRemote(const CallerInfo& callerInfo,
std::vector<DstbMissionInfo>& missionInfos) override;
int32_t StopSyncMissionsFromRemote(const CallerInfo& callerInfo) override;
int32_t StopSyncRemoteMissions(const std::string& devId) override;
#endif
int32_t StartRemoteAbilityByCall(const OHOS::AAFwk::Want& want, const sptr<IRemoteObject>& connect,
int32_t callerUid, int32_t callerPid, uint32_t accessToken) override;
int32_t ReleaseRemoteAbility(const sptr<IRemoteObject>& connect,
const AppExecFwk::ElementName &element) override;
int32_t StartAbilityByCallFromRemote(const OHOS::AAFwk::Want& want, const sptr<IRemoteObject>& connect,
const CallerInfo& callerInfo, const AccountInfo& accountInfo) override;
int32_t ReleaseAbilityFromRemote(const sptr<IRemoteObject>& connect, const AppExecFwk::ElementName &element,
const CallerInfo& callerInfo) override;
int32_t RegisterDistributedComponentListener(const sptr<IRemoteObject>& callback) override;
int32_t GetDistributedComponentList(std::vector<std::string>& distributedComponents) override;
#ifdef SUPPORT_DISTRIBUTED_FORM_SHARE
int32_t StartRemoteShareForm(const std::string &remoteDeviceId,
const OHOS::AppExecFwk::FormShareInfo &formShareInfo) override;
int32_t StartShareFormFromRemote(
const std::string &remoteDeviceId, const OHOS::AppExecFwk::FormShareInfo &formShareInfo) override;
#endif
int32_t StartRemoteFreeInstall(const OHOS::AAFwk::Want& want, int32_t callerUid, int32_t requestCode,
uint32_t accessToken, const sptr<IRemoteObject>& callback) override;
int32_t StartFreeInstallFromRemote(const FreeInstallInfo& info, int64_t taskId) override;
int32_t NotifyCompleteFreeInstallFromRemote(int64_t taskId, int32_t resultCode) override;
int32_t NotifyCompleteFreeInstall(const FreeInstallInfo& info, int64_t taskId, int32_t resultCode);
private:
bool expectedTrue_ = false;
};
} // namespace DistributedSchedule
} // namespace OHOS
#endif // MOCK_DISTRIBUTED_SCHED_H