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

Commit 55697e4d authored by Android Build Coastguard Worker's avatar Android Build Coastguard Worker
Browse files

Snap for 12190349 from 6111c62b to 24Q4-release

Change-Id: I4f548a63fbb67acd65923f847d9f50e3a2be1439
parents 41d351bf 6111c62b
Loading
Loading
Loading
Loading
+15 −10
Original line number Diff line number Diff line
@@ -52,19 +52,18 @@ HealthLoop::~HealthLoop() {
int HealthLoop::RegisterEvent(int fd, BoundFunction func, EventWakeup wakeup) {
    CHECK(!reject_event_register_);

    auto* event_handler =
            event_handlers_
                    .emplace_back(std::make_unique<EventHandler>(EventHandler{this, fd, func}))
    auto* event_handler = event_handlers_
                                  .emplace_back(std::make_unique<EventHandler>(
                                          EventHandler{this, fd, std::move(func)}))
                                  .get();

    struct epoll_event ev;

    ev.events = EPOLLIN;
    struct epoll_event ev = {
            .events = EPOLLIN | EPOLLERR,
            .data.ptr = reinterpret_cast<void*>(event_handler),
    };

    if (wakeup == EVENT_WAKEUP_FD) ev.events |= EPOLLWAKEUP;

    ev.data.ptr = reinterpret_cast<void*>(event_handler);

    if (epoll_ctl(epollfd_, EPOLL_CTL_ADD, fd, &ev) == -1) {
        KLOG_ERROR(LOG_TAG, "epoll_ctl failed; errno=%d\n", errno);
        return -1;
@@ -119,9 +118,15 @@ void HealthLoop::PeriodicChores() {

// TODO(b/140330870): Use BPF instead.
#define UEVENT_MSG_LEN 2048
void HealthLoop::UeventEvent(uint32_t /*epevents*/) {
void HealthLoop::UeventEvent(uint32_t epevents) {
    // No need to lock because uevent_fd_ is guaranteed to be initialized.

    if (epevents & EPOLLERR) {
        // The netlink receive buffer overflowed.
        ScheduleBatteryUpdate();
        return;
    }

    char msg[UEVENT_MSG_LEN + 2];
    char* cp;
    int n;