1 /* 2 * Copyright (c) 2024 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 ABILITY_MANAGER_ACCESS_LOADER_H 17 #define ABILITY_MANAGER_ACCESS_LOADER_H 18 19 #include <iremote_proxy.h> 20 #include <optional> 21 #include "access_token.h" 22 23 namespace OHOS { 24 namespace Security { 25 namespace AccessToken { 26 const static std::string ABILITY_MANAGER_LIBPATH = "libaccesstoken_ability_manager_adapter.z.so"; 27 28 struct InnerWant { 29 std::optional<std::string> bundleName; 30 std::optional<std::string> abilityName; 31 std::optional<std::string> hapBundleName; 32 std::optional<std::string> resource; 33 std::optional<int> hapAppIndex; 34 std::optional<int> hapUserID; 35 std::optional<AccessTokenID> callerTokenId; 36 }; 37 38 class AbilityManagerAccessLoaderInterface { 39 public: AbilityManagerAccessLoaderInterface()40 AbilityManagerAccessLoaderInterface() {} ~AbilityManagerAccessLoaderInterface()41 virtual ~AbilityManagerAccessLoaderInterface() {} 42 virtual int32_t StartAbility(const InnerWant &innerWant, const sptr<IRemoteObject> &callerToken); 43 virtual int32_t KillProcessForPermissionUpdate(uint32_t accessTokenId); 44 }; 45 46 class AbilityManagerAccessLoader final: public AbilityManagerAccessLoaderInterface { 47 int32_t StartAbility(const InnerWant &innerWant, const sptr<IRemoteObject> &callerToken) override; 48 int32_t KillProcessForPermissionUpdate(uint32_t accessTokenId) override; 49 }; 50 51 #ifdef __cplusplus 52 extern "C" { 53 #endif 54 __attribute__((visibility("default"))) void* Create(); 55 __attribute__((visibility("default"))) void Destroy(void* loaderPtr); 56 #ifdef __cplusplus 57 } 58 #endif 59 } // namespace AccessToken 60 } // namespace Security 61 } // namespace OHOS 62 #endif // ABILITY_MANAGER_ACCESS_LOADER_H 63