1 /* 2 * Copyright (c) 2023 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 DRIVER_PKG_MANAGER_H 17 #define DRIVER_PKG_MANAGER_H 18 19 #include <iostream> 20 #include <stdint.h> 21 22 #include "bundle_info.h" 23 #include "bundle_mgr_proxy.h" 24 #include "single_instance.h" 25 26 namespace OHOS { 27 namespace ExternalDeviceManager { 28 using namespace std; 29 using namespace OHOS; 30 using namespace OHOS::AAFwk; 31 using namespace OHOS::AppExecFwk; 32 using namespace OHOS::ExternalDeviceManager; 33 34 enum DDK_PERMISSION { 35 ERROR, 36 CHECK, 37 NOT_CHECK 38 }; 39 40 class ExtPermissionManager { 41 DECLARE_SINGLE_INSTANCE_BASE(ExtPermissionManager); 42 43 public: 44 bool HasPermission(std::string permissionName); 45 46 ~ExtPermissionManager(); 47 private: 48 sptr<IBundleMgr> bundleMgr_ = nullptr; 49 std::mutex bundleMgrMutex_; 50 DDK_PERMISSION NeedCheckPermission(); 51 sptr<OHOS::AppExecFwk::IBundleMgr> GetBundleMgrProxy(); 52 int32_t GetCurrentActiveUserId(); 53 ExtPermissionManager(); 54 std::map<std::string, bool> rightsMap_; 55 }; 56 } // namespace ExternalDeviceManager 57 } // namespace OHOS 58 #endif // DRIVER_PKG_MANAGER_H