PermissionController.h revision 7afcb3f98e7342985ba5e62bf6d3a5ac1282e545
1/* 2 * Copyright (C) 2018 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_PERMISSION_CONTROLLER_H 18#define ANDROID_PERMISSION_CONTROLLER_H 19 20#include <binder/IPermissionController.h> 21 22#include <utils/threads.h> 23 24// --------------------------------------------------------------------------- 25namespace android { 26 27class PermissionController 28{ 29public: 30 31 enum { 32 MATCH_SYSTEM_ONLY = 1<<16, 33 MATCH_UNINSTALLED_PACKAGES = 1<<13, 34 MATCH_FACTORY_ONLY = 1<<21, 35 MATCH_INSTANT = 1<<23 36 }; 37 38 enum { 39 MODE_ALLOWED = 0, 40 MODE_IGNORED = 1, 41 MODE_ERRORED = 2, 42 MODE_DEFAULT = 3, 43 }; 44 45 PermissionController(); 46 47 bool checkPermission(const String16& permission, int32_t pid, int32_t uid); 48 int32_t noteOp(const String16& op, int32_t uid, const String16& packageName); 49 void getPackagesForUid(const uid_t uid, Vector<String16>& packages); 50 bool isRuntimePermission(const String16& permission); 51 int getPackageUid(const String16& package, int flags); 52 53private: 54 Mutex mLock; 55 sp<IPermissionController> mService; 56 57 sp<IPermissionController> getService(); 58}; 59 60 61}; // namespace android 62// --------------------------------------------------------------------------- 63#endif // ANDROID_PERMISSION_CONTROLLER_H 64