1 /* 2 * Copyright (C) 2022 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 AUTH_CENTER_H 17 #define AUTH_CENTER_H 18 19 #include <cstdint> 20 21 namespace OHOS { 22 namespace bluetooth { 23 class AuthCenter { 24 public: 25 static AuthCenter &GetInstance(); 26 27 /** 28 * @Description Verify where the app has the permission to use bluetooth 29 * 30 * @param pid the app's process id. 31 * @param uid the app id. 32 * @return int PERMISSION_DENIED or PERMISSION_GRANTED 33 */ 34 static int VerifyUseBluetoothPermission(const int &pid, const int &uid); 35 36 /** 37 * @Description Verify where the app has the permission to discover bluetooth 38 * 39 * @param pid the app's process id. 40 * @param uid the app id. 41 * @return int PERMISSION_DENIED or PERMISSION_GRANTED 42 */ 43 static int VerifyDiscoverBluetoothPermission(const int &pid, const int &uid); 44 45 /** 46 * @Description Verify where the app has the permission to manager bluetooth 47 * 48 * @param pid the app's process id. 49 * @param uid the app id. 50 * @return int PERMISSION_DENIED or PERMISSION_GRANTED 51 */ 52 static int VerifyManageBluetoothPermission(const int &pid, const int &uid); 53 54 /** 55 * @Description Verify where the app has the permission to Location 56 * 57 * @param pid the app's process id. 58 * @param uid the app id. 59 * @return int PERMISSION_DENIED or PERMISSION_GRANTED 60 */ 61 static int VerifyLocationPermission(const int &pid, const int &uid); 62 63 /** 64 * @Description Verify where the app has the permission to Approximately Location 65 * 66 * @param pid the app's process id. 67 * @param uid the app id. 68 * @return int PERMISSION_DENIED or PERMISSION_GRANTED 69 */ 70 static int VerifyApproximatelyPermission(const int &pid, const int &uid); 71 /** 72 * @Description Verify where the app has the permission to use bluetooth 73 * 74 * @param tokenID the app's token id. 75 * @return int PERMISSION_DENIED or PERMISSION_GRANTED 76 */ 77 static int VerifyUseBluetoothPermission(const std::uint32_t &tokenID); 78 79 /** 80 * @Description Verify where the app has the permission to discover bluetooth 81 * 82 * @param tokenID the app's token id. 83 * @return int PERMISSION_DENIED or PERMISSION_GRANTED 84 */ 85 static int VerifyDiscoverBluetoothPermission(const std::uint32_t &tokenID); 86 }; 87 } // namespace bluetooth 88 } // namespace OHOS 89 #endif