Skip to content

Commit 3001fd6

Browse files
Merge "Enable compilation of libbinder on Fuchsia" into main am: 7317ccb am: fcfe040
Original change: https://android-review.googlesource.com/c/platform/frameworks/native/+/3459704 Change-Id: I7af7ff3260fcb5b8e05a1897ad1e537d34ccdc06 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2 parents 6eb2718 + fcfe040 commit 3001fd6

4 files changed

Lines changed: 25 additions & 8 deletions

File tree

libs/binder/IPCThreadState.cpp

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@
3838
#include "Utils.h"
3939
#include "binder_module.h"
4040

41+
#if (defined(__ANDROID__) || defined(__Fuchsia__)) && !defined(BINDER_WITH_KERNEL_IPC)
42+
#error Android and Fuchsia are expected to have BINDER_WITH_KERNEL_IPC
43+
#endif
44+
4145
#if LOG_NDEBUG
4246

4347
#define IF_LOG_TRANSACTIONS() if (false)
@@ -1229,7 +1233,7 @@ status_t IPCThreadState::talkWithDriver(bool doReceive)
12291233
std::string message = logStream.str();
12301234
ALOGI("%s", message.c_str());
12311235
}
1232-
#if defined(__ANDROID__)
1236+
#if defined(BINDER_WITH_KERNEL_IPC)
12331237
if (ioctl(mProcess->mDriverFD, BINDER_WRITE_READ, &bwr) >= 0)
12341238
err = NO_ERROR;
12351239
else
@@ -1625,7 +1629,7 @@ void IPCThreadState::threadDestructor(void *st)
16251629
IPCThreadState* const self = static_cast<IPCThreadState*>(st);
16261630
if (self) {
16271631
self->flushCommands();
1628-
#if defined(__ANDROID__)
1632+
#if defined(BINDER_WITH_KERNEL_IPC)
16291633
if (self->mProcess->mDriverFD >= 0) {
16301634
ioctl(self->mProcess->mDriverFD, BINDER_THREAD_EXIT, 0);
16311635
}
@@ -1641,7 +1645,7 @@ status_t IPCThreadState::getProcessFreezeInfo(pid_t pid, uint32_t *sync_received
16411645
binder_frozen_status_info info = {};
16421646
info.pid = pid;
16431647

1644-
#if defined(__ANDROID__)
1648+
#if defined(BINDER_WITH_KERNEL_IPC)
16451649
if (ioctl(self()->mProcess->mDriverFD, BINDER_GET_FROZEN_INFO, &info) < 0)
16461650
ret = -errno;
16471651
#endif
@@ -1660,7 +1664,7 @@ status_t IPCThreadState::freeze(pid_t pid, bool enable, uint32_t timeout_ms) {
16601664
info.timeout_ms = timeout_ms;
16611665

16621666

1663-
#if defined(__ANDROID__)
1667+
#if defined(BINDER_WITH_KERNEL_IPC)
16641668
if (ioctl(self()->mProcess->mDriverFD, BINDER_FREEZE, &info) < 0)
16651669
ret = -errno;
16661670
#endif
@@ -1678,7 +1682,7 @@ void IPCThreadState::logExtendedError() {
16781682
if (!ProcessState::isDriverFeatureEnabled(ProcessState::DriverFeature::EXTENDED_ERROR))
16791683
return;
16801684

1681-
#if defined(__ANDROID__)
1685+
#if defined(BINDER_WITH_KERNEL_IPC)
16821686
if (ioctl(self()->mProcess->mDriverFD, BINDER_GET_EXTENDED_ERROR, &ee) < 0) {
16831687
ALOGE("Failed to get extended error: %s", strerror(errno));
16841688
return;

libs/binder/IServiceManager.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,11 @@
4343
#include <binder/IPermissionController.h>
4444
#endif
4545

46-
#ifdef __ANDROID__
46+
#if !(defined(__ANDROID__) || defined(__FUCHSIA))
47+
#define BINDER_SERVICEMANAGEMENT_DELEGATION_SUPPORT
48+
#endif
49+
50+
#if !defined(BINDER_SERVICEMANAGEMENT_DELEGATION_SUPPORT)
4751
#include <cutils/properties.h>
4852
#else
4953
#include "ServiceManagerHost.h"
@@ -902,7 +906,7 @@ std::vector<IServiceManager::ServiceDebugInfo> CppBackendShim::getServiceDebugIn
902906
return ret;
903907
}
904908

905-
#ifndef __ANDROID__
909+
#if defined(BINDER_SERVICEMANAGEMENT_DELEGATION_SUPPORT)
906910
// CppBackendShim for host. Implements the old libbinder android::IServiceManager API.
907911
// The internal implementation of the AIDL interface android::os::IServiceManager calls into
908912
// on-device service manager.

libs/binder/Parcel.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,8 +299,13 @@ status_t Parcel::flattenBinder(const sp<IBinder>& binder) {
299299
obj.handle = handle;
300300
obj.cookie = 0;
301301
} else {
302+
#if __linux__
302303
int policy = local->getMinSchedulerPolicy();
303304
int priority = local->getMinSchedulerPriority();
305+
#else
306+
int policy = 0;
307+
int priority = 0;
308+
#endif
304309

305310
if (policy != 0 || priority != 0) {
306311
// override value, since it is set explicitly

libs/binder/ProcessState.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,10 @@
4848
#define DEFAULT_MAX_BINDER_THREADS 15
4949
#define DEFAULT_ENABLE_ONEWAY_SPAM_DETECTION 1
5050

51+
#if defined(__ANDROID__) || defined(__Fuchsia__)
52+
#define EXPECT_BINDER_OPEN_SUCCESS
53+
#endif
54+
5155
#ifdef __ANDROID_VNDK__
5256
const char* kDefaultDriver = "/dev/vndbinder";
5357
#else
@@ -613,7 +617,7 @@ ProcessState::ProcessState(const char* driver)
613617
}
614618
}
615619

616-
#ifdef __ANDROID__
620+
#if defined(EXPECT_BINDER_OPEN_SUCCESS)
617621
LOG_ALWAYS_FATAL_IF(!opened.ok(),
618622
"Binder driver '%s' could not be opened. Error: %s. Terminating.",
619623
driver, error.c_str());

0 commit comments

Comments
 (0)