• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2020 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 #pragma once
18 
19 #include <android/binder_ibinder.h>
20 
21 __BEGIN_DECLS
22 
23 // platform values for binder_flags_t
24 enum {
25     /**
26      * The transaction and reply will be cleared by the kernel in read-only
27      * binder buffers storing transactions.
28      *
29      * Introduced in API level 31.
30      */
31     FLAG_CLEAR_BUF = 0x20,
32 };
33 
34 /**
35  * Makes calls to AIBinder_getCallingSid work if the kernel supports it. This
36  * must be called on a local binder server before it is sent out to any othe
37  * process. If this is a remote binder, it will abort. If the kernel doesn't
38  * support this feature, you'll always get null from AIBinder_getCallingSid.
39  *
40  * \param binder local server binder to request security contexts on
41  */
42 __attribute__((weak)) void AIBinder_setRequestingSid(AIBinder* binder, bool requestingSid)
43         __INTRODUCED_IN(31);
44 
45 /**
46  * Returns the selinux context of the callee.
47  *
48  * In order for this to work, the following conditions must be met:
49  * - The kernel must be new enough to support this feature.
50  * - The server must have called AIBinder_setRequestingSid.
51  * - The callee must be a remote process.
52  *
53  * \return security context or null if unavailable. The lifetime of this context
54  * is the lifetime of the transaction.
55  */
56 __attribute__((weak, warn_unused_result)) const char* AIBinder_getCallingSid() __INTRODUCED_IN(31);
57 
58 /**
59  * Sets a minimum scheduler policy for all transactions coming into this
60  * AIBinder.
61  *
62  * This must be called before the object is sent to another process.
63  * Aborts on invalid values. Not thread safe.
64  *
65  * \param binder local server binder to set the policy for
66  * \param policy scheduler policy as defined in linux UAPI
67  * \param priority priority. [-20..19] for SCHED_NORMAL, [1..99] for RT
68  */
69 void AIBinder_setMinSchedulerPolicy(AIBinder* binder, int policy, int priority) __INTRODUCED_IN(33);
70 
71 /**
72  * Allow the binder to inherit realtime scheduling policies from its caller.
73  *
74  * This must be called before the object is sent to another process. Not thread
75  * safe.
76  *
77  * \param binder local server binder to set the policy for
78  * \param inheritRt whether to inherit realtime scheduling policies (default is
79  *     false).
80  */
81 void AIBinder_setInheritRt(AIBinder* binder, bool inheritRt) __INTRODUCED_IN(33);
82 
83 __END_DECLS
84