1eace7efcSopenharmony_ci/* 2eace7efcSopenharmony_ci * Copyright (c) 2021-2024 Huawei Device Co., Ltd. 3eace7efcSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 4eace7efcSopenharmony_ci * you may not use this file except in compliance with the License. 5eace7efcSopenharmony_ci * You may obtain a copy of the License at 6eace7efcSopenharmony_ci * 7eace7efcSopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 8eace7efcSopenharmony_ci * 9eace7efcSopenharmony_ci * Unless required by applicable law or agreed to in writing, software 10eace7efcSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 11eace7efcSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12eace7efcSopenharmony_ci * See the License for the specific language governing permissions and 13eace7efcSopenharmony_ci * limitations under the License. 14eace7efcSopenharmony_ci */ 15eace7efcSopenharmony_ci 16eace7efcSopenharmony_ci#include "ability_scheduler_stub.h" 17eace7efcSopenharmony_ci 18eace7efcSopenharmony_ci#include "ability_manager_errors.h" 19eace7efcSopenharmony_ci#include "data_ability_observer_interface.h" 20eace7efcSopenharmony_ci#include "data_ability_operation.h" 21eace7efcSopenharmony_ci#include "data_ability_predicates.h" 22eace7efcSopenharmony_ci#include "data_ability_result.h" 23eace7efcSopenharmony_ci#include "hilog_tag_wrapper.h" 24eace7efcSopenharmony_ci#include "ishared_result_set.h" 25eace7efcSopenharmony_ci#include "session_info.h" 26eace7efcSopenharmony_ci#include "values_bucket.h" 27eace7efcSopenharmony_ci 28eace7efcSopenharmony_cinamespace OHOS { 29eace7efcSopenharmony_cinamespace AAFwk { 30eace7efcSopenharmony_ciconstexpr int CYCLE_LIMIT = 2000; 31eace7efcSopenharmony_ciAbilitySchedulerStub::AbilitySchedulerStub() 32eace7efcSopenharmony_ci{} 33eace7efcSopenharmony_ci 34eace7efcSopenharmony_ciAbilitySchedulerStub::~AbilitySchedulerStub() 35eace7efcSopenharmony_ci{} 36eace7efcSopenharmony_ci 37eace7efcSopenharmony_ciint AbilitySchedulerStub::OnRemoteRequest( 38eace7efcSopenharmony_ci uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) 39eace7efcSopenharmony_ci{ 40eace7efcSopenharmony_ci std::u16string descriptor = AbilitySchedulerStub::GetDescriptor(); 41eace7efcSopenharmony_ci std::u16string remoteDescriptor = data.ReadInterfaceToken(); 42eace7efcSopenharmony_ci if (descriptor != remoteDescriptor) { 43eace7efcSopenharmony_ci TAG_LOGE(AAFwkTag::ABILITYMGR, "descriptor not equal to remote"); 44eace7efcSopenharmony_ci return ERR_INVALID_STATE; 45eace7efcSopenharmony_ci } 46eace7efcSopenharmony_ci return OnRemoteRequestInner(code, data, reply, option); 47eace7efcSopenharmony_ci} 48eace7efcSopenharmony_ci 49eace7efcSopenharmony_ciint AbilitySchedulerStub::OnRemoteRequestInner( 50eace7efcSopenharmony_ci uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) 51eace7efcSopenharmony_ci{ 52eace7efcSopenharmony_ci int retCode = ERR_OK; 53eace7efcSopenharmony_ci retCode = OnRemoteRequestInnerFirst(code, data, reply, option); 54eace7efcSopenharmony_ci if (retCode != ERR_CODE_NOT_EXIST) { 55eace7efcSopenharmony_ci return retCode; 56eace7efcSopenharmony_ci } 57eace7efcSopenharmony_ci retCode = OnRemoteRequestInnerSecond(code, data, reply, option); 58eace7efcSopenharmony_ci if (retCode != ERR_CODE_NOT_EXIST) { 59eace7efcSopenharmony_ci return retCode; 60eace7efcSopenharmony_ci } 61eace7efcSopenharmony_ci retCode = OnRemoteRequestInnerThird(code, data, reply, option); 62eace7efcSopenharmony_ci if (retCode != ERR_CODE_NOT_EXIST) { 63eace7efcSopenharmony_ci return retCode; 64eace7efcSopenharmony_ci } 65eace7efcSopenharmony_ci TAG_LOGW(AAFwkTag::ABILITYMGR, "default case, need check"); 66eace7efcSopenharmony_ci return IPCObjectStub::OnRemoteRequest(code, data, reply, option); 67eace7efcSopenharmony_ci} 68eace7efcSopenharmony_ci 69eace7efcSopenharmony_ciint AbilitySchedulerStub::OnRemoteRequestInnerFirst( 70eace7efcSopenharmony_ci uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) 71eace7efcSopenharmony_ci{ 72eace7efcSopenharmony_ci switch (code) { 73eace7efcSopenharmony_ci case SCHEDULE_ABILITY_TRANSACTION: 74eace7efcSopenharmony_ci return AbilityTransactionInner(data, reply); 75eace7efcSopenharmony_ci case SEND_RESULT: 76eace7efcSopenharmony_ci return SendResultInner(data, reply); 77eace7efcSopenharmony_ci case SCHEDULE_ABILITY_CONNECT: 78eace7efcSopenharmony_ci return ConnectAbilityInner(data, reply); 79eace7efcSopenharmony_ci case SCHEDULE_ABILITY_DISCONNECT: 80eace7efcSopenharmony_ci return DisconnectAbilityInner(data, reply); 81eace7efcSopenharmony_ci case SCHEDULE_ABILITY_COMMAND: 82eace7efcSopenharmony_ci return CommandAbilityInner(data, reply); 83eace7efcSopenharmony_ci case SCHEDULE_ABILITY_PREPARE_TERMINATE: 84eace7efcSopenharmony_ci return PrepareTerminateAbilityInner(data, reply); 85eace7efcSopenharmony_ci case SCHEDULE_ABILITY_COMMAND_WINDOW: 86eace7efcSopenharmony_ci return CommandAbilityWindowInner(data, reply); 87eace7efcSopenharmony_ci case SCHEDULE_SAVE_ABILITY_STATE: 88eace7efcSopenharmony_ci return SaveAbilityStateInner(data, reply); 89eace7efcSopenharmony_ci case SCHEDULE_RESTORE_ABILITY_STATE: 90eace7efcSopenharmony_ci return RestoreAbilityStateInner(data, reply); 91eace7efcSopenharmony_ci case SCHEDULE_GETFILETYPES: 92eace7efcSopenharmony_ci return GetFileTypesInner(data, reply); 93eace7efcSopenharmony_ci case SCHEDULE_OPENFILE: 94eace7efcSopenharmony_ci return OpenFileInner(data, reply); 95eace7efcSopenharmony_ci case SCHEDULE_OPENRAWFILE: 96eace7efcSopenharmony_ci return OpenRawFileInner(data, reply); 97eace7efcSopenharmony_ci case SCHEDULE_INSERT: 98eace7efcSopenharmony_ci return InsertInner(data, reply); 99eace7efcSopenharmony_ci case SCHEDULE_UPDATE: 100eace7efcSopenharmony_ci return UpdatetInner(data, reply); 101eace7efcSopenharmony_ci case SCHEDULE_DELETE: 102eace7efcSopenharmony_ci return DeleteInner(data, reply); 103eace7efcSopenharmony_ci } 104eace7efcSopenharmony_ci return ERR_CODE_NOT_EXIST; 105eace7efcSopenharmony_ci} 106eace7efcSopenharmony_ci 107eace7efcSopenharmony_ciint AbilitySchedulerStub::OnRemoteRequestInnerSecond( 108eace7efcSopenharmony_ci uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) 109eace7efcSopenharmony_ci{ 110eace7efcSopenharmony_ci switch (code) { 111eace7efcSopenharmony_ci case SCHEDULE_QUERY: 112eace7efcSopenharmony_ci return QueryInner(data, reply); 113eace7efcSopenharmony_ci case SCHEDULE_CALL: 114eace7efcSopenharmony_ci return CallInner(data, reply); 115eace7efcSopenharmony_ci case SCHEDULE_GETTYPE: 116eace7efcSopenharmony_ci return GetTypeInner(data, reply); 117eace7efcSopenharmony_ci case SCHEDULE_RELOAD: 118eace7efcSopenharmony_ci return ReloadInner(data, reply); 119eace7efcSopenharmony_ci case SCHEDULE_BATCHINSERT: 120eace7efcSopenharmony_ci return BatchInsertInner(data, reply); 121eace7efcSopenharmony_ci case SCHEDULE_REGISTEROBSERVER: 122eace7efcSopenharmony_ci return RegisterObserverInner(data, reply); 123eace7efcSopenharmony_ci case SCHEDULE_UNREGISTEROBSERVER: 124eace7efcSopenharmony_ci return UnregisterObserverInner(data, reply); 125eace7efcSopenharmony_ci case SCHEDULE_NOTIFYCHANGE: 126eace7efcSopenharmony_ci return NotifyChangeInner(data, reply); 127eace7efcSopenharmony_ci case SCHEDULE_NORMALIZEURI: 128eace7efcSopenharmony_ci return NormalizeUriInner(data, reply); 129eace7efcSopenharmony_ci case SCHEDULE_DENORMALIZEURI: 130eace7efcSopenharmony_ci return DenormalizeUriInner(data, reply); 131eace7efcSopenharmony_ci case SCHEDULE_EXECUTEBATCH: 132eace7efcSopenharmony_ci return ExecuteBatchInner(data, reply); 133eace7efcSopenharmony_ci case NOTIFY_CONTINUATION_RESULT: 134eace7efcSopenharmony_ci return NotifyContinuationResultInner(data, reply); 135eace7efcSopenharmony_ci case REQUEST_CALL_REMOTE: 136eace7efcSopenharmony_ci return CallRequestInner(data, reply); 137eace7efcSopenharmony_ci case CONTINUE_ABILITY: 138eace7efcSopenharmony_ci return ContinueAbilityInner(data, reply); 139eace7efcSopenharmony_ci case DUMP_ABILITY_RUNNER_INNER: 140eace7efcSopenharmony_ci return DumpAbilityInfoInner(data, reply); 141eace7efcSopenharmony_ci } 142eace7efcSopenharmony_ci return ERR_CODE_NOT_EXIST; 143eace7efcSopenharmony_ci} 144eace7efcSopenharmony_ci 145eace7efcSopenharmony_ciint AbilitySchedulerStub::OnRemoteRequestInnerThird( 146eace7efcSopenharmony_ci uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) 147eace7efcSopenharmony_ci{ 148eace7efcSopenharmony_ci switch (code) { 149eace7efcSopenharmony_ci case SCHEDULE_SHARE_DATA: 150eace7efcSopenharmony_ci return ShareDataInner(data, reply); 151eace7efcSopenharmony_ci case SCHEDULE_ONEXECUTE_INTENT: 152eace7efcSopenharmony_ci return OnExecuteIntentInner(data, reply); 153eace7efcSopenharmony_ci case CREATE_MODAL_UI_EXTENSION: 154eace7efcSopenharmony_ci return CreateModalUIExtensionInner(data, reply); 155eace7efcSopenharmony_ci case UPDATE_SESSION_TOKEN: 156eace7efcSopenharmony_ci return UpdateSessionTokenInner(data, reply); 157eace7efcSopenharmony_ci } 158eace7efcSopenharmony_ci return ERR_CODE_NOT_EXIST; 159eace7efcSopenharmony_ci} 160eace7efcSopenharmony_ci 161eace7efcSopenharmony_ciint AbilitySchedulerStub::AbilityTransactionInner(MessageParcel &data, MessageParcel &reply) 162eace7efcSopenharmony_ci{ 163eace7efcSopenharmony_ci std::shared_ptr<Want> want(data.ReadParcelable<Want>()); 164eace7efcSopenharmony_ci if (want == nullptr) { 165eace7efcSopenharmony_ci TAG_LOGE(AAFwkTag::ABILITYMGR, "null want"); 166eace7efcSopenharmony_ci return ERR_INVALID_VALUE; 167eace7efcSopenharmony_ci } 168eace7efcSopenharmony_ci std::unique_ptr<LifeCycleStateInfo> stateInfo(data.ReadParcelable<LifeCycleStateInfo>()); 169eace7efcSopenharmony_ci if (!stateInfo) { 170eace7efcSopenharmony_ci TAG_LOGE(AAFwkTag::ABILITYMGR, "ReadParcelable<LifeCycleStateInfo> failed"); 171eace7efcSopenharmony_ci return ERR_INVALID_VALUE; 172eace7efcSopenharmony_ci } 173eace7efcSopenharmony_ci sptr<SessionInfo> sessionInfo = nullptr; 174eace7efcSopenharmony_ci if (data.ReadBool()) { 175eace7efcSopenharmony_ci sessionInfo = data.ReadParcelable<SessionInfo>(); 176eace7efcSopenharmony_ci } 177eace7efcSopenharmony_ci ScheduleAbilityTransaction(*want, *stateInfo, sessionInfo); 178eace7efcSopenharmony_ci return NO_ERROR; 179eace7efcSopenharmony_ci} 180eace7efcSopenharmony_ci 181eace7efcSopenharmony_ciint AbilitySchedulerStub::ShareDataInner(MessageParcel &data, MessageParcel &reply) 182eace7efcSopenharmony_ci{ 183eace7efcSopenharmony_ci int32_t requestCode = data.ReadInt32(); 184eace7efcSopenharmony_ci TAG_LOGI(AAFwkTag::ABILITYMGR, "requestCode:%{public}d", requestCode); 185eace7efcSopenharmony_ci ScheduleShareData(requestCode); 186eace7efcSopenharmony_ci return NO_ERROR; 187eace7efcSopenharmony_ci} 188eace7efcSopenharmony_ci 189eace7efcSopenharmony_ciint AbilitySchedulerStub::SendResultInner(MessageParcel &data, MessageParcel &reply) 190eace7efcSopenharmony_ci{ 191eace7efcSopenharmony_ci int requestCode = data.ReadInt32(); 192eace7efcSopenharmony_ci int resultCode = data.ReadInt32(); 193eace7efcSopenharmony_ci std::shared_ptr<Want> want(data.ReadParcelable<Want>()); 194eace7efcSopenharmony_ci if (want == nullptr) { 195eace7efcSopenharmony_ci TAG_LOGE(AAFwkTag::ABILITYMGR, "null want"); 196eace7efcSopenharmony_ci return ERR_INVALID_VALUE; 197eace7efcSopenharmony_ci } 198eace7efcSopenharmony_ci SendResult(requestCode, resultCode, *want); 199eace7efcSopenharmony_ci return NO_ERROR; 200eace7efcSopenharmony_ci} 201eace7efcSopenharmony_ci 202eace7efcSopenharmony_ciint AbilitySchedulerStub::ConnectAbilityInner(MessageParcel &data, MessageParcel &reply) 203eace7efcSopenharmony_ci{ 204eace7efcSopenharmony_ci std::shared_ptr<Want> want(data.ReadParcelable<Want>()); 205eace7efcSopenharmony_ci if (want == nullptr) { 206eace7efcSopenharmony_ci TAG_LOGE(AAFwkTag::ABILITYMGR, "null want"); 207eace7efcSopenharmony_ci return ERR_INVALID_VALUE; 208eace7efcSopenharmony_ci } 209eace7efcSopenharmony_ci ScheduleConnectAbility(*want); 210eace7efcSopenharmony_ci return NO_ERROR; 211eace7efcSopenharmony_ci} 212eace7efcSopenharmony_ci 213eace7efcSopenharmony_ciint AbilitySchedulerStub::DisconnectAbilityInner(MessageParcel &data, MessageParcel &reply) 214eace7efcSopenharmony_ci{ 215eace7efcSopenharmony_ci std::shared_ptr<Want> want(data.ReadParcelable<Want>()); 216eace7efcSopenharmony_ci if (want == nullptr) { 217eace7efcSopenharmony_ci TAG_LOGE(AAFwkTag::ABILITYMGR, "null want"); 218eace7efcSopenharmony_ci return ERR_INVALID_VALUE; 219eace7efcSopenharmony_ci } 220eace7efcSopenharmony_ci ScheduleDisconnectAbility(*want); 221eace7efcSopenharmony_ci return NO_ERROR; 222eace7efcSopenharmony_ci} 223eace7efcSopenharmony_ci 224eace7efcSopenharmony_ciint AbilitySchedulerStub::CommandAbilityInner(MessageParcel &data, MessageParcel &reply) 225eace7efcSopenharmony_ci{ 226eace7efcSopenharmony_ci std::shared_ptr<Want> want(data.ReadParcelable<Want>()); 227eace7efcSopenharmony_ci if (want == nullptr) { 228eace7efcSopenharmony_ci TAG_LOGE(AAFwkTag::ABILITYMGR, "null want"); 229eace7efcSopenharmony_ci return ERR_INVALID_VALUE; 230eace7efcSopenharmony_ci } 231eace7efcSopenharmony_ci bool reStart = data.ReadBool(); 232eace7efcSopenharmony_ci int startId = data.ReadInt32(); 233eace7efcSopenharmony_ci TAG_LOGD(AAFwkTag::ABILITYMGR, "ReadInt32, startId:%{public}d", startId); 234eace7efcSopenharmony_ci ScheduleCommandAbility(*want, reStart, startId); 235eace7efcSopenharmony_ci return NO_ERROR; 236eace7efcSopenharmony_ci} 237eace7efcSopenharmony_ci 238eace7efcSopenharmony_ciint AbilitySchedulerStub::PrepareTerminateAbilityInner(MessageParcel &data, MessageParcel &reply) 239eace7efcSopenharmony_ci{ 240eace7efcSopenharmony_ci TAG_LOGI(AAFwkTag::ABILITYMGR, "prepare terminate call"); 241eace7efcSopenharmony_ci bool ret = SchedulePrepareTerminateAbility(); 242eace7efcSopenharmony_ci if (!reply.WriteInt32(ret)) { 243eace7efcSopenharmony_ci TAG_LOGE(AAFwkTag::ABILITYMGR, "fail to write ret"); 244eace7efcSopenharmony_ci return ERR_INVALID_VALUE; 245eace7efcSopenharmony_ci } 246eace7efcSopenharmony_ci return NO_ERROR; 247eace7efcSopenharmony_ci} 248eace7efcSopenharmony_ci 249eace7efcSopenharmony_ciint AbilitySchedulerStub::CommandAbilityWindowInner(MessageParcel &data, MessageParcel &reply) 250eace7efcSopenharmony_ci{ 251eace7efcSopenharmony_ci std::shared_ptr<Want> want(data.ReadParcelable<Want>()); 252eace7efcSopenharmony_ci if (want == nullptr) { 253eace7efcSopenharmony_ci TAG_LOGE(AAFwkTag::ABILITYMGR, "null want"); 254eace7efcSopenharmony_ci return ERR_INVALID_VALUE; 255eace7efcSopenharmony_ci } 256eace7efcSopenharmony_ci sptr<SessionInfo> sessionInfo(data.ReadParcelable<SessionInfo>()); 257eace7efcSopenharmony_ci int32_t winCmd = data.ReadInt32(); 258eace7efcSopenharmony_ci ScheduleCommandAbilityWindow(*want, sessionInfo, static_cast<WindowCommand>(winCmd)); 259eace7efcSopenharmony_ci return NO_ERROR; 260eace7efcSopenharmony_ci} 261eace7efcSopenharmony_ci 262eace7efcSopenharmony_ciint AbilitySchedulerStub::SaveAbilityStateInner(MessageParcel &data, MessageParcel &reply) 263eace7efcSopenharmony_ci{ 264eace7efcSopenharmony_ci ScheduleSaveAbilityState(); 265eace7efcSopenharmony_ci return NO_ERROR; 266eace7efcSopenharmony_ci} 267eace7efcSopenharmony_ci 268eace7efcSopenharmony_ciint AbilitySchedulerStub::RestoreAbilityStateInner(MessageParcel &data, MessageParcel &reply) 269eace7efcSopenharmony_ci{ 270eace7efcSopenharmony_ci std::shared_ptr<PacMap> pacMap(data.ReadParcelable<PacMap>()); 271eace7efcSopenharmony_ci if (pacMap == nullptr) { 272eace7efcSopenharmony_ci TAG_LOGE(AAFwkTag::ABILITYMGR, "null pacMap"); 273eace7efcSopenharmony_ci return ERR_INVALID_VALUE; 274eace7efcSopenharmony_ci } 275eace7efcSopenharmony_ci ScheduleRestoreAbilityState(*pacMap); 276eace7efcSopenharmony_ci return NO_ERROR; 277eace7efcSopenharmony_ci} 278eace7efcSopenharmony_ci 279eace7efcSopenharmony_ciint AbilitySchedulerStub::GetFileTypesInner(MessageParcel &data, MessageParcel &reply) 280eace7efcSopenharmony_ci{ 281eace7efcSopenharmony_ci std::shared_ptr<Uri> uri(data.ReadParcelable<Uri>()); 282eace7efcSopenharmony_ci if (uri == nullptr) { 283eace7efcSopenharmony_ci TAG_LOGE(AAFwkTag::ABILITYMGR, "null uri"); 284eace7efcSopenharmony_ci return ERR_INVALID_VALUE; 285eace7efcSopenharmony_ci } 286eace7efcSopenharmony_ci std::string mimeTypeFilter = data.ReadString(); 287eace7efcSopenharmony_ci if (mimeTypeFilter.empty()) { 288eace7efcSopenharmony_ci TAG_LOGE(AAFwkTag::ABILITYMGR, "null mimeTypeFilter"); 289eace7efcSopenharmony_ci return ERR_INVALID_VALUE; 290eace7efcSopenharmony_ci } 291eace7efcSopenharmony_ci std::vector<std::string> types = GetFileTypes(*uri, mimeTypeFilter); 292eace7efcSopenharmony_ci if (!reply.WriteStringVector(types)) { 293eace7efcSopenharmony_ci TAG_LOGE(AAFwkTag::ABILITYMGR, "fail to WriteStringVector types"); 294eace7efcSopenharmony_ci return ERR_INVALID_VALUE; 295eace7efcSopenharmony_ci } 296eace7efcSopenharmony_ci return NO_ERROR; 297eace7efcSopenharmony_ci} 298eace7efcSopenharmony_ci 299eace7efcSopenharmony_ciint AbilitySchedulerStub::OpenFileInner(MessageParcel &data, MessageParcel &reply) 300eace7efcSopenharmony_ci{ 301eace7efcSopenharmony_ci std::shared_ptr<Uri> uri(data.ReadParcelable<Uri>()); 302eace7efcSopenharmony_ci if (uri == nullptr) { 303eace7efcSopenharmony_ci TAG_LOGE(AAFwkTag::ABILITYMGR, "null uri"); 304eace7efcSopenharmony_ci return ERR_INVALID_VALUE; 305eace7efcSopenharmony_ci } 306eace7efcSopenharmony_ci std::string mode = data.ReadString(); 307eace7efcSopenharmony_ci if (mode.empty()) { 308eace7efcSopenharmony_ci TAG_LOGE(AAFwkTag::ABILITYMGR, "null mode"); 309eace7efcSopenharmony_ci return ERR_INVALID_VALUE; 310eace7efcSopenharmony_ci } 311eace7efcSopenharmony_ci int fd = OpenFile(*uri, mode); 312eace7efcSopenharmony_ci if (fd < 0) { 313eace7efcSopenharmony_ci TAG_LOGE(AAFwkTag::ABILITYMGR, "openFile fail, fd: %{pubilc}d", fd); 314eace7efcSopenharmony_ci return ERR_INVALID_VALUE; 315eace7efcSopenharmony_ci } 316eace7efcSopenharmony_ci if (!reply.WriteFileDescriptor(fd)) { 317eace7efcSopenharmony_ci TAG_LOGE(AAFwkTag::ABILITYMGR, "fail to WriteFileDescriptor fd"); 318eace7efcSopenharmony_ci return ERR_INVALID_VALUE; 319eace7efcSopenharmony_ci } 320eace7efcSopenharmony_ci return NO_ERROR; 321eace7efcSopenharmony_ci} 322eace7efcSopenharmony_ci 323eace7efcSopenharmony_ciint AbilitySchedulerStub::OpenRawFileInner(MessageParcel &data, MessageParcel &reply) 324eace7efcSopenharmony_ci{ 325eace7efcSopenharmony_ci std::shared_ptr<Uri> uri(data.ReadParcelable<Uri>()); 326eace7efcSopenharmony_ci if (uri == nullptr) { 327eace7efcSopenharmony_ci TAG_LOGE(AAFwkTag::ABILITYMGR, "null uri"); 328eace7efcSopenharmony_ci return ERR_INVALID_VALUE; 329eace7efcSopenharmony_ci } 330eace7efcSopenharmony_ci std::string mode = data.ReadString(); 331eace7efcSopenharmony_ci if (mode.empty()) { 332eace7efcSopenharmony_ci TAG_LOGE(AAFwkTag::ABILITYMGR, "null mode"); 333eace7efcSopenharmony_ci return ERR_INVALID_VALUE; 334eace7efcSopenharmony_ci } 335eace7efcSopenharmony_ci int fd = OpenRawFile(*uri, mode); 336eace7efcSopenharmony_ci if (!reply.WriteInt32(fd)) { 337eace7efcSopenharmony_ci TAG_LOGE(AAFwkTag::ABILITYMGR, "fail to WriteInt32 fd"); 338eace7efcSopenharmony_ci return ERR_INVALID_VALUE; 339eace7efcSopenharmony_ci } 340eace7efcSopenharmony_ci return NO_ERROR; 341eace7efcSopenharmony_ci} 342eace7efcSopenharmony_ci 343eace7efcSopenharmony_ciint AbilitySchedulerStub::InsertInner(MessageParcel &data, MessageParcel &reply) 344eace7efcSopenharmony_ci{ 345eace7efcSopenharmony_ci std::shared_ptr<Uri> uri(data.ReadParcelable<Uri>()); 346eace7efcSopenharmony_ci if (uri == nullptr) { 347eace7efcSopenharmony_ci TAG_LOGE(AAFwkTag::ABILITYMGR, "null uri"); 348eace7efcSopenharmony_ci return ERR_INVALID_VALUE; 349eace7efcSopenharmony_ci } 350eace7efcSopenharmony_ci int index = Insert(*uri, NativeRdb::ValuesBucket::Unmarshalling(data)); 351eace7efcSopenharmony_ci if (!reply.WriteInt32(index)) { 352eace7efcSopenharmony_ci TAG_LOGE(AAFwkTag::ABILITYMGR, "fail to WriteInt32 index"); 353eace7efcSopenharmony_ci return ERR_INVALID_VALUE; 354eace7efcSopenharmony_ci } 355eace7efcSopenharmony_ci TAG_LOGI(AAFwkTag::ABILITYMGR, "end"); 356eace7efcSopenharmony_ci return NO_ERROR; 357eace7efcSopenharmony_ci} 358eace7efcSopenharmony_ci 359eace7efcSopenharmony_ciint AbilitySchedulerStub::CallInner(MessageParcel &data, MessageParcel &reply) 360eace7efcSopenharmony_ci{ 361eace7efcSopenharmony_ci std::shared_ptr<Uri> uri(data.ReadParcelable<Uri>()); 362eace7efcSopenharmony_ci if (uri == nullptr) { 363eace7efcSopenharmony_ci TAG_LOGE(AAFwkTag::ABILITYMGR, "null uri"); 364eace7efcSopenharmony_ci return ERR_INVALID_VALUE; 365eace7efcSopenharmony_ci } 366eace7efcSopenharmony_ci std::string method = data.ReadString(); 367eace7efcSopenharmony_ci if (method.empty()) { 368eace7efcSopenharmony_ci TAG_LOGE(AAFwkTag::ABILITYMGR, "null method"); 369eace7efcSopenharmony_ci return ERR_INVALID_VALUE; 370eace7efcSopenharmony_ci } 371eace7efcSopenharmony_ci std::string arg = data.ReadString(); 372eace7efcSopenharmony_ci if (arg.empty()) { 373eace7efcSopenharmony_ci TAG_LOGE(AAFwkTag::ABILITYMGR, "null arg"); 374eace7efcSopenharmony_ci return ERR_INVALID_VALUE; 375eace7efcSopenharmony_ci } 376eace7efcSopenharmony_ci 377eace7efcSopenharmony_ci std::shared_ptr<AppExecFwk::PacMap> pacMap(data.ReadParcelable<AppExecFwk::PacMap>()); 378eace7efcSopenharmony_ci if (pacMap == nullptr) { 379eace7efcSopenharmony_ci TAG_LOGE(AAFwkTag::ABILITYMGR, "null pacMap"); 380eace7efcSopenharmony_ci return ERR_INVALID_VALUE; 381eace7efcSopenharmony_ci } 382eace7efcSopenharmony_ci std::shared_ptr<AppExecFwk::PacMap> result = Call(*uri, method, arg, *pacMap); 383eace7efcSopenharmony_ci if (!reply.WriteParcelable(result.get())) { 384eace7efcSopenharmony_ci TAG_LOGE(AAFwkTag::ABILITYMGR, "fail to WriteParcelable pacMap error"); 385eace7efcSopenharmony_ci return ERR_INVALID_VALUE; 386eace7efcSopenharmony_ci } 387eace7efcSopenharmony_ci TAG_LOGI(AAFwkTag::ABILITYMGR, "end"); 388eace7efcSopenharmony_ci return NO_ERROR; 389eace7efcSopenharmony_ci} 390eace7efcSopenharmony_ci 391eace7efcSopenharmony_ciint AbilitySchedulerStub::UpdatetInner(MessageParcel &data, MessageParcel &reply) 392eace7efcSopenharmony_ci{ 393eace7efcSopenharmony_ci std::shared_ptr<Uri> uri(data.ReadParcelable<Uri>()); 394eace7efcSopenharmony_ci if (uri == nullptr) { 395eace7efcSopenharmony_ci TAG_LOGE(AAFwkTag::ABILITYMGR, "null uri"); 396eace7efcSopenharmony_ci return ERR_INVALID_VALUE; 397eace7efcSopenharmony_ci } 398eace7efcSopenharmony_ci auto value = NativeRdb::ValuesBucket::Unmarshalling(data); 399eace7efcSopenharmony_ci std::shared_ptr<NativeRdb::DataAbilityPredicates> predicates( 400eace7efcSopenharmony_ci data.ReadParcelable<NativeRdb::DataAbilityPredicates>()); 401eace7efcSopenharmony_ci if (predicates == nullptr) { 402eace7efcSopenharmony_ci TAG_LOGE(AAFwkTag::ABILITYMGR, "null predicates"); 403eace7efcSopenharmony_ci return ERR_INVALID_VALUE; 404eace7efcSopenharmony_ci } 405eace7efcSopenharmony_ci int index = Update(*uri, std::move(value), *predicates); 406eace7efcSopenharmony_ci if (!reply.WriteInt32(index)) { 407eace7efcSopenharmony_ci TAG_LOGE(AAFwkTag::ABILITYMGR, "fail to WriteInt32 index"); 408eace7efcSopenharmony_ci return ERR_INVALID_VALUE; 409eace7efcSopenharmony_ci } 410eace7efcSopenharmony_ci return NO_ERROR; 411eace7efcSopenharmony_ci} 412eace7efcSopenharmony_ci 413eace7efcSopenharmony_ciint AbilitySchedulerStub::DeleteInner(MessageParcel &data, MessageParcel &reply) 414eace7efcSopenharmony_ci{ 415eace7efcSopenharmony_ci std::shared_ptr<Uri> uri(data.ReadParcelable<Uri>()); 416eace7efcSopenharmony_ci if (uri == nullptr) { 417eace7efcSopenharmony_ci TAG_LOGE(AAFwkTag::ABILITYMGR, "null uri"); 418eace7efcSopenharmony_ci return ERR_INVALID_VALUE; 419eace7efcSopenharmony_ci } 420eace7efcSopenharmony_ci std::shared_ptr<NativeRdb::DataAbilityPredicates> predicates( 421eace7efcSopenharmony_ci data.ReadParcelable<NativeRdb::DataAbilityPredicates>()); 422eace7efcSopenharmony_ci if (predicates == nullptr) { 423eace7efcSopenharmony_ci TAG_LOGE(AAFwkTag::ABILITYMGR, "null predicates"); 424eace7efcSopenharmony_ci return ERR_INVALID_VALUE; 425eace7efcSopenharmony_ci } 426eace7efcSopenharmony_ci int index = Delete(*uri, *predicates); 427eace7efcSopenharmony_ci if (!reply.WriteInt32(index)) { 428eace7efcSopenharmony_ci TAG_LOGE(AAFwkTag::ABILITYMGR, "fail to WriteInt32 index"); 429eace7efcSopenharmony_ci return ERR_INVALID_VALUE; 430eace7efcSopenharmony_ci } 431eace7efcSopenharmony_ci return NO_ERROR; 432eace7efcSopenharmony_ci} 433eace7efcSopenharmony_ci 434eace7efcSopenharmony_ciint AbilitySchedulerStub::QueryInner(MessageParcel &data, MessageParcel &reply) 435eace7efcSopenharmony_ci{ 436eace7efcSopenharmony_ci std::shared_ptr<Uri> uri(data.ReadParcelable<Uri>()); 437eace7efcSopenharmony_ci if (uri == nullptr) { 438eace7efcSopenharmony_ci TAG_LOGE(AAFwkTag::ABILITYMGR, "null uri"); 439eace7efcSopenharmony_ci return ERR_INVALID_VALUE; 440eace7efcSopenharmony_ci } 441eace7efcSopenharmony_ci std::vector<std::string> columns; 442eace7efcSopenharmony_ci if (!data.ReadStringVector(&columns)) { 443eace7efcSopenharmony_ci TAG_LOGE(AAFwkTag::ABILITYMGR, "fail to ReadStringVector columns"); 444eace7efcSopenharmony_ci return ERR_INVALID_VALUE; 445eace7efcSopenharmony_ci } 446eace7efcSopenharmony_ci std::shared_ptr<NativeRdb::DataAbilityPredicates> predicates( 447eace7efcSopenharmony_ci data.ReadParcelable<NativeRdb::DataAbilityPredicates>()); 448eace7efcSopenharmony_ci if (predicates == nullptr) { 449eace7efcSopenharmony_ci TAG_LOGE(AAFwkTag::ABILITYMGR, "null predicates"); 450eace7efcSopenharmony_ci return ERR_INVALID_VALUE; 451eace7efcSopenharmony_ci } 452eace7efcSopenharmony_ci auto resultSet = Query(*uri, columns, *predicates); 453eace7efcSopenharmony_ci if (resultSet == nullptr) { 454eace7efcSopenharmony_ci TAG_LOGE(AAFwkTag::ABILITYMGR, "null resultSet"); 455eace7efcSopenharmony_ci return ERR_INVALID_VALUE; 456eace7efcSopenharmony_ci } 457eace7efcSopenharmony_ci auto result = NativeRdb::ISharedResultSet::WriteToParcel(std::move(resultSet), reply); 458eace7efcSopenharmony_ci if (result == nullptr) { 459eace7efcSopenharmony_ci TAG_LOGE(AAFwkTag::ABILITYMGR, "null result"); 460eace7efcSopenharmony_ci return ERR_INVALID_VALUE; 461eace7efcSopenharmony_ci } 462eace7efcSopenharmony_ci TAG_LOGI(AAFwkTag::ABILITYMGR, "end"); 463eace7efcSopenharmony_ci return NO_ERROR; 464eace7efcSopenharmony_ci} 465eace7efcSopenharmony_ci 466eace7efcSopenharmony_ciint AbilitySchedulerStub::GetTypeInner(MessageParcel &data, MessageParcel &reply) 467eace7efcSopenharmony_ci{ 468eace7efcSopenharmony_ci std::shared_ptr<Uri> uri(data.ReadParcelable<Uri>()); 469eace7efcSopenharmony_ci if (uri == nullptr) { 470eace7efcSopenharmony_ci TAG_LOGE(AAFwkTag::ABILITYMGR, "null uri"); 471eace7efcSopenharmony_ci return ERR_INVALID_VALUE; 472eace7efcSopenharmony_ci } 473eace7efcSopenharmony_ci std::string type = GetType(*uri); 474eace7efcSopenharmony_ci if (!reply.WriteString(type)) { 475eace7efcSopenharmony_ci TAG_LOGE(AAFwkTag::ABILITYMGR, "fail to WriteString type"); 476eace7efcSopenharmony_ci return ERR_INVALID_VALUE; 477eace7efcSopenharmony_ci } 478eace7efcSopenharmony_ci return NO_ERROR; 479eace7efcSopenharmony_ci} 480eace7efcSopenharmony_ci 481eace7efcSopenharmony_ciint AbilitySchedulerStub::ReloadInner(MessageParcel &data, MessageParcel &reply) 482eace7efcSopenharmony_ci{ 483eace7efcSopenharmony_ci std::shared_ptr<Uri> uri(data.ReadParcelable<Uri>()); 484eace7efcSopenharmony_ci if (uri == nullptr) { 485eace7efcSopenharmony_ci TAG_LOGE(AAFwkTag::ABILITYMGR, "null uri"); 486eace7efcSopenharmony_ci return ERR_INVALID_VALUE; 487eace7efcSopenharmony_ci } 488eace7efcSopenharmony_ci 489eace7efcSopenharmony_ci std::shared_ptr<PacMap> extras(data.ReadParcelable<PacMap>()); 490eace7efcSopenharmony_ci if (extras == nullptr) { 491eace7efcSopenharmony_ci TAG_LOGE(AAFwkTag::ABILITYMGR, "null extras"); 492eace7efcSopenharmony_ci return ERR_INVALID_VALUE; 493eace7efcSopenharmony_ci } 494eace7efcSopenharmony_ci bool ret = Reload(*uri, *extras); 495eace7efcSopenharmony_ci if (!reply.WriteBool(ret)) { 496eace7efcSopenharmony_ci TAG_LOGE(AAFwkTag::ABILITYMGR, "fail to writeBool ret"); 497eace7efcSopenharmony_ci return ERR_INVALID_VALUE; 498eace7efcSopenharmony_ci } 499eace7efcSopenharmony_ci return NO_ERROR; 500eace7efcSopenharmony_ci} 501eace7efcSopenharmony_ci 502eace7efcSopenharmony_ciint AbilitySchedulerStub::BatchInsertInner(MessageParcel &data, MessageParcel &reply) 503eace7efcSopenharmony_ci{ 504eace7efcSopenharmony_ci std::shared_ptr<Uri> uri(data.ReadParcelable<Uri>()); 505eace7efcSopenharmony_ci if (uri == nullptr) { 506eace7efcSopenharmony_ci TAG_LOGE(AAFwkTag::ABILITYMGR, "null uri"); 507eace7efcSopenharmony_ci return ERR_INVALID_VALUE; 508eace7efcSopenharmony_ci } 509eace7efcSopenharmony_ci 510eace7efcSopenharmony_ci int count = 0; 511eace7efcSopenharmony_ci if (!data.ReadInt32(count)) { 512eace7efcSopenharmony_ci TAG_LOGE(AAFwkTag::ABILITYMGR, "fail to ReadInt32 index"); 513eace7efcSopenharmony_ci return ERR_INVALID_VALUE; 514eace7efcSopenharmony_ci } 515eace7efcSopenharmony_ci 516eace7efcSopenharmony_ci if (count > CYCLE_LIMIT) { 517eace7efcSopenharmony_ci TAG_LOGE(AAFwkTag::ABILITYMGR, "count too large"); 518eace7efcSopenharmony_ci return ERR_INVALID_VALUE; 519eace7efcSopenharmony_ci } 520eace7efcSopenharmony_ci std::vector<NativeRdb::ValuesBucket> values; 521eace7efcSopenharmony_ci for (int i = 0; i < count; i++) { 522eace7efcSopenharmony_ci values.emplace_back(NativeRdb::ValuesBucket::Unmarshalling(data)); 523eace7efcSopenharmony_ci } 524eace7efcSopenharmony_ci 525eace7efcSopenharmony_ci int ret = BatchInsert(*uri, values); 526eace7efcSopenharmony_ci if (!reply.WriteInt32(ret)) { 527eace7efcSopenharmony_ci TAG_LOGE(AAFwkTag::ABILITYMGR, "fail to WriteInt32 ret"); 528eace7efcSopenharmony_ci return ERR_INVALID_VALUE; 529eace7efcSopenharmony_ci } 530eace7efcSopenharmony_ci return NO_ERROR; 531eace7efcSopenharmony_ci} 532eace7efcSopenharmony_ci 533eace7efcSopenharmony_ciint AbilitySchedulerStub::RegisterObserverInner(MessageParcel &data, MessageParcel &reply) 534eace7efcSopenharmony_ci{ 535eace7efcSopenharmony_ci std::shared_ptr<Uri> uri(data.ReadParcelable<Uri>()); 536eace7efcSopenharmony_ci if (uri == nullptr) { 537eace7efcSopenharmony_ci TAG_LOGE(AAFwkTag::ABILITYMGR, "null uri"); 538eace7efcSopenharmony_ci return ERR_INVALID_VALUE; 539eace7efcSopenharmony_ci } 540eace7efcSopenharmony_ci auto obServer = iface_cast<IDataAbilityObserver>(data.ReadRemoteObject()); 541eace7efcSopenharmony_ci if (obServer == nullptr) { 542eace7efcSopenharmony_ci TAG_LOGE(AAFwkTag::ABILITYMGR, "null obServer"); 543eace7efcSopenharmony_ci return ERR_INVALID_VALUE; 544eace7efcSopenharmony_ci } 545eace7efcSopenharmony_ci 546eace7efcSopenharmony_ci bool ret = ScheduleRegisterObserver(*uri, obServer); 547eace7efcSopenharmony_ci if (!reply.WriteInt32(ret)) { 548eace7efcSopenharmony_ci TAG_LOGE(AAFwkTag::ABILITYMGR, "fail to WriteInt32 ret"); 549eace7efcSopenharmony_ci return ERR_INVALID_VALUE; 550eace7efcSopenharmony_ci } 551eace7efcSopenharmony_ci return NO_ERROR; 552eace7efcSopenharmony_ci} 553eace7efcSopenharmony_ci 554eace7efcSopenharmony_ciint AbilitySchedulerStub::UnregisterObserverInner(MessageParcel &data, MessageParcel &reply) 555eace7efcSopenharmony_ci{ 556eace7efcSopenharmony_ci std::shared_ptr<Uri> uri(data.ReadParcelable<Uri>()); 557eace7efcSopenharmony_ci if (uri == nullptr) { 558eace7efcSopenharmony_ci TAG_LOGE(AAFwkTag::ABILITYMGR, "null uri"); 559eace7efcSopenharmony_ci return ERR_INVALID_VALUE; 560eace7efcSopenharmony_ci } 561eace7efcSopenharmony_ci auto obServer = iface_cast<IDataAbilityObserver>(data.ReadRemoteObject()); 562eace7efcSopenharmony_ci if (obServer == nullptr) { 563eace7efcSopenharmony_ci TAG_LOGE(AAFwkTag::ABILITYMGR, "null obServer"); 564eace7efcSopenharmony_ci return ERR_INVALID_VALUE; 565eace7efcSopenharmony_ci } 566eace7efcSopenharmony_ci 567eace7efcSopenharmony_ci bool ret = ScheduleUnregisterObserver(*uri, obServer); 568eace7efcSopenharmony_ci if (!reply.WriteInt32(ret)) { 569eace7efcSopenharmony_ci TAG_LOGE(AAFwkTag::ABILITYMGR, "fail to WriteInt32 ret"); 570eace7efcSopenharmony_ci return ERR_INVALID_VALUE; 571eace7efcSopenharmony_ci } 572eace7efcSopenharmony_ci return NO_ERROR; 573eace7efcSopenharmony_ci} 574eace7efcSopenharmony_ci 575eace7efcSopenharmony_ciint AbilitySchedulerStub::NotifyChangeInner(MessageParcel &data, MessageParcel &reply) 576eace7efcSopenharmony_ci{ 577eace7efcSopenharmony_ci std::shared_ptr<Uri> uri(data.ReadParcelable<Uri>()); 578eace7efcSopenharmony_ci if (uri == nullptr) { 579eace7efcSopenharmony_ci TAG_LOGE(AAFwkTag::ABILITYMGR, "null uri"); 580eace7efcSopenharmony_ci return ERR_INVALID_VALUE; 581eace7efcSopenharmony_ci } 582eace7efcSopenharmony_ci 583eace7efcSopenharmony_ci bool ret = ScheduleNotifyChange(*uri); 584eace7efcSopenharmony_ci if (!reply.WriteInt32(ret)) { 585eace7efcSopenharmony_ci TAG_LOGE(AAFwkTag::ABILITYMGR, "fail to WriteInt32 ret"); 586eace7efcSopenharmony_ci return ERR_INVALID_VALUE; 587eace7efcSopenharmony_ci } 588eace7efcSopenharmony_ci return NO_ERROR; 589eace7efcSopenharmony_ci} 590eace7efcSopenharmony_ci 591eace7efcSopenharmony_ciint AbilitySchedulerStub::NormalizeUriInner(MessageParcel &data, MessageParcel &reply) 592eace7efcSopenharmony_ci{ 593eace7efcSopenharmony_ci std::shared_ptr<Uri> uri(data.ReadParcelable<Uri>()); 594eace7efcSopenharmony_ci if (uri == nullptr) { 595eace7efcSopenharmony_ci TAG_LOGE(AAFwkTag::ABILITYMGR, "null uri"); 596eace7efcSopenharmony_ci return ERR_INVALID_VALUE; 597eace7efcSopenharmony_ci } 598eace7efcSopenharmony_ci 599eace7efcSopenharmony_ci Uri ret(""); 600eace7efcSopenharmony_ci ret = NormalizeUri(*uri); 601eace7efcSopenharmony_ci if (!reply.WriteParcelable(&ret)) { 602eace7efcSopenharmony_ci TAG_LOGE(AAFwkTag::ABILITYMGR, "fail to WriteParcelable type"); 603eace7efcSopenharmony_ci return ERR_INVALID_VALUE; 604eace7efcSopenharmony_ci } 605eace7efcSopenharmony_ci return NO_ERROR; 606eace7efcSopenharmony_ci} 607eace7efcSopenharmony_ci 608eace7efcSopenharmony_ciint AbilitySchedulerStub::DenormalizeUriInner(MessageParcel &data, MessageParcel &reply) 609eace7efcSopenharmony_ci{ 610eace7efcSopenharmony_ci std::shared_ptr<Uri> uri(data.ReadParcelable<Uri>()); 611eace7efcSopenharmony_ci if (uri == nullptr) { 612eace7efcSopenharmony_ci TAG_LOGE(AAFwkTag::ABILITYMGR, "null uri"); 613eace7efcSopenharmony_ci return ERR_INVALID_VALUE; 614eace7efcSopenharmony_ci } 615eace7efcSopenharmony_ci 616eace7efcSopenharmony_ci Uri ret(""); 617eace7efcSopenharmony_ci ret = DenormalizeUri(*uri); 618eace7efcSopenharmony_ci if (!reply.WriteParcelable(&ret)) { 619eace7efcSopenharmony_ci TAG_LOGE(AAFwkTag::ABILITYMGR, "fail to WriteParcelable type"); 620eace7efcSopenharmony_ci return ERR_INVALID_VALUE; 621eace7efcSopenharmony_ci } 622eace7efcSopenharmony_ci return NO_ERROR; 623eace7efcSopenharmony_ci} 624eace7efcSopenharmony_ci 625eace7efcSopenharmony_ciint AbilitySchedulerStub::ExecuteBatchInner(MessageParcel &data, MessageParcel &reply) 626eace7efcSopenharmony_ci{ 627eace7efcSopenharmony_ci TAG_LOGI(AAFwkTag::ABILITYMGR, "call"); 628eace7efcSopenharmony_ci int count = 0; 629eace7efcSopenharmony_ci if (!data.ReadInt32(count)) { 630eace7efcSopenharmony_ci TAG_LOGE(AAFwkTag::ABILITYMGR, "fail to ReadInt32 count"); 631eace7efcSopenharmony_ci return ERR_INVALID_VALUE; 632eace7efcSopenharmony_ci } 633eace7efcSopenharmony_ci TAG_LOGI(AAFwkTag::ABILITYMGR, "count:%{public}d", count); 634eace7efcSopenharmony_ci if (count > CYCLE_LIMIT) { 635eace7efcSopenharmony_ci TAG_LOGE(AAFwkTag::ABILITYMGR, "count too large"); 636eace7efcSopenharmony_ci return ERR_INVALID_VALUE; 637eace7efcSopenharmony_ci } 638eace7efcSopenharmony_ci std::vector<std::shared_ptr<AppExecFwk::DataAbilityOperation>> operations; 639eace7efcSopenharmony_ci for (int i = 0; i < count; i++) { 640eace7efcSopenharmony_ci std::shared_ptr<AppExecFwk::DataAbilityOperation> dataAbilityOperation( 641eace7efcSopenharmony_ci data.ReadParcelable<AppExecFwk::DataAbilityOperation>()); 642eace7efcSopenharmony_ci if (dataAbilityOperation == nullptr) { 643eace7efcSopenharmony_ci TAG_LOGE(AAFwkTag::ABILITYMGR, "null dataAbilityOperation, index: %{public}d", i); 644eace7efcSopenharmony_ci return ERR_INVALID_VALUE; 645eace7efcSopenharmony_ci } 646eace7efcSopenharmony_ci operations.push_back(dataAbilityOperation); 647eace7efcSopenharmony_ci } 648eace7efcSopenharmony_ci 649eace7efcSopenharmony_ci std::vector<std::shared_ptr<AppExecFwk::DataAbilityResult>> results = ExecuteBatch(operations); 650eace7efcSopenharmony_ci int total = (int)results.size(); 651eace7efcSopenharmony_ci if (!reply.WriteInt32(total)) { 652eace7efcSopenharmony_ci TAG_LOGE(AAFwkTag::ABILITYMGR, "fail to WriteInt32 ret"); 653eace7efcSopenharmony_ci return ERR_INVALID_VALUE; 654eace7efcSopenharmony_ci } 655eace7efcSopenharmony_ci TAG_LOGI(AAFwkTag::ABILITYMGR, "total:%{public}d", total); 656eace7efcSopenharmony_ci for (int i = 0; i < total; i++) { 657eace7efcSopenharmony_ci if (results[i] == nullptr) { 658eace7efcSopenharmony_ci TAG_LOGE(AAFwkTag::ABILITYMGR, 659eace7efcSopenharmony_ci "null results[i], index: %{public}d", i); 660eace7efcSopenharmony_ci return ERR_INVALID_VALUE; 661eace7efcSopenharmony_ci } 662eace7efcSopenharmony_ci if (!reply.WriteParcelable(results[i].get())) { 663eace7efcSopenharmony_ci TAG_LOGE(AAFwkTag::ABILITYMGR, 664eace7efcSopenharmony_ci "fail to WriteParcelable operation, index: %{public}d", i); 665eace7efcSopenharmony_ci return ERR_INVALID_VALUE; 666eace7efcSopenharmony_ci } 667eace7efcSopenharmony_ci } 668eace7efcSopenharmony_ci TAG_LOGI(AAFwkTag::ABILITYMGR, "end"); 669eace7efcSopenharmony_ci return NO_ERROR; 670eace7efcSopenharmony_ci} 671eace7efcSopenharmony_ci 672eace7efcSopenharmony_ciint AbilitySchedulerStub::ContinueAbilityInner(MessageParcel &data, MessageParcel &reply) 673eace7efcSopenharmony_ci{ 674eace7efcSopenharmony_ci std::string deviceId = data.ReadString(); 675eace7efcSopenharmony_ci uint32_t versionCode = data.ReadUint32(); 676eace7efcSopenharmony_ci ContinueAbility(deviceId, versionCode); 677eace7efcSopenharmony_ci return NO_ERROR; 678eace7efcSopenharmony_ci} 679eace7efcSopenharmony_ci 680eace7efcSopenharmony_ciint AbilitySchedulerStub::NotifyContinuationResultInner(MessageParcel &data, MessageParcel &reply) 681eace7efcSopenharmony_ci{ 682eace7efcSopenharmony_ci int32_t result = data.ReadInt32(); 683eace7efcSopenharmony_ci NotifyContinuationResult(result); 684eace7efcSopenharmony_ci return NO_ERROR; 685eace7efcSopenharmony_ci} 686eace7efcSopenharmony_ci 687eace7efcSopenharmony_ciint AbilitySchedulerStub::DumpAbilityInfoInner(MessageParcel &data, MessageParcel &reply) 688eace7efcSopenharmony_ci{ 689eace7efcSopenharmony_ci std::vector<std::string> infos; 690eace7efcSopenharmony_ci std::vector<std::string> params; 691eace7efcSopenharmony_ci if (!data.ReadStringVector(¶ms)) { 692eace7efcSopenharmony_ci TAG_LOGI(AAFwkTag::ABILITYMGR, "DumpAbilityInfoInner read params error"); 693eace7efcSopenharmony_ci return ERR_INVALID_VALUE; 694eace7efcSopenharmony_ci } 695eace7efcSopenharmony_ci 696eace7efcSopenharmony_ci DumpAbilityInfo(params, infos); 697eace7efcSopenharmony_ci 698eace7efcSopenharmony_ci return NO_ERROR; 699eace7efcSopenharmony_ci} 700eace7efcSopenharmony_ci 701eace7efcSopenharmony_ciint AbilitySchedulerStub::CallRequestInner(MessageParcel &data, MessageParcel &reply) 702eace7efcSopenharmony_ci{ 703eace7efcSopenharmony_ci CallRequest(); 704eace7efcSopenharmony_ci return NO_ERROR; 705eace7efcSopenharmony_ci} 706eace7efcSopenharmony_ci 707eace7efcSopenharmony_ciint AbilitySchedulerStub::OnExecuteIntentInner(MessageParcel &data, MessageParcel &reply) 708eace7efcSopenharmony_ci{ 709eace7efcSopenharmony_ci TAG_LOGI(AAFwkTag::ABILITYMGR, "call"); 710eace7efcSopenharmony_ci std::shared_ptr<Want> want(data.ReadParcelable<Want>()); 711eace7efcSopenharmony_ci if (want == nullptr) { 712eace7efcSopenharmony_ci TAG_LOGE(AAFwkTag::ABILITYMGR, "null want"); 713eace7efcSopenharmony_ci return ERR_INVALID_VALUE; 714eace7efcSopenharmony_ci } 715eace7efcSopenharmony_ci OnExecuteIntent(*want); 716eace7efcSopenharmony_ci return NO_ERROR; 717eace7efcSopenharmony_ci} 718eace7efcSopenharmony_ci 719eace7efcSopenharmony_ciint AbilitySchedulerStub::CreateModalUIExtensionInner(MessageParcel &data, MessageParcel &reply) 720eace7efcSopenharmony_ci{ 721eace7efcSopenharmony_ci std::shared_ptr<Want> want(data.ReadParcelable<Want>()); 722eace7efcSopenharmony_ci if (want == nullptr) { 723eace7efcSopenharmony_ci TAG_LOGE(AAFwkTag::ABILITYMGR, "null want"); 724eace7efcSopenharmony_ci return ERR_INVALID_VALUE; 725eace7efcSopenharmony_ci } 726eace7efcSopenharmony_ci int ret = CreateModalUIExtension(*want); 727eace7efcSopenharmony_ci if (!reply.WriteInt32(ret)) { 728eace7efcSopenharmony_ci TAG_LOGE(AAFwkTag::ABILITYMGR, "fail to WriteInt32 ret"); 729eace7efcSopenharmony_ci return ERR_INVALID_VALUE; 730eace7efcSopenharmony_ci } 731eace7efcSopenharmony_ci return NO_ERROR; 732eace7efcSopenharmony_ci} 733eace7efcSopenharmony_ci 734eace7efcSopenharmony_ciint AbilitySchedulerStub::UpdateSessionTokenInner(MessageParcel &data, MessageParcel &reply) 735eace7efcSopenharmony_ci{ 736eace7efcSopenharmony_ci sptr<IRemoteObject> sessionToken = data.ReadRemoteObject(); 737eace7efcSopenharmony_ci UpdateSessionToken(sessionToken); 738eace7efcSopenharmony_ci return NO_ERROR; 739eace7efcSopenharmony_ci} 740eace7efcSopenharmony_ci 741eace7efcSopenharmony_civoid AbilitySchedulerRecipient::OnRemoteDied(const wptr<IRemoteObject> &remote) 742eace7efcSopenharmony_ci{ 743eace7efcSopenharmony_ci TAG_LOGE(AAFwkTag::ABILITYMGR, "call"); 744eace7efcSopenharmony_ci 745eace7efcSopenharmony_ci if (handler_) { 746eace7efcSopenharmony_ci handler_(remote); 747eace7efcSopenharmony_ci } 748eace7efcSopenharmony_ci} 749eace7efcSopenharmony_ci 750eace7efcSopenharmony_ciAbilitySchedulerRecipient::AbilitySchedulerRecipient(RemoteDiedHandler handler) : handler_(handler) 751eace7efcSopenharmony_ci{} 752eace7efcSopenharmony_ci 753eace7efcSopenharmony_ciAbilitySchedulerRecipient::~AbilitySchedulerRecipient() 754eace7efcSopenharmony_ci{} 755eace7efcSopenharmony_ci} // namespace AAFwk 756eace7efcSopenharmony_ci} // namespace OHOS 757