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

Commit 6ae5c4f5 authored by Felipe Leme's avatar Felipe Leme
Browse files

Reverted wake_lock code.

If dumpstate dies, there is no guarantee the wake_lock will be released...

Fixes: 34193090
Bug: 33327009

Test: dumpstate_test passes
Test: manual verification
Change-Id: I4662722b1f82f3e140e174e506864a452c002fc8
parent ff0a399e
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -21,7 +21,6 @@ COMMON_SHARED_LIBRARIES := \
        libbinder \
        libcutils \
        libdumpstateaidl \
        libhardware_legacy \
        liblog \
        libselinux \
        libutils \
+4 −6
Original line number Diff line number Diff line
@@ -52,8 +52,8 @@ bool DropRootUser() {
        return false;
    }

    gid_t groups[] = {AID_LOG,          AID_SDCARD_R, AID_SDCARD_RW, AID_MOUNT,    AID_INET,
                      AID_NET_BW_STATS, AID_READPROC, AID_WAKELOCK,  AID_BLUETOOTH};
    gid_t groups[] = {AID_LOG,  AID_SDCARD_R,     AID_SDCARD_RW, AID_MOUNT,
                      AID_INET, AID_NET_BW_STATS, AID_READPROC,  AID_BLUETOOTH};
    if (setgroups(sizeof(groups) / sizeof(groups[0]), groups) != 0) {
        MYLOGE("Unable to setgroups, aborting: %s\n", strerror(errno));
        return false;
@@ -74,10 +74,8 @@ bool DropRootUser() {
    capheader.version = _LINUX_CAPABILITY_VERSION_3;
    capheader.pid = 0;

    capdata[CAP_TO_INDEX(CAP_SYSLOG)].permitted =
        (CAP_TO_MASK(CAP_SYSLOG) | CAP_TO_MASK(CAP_BLOCK_SUSPEND));
    capdata[CAP_TO_INDEX(CAP_SYSLOG)].effective =
        (CAP_TO_MASK(CAP_SYSLOG) | CAP_TO_MASK(CAP_BLOCK_SUSPEND));
    capdata[CAP_TO_INDEX(CAP_SYSLOG)].permitted = CAP_TO_MASK(CAP_SYSLOG);
    capdata[CAP_TO_INDEX(CAP_SYSLOG)].effective = CAP_TO_MASK(CAP_SYSLOG);
    capdata[0].inheritable = 0;
    capdata[1].inheritable = 0;

+2 −20
Original line number Diff line number Diff line
@@ -24,7 +24,6 @@
#include <memory>
#include <regex>
#include <set>
#include <signal.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
@@ -46,7 +45,6 @@
#include <android/hardware/vibrator/1.0/IVibrator.h>
#include <cutils/native_handle.h>
#include <cutils/properties.h>
#include <hardware_legacy/power.h>
#include <openssl/sha.h>
#include <private/android_filesystem_config.h>
#include <private/android_logger.h>
@@ -83,7 +81,6 @@ void add_mountinfo();
#define TOMBSTONE_MAX_LEN (sizeof(TOMBSTONE_FILE_PREFIX) + 4)
#define NUM_TOMBSTONES  10
#define WLUTIL "/vendor/xbin/wlutil"
#define WAKE_LOCK_NAME "dumpstate_wakelock"

typedef struct {
  char name[TOMBSTONE_MAX_LEN];
@@ -1245,16 +1242,7 @@ static void ExitOnInvalidArgs() {
    ShowUsageAndExit();
}

static void wake_lock_releaser() {
    if (release_wake_lock(WAKE_LOCK_NAME) < 0) {
        MYLOGE("Failed to release wake lock: %s \n", strerror(errno));
    } else {
        MYLOGD("Wake lock released.\n");
    }
}

static void sig_handler(int signo __attribute__((unused))) {
    wake_lock_releaser();
static void sig_handler(int) {
    _exit(EXIT_FAILURE);
}

@@ -1486,13 +1474,7 @@ int main(int argc, char *argv[]) {

    MYLOGI("begin\n");

    if (acquire_wake_lock(PARTIAL_WAKE_LOCK, WAKE_LOCK_NAME) < 0) {
        MYLOGE("Failed to acquire wake lock: %s \n", strerror(errno));
    } else {
        MYLOGD("Wake lock acquired.\n");
        atexit(wake_lock_releaser);
    register_sig_handler();
    }

    if (do_start_service) {
        MYLOGI("Starting 'dumpstate' service\n");