1 /* 2 * Copyright (c) 2022 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef OHOS_DISTRIBUTED_ABILITY_MANAGER_STUB_H 17 #define OHOS_DISTRIBUTED_ABILITY_MANAGER_STUB_H 18 19 #include <functional> 20 #include <map> 21 22 #include "distributed_ability_manager_interface.h" 23 #include "ipc_types.h" 24 #include "iremote_stub.h" 25 #include "message_option.h" 26 #include "message_parcel.h" 27 #include "refbase.h" 28 29 namespace OHOS { 30 namespace DistributedSchedule { 31 class DistributedAbilityManagerStub : public IRemoteStub<IDistributedAbilityManager> { 32 public: 33 DistributedAbilityManagerStub(); 34 ~DistributedAbilityManagerStub(); 35 int32_t OnRemoteRequest(uint32_t code, MessageParcel& data, 36 MessageParcel& reply, MessageOption& option) override; SendRequestToImpl(uint32_t code,MessageParcel & data,MessageParcel & reply,MessageOption & option)37 virtual int32_t SendRequestToImpl(uint32_t code, MessageParcel& data, MessageParcel& reply, 38 MessageOption& option) 39 { 40 return ERR_NONE; 41 } IsDistributedSchedLoaded()42 virtual bool IsDistributedSchedLoaded() 43 { 44 return false; 45 } 46 47 private: 48 bool EnforceInterfaceToken(MessageParcel& data); 49 50 int32_t RegisterInner(MessageParcel& data, MessageParcel& reply); 51 int32_t UnregisterInner(MessageParcel& data, MessageParcel& reply); 52 int32_t RegisterDeviceSelectionCallbackInner(MessageParcel& data, MessageParcel& reply); 53 int32_t UnregisterDeviceSelectionCallbackInner(MessageParcel& data, MessageParcel& reply); 54 int32_t UpdateConnectStatusInner(MessageParcel& data, MessageParcel& reply); 55 int32_t StartDeviceManagerInner(MessageParcel& data, MessageParcel& reply); 56 int32_t GetDistributedComponentListInner(MessageParcel& data, MessageParcel& reply, MessageOption& option); 57 bool VerifyPermission(uint32_t accessToken, const std::string& permissionName) const; 58 59 using Func = int32_t(DistributedAbilityManagerStub::*)(MessageParcel& data, MessageParcel& reply); 60 std::map<uint32_t, Func> funcsMap_; 61 using distributedFunc = int32_t(DistributedAbilityManagerStub::*)(MessageParcel& data, 62 MessageParcel& reply, MessageOption& option); 63 std::map<uint32_t, distributedFunc> distributedFuncMap_; 64 }; 65 } // namespace DistributedSchedule 66 } // namespace OHOS 67 #endif // OHOS_DISTRIBUTED_ABILITY_MANAGER_STUB_H