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 } LocalFfrtDumperProc(LocalAbilityManagerStub * stub,MessageParcel & data,MessageParcel & reply)62 static int32_t LocalFfrtDumperProc(LocalAbilityManagerStub* stub, MessageParcel& data, MessageParcel& reply) 63 { 64 return stub->FfrtDumperProcInner(data, reply); 65 } LocalSystemAbilityExtProc(LocalAbilityManagerStub * stub,MessageParcel & data,MessageParcel & reply)66 static int32_t LocalSystemAbilityExtProc(LocalAbilityManagerStub* stub, MessageParcel& data, MessageParcel& reply) 67 { 68 return stub->SystemAbilityExtProcInner(data, reply); 69 } 70 int32_t StartAbilityInner(MessageParcel& data, MessageParcel& reply); 71 int32_t StopAbilityInner(MessageParcel& data, MessageParcel& reply); 72 int32_t ActiveAbilityInner(MessageParcel& data, MessageParcel& reply); 73 int32_t IdleAbilityInner(MessageParcel& data, MessageParcel& reply); 74 int32_t SendStrategyToSAInner(MessageParcel& data, MessageParcel& reply); 75 int32_t IpcStatCmdProcInner(MessageParcel& data, MessageParcel& reply); 76 int32_t FfrtDumperProcInner(MessageParcel& data, MessageParcel& reply); 77 int32_t SystemAbilityExtProcInner(MessageParcel& data, MessageParcel& reply); 78 static bool CanRequest(); 79 static bool EnforceInterceToken(MessageParcel& data); 80 static bool CheckPermission(uint32_t code); 81 82 using LocalAbilityManagerStubFunc = 83 int32_t (*)(LocalAbilityManagerStub* stub, MessageParcel& data, MessageParcel& reply); 84 std::map<uint32_t, LocalAbilityManagerStubFunc> memberFuncMap_; 85 }; 86 } 87 #endif 88