Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b9c5a306 authored by Steven Moreland's avatar Steven Moreland Committed by Automerger Merge Worker
Browse files

Merge "libbinder: stricter APEX + VNDK stability checks" am: 635bd936 am:...

Merge "libbinder: stricter APEX + VNDK stability checks" am: 635bd936 am: 8a2eacaa am: 69b471fd am: d2e417ca am: 365abf72

Original change: https://android-review.googlesource.com/c/platform/frameworks/native/+/1377396

Change-Id: Ifa190fa5e159fe8a2452e7814878112c4b06e52a
parents eaec7372 365abf72
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -127,6 +127,10 @@ cc_library {
        export_aidl_headers: true,
    },

    // TODO(b/142684679): for com.android.media which is compiled
    // as vendor and used as system code.
    use_apex_name_macro: true,

    cflags: [
        "-Wall",
        "-Wextra",
+1 −1
Original line number Diff line number Diff line
@@ -224,7 +224,7 @@ status_t BpBinder::transact(
            using android::internal::Stability;

            auto stability = Stability::get(this);
            auto required = privateVendor ? Stability::VENDOR : Stability::kLocalStability;
            auto required = privateVendor ? Stability::VENDOR : Stability::getLocalStability();

            if (CC_UNLIKELY(!Stability::check(stability, required))) {
                ALOGE("Cannot do a user transaction on a %s binder in a %s context.",
+21 −2
Original line number Diff line number Diff line
@@ -22,7 +22,7 @@ namespace android {
namespace internal {

void Stability::markCompilationUnit(IBinder* binder) {
    status_t result = set(binder, kLocalStability, true /*log*/);
    status_t result = set(binder, getLocalStability(), true /*log*/);
    LOG_ALWAYS_FATAL_IF(result != OK, "Should only mark known object.");
}

@@ -45,7 +45,26 @@ bool Stability::requiresVintfDeclaration(const sp<IBinder>& binder) {
}

void Stability::tryMarkCompilationUnit(IBinder* binder) {
    (void) set(binder, kLocalStability, false /*log*/);
    (void) set(binder, getLocalStability(), false /*log*/);
}

Stability::Level Stability::getLocalStability() {
#ifdef __ANDROID_VNDK__
    #ifdef __ANDROID_APEX__
        // TODO(b/142684679) avoid use_vendor on system APEXes
        #if !defined(__ANDROID_APEX_COM_ANDROID_MEDIA_SWCODEC__) \
            && !defined(__ANDROID_APEX_TEST_COM_ANDROID_MEDIA_SWCODEC__)
        #error VNDK + APEX only defined for com.android.media.swcodec
        #endif
        // TODO(b/142684679) avoid use_vendor on system APEXes
        return Level::SYSTEM;
    #else
        return Level::VENDOR;
    #endif
#else
    // TODO(b/139325195): split up stability levels for system/APEX.
    return Level::SYSTEM;
#endif
}

status_t Stability::set(IBinder* binder, int32_t stability, bool log) {
+2 −5
Original line number Diff line number Diff line
@@ -81,11 +81,8 @@ private:
        VINTF = 0b111111,
    };

#if defined(__ANDROID_VNDK__) && !defined(__ANDROID_APEX__)
    static constexpr Level kLocalStability = Level::VENDOR;
#else
    static constexpr Level kLocalStability = Level::SYSTEM;
#endif
    // returns the stability according to how this was built
    static Level getLocalStability();

    // applies stability to binder if stability level is known
    __attribute__((warn_unused_result))