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

Commit 8ea00877 authored by Steven Moreland's avatar Steven Moreland Committed by android-build-merger
Browse files

Merge "libbinder: on host" am: a8cb8d76 am: 240e5819 am: 07bc79d3

am: 68ff4b6e

Change-Id: I2ab4aea327a0ecd8840699fe68c4fd2df9ff2a4c
parents 800f31ef 68ff4b6e
Loading
Loading
Loading
Loading
+37 −30
Original line number Original line Diff line number Diff line
@@ -16,6 +16,8 @@ cc_library_headers {
    name: "libbinder_headers",
    name: "libbinder_headers",
    export_include_dirs: ["include"],
    export_include_dirs: ["include"],
    vendor_available: true,
    vendor_available: true,
    host_supported: true,

    header_libs: [
    header_libs: [
        "libbase_headers",
        "libbase_headers",
        "libcutils_headers",
        "libcutils_headers",
@@ -28,6 +30,27 @@ cc_library_headers {
    ],
    ],
}
}


// These interfaces are android-specific implementation unrelated to binder
// transport itself and should be moved to AIDL or in domain-specific libs.
//
// Currently, these are only on system android (not vendor, not host)
libbinder_device_interface_sources = [
    "ActivityManager.cpp",
    "AppOpsManager.cpp",
    "IActivityManager.cpp",
    "IAppOpsCallback.cpp",
    "IAppOpsService.cpp",
    "IBatteryStats.cpp",
    "IMediaResourceMonitor.cpp",
    "IPermissionController.cpp",
    "IProcessInfoService.cpp",
    "IUidObserver.cpp",
    "PermissionCache.cpp",
    "PermissionController.cpp",
    "ProcessInfoService.cpp",
    "IpPrefix.cpp",
]

cc_library_shared {
cc_library_shared {
    name: "libbinder",
    name: "libbinder",


@@ -37,6 +60,13 @@ cc_library_shared {
        enabled: true,
        enabled: true,
    },
    },
    double_loadable: true,
    double_loadable: true,
    host_supported: true,

    // TODO(b/31559095): get headers from bionic on host
    include_dirs: [
        "bionic/libc/kernel/android/uapi/",
        "bionic/libc/kernel/uapi/",
    ],


    // libbinder does not offer a stable wire protocol.
    // libbinder does not offer a stable wire protocol.
    // if a second copy of it is installed, then it may break after security
    // if a second copy of it is installed, then it may break after security
@@ -44,62 +74,39 @@ cc_library_shared {
    no_apex: true,
    no_apex: true,


    srcs: [
    srcs: [
        "ActivityManager.cpp",
        "AppOpsManager.cpp",
        "Binder.cpp",
        "Binder.cpp",
        "BpBinder.cpp",
        "BpBinder.cpp",
        "BufferedTextOutput.cpp",
        "BufferedTextOutput.cpp",
        "Debug.cpp",
        "Debug.cpp",
        "IActivityManager.cpp",
        "IAppOpsCallback.cpp",
        "IAppOpsService.cpp",
        "IBatteryStats.cpp",
        "IInterface.cpp",
        "IInterface.cpp",
        "IMediaResourceMonitor.cpp",
        "IMemory.cpp",
        "IMemory.cpp",
        "IPCThreadState.cpp",
        "IPCThreadState.cpp",
        "IPermissionController.cpp",
        "IProcessInfoService.cpp",
        "IResultReceiver.cpp",
        "IResultReceiver.cpp",
        "IServiceManager.cpp",
        "IServiceManager.cpp",
        "IShellCallback.cpp",
        "IShellCallback.cpp",
        "IUidObserver.cpp",
        "MemoryBase.cpp",
        "MemoryBase.cpp",
        "MemoryDealer.cpp",
        "MemoryDealer.cpp",
        "MemoryHeapBase.cpp",
        "MemoryHeapBase.cpp",
        "Parcel.cpp",
        "Parcel.cpp",
        "ParcelFileDescriptor.cpp",
        "ParcelFileDescriptor.cpp",
        "PermissionCache.cpp",
        "PermissionController.cpp",
        "PersistableBundle.cpp",
        "PersistableBundle.cpp",
        "ProcessInfoService.cpp",
        "ProcessState.cpp",
        "ProcessState.cpp",
        "Static.cpp",
        "Static.cpp",
        "Stability.cpp",
        "Stability.cpp",
        "Status.cpp",
        "Status.cpp",
        "TextOutput.cpp",
        "TextOutput.cpp",
        "IpPrefix.cpp",
        ":libbinder_aidl",
        ":libbinder_aidl",
    ],
    ],


    target: {
    target: {
        android: {
            srcs: libbinder_device_interface_sources,
        },
        host: {
            cflags: ["-D__ANDROID_HOST__"],
        },
        vendor: {
        vendor: {
            exclude_srcs: [
            exclude_srcs: libbinder_device_interface_sources,
                "ActivityManager.cpp",
                "AppOpsManager.cpp",
                "IActivityManager.cpp",
                "IAppOpsCallback.cpp",
                "IAppOpsService.cpp",
                "IBatteryStats.cpp",
                "IMediaResourceMonitor.cpp",
                "IPermissionController.cpp",
                "IProcessInfoService.cpp",
                "IUidObserver.cpp",
                "PermissionCache.cpp",
                "PermissionController.cpp",
                "ProcessInfoService.cpp",
                "IpPrefix.cpp",
            ],
        },
        },
    },
    },


+13 −5
Original line number Original line Diff line number Diff line
@@ -20,15 +20,19 @@


#include <android/os/BnServiceCallback.h>
#include <android/os/BnServiceCallback.h>
#include <android/os/IServiceManager.h>
#include <android/os/IServiceManager.h>
#include <utils/Log.h>
#include <binder/IPCThreadState.h>
#include <binder/IPCThreadState.h>
#include <binder/Parcel.h>
#include <utils/Log.h>
#include <utils/String8.h>
#include <utils/SystemClock.h>

#ifndef __ANDROID_VNDK__
#ifndef __ANDROID_VNDK__
#include <binder/IPermissionController.h>
#include <binder/IPermissionController.h>
#endif
#endif
#include <binder/Parcel.h>

#ifndef __ANDROID_HOST__
#include <cutils/properties.h>
#include <cutils/properties.h>
#include <utils/String8.h>
#endif
#include <utils/SystemClock.h>


#include "Static.h"
#include "Static.h"


@@ -59,7 +63,7 @@ sp<IServiceManager> defaultServiceManager()
    return gDefaultServiceManager;
    return gDefaultServiceManager;
}
}


