diff options
| author | 2020-11-09 21:25:28 +0000 | |
|---|---|---|
| committer | 2020-11-09 21:25:28 +0000 | |
| commit | 012eb24033608632b5eb5f73628da9486c650863 (patch) | |
| tree | 99e61b4dca91c70b494208a1016e9179833dc101 /native/android | |
| parent | fded2b6d13331c11f9ec6b149834c519382d7dc1 (diff) | |
| parent | 06dbe5bf2cbb4dac0c7294e4cad7831f0d64c889 (diff) | |
Merge "Add APermissionManager_checkPermission to libandroid"
Diffstat (limited to 'native/android')
| -rw-r--r-- | native/android/Android.bp | 1 | ||||
| -rw-r--r-- | native/android/TEST_MAPPING | 17 | ||||
| -rw-r--r-- | native/android/libandroid.map.txt | 1 | ||||
| -rw-r--r-- | native/android/permission_manager.cpp | 43 |
4 files changed, 62 insertions, 0 deletions
diff --git a/native/android/Android.bp b/native/android/Android.bp index 02e1ebe05b02..7793d6c45d5e 100644 --- a/native/android/Android.bp +++ b/native/android/Android.bp @@ -46,6 +46,7 @@ cc_library_shared { "native_window_jni.cpp", "net.c", "obb.cpp", + "permission_manager.cpp", "sensor.cpp", "sharedmem.cpp", "storage_manager.cpp", diff --git a/native/android/TEST_MAPPING b/native/android/TEST_MAPPING new file mode 100644 index 000000000000..6a5d2c008b1d --- /dev/null +++ b/native/android/TEST_MAPPING @@ -0,0 +1,17 @@ +{ + "presubmit": [ + { + "name": "CtsPermissionManagerNativeTestCases", + "file_patterns": ["permission_manager.cpp"] + }, + { + "name": "CtsPermissionTestCases", + "options": [ + { + "include-filter": "android.permission.cts.PermissionManagerNativeJniTest" + } + ], + "file_patterns": ["permission_manager.cpp"] + } + ] +} diff --git a/native/android/libandroid.map.txt b/native/android/libandroid.map.txt index 0414930b4078..3027eac3a224 100644 --- a/native/android/libandroid.map.txt +++ b/native/android/libandroid.map.txt @@ -176,6 +176,7 @@ LIBANDROID { AObbInfo_getPackageName; AObbInfo_getVersion; AObbScanner_getObbInfo; + APermissionManager_checkPermission; # introduced=31 ASensorEventQueue_disableSensor; ASensorEventQueue_enableSensor; ASensorEventQueue_getEvents; diff --git a/native/android/permission_manager.cpp b/native/android/permission_manager.cpp new file mode 100644 index 000000000000..166e00e8dbe2 --- /dev/null +++ b/native/android/permission_manager.cpp @@ -0,0 +1,43 @@ +/* + * Copyright (C) 2020 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include <android/permission_manager.h> +#include <binder/ActivityManager.h> + +namespace android { +namespace permissionmananger { + +// Global instance of ActivityManager, service is obtained only on first use. +static ActivityManager gAm; + +} // permissionmanager +} // android + +using namespace android; +using namespace permissionmananger; + +int32_t APermissionManager_checkPermission(const char* permission, + pid_t pid, + uid_t uid, + int32_t* outResult) { + status_t result = gAm.checkPermission(String16(permission), pid, uid, outResult); + if (result == DEAD_OBJECT) { + return PERMISSION_MANAGER_STATUS_SERVICE_UNAVAILABLE; + } else if (result != NO_ERROR) { + return PERMISSION_MANAGER_STATUS_ERROR_UNKNOWN; + } + return PERMISSION_MANAGER_STATUS_OK; +} |