1 /*
2 * Copyright (C) 2019 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 /**
24 * Private addition to binder_flag_t.
25 */
26 enum {
27 /**
28 * Indicates that this transaction is coupled w/ vendor.img
29 */
30 FLAG_PRIVATE_VENDOR = 0x10000000,
31 };
32
33 #if defined(__ANDROID_VENDOR__)
34
35 enum {
36 FLAG_PRIVATE_LOCAL = FLAG_PRIVATE_VENDOR,
37 };
38
39 /**
40 * This interface has the stability of the vendor image.
41 */
42 void AIBinder_markVendorStability(AIBinder* binder);
43
AIBinder_markCompilationUnitStability(AIBinder * binder)44 static inline void AIBinder_markCompilationUnitStability(AIBinder* binder) {
45 AIBinder_markVendorStability(binder);
46 }
47
48 /**
49 * Given a binder interface at a certain stability, there may be some
50 * requirements associated with that higher stability level. For instance, a
51 * VINTF stability binder is required to be in the VINTF manifest. This API
52 * can be called to use that same interface within the vendor partition.
53 */
54 void AIBinder_forceDowngradeToVendorStability(AIBinder* binder);
55
AIBinder_forceDowngradeToLocalStability(AIBinder * binder)56 static inline void AIBinder_forceDowngradeToLocalStability(AIBinder* binder) {
57 AIBinder_forceDowngradeToVendorStability(binder);
58 }
59
60 #else // defined(__ANDROID_VENDOR__)
61
62 enum {
63 FLAG_PRIVATE_LOCAL = 0,
64 };
65
66 /**
67 * This interface has the stability of the system image.
68 */
69 __attribute__((weak)) void AIBinder_markSystemStability(AIBinder* binder);
70
AIBinder_markCompilationUnitStability(AIBinder * binder)71 static inline void AIBinder_markCompilationUnitStability(AIBinder* binder) {
72 if (AIBinder_markSystemStability == nullptr) return;
73
74 AIBinder_markSystemStability(binder);
75 }
76
77 /**
78 * Given a binder interface at a certain stability, there may be some
79 * requirements associated with that higher stability level. For instance, a
80 * VINTF stability binder is required to be in the VINTF manifest. This API
81 * can be called to use that same interface within the system partition.
82 */
83 void AIBinder_forceDowngradeToSystemStability(AIBinder* binder);
84
AIBinder_forceDowngradeToLocalStability(AIBinder * binder)85 static inline void AIBinder_forceDowngradeToLocalStability(AIBinder* binder) {
86 AIBinder_forceDowngradeToSystemStability(binder);
87 }
88
89 #endif // defined(__ANDROID_VENDOR__)
90
91 /**
92 * WARNING: this is not expected to be used manually. When the build system has
93 * versioned checks in place for an interface that prevent it being changed year
94 * over year (specifically like those for @VintfStability stable AIDL
95 * interfaces), this could be called. Calling this without this or equivalent
96 * infrastructure will lead to de facto frozen APIs or GSI test failures.
97 *
98 * This interface has system<->vendor stability
99 */
100 // b/227835797 - can't use __INTRODUCED_IN(30) because old targets load this code
101 #if __ANDROID_MIN_SDK_VERSION__ < 30
102 __attribute__((weak))
103 #endif // __ANDROID_MIN_SDK_VERSION__ < 30
104 void AIBinder_markVintfStability(AIBinder* binder);
105
106 __END_DECLS
107