1 /* 2 * Copyright (c) 2025 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 INTERFACES_ETS_ANI_PRIVACY_MANAGER_H 17 #define INTERFACES_ETS_ANI_PRIVACY_MANAGER_H 18 19 #include <memory> 20 #include <thread> 21 #include <string> 22 #include <vector> 23 24 #include "ani.h" 25 #include "perm_active_status_customized_cbk.h" 26 27 namespace OHOS { 28 namespace Security { 29 namespace AccessToken { 30 class PermActiveStatusPtr : public std::enable_shared_from_this<PermActiveStatusPtr>, 31 public PermActiveStatusCustomizedCbk { 32 public: 33 explicit PermActiveStatusPtr(const std::vector<std::string>& permList); 34 ~PermActiveStatusPtr() override; 35 void ActiveStatusChangeCallback(ActiveChangeResponse& result) override; 36 void SetVm(ani_vm* vm); 37 void SetEnv(ani_env* env); 38 void SetCallbackRef(const ani_ref& ref); 39 void SetThreadId(const std::thread::id threadId); 40 private: 41 ani_env* env_ = nullptr; 42 ani_vm* vm_ = nullptr; 43 ani_ref ref_ = nullptr; 44 std::thread::id threadId_; 45 }; 46 47 struct RegisterPermActiveChangeContext { 48 ani_env* env = nullptr; 49 ani_ref callbackRef = nullptr; 50 std::string type; 51 std::vector<std::string> permissionList; 52 std::shared_ptr<PermActiveStatusPtr> subscriber = nullptr; 53 std::thread::id threadId; 54 }; 55 } // namespace AccessToken 56 } // namespace Security 57 } // namespace OHOS 58 #endif /* INTERFACES_ETS_ANI_PRIVACY_MANAGER_H */ 59