blob: d81f5142bcd9660f98c2c046a12b411d5ef50e7e [file] [log] [blame]
Svet Ganove752a5c2018-01-15 17:14:20 -08001/*
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
Jiyong Park47f876b2018-04-17 13:56:46 +090020#ifndef __ANDROID_VNDK__
21
Svet Ganove752a5c2018-01-15 17:14:20 -080022#include <binder/IPermissionController.h>
23
24#include <utils/threads.h>
25
26// ---------------------------------------------------------------------------
27namespace android {
28
29class PermissionController
30{
31public:
32
33 enum {
34 MATCH_SYSTEM_ONLY = 1<<16,
35 MATCH_UNINSTALLED_PACKAGES = 1<<13,
36 MATCH_FACTORY_ONLY = 1<<21,
37 MATCH_INSTANT = 1<<23
38 };
39
Jeff Sharkey7afcb3f2018-04-09 12:58:40 -060040 enum {
41 MODE_ALLOWED = 0,
42 MODE_IGNORED = 1,
43 MODE_ERRORED = 2,
44 MODE_DEFAULT = 3,
45 };
46
Svet Ganove752a5c2018-01-15 17:14:20 -080047 PermissionController();
48
49 bool checkPermission(const String16& permission, int32_t pid, int32_t uid);
Jeff Sharkey7afcb3f2018-04-09 12:58:40 -060050 int32_t noteOp(const String16& op, int32_t uid, const String16& packageName);
Svet Ganove752a5c2018-01-15 17:14:20 -080051 void getPackagesForUid(const uid_t uid, Vector<String16>& packages);
52 bool isRuntimePermission(const String16& permission);
53 int getPackageUid(const String16& package, int flags);
54
55private:
56 Mutex mLock;
57 sp<IPermissionController> mService;
58
59 sp<IPermissionController> getService();
60};
61
62
63}; // namespace android
64// ---------------------------------------------------------------------------
Jiyong Park47f876b2018-04-17 13:56:46 +090065#else // __ANDROID_VNDK__
66#error "This header is not visible to vendors"
67#endif // __ANDROID_VNDK__
68
Svet Ganove752a5c2018-01-15 17:14:20 -080069#endif // ANDROID_PERMISSION_CONTROLLER_H