From 2a9f32f1a21e012dfaddc571a741658eaef0d9da Mon Sep 17 00:00:00 2001 From: Steven Moreland Date: Wed, 31 Jul 2019 17:51:25 -0700 Subject: 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 --- libs/binder/Stability.cpp | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) (limited to 'libs/binder/Stability.cpp') 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 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; } -- cgit v1.2.3-59-g8ed1b