1 /* 2 * Copyright (c) 2021 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 17 #ifndef LOCAL_ABILITY_MANAGER_STUB_H 18 #define LOCAL_ABILITY_MANAGER_STUB_H 19 20 #include <map> 21 22 #include "ipc_object_stub.h" 23 #include "refbase.h" 24 #include "if_local_ability_manager.h" 25 #include "nlohmann/json.hpp" 26 27 namespace OHOS { 28 class LocalAbilityManagerStub : public IRemoteStub<ILocalAbilityManager> { 29 public: 30 LocalAbilityManagerStub(); 31 ~LocalAbilityManagerStub() = default; 32 int32_t OnRemoteRequest(uint32_t code, MessageParcel& data, MessageParcel& reply, MessageOption& option) override; 33 34 protected: 35 static bool CheckInputSysAbilityId(int32_t systemAbilityId); 36 37 private: LocalStartAbility(LocalAbilityManagerStub * stub,MessageParcel & data,MessageParcel & reply)38 static int32_t LocalStartAbility(LocalAbilityManagerStub* stub, MessageParcel& data, MessageParcel& reply) 39 { 40 return stub->StartAbilityInner(data, reply); 41 } LocalStopAbility(LocalAbilityManagerStub * stub,MessageParcel & data,MessageParcel & reply)42 static int32_t LocalStopAbility(LocalAbilityManagerStub* stub, MessageParcel& data, MessageParcel& reply) 43 { 44 return stub->StopAbilityInner(data, reply); 45 } LocalActiveAbility(LocalAbilityManagerStub * stub,MessageParcel & data,MessageParcel & reply)46 static int32_t LocalActiveAbility(LocalAbilityManagerStub* stub, MessageParcel& data, MessageParcel& reply) 47 { 48 return stub->ActiveAbilityInner(data, reply); 49 } LocalIdleAbility(LocalAbilityManagerStub * stub,MessageParcel & data,MessageParcel & reply)50 static int32_t LocalIdleAbility(LocalAbilityManagerStub* stub, MessageParcel& data, MessageParcel& reply) 51 { 52 return stub->IdleAbilityInner(data, reply); 53 } LocalSendStrategyToSA(LocalAbilityManagerStub * stub,MessageParcel & data,MessageParcel & reply)54 static int32_t LocalSendStrategyToSA(LocalAbilityManagerStub* stub, MessageParcel& data, MessageParcel& reply) 55 { 56 return stub->SendStrategyToSAInner(data, reply); 57 } LocalIpcStatCmdProc(LocalAbilityManagerStub * stub,MessageParcel & data,MessageParcel & reply)58 static int32_t LocalIpcStatCmdProc(LocalAbilityManagerStub* stub, MessageParcel& data, MessageParcel& reply) 59 { 60 return stub->IpcStatCmdProcInner(data, reply); 61 } LocalFfrtStatCmdProc(LocalAbilityManagerStub * stub,MessageParcel & data,MessageParcel & reply)62 static int32_t LocalFfrtStatCmdProc(LocalAbilityManagerStub* stub, MessageParcel& data, MessageParcel& reply) 63 { 64 return stub->FfrtStatCmdProcInner(data, reply); 65 } LocalFfrtDumperProc(LocalAbilityManagerStub * stub,MessageParcel & data,MessageParcel & reply)66 static int32_t LocalFfrtDumperProc(LocalAbilityManagerStub* stub, MessageParcel& data, MessageParcel& reply) 67 { 68 return stub->FfrtDumperProcInner(data, reply); 69 } LocalSystemAbilityExtProc(LocalAbilityManagerStub * stub,MessageParcel & data,MessageParcel & reply)70 static int32_t LocalSystemAbilityExtProc(LocalAbilityManagerStub* stub, MessageParcel& data, MessageParcel& reply) 71 { 72 return stub->SystemAbilityExtProcInner(data, reply); 73 } LocalServiceControlCmd(LocalAbilityManagerStub * stub,MessageParcel & data,MessageParcel & reply)74 static int32_t LocalServiceControlCmd(LocalAbilityManagerStub* stub, MessageParcel& data, MessageParcel& reply) 75 { 76 return stub->ServiceControlCmdInner(data, reply); 77 } 78 int32_t StartAbilityInner(MessageParcel& data, MessageParcel& reply); 79 int32_t StopAbilityInner(MessageParcel& data, MessageParcel& reply); 80 int32_t ActiveAbilityInner(MessageParcel& data, MessageParcel& reply); 81 int32_t IdleAbilityInner(MessageParcel& data, MessageParcel& reply); 82 int32_t SendStrategyToSAInner(MessageParcel& data, MessageParcel& reply); 83 int32_t IpcStatCmdProcInner(MessageParcel& data, MessageParcel& reply); 84 int32_t FfrtStatCmdProcInner(MessageParcel& data, MessageParcel& reply); 85 int32_t FfrtDumperProcInner(MessageParcel& data, MessageParcel& reply); 86 int32_t SystemAbilityExtProcInner(MessageParcel& data, MessageParcel& reply); 87 int32_t ServiceControlCmdInner(MessageParcel& data, MessageParcel& reply); 88 static bool CanRequest(); 89 static bool EnforceInterceToken(MessageParcel& data); 90 static bool CheckPermission(uint32_t code); 91 92 using LocalAbilityManagerStubFunc = 93 int32_t (*)(LocalAbilityManagerStub* stub, MessageParcel& data, MessageParcel& reply); 94 std::map<uint32_t, LocalAbilityManagerStubFunc> memberFuncMap_; 95 }; 96 } 97 #endif 98