Loading libs/binder/Android.bp +37 −30 Original line number Original line Diff line number Diff line Loading @@ -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", Loading @@ -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", Loading @@ -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 Loading @@ -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", ], }, }, }, }, Loading libs/binder/IServiceManager.cpp +13 −5 Original line number Original line Diff line number Diff line Loading @@ -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" Loading Loading @@ -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) Loading Loading @@ -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; Loading libs/binder/Parcel.cpp +1 −1 Original line number Original line Diff line number Diff line Loading @@ -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); Loading libs/binder/ProcessState.cpp +2 −1 Original line number Original line Diff line number Diff line Loading @@ -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; } } Loading libs/binder/Static.cpp +3 −1 Original line number Original line Diff line number Diff line Loading @@ -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 Loading
libs/binder/Android.bp +37 −30 Original line number Original line Diff line number Diff line Loading @@ -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", Loading @@ -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", Loading @@ -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 Loading @@ -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", ], }, }, }, }, Loading
libs/binder/IServiceManager.cpp +13 −5 Original line number Original line Diff line number Diff line Loading @@ -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" Loading Loading @@ -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) Loading Loading @@ -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; Loading
libs/binder/Parcel.cpp +1 −1 Original line number Original line Diff line number Diff line Loading @@ -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); Loading
libs/binder/ProcessState.cpp +2 −1 Original line number Original line Diff line number Diff line Loading @@ -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; } } Loading
libs/binder/Static.cpp +3 −1 Original line number Original line Diff line number Diff line Loading @@ -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