#ifndef __ANDROID_VNDK__
#if !defined(__ANDROID_VNDK__) && !defined(__ANDROID_HOST__)
// IPermissionController is not accessible to vendors
// IPermissionController is not accessible to vendors


bool checkCallingPermission(const String16& permission)
bool checkCallingPermission(const String16& permission)
@@ -163,10 +167,14 @@ public:
            strcmp(ProcessState::self()->getDriverName().c_str(), "/dev/vndbinder") == 0;
            strcmp(ProcessState::self()->getDriverName().c_str(), "/dev/vndbinder") == 0;
        const long timeout = uptimeMillis() + 5000;
        const long timeout = uptimeMillis() + 5000;
        if (!gSystemBootCompleted && !isVendorService) {
        if (!gSystemBootCompleted && !isVendorService) {
#ifdef __ANDROID_HOST__
            gSystemBootCompleted = true;
#else
            // Vendor code can't access system properties
            // Vendor code can't access system properties
            char bootCompleted[PROPERTY_VALUE_MAX];
            char bootCompleted[PROPERTY_VALUE_MAX];
            property_get("sys.boot_completed", bootCompleted, "0");
            property_get("sys.boot_completed", bootCompleted, "0");
            gSystemBootCompleted = strcmp(bootCompleted, "1") == 0 ? true : false;
            gSystemBootCompleted = strcmp(bootCompleted, "1") == 0 ? true : false;
#endif
        }
        }
        // retry interval in millisecond; note that vendor services stay at 100ms
        // retry interval in millisecond; note that vendor services stay at 100ms
        const long sleepTime = gSystemBootCompleted ? 1000 : 100;
        const long sleepTime = gSystemBootCompleted ? 1000 : 100;
+1 −1
Original line number Original line Diff line number Diff line
@@ -67,7 +67,7 @@
#define PAD_SIZE_UNSAFE(s) (((s)+3)&~3)
#define PAD_SIZE_UNSAFE(s) (((s)+3)&~3)


static size_t pad_size(size_t s) {
static size_t pad_size(size_t s) {
    if (s > (SIZE_T_MAX - 3)) {
    if (s > (std::numeric_limits<size_t>::max() - 3)) {
        abort();
        abort();
    }
    }
    return PAD_SIZE_UNSAFE(s);
    return PAD_SIZE_UNSAFE(s);
+2 −1
Original line number Original line Diff line number Diff line
@@ -189,7 +189,8 @@ ssize_t ProcessState::getKernelReferences(size_t buf_count, uintptr_t* buf)
}
}


void ProcessState::setCallRestriction(CallRestriction restriction) {
void ProcessState::setCallRestriction(CallRestriction restriction) {
    LOG_ALWAYS_FATAL_IF(IPCThreadState::selfOrNull(), "Call restrictions must be set before the threadpool is started.");
    LOG_ALWAYS_FATAL_IF(IPCThreadState::selfOrNull() != nullptr,
        "Call restrictions must be set before the threadpool is started.");


    mCallRestriction = restriction;
    mCallRestriction = restriction;
}
}
+3 −1
Original line number Original line Diff line number Diff line
@@ -54,7 +54,9 @@ public:
protected:
protected:
    virtual status_t writeLines(const struct iovec& vec, size_t N)
    virtual status_t writeLines(const struct iovec& vec, size_t N)
    {
    {
        writev(mFD, &vec, N);
        ssize_t ret = writev(mFD, &vec, N);
        if (ret == -1) return -errno;
        if (static_cast<size_t>(ret) != N) return UNKNOWN_ERROR;
        return NO_ERROR;
        return NO_ERROR;
    }
    }


Loading