Merge "Add APermissionManager_checkPermission to libandroid"
This commit is contained in:
committed by
Android (Google) Code Review
commit
012eb24033
@@ -98,6 +98,8 @@ interface IActivityManager {
|
||||
void unregisterUidObserver(in IUidObserver observer);
|
||||
boolean isUidActive(int uid, String callingPackage);
|
||||
int getUidProcessState(int uid, in String callingPackage);
|
||||
@UnsupportedAppUsage
|
||||
int checkPermission(in String permission, int pid, int uid);
|
||||
// =============== End of transactions used on native side as well ============================
|
||||
|
||||
// Special low-level communication with activity manager.
|
||||
@@ -215,8 +217,6 @@ interface IActivityManager {
|
||||
void setProcessLimit(int max);
|
||||
@UnsupportedAppUsage
|
||||
int getProcessLimit();
|
||||
@UnsupportedAppUsage
|
||||
int checkPermission(in String permission, int pid, int uid);
|
||||
int checkUriPermission(in Uri uri, int pid, int uid, int mode, int userId,
|
||||
in IBinder callerToken);
|
||||
void grantUriPermission(in IApplicationThread caller, in String targetPkg, in Uri uri,
|
||||
|
||||
@@ -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",
|
||||
|
||||
17
native/android/TEST_MAPPING
Normal file
17
native/android/TEST_MAPPING
Normal file
@@ -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"]
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -176,6 +176,7 @@ LIBANDROID {
|
||||
AObbInfo_getPackageName;
|
||||
AObbInfo_getVersion;
|
||||
AObbScanner_getObbInfo;
|
||||
APermissionManager_checkPermission; # introduced=31
|
||||
ASensorEventQueue_disableSensor;
|
||||
ASensorEventQueue_enableSensor;
|
||||
ASensorEventQueue_getEvents;
|
||||
|
||||
43
native/android/permission_manager.cpp
Normal file
43
native/android/permission_manager.cpp
Normal file
@@ -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;
|
||||
}
|
||||
Reference in New Issue
Block a user