1686862fbSopenharmony_ci/*
2686862fbSopenharmony_ci * Copyright (c) 2021-2024 Huawei Device Co., Ltd.
3686862fbSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
4686862fbSopenharmony_ci * you may not use this file except in compliance with the License.
5686862fbSopenharmony_ci * You may obtain a copy of the License at
6686862fbSopenharmony_ci *
7686862fbSopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
8686862fbSopenharmony_ci *
9686862fbSopenharmony_ci * Unless required by applicable law or agreed to in writing, software
10686862fbSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
11686862fbSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12686862fbSopenharmony_ci * See the License for the specific language governing permissions and
13686862fbSopenharmony_ci * limitations under the License.
14686862fbSopenharmony_ci */
15686862fbSopenharmony_ci
16686862fbSopenharmony_ci#include "distributed_sched_stub.h"
17686862fbSopenharmony_ci
18686862fbSopenharmony_ci#include "ability_info.h"
19686862fbSopenharmony_ci#include "datetime_ex.h"
20686862fbSopenharmony_ci#include "ipc_skeleton.h"
21686862fbSopenharmony_ci#include "message_parcel.h"
22686862fbSopenharmony_ci
23686862fbSopenharmony_ci#include "adapter/dnetwork_adapter.h"
24686862fbSopenharmony_ci#include "bundle/bundle_manager_internal.h"
25686862fbSopenharmony_ci#include "caller_info.h"
26686862fbSopenharmony_ci#include "dfx/dms_continue_time_dumper.h"
27686862fbSopenharmony_ci#include "dfx/dms_hisysevent_report.h"
28686862fbSopenharmony_ci#include "dfx/dms_hitrace_chain.h"
29686862fbSopenharmony_ci#include "dfx/dms_hitrace_constants.h"
30686862fbSopenharmony_ci#include "distributed_want.h"
31686862fbSopenharmony_ci#include "distributed_sched_permission.h"
32686862fbSopenharmony_ci#include "distributed_sched_service.h"
33686862fbSopenharmony_ci#include "distributed_sched_types.h"
34686862fbSopenharmony_ci#include "distributed_sched_utils.h"
35686862fbSopenharmony_ci#include "dms_constant.h"
36686862fbSopenharmony_ci#include "dms_version_manager.h"
37686862fbSopenharmony_ci#include "dsched_continue_manager.h"
38686862fbSopenharmony_ci#include "dsched_transport_softbus_adapter.h"
39686862fbSopenharmony_ci#include "dtbschedmgr_log.h"
40686862fbSopenharmony_ci#include "dtbschedmgr_device_info_storage.h"
41686862fbSopenharmony_ci#include "parcel_helper.h"
42686862fbSopenharmony_ci
43686862fbSopenharmony_ci#ifdef SUPPORT_DISTRIBUTED_MISSION_MANAGER
44686862fbSopenharmony_ci#include "image_source.h"
45686862fbSopenharmony_ci
46686862fbSopenharmony_ci#include "mission/distributed_sched_mission_manager.h"
47686862fbSopenharmony_ci#include "mission/dms_continue_recv_manager.h"
48686862fbSopenharmony_ci#include "mission/mission_info_converter.h"
49686862fbSopenharmony_ci#include "mission/snapshot_converter.h"
50686862fbSopenharmony_ci#include "napi_error_code.h"
51686862fbSopenharmony_ci#endif
52686862fbSopenharmony_ci
53686862fbSopenharmony_cinamespace OHOS {
54686862fbSopenharmony_cinamespace DistributedSchedule {
55686862fbSopenharmony_ciusing namespace std;
56686862fbSopenharmony_ciusing namespace AAFwk;
57686862fbSopenharmony_ciusing namespace AppExecFwk;
58686862fbSopenharmony_ci
59686862fbSopenharmony_cinamespace {
60686862fbSopenharmony_ciconstexpr int32_t HID_HAP = 10000; /* first hap user */
61686862fbSopenharmony_ciconst std::string TAG = "DistributedSchedStub";
62686862fbSopenharmony_ciconst std::u16string DMS_STUB_INTERFACE_TOKEN = u"ohos.distributedschedule.accessToken";
63686862fbSopenharmony_ciconst std::string EXTRO_INFO_JSON_KEY_ACCESS_TOKEN = "accessTokenID";
64686862fbSopenharmony_ciconst std::string EXTRO_INFO_JSON_KEY_REQUEST_CODE = "requestCode";
65686862fbSopenharmony_ciconst std::string PARAM_FREEINSTALL_APPID = "ohos.freeinstall.params.callingAppId";
66686862fbSopenharmony_ciconst std::string PARAM_FREEINSTALL_BUNDLENAMES = "ohos.freeinstall.params.callingBundleNames";
67686862fbSopenharmony_ciconst std::string CMPT_PARAM_FREEINSTALL_BUNDLENAMES = "ohos.extra.param.key.allowedBundles";
68686862fbSopenharmony_ciconst std::string FEATURE_ABILITY_FLAG_KEY = "ohos.dms.faFlag";
69686862fbSopenharmony_ciconst std::string DMS_VERSION_ID = "dmsVersion";
70686862fbSopenharmony_ciconst std::string DMS_UID_SPEC_BUNDLE_NAME = "dmsCallerUidBundleName";
71686862fbSopenharmony_ciconstexpr int32_t QOS_THRESHOLD_VERSION = 5;
72686862fbSopenharmony_ciconst int DEFAULT_REQUEST_CODE = -1;
73686862fbSopenharmony_ci}
74686862fbSopenharmony_ci
75686862fbSopenharmony_ciDistributedSchedStub::DistributedSchedStub()
76686862fbSopenharmony_ci{
77686862fbSopenharmony_ci    InitExtendedLocalFuncsInner();
78686862fbSopenharmony_ci    InitLocalFuncsInner();
79686862fbSopenharmony_ci    InitRemoteFuncsInner();
80686862fbSopenharmony_ci}
81686862fbSopenharmony_ci
82686862fbSopenharmony_ciDistributedSchedStub::~DistributedSchedStub()
83686862fbSopenharmony_ci{
84686862fbSopenharmony_ci    remoteFuncsMap_.clear();
85686862fbSopenharmony_ci    localFuncsMap_.clear();
86686862fbSopenharmony_ci}
87686862fbSopenharmony_ci
88686862fbSopenharmony_civoid DistributedSchedStub::InitExtendedLocalFuncsInner()
89686862fbSopenharmony_ci{
90686862fbSopenharmony_ci    // request codes for mission manager
91686862fbSopenharmony_ci#ifdef SUPPORT_DISTRIBUTED_MISSION_MANAGER
92686862fbSopenharmony_ci    localFuncsMap_[static_cast<uint32_t>(IDSchedInterfaceCode::REGISTER_DSCHED_EVENT_LISTENER)] =
93686862fbSopenharmony_ci        &DistributedSchedStub::RegisterDSchedEventListenerInner;
94686862fbSopenharmony_ci    localFuncsMap_[static_cast<uint32_t>(IDSchedInterfaceCode::UNREGISTER_DSCHED_EVENT_LISTENER)] =
95686862fbSopenharmony_ci        &DistributedSchedStub::UnRegisterDSchedEventListenerInner;
96686862fbSopenharmony_ci    localFuncsMap_[static_cast<uint32_t>(IDSchedInterfaceCode::GET_CONTINUE_INFO)] =
97686862fbSopenharmony_ci        &DistributedSchedStub::GetContinueInfoInner;
98686862fbSopenharmony_ci    localFuncsMap_[static_cast<uint32_t>(IDSchedInterfaceCode::GET_DSCHED_EVENT_INFO)] =
99686862fbSopenharmony_ci        &DistributedSchedStub::GetDSchedEventInfoInner;
100686862fbSopenharmony_ci#endif
101686862fbSopenharmony_ci}
102686862fbSopenharmony_ci
103686862fbSopenharmony_civoid DistributedSchedStub::InitLocalFuncsInner()
104686862fbSopenharmony_ci{
105686862fbSopenharmony_ci    localFuncsMap_[static_cast<uint32_t>(IDSchedInterfaceCode::START_REMOTE_ABILITY)] =
106686862fbSopenharmony_ci        &DistributedSchedStub::StartRemoteAbilityInner;
107686862fbSopenharmony_ci    localFuncsMap_[static_cast<uint32_t>(IDSchedInterfaceCode::CONTINUE_MISSION)] =
108686862fbSopenharmony_ci        &DistributedSchedStub::ContinueMissionInner;
109686862fbSopenharmony_ci    localFuncsMap_[static_cast<uint32_t>(IDSchedInterfaceCode::CONTINUE_MISSION_OF_BUNDLENAME)] =
110686862fbSopenharmony_ci        &DistributedSchedStub::ContinueMissionOfBundleNameInner;
111686862fbSopenharmony_ci    localFuncsMap_[static_cast<uint32_t>(IDSchedInterfaceCode::START_CONTINUATION)] =
112686862fbSopenharmony_ci        &DistributedSchedStub::StartContinuationInner;
113686862fbSopenharmony_ci    localFuncsMap_[static_cast<uint32_t>(IDSchedInterfaceCode::NOTIFY_COMPLETE_CONTINUATION)] =
114686862fbSopenharmony_ci        &DistributedSchedStub::NotifyCompleteContinuationInner;
115686862fbSopenharmony_ci    localFuncsMap_[static_cast<uint32_t>(IDSchedInterfaceCode::CONNECT_REMOTE_ABILITY)] =
116686862fbSopenharmony_ci        &DistributedSchedStub::ConnectRemoteAbilityInner;
117686862fbSopenharmony_ci    localFuncsMap_[static_cast<uint32_t>(IDSchedInterfaceCode::DISCONNECT_REMOTE_ABILITY)] =
118686862fbSopenharmony_ci        &DistributedSchedStub::DisconnectRemoteAbilityInner;
119686862fbSopenharmony_ci    // request codes for mission manager
120686862fbSopenharmony_ci#ifdef SUPPORT_DISTRIBUTED_MISSION_MANAGER
121686862fbSopenharmony_ci    InitLocalMissionManagerInner();
122686862fbSopenharmony_ci#endif
123686862fbSopenharmony_ci    localFuncsMap_[static_cast<uint32_t>(IDSchedInterfaceCode::START_REMOTE_ABILITY_BY_CALL)] =
124686862fbSopenharmony_ci        &DistributedSchedStub::StartRemoteAbilityByCallInner;
125686862fbSopenharmony_ci    localFuncsMap_[static_cast<uint32_t>(IDSchedInterfaceCode::RELEASE_REMOTE_ABILITY)] =
126686862fbSopenharmony_ci        &DistributedSchedStub::ReleaseRemoteAbilityInner;
127686862fbSopenharmony_ci#ifdef SUPPORT_DISTRIBUTED_FORM_SHARE
128686862fbSopenharmony_ci    localFuncsMap_[static_cast<uint32_t>(IDSchedInterfaceCode::START_REMOTE_SHARE_FORM)] =
129686862fbSopenharmony_ci        &DistributedSchedStub::StartRemoteShareFormInner;
130686862fbSopenharmony_ci#endif
131686862fbSopenharmony_ci    localFuncsMap_[static_cast<uint32_t>(IDSchedInterfaceCode::GET_DISTRIBUTED_COMPONENT_LIST)] =
132686862fbSopenharmony_ci        &DistributedSchedStub::GetDistributedComponentListInner;
133686862fbSopenharmony_ci    localFuncsMap_[static_cast<uint32_t>(IDSchedInterfaceCode::START_REMOTE_FREE_INSTALL)] =
134686862fbSopenharmony_ci        &DistributedSchedStub::StartRemoteFreeInstallInner;
135686862fbSopenharmony_ci    localFuncsMap_[static_cast<uint32_t>(IDSchedInterfaceCode::STOP_REMOTE_EXTERNSION_ABILITY)] =
136686862fbSopenharmony_ci        &DistributedSchedStub::StopRemoteExtensionAbilityInner;
137686862fbSopenharmony_ci}
138686862fbSopenharmony_ci
139686862fbSopenharmony_civoid DistributedSchedStub::InitLocalMissionManagerInner()
140686862fbSopenharmony_ci{
141686862fbSopenharmony_ci    localFuncsMap_[static_cast<uint32_t>(IDSchedInterfaceCode::GET_REMOTE_MISSION_SNAPSHOT_INFO)] =
142686862fbSopenharmony_ci        &DistributedSchedStub::GetRemoteMissionSnapshotInfoInner;
143686862fbSopenharmony_ci    localFuncsMap_[static_cast<uint32_t>(IDSchedInterfaceCode::REGISTER_MISSION_LISTENER)] =
144686862fbSopenharmony_ci        &DistributedSchedStub::RegisterMissionListenerInner;
145686862fbSopenharmony_ci    localFuncsMap_[static_cast<uint32_t>(IDSchedInterfaceCode::REGISTER_ON_LISTENER)] =
146686862fbSopenharmony_ci        &DistributedSchedStub::RegisterOnListenerInner;
147686862fbSopenharmony_ci    localFuncsMap_[static_cast<uint32_t>(IDSchedInterfaceCode::REGISTER_OFF_LISTENER)] =
148686862fbSopenharmony_ci        &DistributedSchedStub::RegisterOffListenerInner;
149686862fbSopenharmony_ci    localFuncsMap_[static_cast<uint32_t>(IDSchedInterfaceCode::UNREGISTER_MISSION_LISTENER)] =
150686862fbSopenharmony_ci        &DistributedSchedStub::UnRegisterMissionListenerInner;
151686862fbSopenharmony_ci    localFuncsMap_[static_cast<uint32_t>(IDSchedInterfaceCode::GET_MISSION_INFOS)] =
152686862fbSopenharmony_ci        &DistributedSchedStub::GetMissionInfosInner;
153686862fbSopenharmony_ci    localFuncsMap_[static_cast<uint32_t>(IDSchedInterfaceCode::START_SYNC_MISSIONS)] =
154686862fbSopenharmony_ci        &DistributedSchedStub::StartSyncRemoteMissionsInner;
155686862fbSopenharmony_ci    localFuncsMap_[static_cast<uint32_t>(IDSchedInterfaceCode::STOP_SYNC_MISSIONS)] =
156686862fbSopenharmony_ci        &DistributedSchedStub::StopSyncRemoteMissionsInner;
157686862fbSopenharmony_ci    localFuncsMap_[static_cast<uint32_t>(IDSchedInterfaceCode::SET_MISSION_CONTINUE_STATE)] =
158686862fbSopenharmony_ci        &DistributedSchedStub::SetMissionContinueStateInner;
159686862fbSopenharmony_ci}
160686862fbSopenharmony_ci
161686862fbSopenharmony_civoid DistributedSchedStub::InitRemoteFuncsInner()
162686862fbSopenharmony_ci{
163686862fbSopenharmony_ci    remoteFuncsMap_[static_cast<uint32_t>(IDSchedInterfaceCode::START_ABILITY_FROM_REMOTE)] =
164686862fbSopenharmony_ci        &DistributedSchedStub::StartAbilityFromRemoteInner;
165686862fbSopenharmony_ci    remoteFuncsMap_[static_cast<uint32_t>(IDSchedInterfaceCode::STOP_ABILITY_FROM_REMOTE)] =
166686862fbSopenharmony_ci        &DistributedSchedStub::StopAbilityFromRemoteInner;
167686862fbSopenharmony_ci    remoteFuncsMap_[static_cast<uint32_t>(IDSchedInterfaceCode::SEND_RESULT_FROM_REMOTE)] =
168686862fbSopenharmony_ci        &DistributedSchedStub::SendResultFromRemoteInner;
169686862fbSopenharmony_ci    remoteFuncsMap_[static_cast<uint32_t>(IDSchedInterfaceCode::NOTIFY_CONTINUATION_RESULT_FROM_REMOTE)] =
170686862fbSopenharmony_ci        &DistributedSchedStub::NotifyContinuationResultFromRemoteInner;
171686862fbSopenharmony_ci    remoteFuncsMap_[static_cast<uint32_t>(IDSchedInterfaceCode::NOTIFY_DSCHED_EVENT_RESULT_FROM_REMOTE)] =
172686862fbSopenharmony_ci        &DistributedSchedStub::NotifyDSchedEventResultFromRemoteInner;
173686862fbSopenharmony_ci    remoteFuncsMap_[static_cast<uint32_t>(IDSchedInterfaceCode::CONNECT_ABILITY_FROM_REMOTE)] =
174686862fbSopenharmony_ci        &DistributedSchedStub::ConnectAbilityFromRemoteInner;
175686862fbSopenharmony_ci    remoteFuncsMap_[static_cast<uint32_t>(IDSchedInterfaceCode::DISCONNECT_ABILITY_FROM_REMOTE)] =
176686862fbSopenharmony_ci        &DistributedSchedStub::DisconnectAbilityFromRemoteInner;
177686862fbSopenharmony_ci    remoteFuncsMap_[static_cast<uint32_t>(IDSchedInterfaceCode::NOTIFY_PROCESS_DIED_FROM_REMOTE)] =
178686862fbSopenharmony_ci        &DistributedSchedStub::NotifyProcessDiedFromRemoteInner;
179686862fbSopenharmony_ci#ifdef SUPPORT_DISTRIBUTED_MISSION_MANAGER
180686862fbSopenharmony_ci    // request codes for mission manager
181686862fbSopenharmony_ci    remoteFuncsMap_[static_cast<uint32_t>(IDSchedInterfaceCode::START_SYNC_MISSIONS_FROM_REMOTE)] =
182686862fbSopenharmony_ci        &DistributedSchedStub::StartSyncMissionsFromRemoteInner;
183686862fbSopenharmony_ci    remoteFuncsMap_[static_cast<uint32_t>(IDSchedInterfaceCode::STOP_SYNC_MISSIONS_FROM_REMOTE)] =
184686862fbSopenharmony_ci        &DistributedSchedStub::StopSyncMissionsFromRemoteInner;
185686862fbSopenharmony_ci    remoteFuncsMap_[static_cast<uint32_t>(IDSchedInterfaceCode::NOTIFY_MISSIONS_CHANGED_FROM_REMOTE)] =
186686862fbSopenharmony_ci        &DistributedSchedStub::NotifyMissionsChangedFromRemoteInner;
187686862fbSopenharmony_ci#endif
188686862fbSopenharmony_ci    remoteFuncsMap_[static_cast<uint32_t>(IDSchedInterfaceCode::CONTINUE_MISSION)] =
189686862fbSopenharmony_ci        &DistributedSchedStub::ContinueMissionInner;
190686862fbSopenharmony_ci    remoteFuncsMap_[static_cast<uint32_t>(IDSchedInterfaceCode::CONTINUE_MISSION_OF_BUNDLENAME)] =
191686862fbSopenharmony_ci        &DistributedSchedStub::ContinueMissionOfBundleNameInner;
192686862fbSopenharmony_ci    remoteFuncsMap_[static_cast<uint32_t>(IDSchedInterfaceCode::START_ABILITY_BY_CALL_FROM_REMOTE)] =
193686862fbSopenharmony_ci        &DistributedSchedStub::StartAbilityByCallFromRemoteInner;
194686862fbSopenharmony_ci    remoteFuncsMap_[static_cast<uint32_t>(IDSchedInterfaceCode::RELEASE_ABILITY_FROM_REMOTE)] =
195686862fbSopenharmony_ci        &DistributedSchedStub::ReleaseAbilityFromRemoteInner;
196686862fbSopenharmony_ci    remoteFuncsMap_[static_cast<uint32_t>(IDSchedInterfaceCode::NOTIFY_STATE_CHANGED_FROM_REMOTE)] =
197686862fbSopenharmony_ci        &DistributedSchedStub::NotifyStateChangedFromRemoteInner;
198686862fbSopenharmony_ci
199686862fbSopenharmony_ci#ifdef DMSFWK_INTERACTIVE_ADAPTER
200686862fbSopenharmony_ci    remoteFuncsMap_[static_cast<uint32_t>(IDSchedInterfaceCode::NOTIFY_ABILITY_LIFECYCLE_CHANGED_FROM_REMOTE)] =
201686862fbSopenharmony_ci        &DistributedSchedStub::NotifyAbilityLifecycleChangedFromRemoteAdapterInner;
202686862fbSopenharmony_ci#endif
203686862fbSopenharmony_ci
204686862fbSopenharmony_ci#ifdef SUPPORT_DISTRIBUTED_FORM_SHARE
205686862fbSopenharmony_ci    remoteFuncsMap_[static_cast<uint32_t>(IDSchedInterfaceCode::START_SHARE_FORM_FROM_REMOTE)] =
206686862fbSopenharmony_ci        &DistributedSchedStub::StartShareFormFromRemoteInner;
207686862fbSopenharmony_ci#endif
208686862fbSopenharmony_ci    remoteFuncsMap_[static_cast<uint32_t>(IDSchedInterfaceCode::START_FREE_INSTALL_FROM_REMOTE)] =
209686862fbSopenharmony_ci        &DistributedSchedStub::StartFreeInstallFromRemoteInner;
210686862fbSopenharmony_ci    remoteFuncsMap_[static_cast<uint32_t>(IDSchedInterfaceCode::NOTIFY_COMPLETE_FREE_INSTALL_FROM_REMOTE)] =
211686862fbSopenharmony_ci        &DistributedSchedStub::NotifyCompleteFreeInstallFromRemoteInner;
212686862fbSopenharmony_ci    remoteFuncsMap_[static_cast<uint32_t>(IDSchedInterfaceCode::STOP_EXTERNSION_ABILITY_FROM_REMOTE)] =
213686862fbSopenharmony_ci        &DistributedSchedStub::StopExtensionAbilityFromRemoteInner;
214686862fbSopenharmony_ci}
215686862fbSopenharmony_ci
216686862fbSopenharmony_ciint32_t DistributedSchedStub::OnRemoteRequest(uint32_t code,
217686862fbSopenharmony_ci    MessageParcel& data, MessageParcel& reply, MessageOption& option)
218686862fbSopenharmony_ci{
219686862fbSopenharmony_ci    bool IsLocalCalling = IPCSkeleton::IsLocalCalling();
220686862fbSopenharmony_ci    HILOGI("OnRemoteRequest, code = %{public}u, flags = %{public}d, IsLocalCalling = %{public}d.",
221686862fbSopenharmony_ci        code, option.GetFlags(), IsLocalCalling);
222686862fbSopenharmony_ci
223686862fbSopenharmony_ci    const auto& funcsMap = IsLocalCalling ? localFuncsMap_ : remoteFuncsMap_;
224686862fbSopenharmony_ci    auto iter = funcsMap.find(code);
225686862fbSopenharmony_ci    if (iter != funcsMap.end()) {
226686862fbSopenharmony_ci        auto func = iter->second;
227686862fbSopenharmony_ci        if (!EnforceInterfaceToken(data)) {
228686862fbSopenharmony_ci            HILOGW("OnRemoteRequest interface token check failed!");
229686862fbSopenharmony_ci            return DMS_PERMISSION_DENIED;
230686862fbSopenharmony_ci        }
231686862fbSopenharmony_ci        if (func != nullptr) {
232686862fbSopenharmony_ci            return (this->*func)(data, reply);
233686862fbSopenharmony_ci        }
234686862fbSopenharmony_ci    }
235686862fbSopenharmony_ci
236686862fbSopenharmony_ci    HILOGW("OnRemoteRequest default case, need check.");
237686862fbSopenharmony_ci    return IPCObjectStub::OnRemoteRequest(code, data, reply, option);
238686862fbSopenharmony_ci}
239686862fbSopenharmony_ci
240686862fbSopenharmony_ciint32_t DistributedSchedStub::StartRemoteAbilityInner(MessageParcel& data, MessageParcel& reply)
241686862fbSopenharmony_ci{
242686862fbSopenharmony_ci    if (!DistributedSchedPermission::GetInstance().IsFoundationCall()) {
243686862fbSopenharmony_ci        return DMS_PERMISSION_DENIED;
244686862fbSopenharmony_ci    }
245686862fbSopenharmony_ci    DmsHiTraceChain hiTraceChain(TraceValue::START_REMOTE_ABILITY);
246686862fbSopenharmony_ci    HITRACE_METER_NAME(TraceTag::DSCHED, TraceValue::START_REMOTE_ABILITY);
247686862fbSopenharmony_ci    shared_ptr<AAFwk::Want> want(data.ReadParcelable<AAFwk::Want>());
248686862fbSopenharmony_ci    if (want == nullptr) {
249686862fbSopenharmony_ci        HILOGW("START_ABILITY want readParcelable failed!");
250686862fbSopenharmony_ci        return ERR_NULL_OBJECT;
251686862fbSopenharmony_ci    }
252686862fbSopenharmony_ci    DistributedSchedPermission::GetInstance().RemoveRemoteObjectFromWant(want);
253686862fbSopenharmony_ci    int32_t callerUid = 0;
254686862fbSopenharmony_ci    PARCEL_READ_HELPER(data, Int32, callerUid);
255686862fbSopenharmony_ci    int32_t requestCode = 0;
256686862fbSopenharmony_ci    PARCEL_READ_HELPER(data, Int32, requestCode);
257686862fbSopenharmony_ci    uint32_t accessToken = 0;
258686862fbSopenharmony_ci    PARCEL_READ_HELPER(data, Uint32, accessToken);
259686862fbSopenharmony_ci    HILOGD("get callerUid = %{public}d, AccessTokenID = %{private}s", callerUid,
260686862fbSopenharmony_ci        GetAnonymStr(std::to_string(accessToken)).c_str());
261686862fbSopenharmony_ci    DistributedSchedPermission::GetInstance().MarkUriPermission(*want, accessToken);
262686862fbSopenharmony_ci    int32_t result = StartRemoteAbility(*want, callerUid, requestCode, accessToken);
263686862fbSopenharmony_ci    ReportEvent(*want, BehaviorEvent::START_REMOTE_ABILITY, result, callerUid);
264686862fbSopenharmony_ci    HILOGI("StartRemoteAbilityInner result = %{public}d", result);
265686862fbSopenharmony_ci    PARCEL_WRITE_REPLY_NOERROR(reply, Int32, result);
266686862fbSopenharmony_ci}
267686862fbSopenharmony_ci
268686862fbSopenharmony_civoid DistributedSchedStub::ReportEvent(const OHOS::AAFwk::Want& want, const std::string& eventName, int32_t result,
269686862fbSopenharmony_ci    int32_t callerUid)
270686862fbSopenharmony_ci{
271686862fbSopenharmony_ci    std::vector<std::string> bundleNames;
272686862fbSopenharmony_ci    if (!BundleManagerInternal::GetBundleNameListFromBms(callerUid, bundleNames)) {
273686862fbSopenharmony_ci        HILOGE("GetBundleNameListFromBms failed");
274686862fbSopenharmony_ci        return;
275686862fbSopenharmony_ci    }
276686862fbSopenharmony_ci    std::string srcBundleName = bundleNames.empty() ? std::string() : bundleNames.front();
277686862fbSopenharmony_ci    HILOGD("srcBundleName %{public}s", srcBundleName.c_str());
278686862fbSopenharmony_ci    AppExecFwk::BundleInfo localBundleInfo;
279686862fbSopenharmony_ci    if (BundleManagerInternal::GetLocalBundleInfo(srcBundleName, localBundleInfo) != ERR_OK) {
280686862fbSopenharmony_ci        HILOGE("get local bundle info failed");
281686862fbSopenharmony_ci        return;
282686862fbSopenharmony_ci    }
283686862fbSopenharmony_ci    HILOGD("version %{public}s", localBundleInfo.versionName.c_str());
284686862fbSopenharmony_ci
285686862fbSopenharmony_ci    BehaviorEventParam eventParam = { EventCallingType::LOCAL, eventName, result, want.GetElement().GetBundleName(),
286686862fbSopenharmony_ci        want.GetElement().GetAbilityName(), callerUid, srcBundleName, localBundleInfo.versionName };
287686862fbSopenharmony_ci    DmsHiSysEventReport::ReportBehaviorEvent(eventParam);
288686862fbSopenharmony_ci    HILOGD("report event success!");
289686862fbSopenharmony_ci}
290686862fbSopenharmony_ci
291686862fbSopenharmony_cishared_ptr<AAFwk::Want> DistributedSchedStub::ReadDistributedWant(MessageParcel& data)
292686862fbSopenharmony_ci{
293686862fbSopenharmony_ci    shared_ptr<DistributedWant> dstbWant(data.ReadParcelable<DistributedWant>());
294686862fbSopenharmony_ci    shared_ptr<AAFwk::Want> want = nullptr;
295686862fbSopenharmony_ci    if (dstbWant != nullptr) {
296686862fbSopenharmony_ci        want = dstbWant->ToWant();
297686862fbSopenharmony_ci    }
298686862fbSopenharmony_ci    return want;
299686862fbSopenharmony_ci}
300686862fbSopenharmony_ci
301686862fbSopenharmony_ciint32_t DistributedSchedStub::GetStartAbilityFromRemoteExParam(MessageParcel& data,
302686862fbSopenharmony_ci    OHOS::AppExecFwk::AbilityInfo& abilityInfo, int32_t& requestCode,
303686862fbSopenharmony_ci    CallerInfo& callerInfo, AccountInfo& accountInfo)
304686862fbSopenharmony_ci{
305686862fbSopenharmony_ci    unique_ptr<CompatibleAbilityInfo> cmpAbilityInfo(data.ReadParcelable<CompatibleAbilityInfo>());
306686862fbSopenharmony_ci    if (cmpAbilityInfo == nullptr) {
307686862fbSopenharmony_ci        HILOGE("AbilityInfo readParcelable failed!");
308686862fbSopenharmony_ci        return ERR_NULL_OBJECT;
309686862fbSopenharmony_ci    }
310686862fbSopenharmony_ci    cmpAbilityInfo->ConvertToAbilityInfo(abilityInfo);
311686862fbSopenharmony_ci
312686862fbSopenharmony_ci    PARCEL_READ_HELPER(data, Int32, requestCode);
313686862fbSopenharmony_ci
314686862fbSopenharmony_ci    PARCEL_READ_HELPER(data, Int32, callerInfo.uid);
315686862fbSopenharmony_ci    PARCEL_READ_HELPER(data, String, callerInfo.sourceDeviceId);
316686862fbSopenharmony_ci    callerInfo.callerType = CALLER_TYPE_HARMONY;
317686862fbSopenharmony_ci
318686862fbSopenharmony_ci    accountInfo.accountType = data.ReadInt32();
319686862fbSopenharmony_ci    PARCEL_READ_HELPER(data, StringVector, &accountInfo.groupIdList);
320686862fbSopenharmony_ci
321686862fbSopenharmony_ci    callerInfo.callerAppId = data.ReadString();
322686862fbSopenharmony_ci    std::string extraInfo = data.ReadString();
323686862fbSopenharmony_ci    if (!extraInfo.empty()) {
324686862fbSopenharmony_ci        nlohmann::json extraInfoJson = nlohmann::json::parse(extraInfo, nullptr, false);
325686862fbSopenharmony_ci        if (!extraInfoJson.is_discarded()) {
326686862fbSopenharmony_ci            SaveExtraInfo(extraInfoJson, callerInfo, accountInfo);
327686862fbSopenharmony_ci            HILOGD("parse extra info");
328686862fbSopenharmony_ci        }
329686862fbSopenharmony_ci    }
330686862fbSopenharmony_ci    return ERR_OK;
331686862fbSopenharmony_ci}
332686862fbSopenharmony_ci
333686862fbSopenharmony_ciint32_t DistributedSchedStub::GetConnectAbilityFromRemoteExParam(MessageParcel& data,
334686862fbSopenharmony_ci    AppExecFwk::AbilityInfo& abilityInfo, sptr<IRemoteObject>& connect,
335686862fbSopenharmony_ci    CallerInfo& callerInfo, AccountInfo& accountInfo)
336686862fbSopenharmony_ci{
337686862fbSopenharmony_ci    unique_ptr<CompatibleAbilityInfo> cmpAbilityInfo(data.ReadParcelable<CompatibleAbilityInfo>());
338686862fbSopenharmony_ci    if (cmpAbilityInfo == nullptr) {
339686862fbSopenharmony_ci        HILOGE("abilityInfo readParcelable failed!");
340686862fbSopenharmony_ci        return ERR_NULL_OBJECT;
341686862fbSopenharmony_ci    }
342686862fbSopenharmony_ci    cmpAbilityInfo->ConvertToAbilityInfo(abilityInfo);
343686862fbSopenharmony_ci
344686862fbSopenharmony_ci    connect = data.ReadRemoteObject();
345686862fbSopenharmony_ci
346686862fbSopenharmony_ci    int32_t result = ReadDataForConnect(data, callerInfo, accountInfo);
347686862fbSopenharmony_ci    if (result != ERR_NONE) {
348686862fbSopenharmony_ci        HILOGD("Read callerInfo and accountInfo for connect fail, ret %{public}d.", result);
349686862fbSopenharmony_ci        return result;
350686862fbSopenharmony_ci    }
351686862fbSopenharmony_ci    std::string extraInfo = data.ReadString();
352686862fbSopenharmony_ci    if (extraInfo.empty()) {
353686862fbSopenharmony_ci        HILOGD("extra info is empty!");
354686862fbSopenharmony_ci    }
355686862fbSopenharmony_ci    nlohmann::json extraInfoJson = nlohmann::json::parse(extraInfo, nullptr, false);
356686862fbSopenharmony_ci    if (!extraInfoJson.is_discarded()) {
357686862fbSopenharmony_ci        SaveExtraInfo(extraInfoJson, callerInfo, accountInfo);
358686862fbSopenharmony_ci        HILOGD("parse extra info");
359686862fbSopenharmony_ci    }
360686862fbSopenharmony_ci    return ERR_OK;
361686862fbSopenharmony_ci}
362686862fbSopenharmony_ci
363686862fbSopenharmony_ciint32_t DistributedSchedStub::StartAbilityFromRemoteInner(MessageParcel& data, MessageParcel& reply)
364686862fbSopenharmony_ci{
365686862fbSopenharmony_ci#ifdef DMSFWK_INTERACTIVE_ADAPTER
366686862fbSopenharmony_ci    if (CheckRemoteOsType(IPCSkeleton::GetCallingDeviceID())) {
367686862fbSopenharmony_ci        return StartAbilityFromRemoteAdapterInner(data, reply);
368686862fbSopenharmony_ci    }
369686862fbSopenharmony_ci#endif
370686862fbSopenharmony_ci
371686862fbSopenharmony_ci    if (!CheckCallingUid()) {
372686862fbSopenharmony_ci        HILOGW("request DENIED!");
373686862fbSopenharmony_ci        return DMS_PERMISSION_DENIED;
374686862fbSopenharmony_ci    }
375686862fbSopenharmony_ci    int64_t begin = GetTickCount();
376686862fbSopenharmony_ci
377686862fbSopenharmony_ci    shared_ptr<AAFwk::Want> want = ReadDistributedWant(data);
378686862fbSopenharmony_ci    if (want == nullptr) {
379686862fbSopenharmony_ci        HILOGW("want readParcelable failed!");
380686862fbSopenharmony_ci        return ERR_NULL_OBJECT;
381686862fbSopenharmony_ci    }
382686862fbSopenharmony_ci    DistributedSchedPermission::GetInstance().RemoveRemoteObjectFromWant(want);
383686862fbSopenharmony_ci
384686862fbSopenharmony_ci    AbilityInfo abilityInfo;
385686862fbSopenharmony_ci    int32_t requestCode = 0;
386686862fbSopenharmony_ci    CallerInfo callerInfo;
387686862fbSopenharmony_ci    AccountInfo accountInfo;
388686862fbSopenharmony_ci    if (GetStartAbilityFromRemoteExParam(data, abilityInfo, requestCode, callerInfo, accountInfo) != ERR_OK) {
389686862fbSopenharmony_ci        HILOGE("Get start ability from remote exParam fail!");
390686862fbSopenharmony_ci        return INVALID_PARAMETERS_ERR;
391686862fbSopenharmony_ci    }
392686862fbSopenharmony_ci    std::string package = abilityInfo.bundleName;
393686862fbSopenharmony_ci    std::string deviceId = abilityInfo.deviceId;
394686862fbSopenharmony_ci
395686862fbSopenharmony_ci    int32_t result = StartAbilityFromRemote(*want, abilityInfo, requestCode, callerInfo, accountInfo);
396686862fbSopenharmony_ci    BehaviorEventParam eventParam = { EventCallingType::REMOTE, BehaviorEvent::START_REMOTE_ABILITY, result,
397686862fbSopenharmony_ci        want->GetElement().GetBundleName(), want->GetElement().GetAbilityName(), callerInfo.uid };
398686862fbSopenharmony_ci    DmsHiSysEventReport::ReportBehaviorEvent(eventParam);
399686862fbSopenharmony_ci    HILOGI("result = %{public}d", result);
400686862fbSopenharmony_ci    PARCEL_WRITE_HELPER(reply, Int32, result);
401686862fbSopenharmony_ci    int64_t end = GetTickCount();
402686862fbSopenharmony_ci    PARCEL_WRITE_HELPER(reply, Int64, end - begin);
403686862fbSopenharmony_ci    PARCEL_WRITE_HELPER(reply, String, package);
404686862fbSopenharmony_ci    PARCEL_WRITE_HELPER(reply, String, deviceId);
405686862fbSopenharmony_ci    return ERR_NONE;
406686862fbSopenharmony_ci}
407686862fbSopenharmony_ci
408686862fbSopenharmony_ciint32_t DistributedSchedStub::StopAbilityFromRemoteInner(MessageParcel& data, MessageParcel& reply)
409686862fbSopenharmony_ci{
410686862fbSopenharmony_ci#ifdef DMSFWK_INTERACTIVE_ADAPTER
411686862fbSopenharmony_ci    if (CheckRemoteOsType(IPCSkeleton::GetCallingDeviceID())) {
412686862fbSopenharmony_ci        return StopAbilityFromRemoteAdapterInner(data, reply);
413686862fbSopenharmony_ci    }
414686862fbSopenharmony_ci#endif
415686862fbSopenharmony_ci    int32_t result = ERR_OK;
416686862fbSopenharmony_ci    PARCEL_WRITE_REPLY_NOERROR(reply, Int32, result);
417686862fbSopenharmony_ci}
418686862fbSopenharmony_ci
419686862fbSopenharmony_civoid DistributedSchedStub::SaveExtraInfo(const nlohmann::json& extraInfoJson, CallerInfo& callerInfo,
420686862fbSopenharmony_ci    AccountInfo& accountInfo)
421686862fbSopenharmony_ci{
422686862fbSopenharmony_ci    if (extraInfoJson.find(EXTRO_INFO_JSON_KEY_ACCESS_TOKEN) != extraInfoJson.end() &&
423686862fbSopenharmony_ci        extraInfoJson[EXTRO_INFO_JSON_KEY_ACCESS_TOKEN].is_number_unsigned()) {
424686862fbSopenharmony_ci        uint32_t accessToken = extraInfoJson[EXTRO_INFO_JSON_KEY_ACCESS_TOKEN];
425686862fbSopenharmony_ci        callerInfo.accessToken = accessToken;
426686862fbSopenharmony_ci        HILOGD("parse extra info, accessTokenID = %s", GetAnonymStr(std::to_string(accessToken)).c_str());
427686862fbSopenharmony_ci    }
428686862fbSopenharmony_ci
429686862fbSopenharmony_ci    if (extraInfoJson.find(DMS_VERSION_ID) != extraInfoJson.end() && extraInfoJson[DMS_VERSION_ID].is_string()) {
430686862fbSopenharmony_ci        std::string dmsVersion = extraInfoJson[DMS_VERSION_ID];
431686862fbSopenharmony_ci        callerInfo.extraInfoJson[DMS_VERSION_ID] = dmsVersion;
432686862fbSopenharmony_ci    }
433686862fbSopenharmony_ci
434686862fbSopenharmony_ci    if (extraInfoJson.find(DMS_UID_SPEC_BUNDLE_NAME) != extraInfoJson.end() &&
435686862fbSopenharmony_ci        extraInfoJson[DMS_UID_SPEC_BUNDLE_NAME].is_string()) {
436686862fbSopenharmony_ci        std::string uidBundleName = extraInfoJson[DMS_UID_SPEC_BUNDLE_NAME];
437686862fbSopenharmony_ci        callerInfo.extraInfoJson[DMS_UID_SPEC_BUNDLE_NAME] = uidBundleName;
438686862fbSopenharmony_ci    }
439686862fbSopenharmony_ci
440686862fbSopenharmony_ci    if (extraInfoJson.find(Constants::EXTRO_INFO_JSON_KEY_ACCOUNT_ID) != extraInfoJson.end() &&
441686862fbSopenharmony_ci        extraInfoJson[Constants::EXTRO_INFO_JSON_KEY_ACCOUNT_ID].is_string()) {
442686862fbSopenharmony_ci        accountInfo.activeAccountId = extraInfoJson[Constants::EXTRO_INFO_JSON_KEY_ACCOUNT_ID];
443686862fbSopenharmony_ci    }
444686862fbSopenharmony_ci    if (extraInfoJson.find(Constants::EXTRO_INFO_JSON_KEY_USERID_ID) != extraInfoJson.end() &&
445686862fbSopenharmony_ci        extraInfoJson[Constants::EXTRO_INFO_JSON_KEY_USERID_ID].is_number()) {
446686862fbSopenharmony_ci        accountInfo.userId = extraInfoJson[Constants::EXTRO_INFO_JSON_KEY_USERID_ID];
447686862fbSopenharmony_ci    }
448686862fbSopenharmony_ci    HILOGD("save dms version");
449686862fbSopenharmony_ci}
450686862fbSopenharmony_ci
451686862fbSopenharmony_civoid DistributedSchedStub::SaveSendResultExtraInfo(const nlohmann::json& extraInfoJson, CallerInfo& callerInfo,
452686862fbSopenharmony_ci    AccountInfo& accountInfo)
453686862fbSopenharmony_ci{
454686862fbSopenharmony_ci    if (extraInfoJson.find(Constants::EXTRO_INFO_JSON_KEY_ACCOUNT_ID) != extraInfoJson.end() &&
455686862fbSopenharmony_ci        extraInfoJson[Constants::EXTRO_INFO_JSON_KEY_ACCOUNT_ID].is_string()) {
456686862fbSopenharmony_ci        accountInfo.activeAccountId = extraInfoJson[Constants::EXTRO_INFO_JSON_KEY_ACCOUNT_ID];
457686862fbSopenharmony_ci    }
458686862fbSopenharmony_ci    if (extraInfoJson.find(Constants::EXTRO_INFO_JSON_KEY_USERID_ID) != extraInfoJson.end() &&
459686862fbSopenharmony_ci        extraInfoJson[Constants::EXTRO_INFO_JSON_KEY_USERID_ID].is_number()) {
460686862fbSopenharmony_ci        accountInfo.userId = extraInfoJson[Constants::EXTRO_INFO_JSON_KEY_USERID_ID];
461686862fbSopenharmony_ci    }
462686862fbSopenharmony_ci
463686862fbSopenharmony_ci    if (extraInfoJson.find(Constants::EXTRO_INFO_JSON_KEY_CALLER_INFO_EX) != extraInfoJson.end() &&
464686862fbSopenharmony_ci        extraInfoJson[Constants::EXTRO_INFO_JSON_KEY_CALLER_INFO_EX].is_string()) {
465686862fbSopenharmony_ci        std::string callerExJsonStr = extraInfoJson[Constants::EXTRO_INFO_JSON_KEY_CALLER_INFO_EX];
466686862fbSopenharmony_ci        if (callerExJsonStr.empty()) {
467686862fbSopenharmony_ci            HILOGD("caller extra info json string is empty!");
468686862fbSopenharmony_ci        }
469686862fbSopenharmony_ci        callerInfo.extraInfoJson = nlohmann::json::parse(callerExJsonStr, nullptr, false);
470686862fbSopenharmony_ci    }
471686862fbSopenharmony_ci    HILOGD("save dms version");
472686862fbSopenharmony_ci}
473686862fbSopenharmony_ci
474686862fbSopenharmony_ciint32_t DistributedSchedStub::SendResultFromRemoteInner(MessageParcel& data, MessageParcel& reply)
475686862fbSopenharmony_ci{
476686862fbSopenharmony_ci    if (!CheckCallingUid()) {
477686862fbSopenharmony_ci        HILOGW("request DENIED!");
478686862fbSopenharmony_ci        return DMS_PERMISSION_DENIED;
479686862fbSopenharmony_ci    }
480686862fbSopenharmony_ci    shared_ptr<DistributedWant> dstbWant(data.ReadParcelable<DistributedWant>());
481686862fbSopenharmony_ci    shared_ptr<AAFwk::Want> want = nullptr;
482686862fbSopenharmony_ci    if (dstbWant != nullptr) {
483686862fbSopenharmony_ci        want = dstbWant->ToWant();
484686862fbSopenharmony_ci    }
485686862fbSopenharmony_ci    if (want == nullptr) {
486686862fbSopenharmony_ci        HILOGW("want readParcelable failed!");
487686862fbSopenharmony_ci        return ERR_NULL_OBJECT;
488686862fbSopenharmony_ci    }
489686862fbSopenharmony_ci    DistributedSchedPermission::GetInstance().RemoveRemoteObjectFromWant(want);
490686862fbSopenharmony_ci    int64_t begin = GetTickCount();
491686862fbSopenharmony_ci    int32_t requestCode = 0;
492686862fbSopenharmony_ci    PARCEL_READ_HELPER(data, Int32, requestCode);
493686862fbSopenharmony_ci    CallerInfo callerInfo;
494686862fbSopenharmony_ci    PARCEL_READ_HELPER(data, Int32, callerInfo.uid);
495686862fbSopenharmony_ci    PARCEL_READ_HELPER(data, String, callerInfo.sourceDeviceId);
496686862fbSopenharmony_ci    callerInfo.callerType = CALLER_TYPE_HARMONY;
497686862fbSopenharmony_ci    AccountInfo accountInfo;
498686862fbSopenharmony_ci    accountInfo.accountType = data.ReadInt32();
499686862fbSopenharmony_ci    PARCEL_READ_HELPER(data, StringVector, &accountInfo.groupIdList);
500686862fbSopenharmony_ci    callerInfo.callerAppId = data.ReadString();
501686862fbSopenharmony_ci    int32_t resultCode = 0;
502686862fbSopenharmony_ci    PARCEL_READ_HELPER(data, Int32, resultCode);
503686862fbSopenharmony_ci    std::string extraInfo = data.ReadString();
504686862fbSopenharmony_ci    if (extraInfo.empty()) {
505686862fbSopenharmony_ci        HILOGD("extra info is empty!");
506686862fbSopenharmony_ci    }
507686862fbSopenharmony_ci    nlohmann::json extraInfoJson = nlohmann::json::parse(extraInfo, nullptr, false);
508686862fbSopenharmony_ci    if (!extraInfoJson.is_discarded()) {
509686862fbSopenharmony_ci        SaveSendResultExtraInfo(extraInfoJson, callerInfo, accountInfo);
510686862fbSopenharmony_ci        HILOGD("parse extra info");
511686862fbSopenharmony_ci    }
512686862fbSopenharmony_ci
513686862fbSopenharmony_ci    int32_t result = SendResultFromRemote(*want, requestCode, callerInfo, accountInfo, resultCode);
514686862fbSopenharmony_ci    HILOGI("result = %{public}d", result);
515686862fbSopenharmony_ci    PARCEL_WRITE_HELPER(reply, Int32, result);
516686862fbSopenharmony_ci    int64_t end = GetTickCount();
517686862fbSopenharmony_ci    PARCEL_WRITE_HELPER(reply, Int64, end - begin);
518686862fbSopenharmony_ci    return ERR_NONE;
519686862fbSopenharmony_ci}
520686862fbSopenharmony_ci
521686862fbSopenharmony_ciint32_t DistributedSchedStub::ContinueMissionInner(MessageParcel& data, MessageParcel& reply)
522686862fbSopenharmony_ci{
523686862fbSopenharmony_ci    bool isLocalCalling = IPCSkeleton::IsLocalCalling();
524686862fbSopenharmony_ci    if ((isLocalCalling && !DistributedSchedPermission::GetInstance().IsFoundationCall()) ||
525686862fbSopenharmony_ci        (!isLocalCalling && !CheckCallingUid())) {
526686862fbSopenharmony_ci        HILOGE("check permission failed!");
527686862fbSopenharmony_ci        return DMS_PERMISSION_DENIED;
528686862fbSopenharmony_ci    }
529686862fbSopenharmony_ci
530686862fbSopenharmony_ci    std::string srcDevId;
531686862fbSopenharmony_ci    std::string dstDevId;
532686862fbSopenharmony_ci    PARCEL_READ_HELPER(data, String, srcDevId);
533686862fbSopenharmony_ci    PARCEL_READ_HELPER(data, String, dstDevId);
534686862fbSopenharmony_ci    int32_t missionId = 0;
535686862fbSopenharmony_ci    PARCEL_READ_HELPER(data, Int32, missionId);
536686862fbSopenharmony_ci    sptr<IRemoteObject> callback = data.ReadRemoteObject();
537686862fbSopenharmony_ci    if (callback == nullptr) {
538686862fbSopenharmony_ci        HILOGW("read callback failed!");
539686862fbSopenharmony_ci        return ERR_NULL_OBJECT;
540686862fbSopenharmony_ci    }
541686862fbSopenharmony_ci    shared_ptr<AAFwk::WantParams> wantParams(data.ReadParcelable<AAFwk::WantParams>());
542686862fbSopenharmony_ci    if (wantParams == nullptr) {
543686862fbSopenharmony_ci        HILOGW("wantParams readParcelable failed!");
544686862fbSopenharmony_ci        return ERR_NULL_OBJECT;
545686862fbSopenharmony_ci    }
546686862fbSopenharmony_ci
547686862fbSopenharmony_ci    int32_t result = ERR_OK;
548686862fbSopenharmony_ci    AAFwk::MissionInfo missionInfo;
549686862fbSopenharmony_ci    if (isLocalCalling) {
550686862fbSopenharmony_ci        std::string remoteDeviceId = (IPCSkeleton::GetCallingDeviceID() == srcDevId) ? dstDevId : srcDevId;
551686862fbSopenharmony_ci        if (AAFwk::AbilityManagerClient::GetInstance()->GetMissionInfo("", missionId, missionInfo) != ERR_OK) {
552686862fbSopenharmony_ci            return ERR_NULL_OBJECT;
553686862fbSopenharmony_ci        }
554686862fbSopenharmony_ci        std::string sourceBundleName = missionInfo.want.GetBundle();
555686862fbSopenharmony_ci        missionInfo.want.SetParams(*wantParams);
556686862fbSopenharmony_ci        bool isFreeInstall = missionInfo.want.GetBoolParam("isFreeInstall", false);
557686862fbSopenharmony_ci        if ((!isFreeInstall && IsUsingQos(remoteDeviceId)) ||
558686862fbSopenharmony_ci            (isFreeInstall && IsRemoteInstall(remoteDeviceId, sourceBundleName))) {
559686862fbSopenharmony_ci            DSchedTransportSoftbusAdapter::GetInstance().SetCallingTokenId(IPCSkeleton::GetCallingTokenID());
560686862fbSopenharmony_ci            result = DSchedContinueManager::GetInstance().ContinueMission(srcDevId, dstDevId, missionId, callback,
561686862fbSopenharmony_ci                *wantParams);
562686862fbSopenharmony_ci            HILOGI("result = %{public}d", result);
563686862fbSopenharmony_ci            PARCEL_WRITE_REPLY_NOERROR(reply, Int32, result);
564686862fbSopenharmony_ci        }
565686862fbSopenharmony_ci    }
566686862fbSopenharmony_ci    result = ContinueMission(srcDevId, dstDevId, missionId, callback, *wantParams);
567686862fbSopenharmony_ci    HILOGI("result = %{public}d", result);
568686862fbSopenharmony_ci    PARCEL_WRITE_REPLY_NOERROR(reply, Int32, result);
569686862fbSopenharmony_ci}
570686862fbSopenharmony_ci
571686862fbSopenharmony_ciint32_t DistributedSchedStub::ContinueMissionOfBundleNameInner(MessageParcel& data, MessageParcel& reply)
572686862fbSopenharmony_ci{
573686862fbSopenharmony_ci    bool isLocalCalling = IPCSkeleton::IsLocalCalling();
574686862fbSopenharmony_ci    if ((isLocalCalling && !DistributedSchedPermission::GetInstance().IsFoundationCall()) ||
575686862fbSopenharmony_ci        (!isLocalCalling && !CheckCallingUid())) {
576686862fbSopenharmony_ci        HILOGE("check permission failed!");
577686862fbSopenharmony_ci        return DMS_PERMISSION_DENIED;
578686862fbSopenharmony_ci    }
579686862fbSopenharmony_ci
580686862fbSopenharmony_ci    std::string srcDevId;
581686862fbSopenharmony_ci    std::string dstDevId;
582686862fbSopenharmony_ci    std::string bundleName;
583686862fbSopenharmony_ci    PARCEL_READ_HELPER(data, String, srcDevId);
584686862fbSopenharmony_ci    PARCEL_READ_HELPER(data, String, dstDevId);
585686862fbSopenharmony_ci    PARCEL_READ_HELPER(data, String, bundleName);
586686862fbSopenharmony_ci    sptr<IRemoteObject> callback = data.ReadRemoteObject();
587686862fbSopenharmony_ci    if (callback == nullptr) {
588686862fbSopenharmony_ci        HILOGW("read callback failed!");
589686862fbSopenharmony_ci        return ERR_NULL_OBJECT;
590686862fbSopenharmony_ci    }
591686862fbSopenharmony_ci    shared_ptr<AAFwk::WantParams> wantParams(data.ReadParcelable<AAFwk::WantParams>());
592686862fbSopenharmony_ci    if (wantParams == nullptr) {
593686862fbSopenharmony_ci        HILOGW("wantParams readParcelable failed!");
594686862fbSopenharmony_ci        return ERR_NULL_OBJECT;
595686862fbSopenharmony_ci    }
596686862fbSopenharmony_ci
597686862fbSopenharmony_ci    std::string srcBundleName;
598686862fbSopenharmony_ci    std::string continueType;
599686862fbSopenharmony_ci    PARCEL_READ_HELPER_NORET(data, String, srcBundleName);
600686862fbSopenharmony_ci    PARCEL_READ_HELPER_NORET(data, String, continueType);
601686862fbSopenharmony_ci    if (continueType == "") {
602686862fbSopenharmony_ci        continueType = DMSContinueRecvMgr::GetInstance().GetContinueType(bundleName);
603686862fbSopenharmony_ci    }
604686862fbSopenharmony_ci
605686862fbSopenharmony_ci    int32_t result = ERR_OK;
606686862fbSopenharmony_ci    AAFwk::MissionInfo missionInfo;
607686862fbSopenharmony_ci    if (isLocalCalling) {
608686862fbSopenharmony_ci        std::string remoteDeviceId = (IPCSkeleton::GetCallingDeviceID() == srcDevId) ? dstDevId : srcDevId;
609686862fbSopenharmony_ci        missionInfo.want.SetParams(*wantParams);
610686862fbSopenharmony_ci        bool isFreeInstall = missionInfo.want.GetBoolParam("isFreeInstall", false);
611686862fbSopenharmony_ci        if ((!isFreeInstall && IsUsingQos(remoteDeviceId)) ||
612686862fbSopenharmony_ci            (isFreeInstall && IsRemoteInstall(remoteDeviceId, bundleName))) {
613686862fbSopenharmony_ci            DSchedTransportSoftbusAdapter::GetInstance().SetCallingTokenId(IPCSkeleton::GetCallingTokenID());
614686862fbSopenharmony_ci            result = DSchedContinueManager::GetInstance().ContinueMission(
615686862fbSopenharmony_ci                DSchedContinueInfo(srcDevId, srcBundleName, dstDevId, bundleName, continueType),
616686862fbSopenharmony_ci                callback, *wantParams);
617686862fbSopenharmony_ci            HILOGI("result = %{public}d", result);
618686862fbSopenharmony_ci            PARCEL_WRITE_REPLY_NOERROR(reply, Int32, result);
619686862fbSopenharmony_ci        }
620686862fbSopenharmony_ci    }
621686862fbSopenharmony_ci    result = ContinueMission(srcDevId, dstDevId, bundleName, callback, *wantParams);
622686862fbSopenharmony_ci    HILOGI("result = %{public}d", result);
623686862fbSopenharmony_ci    PARCEL_WRITE_REPLY_NOERROR(reply, Int32, result);
624686862fbSopenharmony_ci}
625686862fbSopenharmony_ci
626686862fbSopenharmony_cibool DistributedSchedStub::IsRemoteInstall(const std::string &networkId, const std::string &bundleName)
627686862fbSopenharmony_ci{
628686862fbSopenharmony_ci    DmsBundleInfo info;
629686862fbSopenharmony_ci    DmsBmStorage::GetInstance()->GetStorageDistributeInfo(networkId, bundleName, info);
630686862fbSopenharmony_ci    if (info.bundleName.empty()) {
631686862fbSopenharmony_ci        return false;
632686862fbSopenharmony_ci    }
633686862fbSopenharmony_ci    return true;
634686862fbSopenharmony_ci}
635686862fbSopenharmony_ci
636686862fbSopenharmony_ciint32_t DistributedSchedStub::StartContinuationInner(MessageParcel& data, MessageParcel& reply)
637686862fbSopenharmony_ci{
638686862fbSopenharmony_ci    int64_t saveDataEnd = GetTickCount();
639686862fbSopenharmony_ci    DmsContinueTime::GetInstance().SetSaveDataDurationEnd(saveDataEnd);
640686862fbSopenharmony_ci
641686862fbSopenharmony_ci    if (!DistributedSchedPermission::GetInstance().IsFoundationCall()) {
642686862fbSopenharmony_ci        return DMS_PERMISSION_DENIED;
643686862fbSopenharmony_ci    }
644686862fbSopenharmony_ci    DmsHiTraceChain hiTraceChain(TraceValue::START_CONTINUATION);
645686862fbSopenharmony_ci    HITRACE_METER_NAME(TraceTag::DSCHED, TraceValue::START_CONTINUATION);
646686862fbSopenharmony_ci    shared_ptr<AAFwk::Want> want(data.ReadParcelable<AAFwk::Want>());
647686862fbSopenharmony_ci    if (want == nullptr) {
648686862fbSopenharmony_ci        HILOGW("want readParcelable failed!");
649686862fbSopenharmony_ci        return ERR_NULL_OBJECT;
650686862fbSopenharmony_ci    }
651686862fbSopenharmony_ci    DistributedSchedPermission::GetInstance().RemoveRemoteObjectFromWant(want);
652686862fbSopenharmony_ci    int32_t missionId = data.ReadInt32();
653686862fbSopenharmony_ci    int32_t callerUid = data.ReadInt32();
654686862fbSopenharmony_ci    int32_t status = data.ReadInt32();
655686862fbSopenharmony_ci    uint32_t accessToken = 0;
656686862fbSopenharmony_ci    PARCEL_READ_HELPER(data, Uint32, accessToken);
657686862fbSopenharmony_ci    HILOGI("get AccessTokenID = %{public}s", GetAnonymStr(std::to_string(accessToken)).c_str());
658686862fbSopenharmony_ci    DistributedSchedPermission::GetInstance().MarkUriPermission(*want, accessToken);
659686862fbSopenharmony_ci
660686862fbSopenharmony_ci    // set in ability runtime, used to seperate callings from FA or stage model
661686862fbSopenharmony_ci    bool isFA = want->GetBoolParam(FEATURE_ABILITY_FLAG_KEY, false);
662686862fbSopenharmony_ci    want->RemoveParam(FEATURE_ABILITY_FLAG_KEY);
663686862fbSopenharmony_ci
664686862fbSopenharmony_ci    bool isFreeInstall = DistributedSchedService::GetInstance().GetIsFreeInstall(missionId);
665686862fbSopenharmony_ci
666686862fbSopenharmony_ci    int32_t result = (isFA || isFreeInstall || !IsUsingQos(want->GetElement().GetDeviceID())) ?
667686862fbSopenharmony_ci        StartContinuation(*want, missionId, callerUid, status, accessToken) :
668686862fbSopenharmony_ci        DSchedContinueManager::GetInstance().StartContinuation(*want, missionId, callerUid, status, accessToken);
669686862fbSopenharmony_ci
670686862fbSopenharmony_ci    ReportEvent(*want, BehaviorEvent::START_CONTINUATION, result, callerUid);
671686862fbSopenharmony_ci    HILOGI("result = %{public}d", result);
672686862fbSopenharmony_ci    PARCEL_WRITE_REPLY_NOERROR(reply, Int32, result);
673686862fbSopenharmony_ci}
674686862fbSopenharmony_ci
675686862fbSopenharmony_ciint32_t DistributedSchedStub::NotifyCompleteContinuationInner(MessageParcel& data,
676686862fbSopenharmony_ci    [[maybe_unused]] MessageParcel& reply)
677686862fbSopenharmony_ci{
678686862fbSopenharmony_ci    if (!DistributedSchedPermission::GetInstance().IsFoundationCall()) {
679686862fbSopenharmony_ci        HILOGE("check permission failed!");
680686862fbSopenharmony_ci        return DMS_PERMISSION_DENIED;
681686862fbSopenharmony_ci    }
682686862fbSopenharmony_ci
683686862fbSopenharmony_ci    u16string devId = data.ReadString16();
684686862fbSopenharmony_ci    if (devId.empty()) {
685686862fbSopenharmony_ci        HILOGE("devId is empty!");
686686862fbSopenharmony_ci        return INVALID_PARAMETERS_ERR;
687686862fbSopenharmony_ci    }
688686862fbSopenharmony_ci    int32_t sessionId = 0;
689686862fbSopenharmony_ci    PARCEL_READ_HELPER(data, Int32, sessionId);
690686862fbSopenharmony_ci    bool continuationResult = false;
691686862fbSopenharmony_ci    PARCEL_READ_HELPER(data, Bool, continuationResult);
692686862fbSopenharmony_ci    std::string callerBundleName = data.ReadString();
693686862fbSopenharmony_ci    auto dContinue = DSchedContinueManager::GetInstance().GetDSchedContinueByDevId(devId, sessionId);
694686862fbSopenharmony_ci    if (dContinue != nullptr) {
695686862fbSopenharmony_ci        DSchedContinueManager::GetInstance().NotifyCompleteContinuation(devId, sessionId, continuationResult,
696686862fbSopenharmony_ci            callerBundleName);
697686862fbSopenharmony_ci    } else {
698686862fbSopenharmony_ci        NotifyCompleteContinuation(devId, sessionId, continuationResult);
699686862fbSopenharmony_ci    }
700686862fbSopenharmony_ci    return ERR_OK;
701686862fbSopenharmony_ci}
702686862fbSopenharmony_ci
703686862fbSopenharmony_cibool DistributedSchedStub::IsUsingQos(const std::string& remoteDeviceId)
704686862fbSopenharmony_ci{
705686862fbSopenharmony_ci    if (remoteDeviceId.empty()) {
706686862fbSopenharmony_ci        HILOGW("remote deviceId empty, using rpc");
707686862fbSopenharmony_ci        return false;
708686862fbSopenharmony_ci    }
709686862fbSopenharmony_ci
710686862fbSopenharmony_ci    DmsVersion thresholdDmsVersion = {QOS_THRESHOLD_VERSION, 0, 0};
711686862fbSopenharmony_ci    if (DmsVersionManager::IsRemoteDmsVersionLower(remoteDeviceId, thresholdDmsVersion)) {
712686862fbSopenharmony_ci        HILOGW("remote dms not support qos, using rpc");
713686862fbSopenharmony_ci        return false;
714686862fbSopenharmony_ci    }
715686862fbSopenharmony_ci    HILOGI("remote device satisfied qos condition");
716686862fbSopenharmony_ci    return true;
717686862fbSopenharmony_ci}
718686862fbSopenharmony_ci
719686862fbSopenharmony_ciint32_t DistributedSchedStub::NotifyDSchedEventResultFromRemoteInner(MessageParcel& data,
720686862fbSopenharmony_ci    [[maybe_unused]] MessageParcel& reply)
721686862fbSopenharmony_ci{
722686862fbSopenharmony_ci    if (!CheckCallingUid()) {
723686862fbSopenharmony_ci        HILOGW("request DENIED!");
724686862fbSopenharmony_ci        return DMS_PERMISSION_DENIED;
725686862fbSopenharmony_ci    }
726686862fbSopenharmony_ci
727686862fbSopenharmony_ci    std::string type = "";
728686862fbSopenharmony_ci    PARCEL_READ_HELPER(data, String, type);
729686862fbSopenharmony_ci    int32_t dSchedEventResult = -1;
730686862fbSopenharmony_ci    PARCEL_READ_HELPER(data, Int32, dSchedEventResult);
731686862fbSopenharmony_ci    return NotifyDSchedEventResultFromRemote(type, dSchedEventResult);
732686862fbSopenharmony_ci}
733686862fbSopenharmony_ci
734686862fbSopenharmony_ciint32_t DistributedSchedStub::NotifyContinuationResultFromRemoteInner(MessageParcel& data,
735686862fbSopenharmony_ci    [[maybe_unused]] MessageParcel& reply)
736686862fbSopenharmony_ci{
737686862fbSopenharmony_ci    if (!CheckCallingUid()) {
738686862fbSopenharmony_ci        HILOGW("request DENIED!");
739686862fbSopenharmony_ci        return DMS_PERMISSION_DENIED;
740686862fbSopenharmony_ci    }
741686862fbSopenharmony_ci
742686862fbSopenharmony_ci    int32_t sessionId = 0;
743686862fbSopenharmony_ci    PARCEL_READ_HELPER(data, Int32, sessionId);
744686862fbSopenharmony_ci    bool continuationResult = false;
745686862fbSopenharmony_ci    PARCEL_READ_HELPER(data, Bool, continuationResult);
746686862fbSopenharmony_ci    std::string dstInfo;
747686862fbSopenharmony_ci    PARCEL_READ_HELPER_NORET(data, String, dstInfo);
748686862fbSopenharmony_ci    return NotifyContinuationResultFromRemote(sessionId, continuationResult, dstInfo);
749686862fbSopenharmony_ci}
750686862fbSopenharmony_ci
751686862fbSopenharmony_ciint32_t DistributedSchedStub::ConnectRemoteAbilityInner(MessageParcel& data, MessageParcel& reply)
752686862fbSopenharmony_ci{
753686862fbSopenharmony_ci    if (!DistributedSchedPermission::GetInstance().IsFoundationCall()) {
754686862fbSopenharmony_ci        return DMS_PERMISSION_DENIED;
755686862fbSopenharmony_ci    }
756686862fbSopenharmony_ci    DmsHiTraceChain hiTraceChain(TraceValue::CONNECT_REMOTE_ABILITY);
757686862fbSopenharmony_ci    HITRACE_METER_NAME(TraceTag::DSCHED, TraceValue::CONNECT_REMOTE_ABILITY);
758686862fbSopenharmony_ci    shared_ptr<AAFwk::Want> want(data.ReadParcelable<AAFwk::Want>());
759686862fbSopenharmony_ci    if (want == nullptr) {
760686862fbSopenharmony_ci        HILOGW("want readParcelable failed!");
761686862fbSopenharmony_ci        return ERR_NULL_OBJECT;
762686862fbSopenharmony_ci    }
763686862fbSopenharmony_ci    DistributedSchedPermission::GetInstance().RemoveRemoteObjectFromWant(want);
764686862fbSopenharmony_ci    sptr<IRemoteObject> connect = data.ReadRemoteObject();
765686862fbSopenharmony_ci    int32_t callerUid = 0;
766686862fbSopenharmony_ci    PARCEL_READ_HELPER(data, Int32, callerUid);
767686862fbSopenharmony_ci    int32_t callerPid = 0;
768686862fbSopenharmony_ci    PARCEL_READ_HELPER(data, Int32, callerPid);
769686862fbSopenharmony_ci    uint32_t accessToken = 0;
770686862fbSopenharmony_ci    PARCEL_READ_HELPER(data, Uint32, accessToken);
771686862fbSopenharmony_ci    HILOGD("get callerUid = %{public}d, callerPid = %{public}d, AccessTokenID = %{private}s", callerUid, callerPid,
772686862fbSopenharmony_ci        GetAnonymStr(std::to_string(accessToken)).c_str());
773686862fbSopenharmony_ci    int32_t result = ConnectRemoteAbility(*want, connect, callerUid, callerPid, accessToken);
774686862fbSopenharmony_ci    ReportEvent(*want, BehaviorEvent::CONNECT_REMOTE_ABILITY, result, callerUid);
775686862fbSopenharmony_ci    HILOGI("result = %{public}d", result);
776686862fbSopenharmony_ci    PARCEL_WRITE_REPLY_NOERROR(reply, Int32, result);
777686862fbSopenharmony_ci}
778686862fbSopenharmony_ci
779686862fbSopenharmony_ciint32_t DistributedSchedStub::DisconnectRemoteAbilityInner(MessageParcel& data, MessageParcel& reply)
780686862fbSopenharmony_ci{
781686862fbSopenharmony_ci    if (!DistributedSchedPermission::GetInstance().IsFoundationCall()) {
782686862fbSopenharmony_ci        return DMS_PERMISSION_DENIED;
783686862fbSopenharmony_ci    }
784686862fbSopenharmony_ci    DmsHiTraceChain hiTraceChain(TraceValue::DISCONNECT_REMOTE_ABILITY);
785686862fbSopenharmony_ci    HITRACE_METER_NAME(TraceTag::DSCHED, TraceValue::DISCONNECT_REMOTE_ABILITY);
786686862fbSopenharmony_ci    sptr<IRemoteObject> connect = data.ReadRemoteObject();
787686862fbSopenharmony_ci    int32_t callerUid = 0;
788686862fbSopenharmony_ci    PARCEL_READ_HELPER(data, Int32, callerUid);
789686862fbSopenharmony_ci    uint32_t accessToken = 0;
790686862fbSopenharmony_ci    PARCEL_READ_HELPER(data, Uint32, accessToken);
791686862fbSopenharmony_ci    HILOGD("get callerUid = %{public}d, AccessTokenID = %{private}s", callerUid,
792686862fbSopenharmony_ci        GetAnonymStr(std::to_string(accessToken)).c_str());
793686862fbSopenharmony_ci    int32_t result = DisconnectRemoteAbility(connect, callerUid, accessToken);
794686862fbSopenharmony_ci    BehaviorEventParam eventParam = { EventCallingType::LOCAL, BehaviorEvent::DISCONNECT_REMOTE_ABILITY, result };
795686862fbSopenharmony_ci    DmsHiSysEventReport::ReportBehaviorEvent(eventParam);
796686862fbSopenharmony_ci    HILOGI("result = %{public}d", result);
797686862fbSopenharmony_ci    PARCEL_WRITE_REPLY_NOERROR(reply, Int32, result);
798686862fbSopenharmony_ci}
799686862fbSopenharmony_ci
800686862fbSopenharmony_ciint32_t DistributedSchedStub::ReadDataForConnect(MessageParcel& data, CallerInfo& callerInfo, AccountInfo& accountInfo)
801686862fbSopenharmony_ci{
802686862fbSopenharmony_ci    PARCEL_READ_HELPER(data, Int32, callerInfo.uid);
803686862fbSopenharmony_ci    PARCEL_READ_HELPER(data, Int32, callerInfo.pid);
804686862fbSopenharmony_ci    PARCEL_READ_HELPER(data, String, callerInfo.sourceDeviceId);
805686862fbSopenharmony_ci    callerInfo.callerType = CALLER_TYPE_HARMONY;
806686862fbSopenharmony_ci    accountInfo.accountType = data.ReadInt32();
807686862fbSopenharmony_ci    PARCEL_READ_HELPER(data, StringVector, &accountInfo.groupIdList);
808686862fbSopenharmony_ci    callerInfo.callerAppId = data.ReadString();
809686862fbSopenharmony_ci    return ERR_NONE;
810686862fbSopenharmony_ci}
811686862fbSopenharmony_ci
812686862fbSopenharmony_ciint32_t DistributedSchedStub::ConnectAbilityFromRemoteInner(MessageParcel& data, MessageParcel& reply)
813686862fbSopenharmony_ci{
814686862fbSopenharmony_ci#ifdef DMSFWK_INTERACTIVE_ADAPTER
815686862fbSopenharmony_ci    if (CheckRemoteOsType(IPCSkeleton::GetCallingDeviceID())) {
816686862fbSopenharmony_ci        return ConnectAbilityFromRemoteAdapterInner(data, reply);
817686862fbSopenharmony_ci    }
818686862fbSopenharmony_ci#endif
819686862fbSopenharmony_ci
820686862fbSopenharmony_ci    if (!CheckCallingUid()) {
821686862fbSopenharmony_ci        HILOGW("request DENIED!");
822686862fbSopenharmony_ci        return DMS_PERMISSION_DENIED;
823686862fbSopenharmony_ci    }
824686862fbSopenharmony_ci
825686862fbSopenharmony_ci    shared_ptr<AAFwk::Want> want = ReadDistributedWant(data);
826686862fbSopenharmony_ci    if (want == nullptr) {
827686862fbSopenharmony_ci        HILOGW("want readParcelable failed!");
828686862fbSopenharmony_ci        return ERR_NULL_OBJECT;
829686862fbSopenharmony_ci    }
830686862fbSopenharmony_ci    DistributedSchedPermission::GetInstance().RemoveRemoteObjectFromWant(want);
831686862fbSopenharmony_ci
832686862fbSopenharmony_ci    AbilityInfo abilityInfo;
833686862fbSopenharmony_ci    sptr<IRemoteObject> connect = nullptr;
834686862fbSopenharmony_ci    CallerInfo callerInfo;
835686862fbSopenharmony_ci    AccountInfo accountInfo;
836686862fbSopenharmony_ci    if (GetConnectAbilityFromRemoteExParam(data, abilityInfo, connect, callerInfo, accountInfo) != ERR_OK) {
837686862fbSopenharmony_ci        HILOGE("Get connect ability from remote exParam fail!");
838686862fbSopenharmony_ci        return INVALID_PARAMETERS_ERR;
839686862fbSopenharmony_ci    }
840686862fbSopenharmony_ci
841686862fbSopenharmony_ci    std::string package = abilityInfo.bundleName;
842686862fbSopenharmony_ci    std::string deviceId = abilityInfo.deviceId;
843686862fbSopenharmony_ci    int64_t begin = GetTickCount();
844686862fbSopenharmony_ci    int32_t result = ConnectAbilityFromRemote(*want, abilityInfo, connect, callerInfo, accountInfo);
845686862fbSopenharmony_ci    BehaviorEventParam eventParam = { EventCallingType::REMOTE, BehaviorEvent::CONNECT_REMOTE_ABILITY, result,
846686862fbSopenharmony_ci        want->GetElement().GetBundleName(), want->GetElement().GetAbilityName(), callerInfo.uid };
847686862fbSopenharmony_ci    DmsHiSysEventReport::ReportBehaviorEvent(eventParam);
848686862fbSopenharmony_ci    HILOGW("result = %{public}d", result);
849686862fbSopenharmony_ci    int64_t end = GetTickCount();
850686862fbSopenharmony_ci    PARCEL_WRITE_HELPER(reply, Int32, result);
851686862fbSopenharmony_ci    PARCEL_WRITE_HELPER(reply, Int64, end - begin);
852686862fbSopenharmony_ci    PARCEL_WRITE_HELPER(reply, String, package);
853686862fbSopenharmony_ci    PARCEL_WRITE_HELPER(reply, String, deviceId);
854686862fbSopenharmony_ci    return ERR_NONE;
855686862fbSopenharmony_ci}
856686862fbSopenharmony_ci
857686862fbSopenharmony_ciint32_t DistributedSchedStub::DisconnectAbilityFromRemoteInner(MessageParcel& data, MessageParcel& reply)
858686862fbSopenharmony_ci{
859686862fbSopenharmony_ci#ifdef DMSFWK_INTERACTIVE_ADAPTER
860686862fbSopenharmony_ci    if (CheckRemoteOsType(IPCSkeleton::GetCallingDeviceID())) {
861686862fbSopenharmony_ci        return DisconnectAbilityFromRemoteAdapterInner(data, reply);
862686862fbSopenharmony_ci    }
863686862fbSopenharmony_ci#endif
864686862fbSopenharmony_ci
865686862fbSopenharmony_ci    if (!CheckCallingUid()) {
866686862fbSopenharmony_ci        HILOGW("request DENIED!");
867686862fbSopenharmony_ci        return DMS_PERMISSION_DENIED;
868686862fbSopenharmony_ci    }
869686862fbSopenharmony_ci
870686862fbSopenharmony_ci    sptr<IRemoteObject> connect = data.ReadRemoteObject();
871686862fbSopenharmony_ci    int32_t uid = 0;
872686862fbSopenharmony_ci    PARCEL_READ_HELPER(data, Int32, uid);
873686862fbSopenharmony_ci    string sourceDeviceId;
874686862fbSopenharmony_ci    PARCEL_READ_HELPER(data, String, sourceDeviceId);
875686862fbSopenharmony_ci    int32_t result = DisconnectAbilityFromRemote(connect, uid, sourceDeviceId);
876686862fbSopenharmony_ci    BehaviorEventParam eventParam = { EventCallingType::REMOTE, BehaviorEvent::DISCONNECT_REMOTE_ABILITY, result };
877686862fbSopenharmony_ci    DmsHiSysEventReport::ReportBehaviorEvent(eventParam);
878686862fbSopenharmony_ci    HILOGI("result %{public}d", result);
879686862fbSopenharmony_ci    PARCEL_WRITE_REPLY_NOERROR(reply, Int32, result);
880686862fbSopenharmony_ci}
881686862fbSopenharmony_ci
882686862fbSopenharmony_ciint32_t DistributedSchedStub::NotifyProcessDiedFromRemoteInner(MessageParcel& data, MessageParcel& reply)
883686862fbSopenharmony_ci{
884686862fbSopenharmony_ci    if (!CheckCallingUid()) {
885686862fbSopenharmony_ci        HILOGW("request DENIED!");
886686862fbSopenharmony_ci        return DMS_PERMISSION_DENIED;
887686862fbSopenharmony_ci    }
888686862fbSopenharmony_ci
889686862fbSopenharmony_ci    int32_t uid = 0;
890686862fbSopenharmony_ci    PARCEL_READ_HELPER(data, Int32, uid);
891686862fbSopenharmony_ci    int32_t pid = 0;
892686862fbSopenharmony_ci    PARCEL_READ_HELPER(data, Int32, pid);
893686862fbSopenharmony_ci    string sourceDeviceId;
894686862fbSopenharmony_ci    PARCEL_READ_HELPER(data, String, sourceDeviceId);
895686862fbSopenharmony_ci    CallerInfo callerInfo;
896686862fbSopenharmony_ci    callerInfo.uid = uid;
897686862fbSopenharmony_ci    callerInfo.pid = pid;
898686862fbSopenharmony_ci    callerInfo.sourceDeviceId = sourceDeviceId;
899686862fbSopenharmony_ci    callerInfo.callerType = CALLER_TYPE_HARMONY;
900686862fbSopenharmony_ci    int32_t result = NotifyProcessDiedFromRemote(callerInfo);
901686862fbSopenharmony_ci    HILOGI("result %{public}d", result);
902686862fbSopenharmony_ci    PARCEL_WRITE_REPLY_NOERROR(reply, Int32, result);
903686862fbSopenharmony_ci}
904686862fbSopenharmony_ci
905686862fbSopenharmony_cibool DistributedSchedStub::CheckCallingUid()
906686862fbSopenharmony_ci{
907686862fbSopenharmony_ci    // never allow non-system uid for distributed request
908686862fbSopenharmony_ci    auto callingUid = IPCSkeleton::GetCallingUid();
909686862fbSopenharmony_ci    return callingUid < HID_HAP;
910686862fbSopenharmony_ci}
911686862fbSopenharmony_ci
912686862fbSopenharmony_cibool DistributedSchedStub::EnforceInterfaceToken(MessageParcel& data)
913686862fbSopenharmony_ci{
914686862fbSopenharmony_ci    u16string interfaceToken = data.ReadInterfaceToken();
915686862fbSopenharmony_ci    return interfaceToken == DMS_STUB_INTERFACE_TOKEN;
916686862fbSopenharmony_ci}
917686862fbSopenharmony_ci
918686862fbSopenharmony_ci#ifdef SUPPORT_DISTRIBUTED_MISSION_MANAGER
919686862fbSopenharmony_ciint32_t DistributedSchedStub::GetMissionInfosInner(MessageParcel& data, MessageParcel& reply)
920686862fbSopenharmony_ci{
921686862fbSopenharmony_ci    HILOGI("[PerformanceTest] called, IPC end = %{public}" PRId64, GetTickCount());
922686862fbSopenharmony_ci    if (!DistributedSchedPermission::GetInstance().IsFoundationCall() &&
923686862fbSopenharmony_ci        !DistributedSchedPermission::GetInstance().IsSceneBoardCall()) {
924686862fbSopenharmony_ci        return DMS_PERMISSION_DENIED;
925686862fbSopenharmony_ci    }
926686862fbSopenharmony_ci    std::u16string deviceId = data.ReadString16();
927686862fbSopenharmony_ci    int32_t numMissions = 0;
928686862fbSopenharmony_ci    PARCEL_READ_HELPER(data, Int32, numMissions);
929686862fbSopenharmony_ci
930686862fbSopenharmony_ci    std::vector<MissionInfo> missionInfos;
931686862fbSopenharmony_ci    int32_t result = GetMissionInfos(Str16ToStr8(deviceId), numMissions, missionInfos);
932686862fbSopenharmony_ci    HILOGI("result = %{public}d", result);
933686862fbSopenharmony_ci    if (result == ERR_NONE) {
934686862fbSopenharmony_ci        result = MissionInfoConverter::WriteMissionInfosToParcel(reply, missionInfos) ? ERR_NONE : ERR_FLATTEN_OBJECT;
935686862fbSopenharmony_ci    }
936686862fbSopenharmony_ci    return result;
937686862fbSopenharmony_ci}
938686862fbSopenharmony_ci
939686862fbSopenharmony_ciint32_t DistributedSchedStub::GetRemoteMissionSnapshotInfoInner(MessageParcel& data, MessageParcel& reply)
940686862fbSopenharmony_ci{
941686862fbSopenharmony_ci    HILOGI("[PerformanceTest] called, IPC end = %{public}" PRId64, GetTickCount());
942686862fbSopenharmony_ci    if (!DistributedSchedPermission::GetInstance().IsFoundationCall() &&
943686862fbSopenharmony_ci        !DistributedSchedPermission::GetInstance().IsSceneBoardCall()) {
944686862fbSopenharmony_ci        return DMS_PERMISSION_DENIED;
945686862fbSopenharmony_ci    }
946686862fbSopenharmony_ci    string networkId = data.ReadString();
947686862fbSopenharmony_ci    if (networkId.empty()) {
948686862fbSopenharmony_ci        HILOGE("networkId is empty!");
949686862fbSopenharmony_ci        return ERR_FLATTEN_OBJECT;
950686862fbSopenharmony_ci    }
951686862fbSopenharmony_ci    int32_t missionId = 0;
952686862fbSopenharmony_ci    PARCEL_READ_HELPER(data, Int32, missionId);
953686862fbSopenharmony_ci    if (missionId < 0) {
954686862fbSopenharmony_ci        HILOGE("missionId is invalid");
955686862fbSopenharmony_ci        return INVALID_PARAMETERS_ERR;
956686862fbSopenharmony_ci    }
957686862fbSopenharmony_ci    std::unique_ptr<MissionSnapshot> missionSnapshotPtr = std::make_unique<MissionSnapshot>();
958686862fbSopenharmony_ci    int32_t errCode = GetRemoteMissionSnapshotInfo(networkId, missionId, missionSnapshotPtr);
959686862fbSopenharmony_ci    if (errCode != ERR_NONE) {
960686862fbSopenharmony_ci        HILOGE("get mission snapshot failed!");
961686862fbSopenharmony_ci        return ERR_NULL_OBJECT;
962686862fbSopenharmony_ci    }
963686862fbSopenharmony_ci    PARCEL_WRITE_HELPER(reply, Parcelable, missionSnapshotPtr.get());
964686862fbSopenharmony_ci    std::string uuid = DnetworkAdapter::GetInstance()->GetUuidByNetworkId(networkId);
965686862fbSopenharmony_ci    if (uuid.empty()) {
966686862fbSopenharmony_ci        HILOGE("uuid is empty!");
967686862fbSopenharmony_ci        return ERR_NULL_OBJECT;
968686862fbSopenharmony_ci    }
969686862fbSopenharmony_ci    std::unique_ptr<Snapshot> snapshotPtr = make_unique<Snapshot>();
970686862fbSopenharmony_ci    SnapshotConverter::ConvertToSnapshot(*missionSnapshotPtr, snapshotPtr);
971686862fbSopenharmony_ci    DistributedSchedMissionManager::GetInstance().EnqueueCachedSnapshotInfo(uuid,
972686862fbSopenharmony_ci        missionId, std::move(snapshotPtr));
973686862fbSopenharmony_ci    return ERR_NONE;
974686862fbSopenharmony_ci}
975686862fbSopenharmony_ci
976686862fbSopenharmony_ciint32_t DistributedSchedStub::RegisterMissionListenerInner(MessageParcel& data, MessageParcel& reply)
977686862fbSopenharmony_ci{
978686862fbSopenharmony_ci    if (!DistributedSchedPermission::GetInstance().IsFoundationCall()) {
979686862fbSopenharmony_ci        return DMS_PERMISSION_DENIED;
980686862fbSopenharmony_ci    }
981686862fbSopenharmony_ci    HILOGI("[PerformanceTest] called, IPC end = %{public}" PRId64, GetTickCount());
982686862fbSopenharmony_ci    u16string devId = data.ReadString16();
983686862fbSopenharmony_ci    if (devId.empty()) {
984686862fbSopenharmony_ci        HILOGW("read deviceId failed!");
985686862fbSopenharmony_ci        return INVALID_PARAMETERS_ERR;
986686862fbSopenharmony_ci    }
987686862fbSopenharmony_ci    sptr<IRemoteObject> missionChangedListener = data.ReadRemoteObject();
988686862fbSopenharmony_ci    if (missionChangedListener == nullptr) {
989686862fbSopenharmony_ci        HILOGW("read IRemoteObject failed!");
990686862fbSopenharmony_ci        return ERR_FLATTEN_OBJECT;
991686862fbSopenharmony_ci    }
992686862fbSopenharmony_ci    int32_t result = RegisterMissionListener(devId, missionChangedListener);
993686862fbSopenharmony_ci    PARCEL_WRITE_REPLY_NOERROR(reply, Int32, result);
994686862fbSopenharmony_ci}
995686862fbSopenharmony_ci
996686862fbSopenharmony_ciint32_t DistributedSchedStub::RegisterDSchedEventListenerInner(MessageParcel& data, MessageParcel& reply)
997686862fbSopenharmony_ci{
998686862fbSopenharmony_ci    HILOGI("[PerformanceTest] called, IPC end = %{public}" PRId64, GetTickCount());
999686862fbSopenharmony_ci    if (!CheckCallingUid()) {
1000686862fbSopenharmony_ci        HILOGW("request DENIED!");
1001686862fbSopenharmony_ci        return DMS_PERMISSION_DENIED;
1002686862fbSopenharmony_ci    }
1003686862fbSopenharmony_ci    DSchedEventType type = static_cast<DSchedEventType>(data.ReadUint8());
1004686862fbSopenharmony_ci    sptr<IRemoteObject> dSchedEventListener = data.ReadRemoteObject();
1005686862fbSopenharmony_ci    if (dSchedEventListener == nullptr) {
1006686862fbSopenharmony_ci        HILOGW("read IRemoteObject failed!");
1007686862fbSopenharmony_ci        return ERR_FLATTEN_OBJECT;
1008686862fbSopenharmony_ci    }
1009686862fbSopenharmony_ci    int32_t result = RegisterDSchedEventListener(type, dSchedEventListener);
1010686862fbSopenharmony_ci    PARCEL_WRITE_REPLY_NOERROR(reply, Int32, result);
1011686862fbSopenharmony_ci}
1012686862fbSopenharmony_ci
1013686862fbSopenharmony_ciint32_t DistributedSchedStub::UnRegisterDSchedEventListenerInner(MessageParcel& data, MessageParcel& reply)
1014686862fbSopenharmony_ci{
1015686862fbSopenharmony_ci    HILOGI("[PerformanceTest] called, IPC end = %{public}" PRId64, GetTickCount());
1016686862fbSopenharmony_ci    if (!CheckCallingUid()) {
1017686862fbSopenharmony_ci        HILOGW("request DENIED!");
1018686862fbSopenharmony_ci        return DMS_PERMISSION_DENIED;
1019686862fbSopenharmony_ci    }
1020686862fbSopenharmony_ci    DSchedEventType type = static_cast<DSchedEventType>(data.ReadUint8());
1021686862fbSopenharmony_ci    sptr<IRemoteObject> dSchedEventListener = data.ReadRemoteObject();
1022686862fbSopenharmony_ci    if (dSchedEventListener == nullptr) {
1023686862fbSopenharmony_ci        HILOGW("read IRemoteObject failed!");
1024686862fbSopenharmony_ci        return ERR_FLATTEN_OBJECT;
1025686862fbSopenharmony_ci    }
1026686862fbSopenharmony_ci    int32_t result = UnRegisterDSchedEventListener(type, dSchedEventListener);
1027686862fbSopenharmony_ci    PARCEL_WRITE_REPLY_NOERROR(reply, Int32, result);
1028686862fbSopenharmony_ci}
1029686862fbSopenharmony_ci
1030686862fbSopenharmony_ciint32_t DistributedSchedStub::GetContinueInfoInner(MessageParcel& data, MessageParcel& reply)
1031686862fbSopenharmony_ci{
1032686862fbSopenharmony_ci    HILOGI("[PerformanceTest] called, IPC end = %{public}" PRId64, GetTickCount());
1033686862fbSopenharmony_ci    std::string dstNetworkId;
1034686862fbSopenharmony_ci    std::string srcNetworkId;
1035686862fbSopenharmony_ci    int32_t result = DSchedContinueManager::GetInstance().GetContinueInfo(dstNetworkId, srcNetworkId);
1036686862fbSopenharmony_ci    PARCEL_WRITE_HELPER(reply, String, dstNetworkId);
1037686862fbSopenharmony_ci    PARCEL_WRITE_HELPER(reply, String, srcNetworkId);
1038686862fbSopenharmony_ci    return result;
1039686862fbSopenharmony_ci}
1040686862fbSopenharmony_ci
1041686862fbSopenharmony_ciint32_t DistributedSchedStub::GetEncodeDSchedEventNotify(const EventNotify& event, MessageParcel& reply)
1042686862fbSopenharmony_ci{
1043686862fbSopenharmony_ci    PARCEL_WRITE_HELPER(reply, Int32, event.eventResult_);
1044686862fbSopenharmony_ci    PARCEL_WRITE_HELPER(reply, String, event.srcNetworkId_);
1045686862fbSopenharmony_ci    PARCEL_WRITE_HELPER(reply, String, event.dstNetworkId_);
1046686862fbSopenharmony_ci    PARCEL_WRITE_HELPER(reply, String, event.srcBundleName_);
1047686862fbSopenharmony_ci    PARCEL_WRITE_HELPER(reply, String, event.srcModuleName_);
1048686862fbSopenharmony_ci    PARCEL_WRITE_HELPER(reply, String, event.srcAbilityName_);
1049686862fbSopenharmony_ci    PARCEL_WRITE_HELPER(reply, String, event.destBundleName_);
1050686862fbSopenharmony_ci    PARCEL_WRITE_HELPER(reply, String, event.destModuleName_);
1051686862fbSopenharmony_ci    PARCEL_WRITE_HELPER(reply, String, event.destAbilityName_);
1052686862fbSopenharmony_ci    PARCEL_WRITE_HELPER(reply, Int32, event.dSchedEventType_);
1053686862fbSopenharmony_ci    PARCEL_WRITE_HELPER(reply, Int32, event.state_);
1054686862fbSopenharmony_ci    return ERR_OK;
1055686862fbSopenharmony_ci}
1056686862fbSopenharmony_ci
1057686862fbSopenharmony_ciint32_t DistributedSchedStub::GetDSchedEventInfoInner(MessageParcel& data, MessageParcel& reply)
1058686862fbSopenharmony_ci{
1059686862fbSopenharmony_ci    HILOGI("[PerformanceTest] called, IPC end = %{public}" PRId64, GetTickCount());
1060686862fbSopenharmony_ci    DSchedEventType type = static_cast<DSchedEventType>(data.ReadInt32());
1061686862fbSopenharmony_ci    std::vector<EventNotify> eventInfos;
1062686862fbSopenharmony_ci    int32_t result = GetDSchedEventInfo(type, eventInfos);
1063686862fbSopenharmony_ci
1064686862fbSopenharmony_ci    PARCEL_WRITE_HELPER(reply, Int32, result);
1065686862fbSopenharmony_ci    PARCEL_WRITE_HELPER(reply, Uint32, eventInfos.size());
1066686862fbSopenharmony_ci    for (const auto &event : eventInfos) {
1067686862fbSopenharmony_ci        result = GetEncodeDSchedEventNotify(event, reply);
1068686862fbSopenharmony_ci        if (result != ERR_OK) {
1069686862fbSopenharmony_ci            HILOGE("Get encode Dms event notify failed!");
1070686862fbSopenharmony_ci            return DMS_WRITE_FILE_FAILED_ERR;
1071686862fbSopenharmony_ci        }
1072686862fbSopenharmony_ci    }
1073686862fbSopenharmony_ci    return result;
1074686862fbSopenharmony_ci}
1075686862fbSopenharmony_ci
1076686862fbSopenharmony_ciint32_t DistributedSchedStub::RegisterOnListenerInner(MessageParcel& data, MessageParcel& reply)
1077686862fbSopenharmony_ci{
1078686862fbSopenharmony_ci    if (!DistributedSchedPermission::GetInstance().IsFoundationCall()) {
1079686862fbSopenharmony_ci        return DMS_PERMISSION_DENIED;
1080686862fbSopenharmony_ci    }
1081686862fbSopenharmony_ci    HILOGI("[PerformanceTest] called, IPC end = %{public}" PRId64, GetTickCount());
1082686862fbSopenharmony_ci    string type = data.ReadString();
1083686862fbSopenharmony_ci    if (type.empty()) {
1084686862fbSopenharmony_ci        HILOGW("read type failed!");
1085686862fbSopenharmony_ci        return ERR_FLATTEN_OBJECT;
1086686862fbSopenharmony_ci    }
1087686862fbSopenharmony_ci    sptr<IRemoteObject> onListener = data.ReadRemoteObject();
1088686862fbSopenharmony_ci    if (onListener == nullptr) {
1089686862fbSopenharmony_ci        HILOGW("read IRemoteObject failed!");
1090686862fbSopenharmony_ci        return ERR_FLATTEN_OBJECT;
1091686862fbSopenharmony_ci    }
1092686862fbSopenharmony_ci    int32_t callingUid = data.ReadInt32();
1093686862fbSopenharmony_ci    if (callingUid < 0) {
1094686862fbSopenharmony_ci        HILOGW("read callingUid failed!");
1095686862fbSopenharmony_ci        return ERR_FLATTEN_OBJECT;
1096686862fbSopenharmony_ci    }
1097686862fbSopenharmony_ci    int32_t result = RegisterOnListener(type, onListener, callingUid);
1098686862fbSopenharmony_ci    PARCEL_WRITE_REPLY_NOERROR(reply, Int32, result);
1099686862fbSopenharmony_ci}
1100686862fbSopenharmony_ci
1101686862fbSopenharmony_ciint32_t DistributedSchedStub::RegisterOffListenerInner(MessageParcel& data, MessageParcel& reply)
1102686862fbSopenharmony_ci{
1103686862fbSopenharmony_ci    if (!DistributedSchedPermission::GetInstance().IsFoundationCall()) {
1104686862fbSopenharmony_ci        return DMS_PERMISSION_DENIED;
1105686862fbSopenharmony_ci    }
1106686862fbSopenharmony_ci    HILOGI("[PerformanceTest] called, IPC end = %{public}" PRId64, GetTickCount());
1107686862fbSopenharmony_ci    string type = data.ReadString();
1108686862fbSopenharmony_ci    if (type.empty()) {
1109686862fbSopenharmony_ci        HILOGW("read type failed!");
1110686862fbSopenharmony_ci        return ERR_FLATTEN_OBJECT;
1111686862fbSopenharmony_ci    }
1112686862fbSopenharmony_ci    sptr<IRemoteObject> onListener = data.ReadRemoteObject();
1113686862fbSopenharmony_ci    if (onListener == nullptr) {
1114686862fbSopenharmony_ci        HILOGW("read IRemoteObject failed!");
1115686862fbSopenharmony_ci        return ERR_FLATTEN_OBJECT;
1116686862fbSopenharmony_ci    }
1117686862fbSopenharmony_ci    int32_t callingUid = data.ReadInt32();
1118686862fbSopenharmony_ci    if (callingUid < 0) {
1119686862fbSopenharmony_ci        HILOGW("read callingUid failed!");
1120686862fbSopenharmony_ci        return ERR_FLATTEN_OBJECT;
1121686862fbSopenharmony_ci    }
1122686862fbSopenharmony_ci    int32_t result = RegisterOffListener(type, onListener, callingUid);
1123686862fbSopenharmony_ci    PARCEL_WRITE_REPLY_NOERROR(reply, Int32, result);
1124686862fbSopenharmony_ci}
1125686862fbSopenharmony_ci
1126686862fbSopenharmony_ciint32_t DistributedSchedStub::UnRegisterMissionListenerInner(MessageParcel& data, MessageParcel& reply)
1127686862fbSopenharmony_ci{
1128686862fbSopenharmony_ci    if (!DistributedSchedPermission::GetInstance().IsFoundationCall()) {
1129686862fbSopenharmony_ci        return DMS_PERMISSION_DENIED;
1130686862fbSopenharmony_ci    }
1131686862fbSopenharmony_ci    HILOGI("[PerformanceTest] called, IPC end = %{public}" PRId64, GetTickCount());
1132686862fbSopenharmony_ci    u16string devId = data.ReadString16();
1133686862fbSopenharmony_ci    if (devId.empty()) {
1134686862fbSopenharmony_ci        HILOGW("read deviceId failed!");
1135686862fbSopenharmony_ci        return INVALID_PARAMETERS_ERR;
1136686862fbSopenharmony_ci    }
1137686862fbSopenharmony_ci    sptr<IRemoteObject> missionChangedListener = data.ReadRemoteObject();
1138686862fbSopenharmony_ci    if (missionChangedListener == nullptr) {
1139686862fbSopenharmony_ci        HILOGW("read IRemoteObject failed!");
1140686862fbSopenharmony_ci        return ERR_FLATTEN_OBJECT;
1141686862fbSopenharmony_ci    }
1142686862fbSopenharmony_ci    int32_t result = UnRegisterMissionListener(devId, missionChangedListener);
1143686862fbSopenharmony_ci    PARCEL_WRITE_REPLY_NOERROR(reply, Int32, result);
1144686862fbSopenharmony_ci}
1145686862fbSopenharmony_ci
1146686862fbSopenharmony_ciint32_t DistributedSchedStub::StartSyncMissionsFromRemoteInner(MessageParcel& data, MessageParcel& reply)
1147686862fbSopenharmony_ci{
1148686862fbSopenharmony_ci    if (!CheckCallingUid()) {
1149686862fbSopenharmony_ci        HILOGW("request DENIED!");
1150686862fbSopenharmony_ci        return DMS_PERMISSION_DENIED;
1151686862fbSopenharmony_ci    }
1152686862fbSopenharmony_ci    CallerInfo callerInfo;
1153686862fbSopenharmony_ci    if (!CallerInfoUnmarshalling(callerInfo, data)) {
1154686862fbSopenharmony_ci        HILOGW("read callerInfo failed!");
1155686862fbSopenharmony_ci        return ERR_FLATTEN_OBJECT;
1156686862fbSopenharmony_ci    }
1157686862fbSopenharmony_ci    std::vector<DstbMissionInfo> missionInfos;
1158686862fbSopenharmony_ci    if (StartSyncMissionsFromRemote(callerInfo, missionInfos) != ERR_NONE) {
1159686862fbSopenharmony_ci        return ERR_FLATTEN_OBJECT;
1160686862fbSopenharmony_ci    }
1161686862fbSopenharmony_ci    if (!reply.WriteInt32(VERSION)) {
1162686862fbSopenharmony_ci        return ERR_FLATTEN_OBJECT;
1163686862fbSopenharmony_ci    }
1164686862fbSopenharmony_ci    if (!DstbMissionInfo::WriteDstbMissionInfosToParcel(reply, missionInfos)) {
1165686862fbSopenharmony_ci        HILOGE("write mission info failed!");
1166686862fbSopenharmony_ci        return ERR_FLATTEN_OBJECT;
1167686862fbSopenharmony_ci    }
1168686862fbSopenharmony_ci    return ERR_NONE;
1169686862fbSopenharmony_ci}
1170686862fbSopenharmony_ci
1171686862fbSopenharmony_ciint32_t DistributedSchedStub::StopSyncRemoteMissionsInner(MessageParcel& data, MessageParcel& reply)
1172686862fbSopenharmony_ci{
1173686862fbSopenharmony_ci    HILOGI("[PerformanceTest] called, IPC end = %{public}" PRId64, GetTickCount());
1174686862fbSopenharmony_ci    if (!DistributedSchedPermission::GetInstance().IsFoundationCall()) {
1175686862fbSopenharmony_ci        return DMS_PERMISSION_DENIED;
1176686862fbSopenharmony_ci    }
1177686862fbSopenharmony_ci    u16string devId = data.ReadString16();
1178686862fbSopenharmony_ci    if (devId.empty()) {
1179686862fbSopenharmony_ci        HILOGW("read deviceId failed!");
1180686862fbSopenharmony_ci        return INVALID_PARAMETERS_ERR;
1181686862fbSopenharmony_ci    }
1182686862fbSopenharmony_ci    int32_t result = StopSyncRemoteMissions(Str16ToStr8(devId));
1183686862fbSopenharmony_ci    PARCEL_WRITE_REPLY_NOERROR(reply, Int32, result);
1184686862fbSopenharmony_ci}
1185686862fbSopenharmony_ci
1186686862fbSopenharmony_ciint32_t DistributedSchedStub::StopSyncMissionsFromRemoteInner(MessageParcel& data, MessageParcel& reply)
1187686862fbSopenharmony_ci{
1188686862fbSopenharmony_ci    if (!CheckCallingUid()) {
1189686862fbSopenharmony_ci        HILOGW("request DENIED!");
1190686862fbSopenharmony_ci        return DMS_PERMISSION_DENIED;
1191686862fbSopenharmony_ci    }
1192686862fbSopenharmony_ci    CallerInfo callerInfo;
1193686862fbSopenharmony_ci    if (!CallerInfoUnmarshalling(callerInfo, data)) {
1194686862fbSopenharmony_ci        HILOGW("read callerInfo failed!");
1195686862fbSopenharmony_ci        return ERR_FLATTEN_OBJECT;
1196686862fbSopenharmony_ci    }
1197686862fbSopenharmony_ci    int32_t result = StopSyncMissionsFromRemote(callerInfo);
1198686862fbSopenharmony_ci    PARCEL_WRITE_REPLY_NOERROR(reply, Int32, result);
1199686862fbSopenharmony_ci}
1200686862fbSopenharmony_ci
1201686862fbSopenharmony_ciint32_t DistributedSchedStub::NotifyMissionsChangedFromRemoteInner(MessageParcel& data, MessageParcel& reply)
1202686862fbSopenharmony_ci{
1203686862fbSopenharmony_ci    if (!CheckCallingUid()) {
1204686862fbSopenharmony_ci        HILOGW("request DENIED!");
1205686862fbSopenharmony_ci        return DMS_PERMISSION_DENIED;
1206686862fbSopenharmony_ci    }
1207686862fbSopenharmony_ci    int32_t version = data.ReadInt32();
1208686862fbSopenharmony_ci    HILOGD("version is %{public}d", version);
1209686862fbSopenharmony_ci    std::vector<DstbMissionInfo> missionInfos;
1210686862fbSopenharmony_ci    if (!DstbMissionInfo::ReadDstbMissionInfosFromParcel(data, missionInfos)) {
1211686862fbSopenharmony_ci        return ERR_FLATTEN_OBJECT;
1212686862fbSopenharmony_ci    }
1213686862fbSopenharmony_ci    CallerInfo callerInfo;
1214686862fbSopenharmony_ci    callerInfo.sourceDeviceId = data.ReadString();
1215686862fbSopenharmony_ci    callerInfo.uid = data.ReadInt32();
1216686862fbSopenharmony_ci    callerInfo.pid = data.ReadInt32();
1217686862fbSopenharmony_ci    callerInfo.dmsVersion = data.ReadInt32();
1218686862fbSopenharmony_ci    int32_t result = NotifyMissionsChangedFromRemote(missionInfos, callerInfo);
1219686862fbSopenharmony_ci    PARCEL_WRITE_REPLY_NOERROR(reply, Int32, result);
1220686862fbSopenharmony_ci}
1221686862fbSopenharmony_ci
1222686862fbSopenharmony_ciint32_t DistributedSchedStub::StartSyncRemoteMissionsInner(MessageParcel& data, MessageParcel& reply)
1223686862fbSopenharmony_ci{
1224686862fbSopenharmony_ci    if (!DistributedSchedPermission::GetInstance().IsFoundationCall()) {
1225686862fbSopenharmony_ci        return DMS_PERMISSION_DENIED;
1226686862fbSopenharmony_ci    }
1227686862fbSopenharmony_ci    HILOGI("[PerformanceTest], IPC end = %{public}" PRId64, GetTickCount());
1228686862fbSopenharmony_ci    u16string devId = data.ReadString16();
1229686862fbSopenharmony_ci    if (devId.empty()) {
1230686862fbSopenharmony_ci        HILOGW("read deviceId failed!");
1231686862fbSopenharmony_ci        return INVALID_PARAMETERS_ERR;
1232686862fbSopenharmony_ci    }
1233686862fbSopenharmony_ci    string deviceId = Str16ToStr8(devId);
1234686862fbSopenharmony_ci    bool fixConflict = data.ReadBool();
1235686862fbSopenharmony_ci    int64_t tag = data.ReadInt64();
1236686862fbSopenharmony_ci    int32_t result = StartSyncRemoteMissions(deviceId, fixConflict, tag);
1237686862fbSopenharmony_ci    PARCEL_WRITE_REPLY_NOERROR(reply, Int32, result);
1238686862fbSopenharmony_ci}
1239686862fbSopenharmony_ci
1240686862fbSopenharmony_ciint32_t DistributedSchedStub::SetMissionContinueStateInner(MessageParcel& data, MessageParcel& reply)
1241686862fbSopenharmony_ci{
1242686862fbSopenharmony_ci    if (!CheckCallingUid() && !DistributedSchedPermission::GetInstance().IsSceneBoardCall()) {
1243686862fbSopenharmony_ci        HILOGW("request DENIED!");
1244686862fbSopenharmony_ci        return DMS_PERMISSION_DENIED;
1245686862fbSopenharmony_ci    }
1246686862fbSopenharmony_ci
1247686862fbSopenharmony_ci    int32_t missionId = 0;
1248686862fbSopenharmony_ci    PARCEL_READ_HELPER(data, Int32, missionId);
1249686862fbSopenharmony_ci    int32_t state = 0;
1250686862fbSopenharmony_ci    PARCEL_READ_HELPER(data, Int32, state);
1251686862fbSopenharmony_ci
1252686862fbSopenharmony_ci    int32_t result = SetMissionContinueState(missionId, static_cast<AAFwk::ContinueState>(state));
1253686862fbSopenharmony_ci    HILOGI("result %{public}d", result);
1254686862fbSopenharmony_ci    PARCEL_WRITE_REPLY_NOERROR(reply, Int32, result);
1255686862fbSopenharmony_ci}
1256686862fbSopenharmony_ci#endif
1257686862fbSopenharmony_ci
1258686862fbSopenharmony_cibool DistributedSchedStub::CallerInfoUnmarshalling(CallerInfo& callerInfo, MessageParcel& data)
1259686862fbSopenharmony_ci{
1260686862fbSopenharmony_ci    int32_t uid = -1;
1261686862fbSopenharmony_ci    PARCEL_READ_HELPER_RET(data, Int32, uid, false);
1262686862fbSopenharmony_ci    int32_t pid = -1;
1263686862fbSopenharmony_ci    PARCEL_READ_HELPER_RET(data, Int32, pid, false);
1264686862fbSopenharmony_ci    int32_t callerType = CALLER_TYPE_NONE;
1265686862fbSopenharmony_ci    PARCEL_READ_HELPER_RET(data, Int32, callerType, false);
1266686862fbSopenharmony_ci    std::string sourceDeviceId;
1267686862fbSopenharmony_ci    PARCEL_READ_HELPER_RET(data, String, sourceDeviceId, false);
1268686862fbSopenharmony_ci    HILOGI("sourceDeviceId = %{public}s", GetAnonymStr(sourceDeviceId).c_str());
1269686862fbSopenharmony_ci    int32_t duid = -1;
1270686862fbSopenharmony_ci    PARCEL_READ_HELPER_RET(data, Int32, duid, false);
1271686862fbSopenharmony_ci    std::string callerAppId;
1272686862fbSopenharmony_ci    PARCEL_READ_HELPER_RET(data, String, callerAppId, false);
1273686862fbSopenharmony_ci    int32_t version = -1;
1274686862fbSopenharmony_ci    PARCEL_READ_HELPER_RET(data, Int32, version, false);
1275686862fbSopenharmony_ci    callerInfo.uid = uid;
1276686862fbSopenharmony_ci    callerInfo.pid = pid;
1277686862fbSopenharmony_ci    callerInfo.callerType = callerType;
1278686862fbSopenharmony_ci    callerInfo.sourceDeviceId = sourceDeviceId;
1279686862fbSopenharmony_ci    callerInfo.duid = duid;
1280686862fbSopenharmony_ci    callerInfo.callerAppId = callerAppId;
1281686862fbSopenharmony_ci    callerInfo.dmsVersion = version;
1282686862fbSopenharmony_ci    return true;
1283686862fbSopenharmony_ci}
1284686862fbSopenharmony_ci
1285686862fbSopenharmony_ciint32_t DistributedSchedStub::StartRemoteAbilityByCallInner(MessageParcel& data, MessageParcel& reply)
1286686862fbSopenharmony_ci{
1287686862fbSopenharmony_ci    if (!DistributedSchedPermission::GetInstance().IsFoundationCall()) {
1288686862fbSopenharmony_ci        return DMS_PERMISSION_DENIED;
1289686862fbSopenharmony_ci    }
1290686862fbSopenharmony_ci    DmsHiTraceChain hiTraceChain(TraceValue::START_REMOTE_ABILITY_BYCALL);
1291686862fbSopenharmony_ci    HITRACE_METER_NAME(TraceTag::DSCHED, TraceValue::START_REMOTE_ABILITY_BYCALL);
1292686862fbSopenharmony_ci    shared_ptr<AAFwk::Want> want(data.ReadParcelable<AAFwk::Want>());
1293686862fbSopenharmony_ci    if (want == nullptr) {
1294686862fbSopenharmony_ci        HILOGW("want readParcelable failed!");
1295686862fbSopenharmony_ci        return ERR_NULL_OBJECT;
1296686862fbSopenharmony_ci    }
1297686862fbSopenharmony_ci    DistributedSchedPermission::GetInstance().RemoveRemoteObjectFromWant(want);
1298686862fbSopenharmony_ci    sptr<IRemoteObject> connect = data.ReadRemoteObject();
1299686862fbSopenharmony_ci    int32_t callerUid = 0;
1300686862fbSopenharmony_ci    PARCEL_READ_HELPER(data, Int32, callerUid);
1301686862fbSopenharmony_ci    int32_t callerPid = 0;
1302686862fbSopenharmony_ci    PARCEL_READ_HELPER(data, Int32, callerPid);
1303686862fbSopenharmony_ci    uint32_t accessToken = 0;
1304686862fbSopenharmony_ci    PARCEL_READ_HELPER(data, Uint32, accessToken);
1305686862fbSopenharmony_ci    int32_t result = StartRemoteAbilityByCall(*want, connect, callerUid, callerPid, accessToken);
1306686862fbSopenharmony_ci    ReportEvent(*want, BehaviorEvent::START_REMOTE_ABILITY_BYCALL, result, callerUid);
1307686862fbSopenharmony_ci    HILOGI("result = %{public}d", result);
1308686862fbSopenharmony_ci    PARCEL_WRITE_REPLY_NOERROR(reply, Int32, result);
1309686862fbSopenharmony_ci}
1310686862fbSopenharmony_ci
1311686862fbSopenharmony_ciint32_t DistributedSchedStub::ReleaseRemoteAbilityInner(MessageParcel& data, MessageParcel& reply)
1312686862fbSopenharmony_ci{
1313686862fbSopenharmony_ci    if (!DistributedSchedPermission::GetInstance().IsFoundationCall()) {
1314686862fbSopenharmony_ci        return DMS_PERMISSION_DENIED;
1315686862fbSopenharmony_ci    }
1316686862fbSopenharmony_ci    DmsHiTraceChain hiTraceChain(TraceValue::RELEASE_REMOTE_ABILITY);
1317686862fbSopenharmony_ci    HITRACE_METER_NAME(TraceTag::DSCHED, TraceValue::RELEASE_REMOTE_ABILITY);
1318686862fbSopenharmony_ci    sptr<IRemoteObject> connect = data.ReadRemoteObject();
1319686862fbSopenharmony_ci    shared_ptr<AppExecFwk::ElementName> element(data.ReadParcelable<AppExecFwk::ElementName>());
1320686862fbSopenharmony_ci    if (element == nullptr) {
1321686862fbSopenharmony_ci        HILOGE("ReleaseRemoteAbilityInner receive element is nullptr");
1322686862fbSopenharmony_ci        return ERR_INVALID_VALUE;
1323686862fbSopenharmony_ci    }
1324686862fbSopenharmony_ci    int32_t result = ReleaseRemoteAbility(connect, *element);
1325686862fbSopenharmony_ci    BehaviorEventParam eventParam = { EventCallingType::LOCAL, BehaviorEvent::RELEASE_REMOTE_ABILITY, result,
1326686862fbSopenharmony_ci        element->GetBundleName(), element->GetAbilityName() };
1327686862fbSopenharmony_ci    DmsHiSysEventReport::ReportBehaviorEvent(eventParam);
1328686862fbSopenharmony_ci    HILOGI("result = %{public}d", result);
1329686862fbSopenharmony_ci    PARCEL_WRITE_REPLY_NOERROR(reply, Int32, result);
1330686862fbSopenharmony_ci}
1331686862fbSopenharmony_ci
1332686862fbSopenharmony_ciint32_t DistributedSchedStub::StartAbilityByCallFromRemoteInner(MessageParcel& data, MessageParcel& reply)
1333686862fbSopenharmony_ci{
1334686862fbSopenharmony_ci    if (!CheckCallingUid()) {
1335686862fbSopenharmony_ci        HILOGW("request DENIED!");
1336686862fbSopenharmony_ci        return DMS_PERMISSION_DENIED;
1337686862fbSopenharmony_ci    }
1338686862fbSopenharmony_ci
1339686862fbSopenharmony_ci    sptr<IRemoteObject> connect = data.ReadRemoteObject();
1340686862fbSopenharmony_ci    CallerInfo callerInfo;
1341686862fbSopenharmony_ci    PARCEL_READ_HELPER(data, Int32, callerInfo.uid);
1342686862fbSopenharmony_ci    PARCEL_READ_HELPER(data, Int32, callerInfo.pid);
1343686862fbSopenharmony_ci    PARCEL_READ_HELPER(data, String, callerInfo.sourceDeviceId);
1344686862fbSopenharmony_ci    AccountInfo accountInfo;
1345686862fbSopenharmony_ci    accountInfo.accountType = data.ReadInt32();
1346686862fbSopenharmony_ci    PARCEL_READ_HELPER(data, StringVector, &accountInfo.groupIdList);
1347686862fbSopenharmony_ci    callerInfo.callerAppId = data.ReadString();
1348686862fbSopenharmony_ci    std::string extraInfo = data.ReadString();
1349686862fbSopenharmony_ci    if (extraInfo.empty()) {
1350686862fbSopenharmony_ci        HILOGW("read extraInfo failed!");
1351686862fbSopenharmony_ci        return ERR_NULL_OBJECT;
1352686862fbSopenharmony_ci    }
1353686862fbSopenharmony_ci    nlohmann::json extraInfoJson = nlohmann::json::parse(extraInfo, nullptr, false);
1354686862fbSopenharmony_ci    if (!extraInfoJson.is_discarded()) {
1355686862fbSopenharmony_ci        SaveExtraInfo(extraInfoJson, callerInfo, accountInfo);
1356686862fbSopenharmony_ci        HILOGD("parse extra info");
1357686862fbSopenharmony_ci    }
1358686862fbSopenharmony_ci    shared_ptr<DistributedWant> dstbWant(data.ReadParcelable<DistributedWant>());
1359686862fbSopenharmony_ci    shared_ptr<AAFwk::Want> want = nullptr;
1360686862fbSopenharmony_ci    if (dstbWant != nullptr) {
1361686862fbSopenharmony_ci        want = dstbWant->ToWant();
1362686862fbSopenharmony_ci    }
1363686862fbSopenharmony_ci    if (want == nullptr) {
1364686862fbSopenharmony_ci        HILOGW("want readParcelable failed!");
1365686862fbSopenharmony_ci        return ERR_NULL_OBJECT;
1366686862fbSopenharmony_ci    }
1367686862fbSopenharmony_ci    DistributedSchedPermission::GetInstance().RemoveRemoteObjectFromWant(want);
1368686862fbSopenharmony_ci    int32_t result = StartAbilityByCallFromRemote(*want, connect, callerInfo, accountInfo);
1369686862fbSopenharmony_ci    BehaviorEventParam eventParam = { EventCallingType::REMOTE, BehaviorEvent::START_REMOTE_ABILITY_BYCALL, result,
1370686862fbSopenharmony_ci        want->GetElement().GetBundleName(), want->GetElement().GetAbilityName(), callerInfo.uid };
1371686862fbSopenharmony_ci    DmsHiSysEventReport::ReportBehaviorEvent(eventParam);
1372686862fbSopenharmony_ci    HILOGI("result = %{public}d", result);
1373686862fbSopenharmony_ci    PARCEL_WRITE_HELPER(reply, Int32, result);
1374686862fbSopenharmony_ci    return ERR_NONE;
1375686862fbSopenharmony_ci}
1376686862fbSopenharmony_ci
1377686862fbSopenharmony_ciint32_t DistributedSchedStub::ReleaseAbilityFromRemoteInner(MessageParcel& data, MessageParcel& reply)
1378686862fbSopenharmony_ci{
1379686862fbSopenharmony_ci    if (!CheckCallingUid()) {
1380686862fbSopenharmony_ci        HILOGW("request DENIED!");
1381686862fbSopenharmony_ci        return DMS_PERMISSION_DENIED;
1382686862fbSopenharmony_ci    }
1383686862fbSopenharmony_ci
1384686862fbSopenharmony_ci    sptr<IRemoteObject> connect = data.ReadRemoteObject();
1385686862fbSopenharmony_ci    shared_ptr<AppExecFwk::ElementName> element(data.ReadParcelable<AppExecFwk::ElementName>());
1386686862fbSopenharmony_ci    if (element == nullptr) {
1387686862fbSopenharmony_ci        HILOGE("ReleaseAbilityFromRemoteInner receive element is nullptr");
1388686862fbSopenharmony_ci        return ERR_INVALID_VALUE;
1389686862fbSopenharmony_ci    }
1390686862fbSopenharmony_ci    CallerInfo callerInfo;
1391686862fbSopenharmony_ci    PARCEL_READ_HELPER(data, String, callerInfo.sourceDeviceId);
1392686862fbSopenharmony_ci    std::string extraInfo;
1393686862fbSopenharmony_ci    PARCEL_READ_HELPER(data, String, extraInfo);
1394686862fbSopenharmony_ci    int32_t result = ReleaseAbilityFromRemote(connect, *element, callerInfo);
1395686862fbSopenharmony_ci    BehaviorEventParam eventParam = { EventCallingType::REMOTE, BehaviorEvent::RELEASE_REMOTE_ABILITY, result,
1396686862fbSopenharmony_ci        element->GetBundleName(), element->GetAbilityName() };
1397686862fbSopenharmony_ci    DmsHiSysEventReport::ReportBehaviorEvent(eventParam);
1398686862fbSopenharmony_ci    HILOGI("result %{public}d", result);
1399686862fbSopenharmony_ci    PARCEL_WRITE_REPLY_NOERROR(reply, Int32, result);
1400686862fbSopenharmony_ci}
1401686862fbSopenharmony_ci
1402686862fbSopenharmony_ci#ifdef SUPPORT_DISTRIBUTED_FORM_SHARE
1403686862fbSopenharmony_ciint32_t DistributedSchedStub::StartRemoteShareFormInner(MessageParcel& data, MessageParcel& reply)
1404686862fbSopenharmony_ci{
1405686862fbSopenharmony_ci    HILOGD("SHAREFORM:: func call");
1406686862fbSopenharmony_ci    if (!DistributedSchedPermission::GetInstance().IsFoundationCall()) {
1407686862fbSopenharmony_ci        return DMS_PERMISSION_DENIED;
1408686862fbSopenharmony_ci    }
1409686862fbSopenharmony_ci
1410686862fbSopenharmony_ci    std::string deviceId = "";
1411686862fbSopenharmony_ci    PARCEL_READ_HELPER(data, String, deviceId);
1412686862fbSopenharmony_ci    shared_ptr<AppExecFwk::FormShareInfo> formShareInfo(data.ReadParcelable<AppExecFwk::FormShareInfo>());
1413686862fbSopenharmony_ci    if (formShareInfo == nullptr) {
1414686862fbSopenharmony_ci        HILOGW("SHARE_FORM readParcelable failed!");
1415686862fbSopenharmony_ci        PARCEL_WRITE_REPLY_NOERROR(reply, Int32, static_cast<int32_t>(ERR_FLATTEN_OBJECT));
1416686862fbSopenharmony_ci        return ERR_FLATTEN_OBJECT;
1417686862fbSopenharmony_ci    }
1418686862fbSopenharmony_ci
1419686862fbSopenharmony_ci    int32_t result = StartRemoteShareForm(deviceId, *formShareInfo);
1420686862fbSopenharmony_ci    HILOGI("result = %{public}d", result);
1421686862fbSopenharmony_ci    PARCEL_WRITE_REPLY_NOERROR(reply, Int32, result);
1422686862fbSopenharmony_ci}
1423686862fbSopenharmony_ci
1424686862fbSopenharmony_ciint32_t DistributedSchedStub::StartShareFormFromRemoteInner(MessageParcel& data, MessageParcel& reply)
1425686862fbSopenharmony_ci{
1426686862fbSopenharmony_ci    HILOGD("SHAREFORM:: func call");
1427686862fbSopenharmony_ci    if (!CheckCallingUid()) {
1428686862fbSopenharmony_ci        HILOGW("request DENIED!");
1429686862fbSopenharmony_ci        PARCEL_WRITE_REPLY_NOERROR(reply, Int32, static_cast<int32_t>(DMS_PERMISSION_DENIED));
1430686862fbSopenharmony_ci        return DMS_PERMISSION_DENIED;
1431686862fbSopenharmony_ci    }
1432686862fbSopenharmony_ci
1433686862fbSopenharmony_ci    std::string deviceId = "";
1434686862fbSopenharmony_ci    PARCEL_READ_HELPER(data, String, deviceId);
1435686862fbSopenharmony_ci    shared_ptr<AppExecFwk::FormShareInfo> formShareInfo(data.ReadParcelable<AppExecFwk::FormShareInfo>());
1436686862fbSopenharmony_ci    if (formShareInfo == nullptr) {
1437686862fbSopenharmony_ci        HILOGW("SHARE_FORM readParcelable failed!");
1438686862fbSopenharmony_ci        PARCEL_WRITE_REPLY_NOERROR(reply, Int32, static_cast<int32_t>(ERR_FLATTEN_OBJECT));
1439686862fbSopenharmony_ci        return ERR_FLATTEN_OBJECT;
1440686862fbSopenharmony_ci    }
1441686862fbSopenharmony_ci
1442686862fbSopenharmony_ci    int32_t result = StartShareFormFromRemote(deviceId, *formShareInfo);
1443686862fbSopenharmony_ci    HILOGI("result = %{public}d", result);
1444686862fbSopenharmony_ci    PARCEL_WRITE_REPLY_NOERROR(reply, Int32, result);
1445686862fbSopenharmony_ci}
1446686862fbSopenharmony_ci#endif
1447686862fbSopenharmony_ci
1448686862fbSopenharmony_ciint32_t DistributedSchedStub::GetDistributedComponentListInner(MessageParcel& data, MessageParcel& reply)
1449686862fbSopenharmony_ci{
1450686862fbSopenharmony_ci    if (!CheckCallingUid()) {
1451686862fbSopenharmony_ci        HILOGW("request DENIED!");
1452686862fbSopenharmony_ci        return DMS_PERMISSION_DENIED;
1453686862fbSopenharmony_ci    }
1454686862fbSopenharmony_ci    std::vector<std::string> distributedComponents;
1455686862fbSopenharmony_ci    int32_t result = GetDistributedComponentList(distributedComponents);
1456686862fbSopenharmony_ci    HILOGI("result = %{public}d", result);
1457686862fbSopenharmony_ci    PARCEL_WRITE_HELPER(reply, Int32, result);
1458686862fbSopenharmony_ci    PARCEL_WRITE_HELPER(reply, StringVector, distributedComponents);
1459686862fbSopenharmony_ci    return ERR_NONE;
1460686862fbSopenharmony_ci}
1461686862fbSopenharmony_ci
1462686862fbSopenharmony_ciint32_t DistributedSchedStub::NotifyStateChangedFromRemoteInner(MessageParcel& data, MessageParcel& reply)
1463686862fbSopenharmony_ci{
1464686862fbSopenharmony_ci    if (!CheckCallingUid()) {
1465686862fbSopenharmony_ci        HILOGW("request DENIED!");
1466686862fbSopenharmony_ci        return DMS_PERMISSION_DENIED;
1467686862fbSopenharmony_ci    }
1468686862fbSopenharmony_ci    int32_t abilityState = 0;
1469686862fbSopenharmony_ci    PARCEL_READ_HELPER(data, Int32, abilityState);
1470686862fbSopenharmony_ci    int32_t connectToken = 0;
1471686862fbSopenharmony_ci    PARCEL_READ_HELPER(data, Int32, connectToken);
1472686862fbSopenharmony_ci    shared_ptr<AppExecFwk::ElementName> element(data.ReadParcelable<AppExecFwk::ElementName>());
1473686862fbSopenharmony_ci    if (element == nullptr) {
1474686862fbSopenharmony_ci        HILOGE("NotifyStateChangedFromRemoteInner receive element is nullptr");
1475686862fbSopenharmony_ci        return ERR_INVALID_VALUE;
1476686862fbSopenharmony_ci    }
1477686862fbSopenharmony_ci    int32_t result = NotifyStateChangedFromRemote(abilityState, connectToken, *element);
1478686862fbSopenharmony_ci    HILOGI("result = %{public}d", result);
1479686862fbSopenharmony_ci    PARCEL_WRITE_HELPER(reply, Int32, result);
1480686862fbSopenharmony_ci    return ERR_NONE;
1481686862fbSopenharmony_ci}
1482686862fbSopenharmony_ci
1483686862fbSopenharmony_ciint32_t DistributedSchedStub::StartRemoteFreeInstallInner(MessageParcel& data, MessageParcel& reply)
1484686862fbSopenharmony_ci{
1485686862fbSopenharmony_ci    if (!DistributedSchedPermission::GetInstance().IsFoundationCall()) {
1486686862fbSopenharmony_ci        return DMS_PERMISSION_DENIED;
1487686862fbSopenharmony_ci    }
1488686862fbSopenharmony_ci    shared_ptr<AAFwk::Want> want(data.ReadParcelable<AAFwk::Want>());
1489686862fbSopenharmony_ci    if (want == nullptr) {
1490686862fbSopenharmony_ci        HILOGE("want readParcelable failed!");
1491686862fbSopenharmony_ci        return ERR_NULL_OBJECT;
1492686862fbSopenharmony_ci    }
1493686862fbSopenharmony_ci    DistributedSchedPermission::GetInstance().RemoveRemoteObjectFromWant(want);
1494686862fbSopenharmony_ci    int32_t callerUid = 0;
1495686862fbSopenharmony_ci    int32_t requestCode = 0;
1496686862fbSopenharmony_ci    uint32_t accessToken = 0;
1497686862fbSopenharmony_ci    PARCEL_READ_HELPER(data, Int32, callerUid);
1498686862fbSopenharmony_ci    PARCEL_READ_HELPER(data, Int32, requestCode);
1499686862fbSopenharmony_ci    PARCEL_READ_HELPER(data, Uint32, accessToken);
1500686862fbSopenharmony_ci    sptr<IRemoteObject> callback = data.ReadRemoteObject();
1501686862fbSopenharmony_ci    if (callback == nullptr) {
1502686862fbSopenharmony_ci        HILOGE("read callback failed!");
1503686862fbSopenharmony_ci        return ERR_NULL_OBJECT;
1504686862fbSopenharmony_ci    }
1505686862fbSopenharmony_ci    int32_t result = StartRemoteFreeInstall(*want, callerUid, requestCode, accessToken, callback);
1506686862fbSopenharmony_ci    HILOGI("result = %{public}d", result);
1507686862fbSopenharmony_ci    PARCEL_WRITE_REPLY_NOERROR(reply, Int32, result);
1508686862fbSopenharmony_ci    return ERR_NONE;
1509686862fbSopenharmony_ci}
1510686862fbSopenharmony_ci
1511686862fbSopenharmony_ciint32_t DistributedSchedStub::ReadDataForFreeInstall(MessageParcel& data, CallerInfo &callerInfo,
1512686862fbSopenharmony_ci    AccountInfo &accountInfo, int64_t &taskId)
1513686862fbSopenharmony_ci{
1514686862fbSopenharmony_ci    callerInfo.callerType = CALLER_TYPE_HARMONY;
1515686862fbSopenharmony_ci    PARCEL_READ_HELPER(data, Int32, callerInfo.uid);
1516686862fbSopenharmony_ci    PARCEL_READ_HELPER(data, String, callerInfo.sourceDeviceId);
1517686862fbSopenharmony_ci    accountInfo.accountType = data.ReadInt32();
1518686862fbSopenharmony_ci    PARCEL_READ_HELPER(data, StringVector, &accountInfo.groupIdList);
1519686862fbSopenharmony_ci    callerInfo.callerAppId = data.ReadString();
1520686862fbSopenharmony_ci    PARCEL_READ_HELPER(data, Int64, taskId);
1521686862fbSopenharmony_ci    return ERR_NONE;
1522686862fbSopenharmony_ci}
1523686862fbSopenharmony_ci
1524686862fbSopenharmony_ciint32_t DistributedSchedStub::CreateJsonObject(std::string& extraInfo, CallerInfo& callerInfo,
1525686862fbSopenharmony_ci    AccountInfo& accountInfo)
1526686862fbSopenharmony_ci{
1527686862fbSopenharmony_ci    nlohmann::json extraInfoJson = nlohmann::json::parse(extraInfo, nullptr, false);
1528686862fbSopenharmony_ci    int32_t requestCode = DEFAULT_REQUEST_CODE;
1529686862fbSopenharmony_ci    if (!extraInfoJson.is_discarded()) {
1530686862fbSopenharmony_ci        SaveExtraInfo(extraInfoJson, callerInfo, accountInfo);
1531686862fbSopenharmony_ci        if (extraInfoJson.find(EXTRO_INFO_JSON_KEY_REQUEST_CODE) != extraInfoJson.end() &&
1532686862fbSopenharmony_ci            extraInfoJson[EXTRO_INFO_JSON_KEY_REQUEST_CODE].is_number_integer()) {
1533686862fbSopenharmony_ci            requestCode = extraInfoJson[EXTRO_INFO_JSON_KEY_REQUEST_CODE];
1534686862fbSopenharmony_ci            HILOGD("parse extra info, requestCode = %{public}d", requestCode);
1535686862fbSopenharmony_ci        }
1536686862fbSopenharmony_ci    }
1537686862fbSopenharmony_ci    return requestCode;
1538686862fbSopenharmony_ci}
1539686862fbSopenharmony_ci
1540686862fbSopenharmony_ciint32_t DistributedSchedStub::StartFreeInstallFromRemoteInner(MessageParcel& data, MessageParcel& reply)
1541686862fbSopenharmony_ci{
1542686862fbSopenharmony_ci    if (!CheckCallingUid()) {
1543686862fbSopenharmony_ci        HILOGW("request DENIED!");
1544686862fbSopenharmony_ci        return DMS_PERMISSION_DENIED;
1545686862fbSopenharmony_ci    }
1546686862fbSopenharmony_ci    shared_ptr<AAFwk::Want> want = ReadDistributedWant(data);
1547686862fbSopenharmony_ci    if (want == nullptr) {
1548686862fbSopenharmony_ci        HILOGE("want readParcelable failed!");
1549686862fbSopenharmony_ci        return ERR_NULL_OBJECT;
1550686862fbSopenharmony_ci    }
1551686862fbSopenharmony_ci    DistributedSchedPermission::GetInstance().RemoveRemoteObjectFromWant(want);
1552686862fbSopenharmony_ci    int64_t begin = GetTickCount();
1553686862fbSopenharmony_ci    CallerInfo callerInfo = {.accessToken = 0};
1554686862fbSopenharmony_ci    AccountInfo accountInfo = {};
1555686862fbSopenharmony_ci    int64_t taskId = 0;
1556686862fbSopenharmony_ci    int32_t result = ReadDataForFreeInstall(data, callerInfo, accountInfo, taskId);
1557686862fbSopenharmony_ci    if (result != ERR_NONE) {
1558686862fbSopenharmony_ci        return result;
1559686862fbSopenharmony_ci    }
1560686862fbSopenharmony_ci    shared_ptr<DistributedWant> cmpDstbWant(data.ReadParcelable<DistributedWant>());
1561686862fbSopenharmony_ci    shared_ptr<AAFwk::Want> cmpWant = nullptr;
1562686862fbSopenharmony_ci    if (cmpDstbWant != nullptr) {
1563686862fbSopenharmony_ci        cmpWant = cmpDstbWant->ToWant();
1564686862fbSopenharmony_ci    }
1565686862fbSopenharmony_ci    DistributedSchedPermission::GetInstance().RemoveRemoteObjectFromWant(cmpWant);
1566686862fbSopenharmony_ci    std::string extraInfo = data.ReadString();
1567686862fbSopenharmony_ci    if (extraInfo.empty()) {
1568686862fbSopenharmony_ci        HILOGD("extra info is empty!");
1569686862fbSopenharmony_ci    }
1570686862fbSopenharmony_ci    int32_t requestCode = CreateJsonObject(extraInfo, callerInfo, accountInfo);
1571686862fbSopenharmony_ci    FreeInstallInfo info = {
1572686862fbSopenharmony_ci        .want = *want, .requestCode = requestCode, .callerInfo = callerInfo, .accountInfo = accountInfo};
1573686862fbSopenharmony_ci    info.want.RemoveParam(PARAM_FREEINSTALL_APPID);
1574686862fbSopenharmony_ci    info.want.SetParam(PARAM_FREEINSTALL_APPID, callerInfo.callerAppId);
1575686862fbSopenharmony_ci    info.want.RemoveParam(PARAM_FREEINSTALL_BUNDLENAMES);
1576686862fbSopenharmony_ci    if (cmpWant == nullptr) {
1577686862fbSopenharmony_ci        return ERR_NULL_OBJECT;
1578686862fbSopenharmony_ci    }
1579686862fbSopenharmony_ci    info.want.SetParam(
1580686862fbSopenharmony_ci        PARAM_FREEINSTALL_BUNDLENAMES, (*cmpWant).GetStringArrayParam(CMPT_PARAM_FREEINSTALL_BUNDLENAMES));
1581686862fbSopenharmony_ci    result = StartFreeInstallFromRemote(info, taskId);
1582686862fbSopenharmony_ci    HILOGI("result = %{public}d", result);
1583686862fbSopenharmony_ci    PARCEL_WRITE_HELPER(reply, Int32, result);
1584686862fbSopenharmony_ci    int64_t end = GetTickCount();
1585686862fbSopenharmony_ci    PARCEL_WRITE_HELPER(reply, Int64, end - begin);
1586686862fbSopenharmony_ci    return ERR_NONE;
1587686862fbSopenharmony_ci}
1588686862fbSopenharmony_ci
1589686862fbSopenharmony_ciint32_t DistributedSchedStub::NotifyCompleteFreeInstallFromRemoteInner(MessageParcel& data, MessageParcel& reply)
1590686862fbSopenharmony_ci{
1591686862fbSopenharmony_ci    if (!CheckCallingUid()) {
1592686862fbSopenharmony_ci        HILOGW("request DENIED!");
1593686862fbSopenharmony_ci        return DMS_PERMISSION_DENIED;
1594686862fbSopenharmony_ci    }
1595686862fbSopenharmony_ci    int64_t taskId = 0;
1596686862fbSopenharmony_ci    int32_t resultCode = 0;
1597686862fbSopenharmony_ci    PARCEL_READ_HELPER(data, Int64, taskId);
1598686862fbSopenharmony_ci    PARCEL_READ_HELPER(data, Int32, resultCode);
1599686862fbSopenharmony_ci    int32_t result = NotifyCompleteFreeInstallFromRemote(taskId, resultCode);
1600686862fbSopenharmony_ci    HILOGI("result = %{public}d", result);
1601686862fbSopenharmony_ci    PARCEL_WRITE_REPLY_NOERROR(reply, Int32, result);
1602686862fbSopenharmony_ci}
1603686862fbSopenharmony_ci
1604686862fbSopenharmony_ciint32_t DistributedSchedStub::StopRemoteExtensionAbilityInner(MessageParcel& data, MessageParcel& reply)
1605686862fbSopenharmony_ci{
1606686862fbSopenharmony_ci    if (!DistributedSchedPermission::GetInstance().IsFoundationCall()) {
1607686862fbSopenharmony_ci        HILOGW("request DENIED!");
1608686862fbSopenharmony_ci        return DMS_PERMISSION_DENIED;
1609686862fbSopenharmony_ci    }
1610686862fbSopenharmony_ci    shared_ptr<AAFwk::Want> want(data.ReadParcelable<AAFwk::Want>());
1611686862fbSopenharmony_ci    if (want == nullptr) {
1612686862fbSopenharmony_ci        HILOGW("Stop reomte extension ability want readParcelable failed!");
1613686862fbSopenharmony_ci        return ERR_NULL_OBJECT;
1614686862fbSopenharmony_ci    }
1615686862fbSopenharmony_ci    DistributedSchedPermission::GetInstance().RemoveRemoteObjectFromWant(want);
1616686862fbSopenharmony_ci    int32_t callerUid = 0;
1617686862fbSopenharmony_ci    PARCEL_READ_HELPER(data, Int32, callerUid);
1618686862fbSopenharmony_ci    uint32_t accessToken = 0;
1619686862fbSopenharmony_ci    PARCEL_READ_HELPER(data, Uint32, accessToken);
1620686862fbSopenharmony_ci    int32_t serviceType = 0;
1621686862fbSopenharmony_ci    PARCEL_READ_HELPER(data, Int32, serviceType);
1622686862fbSopenharmony_ci    HILOGD("get callerUid = %{private}d, AccessTokenID = %{private}s", callerUid,
1623686862fbSopenharmony_ci        GetAnonymStr(std::to_string(accessToken)).c_str());
1624686862fbSopenharmony_ci    auto result = StopRemoteExtensionAbility(*want, callerUid, accessToken, serviceType);
1625686862fbSopenharmony_ci    HILOGD("StartRemoteAbilityInner result = %{public}d", result);
1626686862fbSopenharmony_ci    PARCEL_WRITE_REPLY_NOERROR(reply, Int32, result);
1627686862fbSopenharmony_ci}
1628686862fbSopenharmony_ci
1629686862fbSopenharmony_ciint32_t DistributedSchedStub::StopExtensionAbilityFromRemoteInner(MessageParcel& data, MessageParcel& reply)
1630686862fbSopenharmony_ci{
1631686862fbSopenharmony_ci    if (!CheckCallingUid()) {
1632686862fbSopenharmony_ci        HILOGW("request DENIED!");
1633686862fbSopenharmony_ci        return DMS_PERMISSION_DENIED;
1634686862fbSopenharmony_ci    }
1635686862fbSopenharmony_ci    shared_ptr<DistributedWant> dstbWant(data.ReadParcelable<DistributedWant>());
1636686862fbSopenharmony_ci    shared_ptr<AAFwk::Want> want = nullptr;
1637686862fbSopenharmony_ci    if (dstbWant != nullptr) {
1638686862fbSopenharmony_ci        want = dstbWant->ToWant();
1639686862fbSopenharmony_ci    }
1640686862fbSopenharmony_ci    if (want == nullptr) {
1641686862fbSopenharmony_ci        HILOGW("want readParcelable failed!");
1642686862fbSopenharmony_ci        return ERR_NULL_OBJECT;
1643686862fbSopenharmony_ci    }
1644686862fbSopenharmony_ci    DistributedSchedPermission::GetInstance().RemoveRemoteObjectFromWant(want);
1645686862fbSopenharmony_ci    int32_t serviceType = 0;
1646686862fbSopenharmony_ci    PARCEL_READ_HELPER(data, Int32, serviceType);
1647686862fbSopenharmony_ci    CallerInfo callerInfo;
1648686862fbSopenharmony_ci    PARCEL_READ_HELPER(data, Int32, callerInfo.uid);
1649686862fbSopenharmony_ci    PARCEL_READ_HELPER(data, String, callerInfo.sourceDeviceId);
1650686862fbSopenharmony_ci    callerInfo.callerType = CALLER_TYPE_HARMONY;
1651686862fbSopenharmony_ci    AccountInfo accountInfo;
1652686862fbSopenharmony_ci    accountInfo.accountType = data.ReadInt32();
1653686862fbSopenharmony_ci    PARCEL_READ_HELPER(data, StringVector, &accountInfo.groupIdList);
1654686862fbSopenharmony_ci    callerInfo.callerAppId = data.ReadString();
1655686862fbSopenharmony_ci    std::string extraInfo = data.ReadString();
1656686862fbSopenharmony_ci    if (extraInfo.empty()) {
1657686862fbSopenharmony_ci        HILOGD("extra info is empty!");
1658686862fbSopenharmony_ci    }
1659686862fbSopenharmony_ci    nlohmann::json extraInfoJson = nlohmann::json::parse(extraInfo, nullptr, false);
1660686862fbSopenharmony_ci    if (!extraInfoJson.is_discarded() && extraInfoJson.find(EXTRO_INFO_JSON_KEY_ACCESS_TOKEN) != extraInfoJson.end() &&
1661686862fbSopenharmony_ci        extraInfoJson[EXTRO_INFO_JSON_KEY_ACCESS_TOKEN].is_number_unsigned()) {
1662686862fbSopenharmony_ci        uint32_t accessToken = extraInfoJson[EXTRO_INFO_JSON_KEY_ACCESS_TOKEN];
1663686862fbSopenharmony_ci        callerInfo.accessToken = accessToken;
1664686862fbSopenharmony_ci        HILOGD("parse extra info, accessTokenID = %{private}s", GetAnonymStr(std::to_string(accessToken)).c_str());
1665686862fbSopenharmony_ci    }
1666686862fbSopenharmony_ci    auto result = StopExtensionAbilityFromRemote(*want, callerInfo, accountInfo, serviceType);
1667686862fbSopenharmony_ci    HILOGD("result = %{public}d", result);
1668686862fbSopenharmony_ci    PARCEL_WRITE_HELPER(reply, Int32, result);
1669686862fbSopenharmony_ci    return ERR_NONE;
1670686862fbSopenharmony_ci}
1671686862fbSopenharmony_ci
1672686862fbSopenharmony_ci#ifdef DMSFWK_INTERACTIVE_ADAPTER
1673686862fbSopenharmony_cibool DistributedSchedStub::CheckDmsExtensionCallingUid()
1674686862fbSopenharmony_ci{
1675686862fbSopenharmony_ci    // never allow non-system uid for distributed request
1676686862fbSopenharmony_ci    constexpr int32_t MULTIUSER_HAP_PER_USER_RANGE_EXT = 100000;
1677686862fbSopenharmony_ci    constexpr int32_t HID_HAP_EXT = 10000;
1678686862fbSopenharmony_ci    auto callingUid = IPCSkeleton::GetCallingUid();
1679686862fbSopenharmony_ci    auto uid = callingUid % MULTIUSER_HAP_PER_USER_RANGE_EXT;
1680686862fbSopenharmony_ci    return uid < HID_HAP_EXT;
1681686862fbSopenharmony_ci}
1682686862fbSopenharmony_ci
1683686862fbSopenharmony_ciint32_t DistributedSchedStub::StartAbilityFromRemoteAdapterInner(MessageParcel& data, MessageParcel& reply)
1684686862fbSopenharmony_ci{
1685686862fbSopenharmony_ci    if (!CheckDmsExtensionCallingUid()) {
1686686862fbSopenharmony_ci        HILOGW("Start ability from remote adapter request DENIED!");
1687686862fbSopenharmony_ci        return DMS_PERMISSION_DENIED;
1688686862fbSopenharmony_ci    }
1689686862fbSopenharmony_ci
1690686862fbSopenharmony_ci    int32_t result = StartAbilityFromRemoteAdapter(data, reply);
1691686862fbSopenharmony_ci    HILOGI("Start ability from remote adapter result = %{public}d", result);
1692686862fbSopenharmony_ci    return result;
1693686862fbSopenharmony_ci}
1694686862fbSopenharmony_ci
1695686862fbSopenharmony_ciint32_t DistributedSchedStub::StopAbilityFromRemoteAdapterInner(MessageParcel& data, MessageParcel& reply)
1696686862fbSopenharmony_ci{
1697686862fbSopenharmony_ci    if (!CheckDmsExtensionCallingUid()) {
1698686862fbSopenharmony_ci        HILOGW("Stop ability from remote adapter request DENIED!");
1699686862fbSopenharmony_ci        return DMS_PERMISSION_DENIED;
1700686862fbSopenharmony_ci    }
1701686862fbSopenharmony_ci
1702686862fbSopenharmony_ci    int32_t result = StopAbilityFromRemoteAdapter(data, reply);
1703686862fbSopenharmony_ci    HILOGI("Stop ability from remote adapter result = %{public}d", result);
1704686862fbSopenharmony_ci    return ERR_OK;
1705686862fbSopenharmony_ci}
1706686862fbSopenharmony_ci
1707686862fbSopenharmony_ciint32_t DistributedSchedStub::ConnectAbilityFromRemoteAdapterInner(MessageParcel& data, MessageParcel& reply)
1708686862fbSopenharmony_ci{
1709686862fbSopenharmony_ci    if (!CheckDmsExtensionCallingUid()) {
1710686862fbSopenharmony_ci        HILOGW("Connect ability from remote adapter request DENIED!");
1711686862fbSopenharmony_ci        return DMS_PERMISSION_DENIED;
1712686862fbSopenharmony_ci    }
1713686862fbSopenharmony_ci
1714686862fbSopenharmony_ci    int32_t result = ConnectAbilityFromRemoteAdapter(data, reply);
1715686862fbSopenharmony_ci    HILOGI("Connect ability from remote adapter result = %{public}d", result);
1716686862fbSopenharmony_ci    return ERR_OK;
1717686862fbSopenharmony_ci}
1718686862fbSopenharmony_ci
1719686862fbSopenharmony_ciint32_t DistributedSchedStub::DisconnectAbilityFromRemoteAdapterInner(MessageParcel& data, MessageParcel& reply)
1720686862fbSopenharmony_ci{
1721686862fbSopenharmony_ci    if (!CheckDmsExtensionCallingUid()) {
1722686862fbSopenharmony_ci        HILOGW("Disconnect ability from remote adapter request DENIED!");
1723686862fbSopenharmony_ci        return DMS_PERMISSION_DENIED;
1724686862fbSopenharmony_ci    }
1725686862fbSopenharmony_ci
1726686862fbSopenharmony_ci    int32_t result = DisconnectAbilityFromRemoteAdapter(data, reply);
1727686862fbSopenharmony_ci    HILOGI("Disconnect ability from remote adapter result = %{public}d", result);
1728686862fbSopenharmony_ci    return ERR_OK;
1729686862fbSopenharmony_ci}
1730686862fbSopenharmony_ci
1731686862fbSopenharmony_ciint32_t DistributedSchedStub::NotifyAbilityLifecycleChangedFromRemoteAdapterInner(MessageParcel& data,
1732686862fbSopenharmony_ci    MessageParcel& reply)
1733686862fbSopenharmony_ci{
1734686862fbSopenharmony_ci    if (!CheckDmsExtensionCallingUid()) {
1735686862fbSopenharmony_ci        HILOGW("Disconnect ability from remote adapter request DENIED!");
1736686862fbSopenharmony_ci        return DMS_PERMISSION_DENIED;
1737686862fbSopenharmony_ci    }
1738686862fbSopenharmony_ci
1739686862fbSopenharmony_ci    int32_t result = NotifyAbilityLifecycleChangedFromRemoteAdapter(data, reply);
1740686862fbSopenharmony_ci    HILOGI("Disconnect ability from remote adapter result = %{public}d", result);
1741686862fbSopenharmony_ci    return ERR_OK;
1742686862fbSopenharmony_ci}
1743686862fbSopenharmony_ci#endif
1744686862fbSopenharmony_ci} // namespace DistributedSchedule
1745686862fbSopenharmony_ci} // namespace OHOS
1746