• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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  * WARNING: you must hold on to a binder instance after this is set, while you
55  * are using it. If you get a binder (e.g. `...->asBinder().get()`), you must
56  * save this binder and then
57  * use it. For instance:
58  *
59  *     auto binder = ...->asBinder();
60  *     AIBinder_forceDowngradeToVendorStability(binder.get());
61  *     doSomething(binder);
62  */
63 void AIBinder_forceDowngradeToVendorStability(AIBinder* binder);
64 
AIBinder_forceDowngradeToLocalStability(AIBinder * binder)65 static inline void AIBinder_forceDowngradeToLocalStability(AIBinder* binder) {
66     AIBinder_forceDowngradeToVendorStability(binder);
67 }
68 
69 #else  // defined(__ANDROID_VENDOR__)
70 
71 enum {
72     FLAG_PRIVATE_LOCAL = 0,
73 };
74 
75 /**
76  * This interface has the stability of the system image.
77  */
78 __attribute__((weak)) void AIBinder_markSystemStability(AIBinder* binder);
79 
AIBinder_markCompilationUnitStability(AIBinder * binder)80 static inline void AIBinder_markCompilationUnitStability(AIBinder* binder) {
81     if (AIBinder_markSystemStability == nullptr) return;
82 
83     AIBinder_markSystemStability(binder);
84 }
85 
86 /**
87  * Given a binder interface at a certain stability, there may be some
88  * requirements associated with that higher stability level. For instance, a
89  * VINTF stability binder is required to be in the VINTF manifest. This API
90  * can be called to use that same interface within the system partition.
91  *
92  * WARNING: you must hold on to a binder instance after this is set, while you
93  * are using it. If you get a binder (e.g. `...->asBinder().get()`), you must
94  * save this binder and then
95  * use it. For instance:
96  *
97  *     auto binder = ...->asBinder();
98  *     AIBinder_forceDowngradeToSystemStability(binder.get());
99  *     doSomething(binder);
100  */
101 void AIBinder_forceDowngradeToSystemStability(AIBinder* binder);
102 
AIBinder_forceDowngradeToLocalStability(AIBinder * binder)103 static inline void AIBinder_forceDowngradeToLocalStability(AIBinder* binder) {
104     AIBinder_forceDowngradeToSystemStability(binder);
105 }
106 
107 #endif  // defined(__ANDROID_VENDOR__)
108 
109 /**
110  * WARNING: this is not expected to be used manually. When the build system has
111  * versioned checks in place for an interface that prevent it being changed year
112  * over year (specifically like those for @VintfStability stable AIDL
113  * interfaces), this could be called. Calling this without this or equivalent
114  * infrastructure will lead to de facto frozen APIs or GSI test failures.
115  *
116  * This interface has system<->vendor stability
117  */
118 // b/227835797 - can't use __INTRODUCED_IN(30) because old targets load this code
119 #if defined(__ANDROID_MIN_SDK_VERSION__) && __ANDROID_MIN_SDK_VERSION__ < 30
120 __attribute__((weak))
121 #endif  // defined(__ANDROID_MIN_SDK_VERSION__) && __ANDROID_MIN_SDK_VERSION__ < 30
122 void AIBinder_markVintfStability(AIBinder* binder);
123 
124 __END_DECLS
125