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 /** 73 * @Description Verify where the app has the permission to access bluetooth 74 * 75 * @param pid the app's process id. 76 * @param uid the app id. 77 * @return int PERMISSION_DENIED or PERMISSION_GRANTED 78 */ 79 static int VerifyAccessBluetoothPermission(const int &pid, const int &uid); 80 81 /** 82 * @Description Verify where the app has the permission to get bluetooth local mac 83 * 84 * @param pid the app's process id. 85 * @param uid the app id. 86 * @return int PERMISSION_DENIED or PERMISSION_GRANTED 87 */ 88 static int VerifyGetBluetoothLocalMacPermission(const int &pid, const int &uid); 89 90 /** 91 * @Description Verify where the app has the permission to use bluetooth 92 * 93 * @param tokenID the app's token id. 94 * @return int PERMISSION_DENIED or PERMISSION_GRANTED 95 */ 96 static int VerifyUseBluetoothPermission(const std::uint32_t &tokenID); 97 98 /** 99 * @Description Verify where the app has the permission to discover bluetooth 100 * 101 * @param tokenID the app's token id. 102 * @return int PERMISSION_DENIED or PERMISSION_GRANTED 103 */ 104 static int VerifyDiscoverBluetoothPermission(const std::uint32_t &tokenID); 105 }; 106 } // namespace bluetooth 107 } // namespace OHOS 108 #endif