PermissionController.h revision e752a5cc64b78f799525aa4e44e5f74e8c402465
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 PermissionController(); 39 40 bool checkPermission(const String16& permission, int32_t pid, int32_t uid); 41 void getPackagesForUid(const uid_t uid, Vector<String16>& packages); 42 bool isRuntimePermission(const String16& permission); 43 int getPackageUid(const String16& package, int flags); 44 45private: 46 Mutex mLock; 47 sp<IPermissionController> mService; 48 49 sp<IPermissionController> getService(); 50}; 51 52 53}; // namespace android 54// --------------------------------------------------------------------------- 55#endif // ANDROID_PERMISSION_CONTROLLER_H 56