diff options
author | 2019-07-31 17:51:25 -0700 | |
---|---|---|
committer | 2019-08-02 20:34:44 -0700 | |
commit | 2a9f32f1a21e012dfaddc571a741658eaef0d9da (patch) | |
tree | 90423b51ab1506416e1e114fcbe9dd690e499fda /libs/binder/Stability.cpp | |
parent | bec7c58e8c98d4517296e7001dbafe414a993f2e (diff) |
Set stability for unset interfaces.
This specifically has handwritten interfaces in mind. This CL ensures
that if there is a handwritten interface, it'll be marked with 'local'
stability before it is sent out. This means that a handwritten interface
won't accidentally be interpretted as a stable interface.
Bug: 136027762
Test: boot
Merged-In: I97e3e7c72f99e12dbf00996ff0c68fb683f3c494
Change-Id: I97e3e7c72f99e12dbf00996ff0c68fb683f3c494
Diffstat (limited to 'libs/binder/Stability.cpp')
-rw-r--r-- | libs/binder/Stability.cpp | 34 |
1 files changed, 17 insertions, 17 deletions
diff --git a/libs/binder/Stability.cpp b/libs/binder/Stability.cpp index d6d312a842..f18bdca1fd 100644 --- a/libs/binder/Stability.cpp +++ b/libs/binder/Stability.cpp @@ -13,29 +13,26 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - #include <binder/Stability.h> namespace android { namespace internal { void Stability::markCompilationUnit(IBinder* binder) { -#ifdef __ANDROID_VNDK__ -constexpr Stability::Level kLocalStability = Stability::Level::VENDOR; -#else -constexpr Stability::Level kLocalStability = Stability::Level::SYSTEM; -#endif - - status_t result = set(binder, kLocalStability); + status_t result = set(binder, kLocalStability, true /*log*/); LOG_ALWAYS_FATAL_IF(result != OK, "Should only mark known object."); } void Stability::markVintf(IBinder* binder) { - status_t result = set(binder, Level::VINTF); + status_t result = set(binder, Level::VINTF, true /*log*/); LOG_ALWAYS_FATAL_IF(result != OK, "Should only mark known object."); } -status_t Stability::set(IBinder* binder, int32_t stability) { +void Stability::tryMarkCompilationUnit(IBinder* binder) { + (void) set(binder, kLocalStability, false /*log*/); +} + +status_t Stability::set(IBinder* binder, int32_t stability, bool log) { Level currentStability = get(binder); // null binder is always written w/ 'UNDECLARED' stability @@ -43,23 +40,26 @@ status_t Stability::set(IBinder* binder, int32_t stability) { if (stability == UNDECLARED) { return OK; } else { - ALOGE("Null binder written with stability %s.", stabilityString(stability).c_str()); + if (log) { + ALOGE("Null binder written with stability %s.", + stabilityString(stability).c_str()); + } return BAD_TYPE; } } if (!isDeclaredStability(stability)) { - // There are UNDECLARED sets because some binder interfaces don't set their stability, and - // then UNDECLARED stability is sent on the other side. - if (stability != UNDECLARED) { + if (log) { ALOGE("Can only set known stability, not %d.", stability); - return BAD_TYPE; } + return BAD_TYPE; } if (currentStability != Level::UNDECLARED && currentStability != stability) { - ALOGE("Interface being set with %s but it is already marked as %s.", - stabilityString(stability).c_str(), stabilityString(stability).c_str()); + if (log) { + ALOGE("Interface being set with %s but it is already marked as %s.", + stabilityString(stability).c_str(), stabilityString(stability).c_str()); + } return BAD_TYPE; } |