• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2021 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef ANDROID_HARDWARE_CONTEXTHUB_COMMON_PERMISSIONS_UTIL_H
18 #define ANDROID_HARDWARE_CONTEXTHUB_COMMON_PERMISSIONS_UTIL_H
19 
20 #include <string>
21 #include <vector>
22 
23 namespace android::hardware::contexthub::common::implementation {
24 
25 // List of permissions supported by this HAL.
26 const std::string kBackgroundLocationPerm =
27     "android.permission.ACCESS_BACKGROUND_LOCATION";
28 const std::string kFineLocationPerm = "android.permission.ACCESS_FINE_LOCATION";
29 const std::string kRecordAudioPerm = "android.permission.RECORD_AUDIO";
30 const std::string kBluetoothScanPerm = "android.permission.BLUETOOTH_SCAN";
31 const std::vector<std::string> kSupportedPermissions = {
32     kBackgroundLocationPerm, kFineLocationPerm, kRecordAudioPerm,
33     kBluetoothScanPerm};
34 
35 //! Converts the CHRE permissions bitmask to a list of CHRE permissions.
36 std::vector<std::string> chreToAndroidPermissions(uint32_t chrePermissions);
37 
38 //! Converts list of Android permissions to CHRE permissions.
39 uint32_t androidToChrePermissions(
40     const std::vector<std::string> &androidPermissions);
41 
42 }  // namespace android::hardware::contexthub::common::implementation
43 
44 #endif  // ANDROID_HARDWARE_CONTEXTHUB_COMMON_PERMISSIONS_UTIL_H
45