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

Commit cf5cf971 authored by android-build-team Robot's avatar android-build-team Robot
Browse files

Snap for 4585119 from bd1f9850 to pi-release

Change-Id: I8e6dd14edde7abc83b8d3a8f68a81c833c415f51
parents 3aaea90b bd1f9850
Loading
Loading
Loading
Loading
+30 −0
Original line number Original line Diff line number Diff line
@@ -32,11 +32,14 @@
#include <unistd.h>
#include <unistd.h>


#include <memory>
#include <memory>
#include <string>
#include <thread>
#include <thread>
#include <vector>


#include <android-base/file.h>
#include <android-base/file.h>
#include <android-base/properties.h>
#include <android-base/properties.h>
#include <android-base/stringprintf.h>
#include <android-base/stringprintf.h>
#include <android-base/strings.h>
#include <android-base/unique_fd.h>
#include <android-base/unique_fd.h>
#include <cutils/android_filesystem_config.h>
#include <cutils/android_filesystem_config.h>
#include <cutils/android_reboot.h>
#include <cutils/android_reboot.h>
@@ -775,6 +778,22 @@ static int handle_encryptable(const struct fstab_rec* rec)
    }
    }
}
}


static bool call_vdc(const std::vector<std::string>& args) {
    std::vector<char const*> argv;
    argv.emplace_back("/system/bin/vdc");
    for (auto& arg : args) {
        argv.emplace_back(arg.c_str());
    }
    LOG(INFO) << "Calling: " << android::base::Join(argv, ' ');
    int ret = android_fork_execvp(4, const_cast<char**>(argv.data()), nullptr, false, true);
    if (ret != 0) {
        LOG(ERROR) << "vdc returned error code: " << ret;
        return false;
    }
    LOG(DEBUG) << "vdc finished successfully";
    return true;
}

/* When multiple fstab records share the same mount_point, it will
/* When multiple fstab records share the same mount_point, it will
 * try to mount each one in turn, and ignore any duplicates after a
 * try to mount each one in turn, and ignore any duplicates after a
 * first successful mount.
 * first successful mount.
@@ -881,6 +900,13 @@ int fs_mgr_mount_all(struct fstab *fstab, int mount_mode)
                    LERROR << "Only one encryptable/encrypted partition supported";
                    LERROR << "Only one encryptable/encrypted partition supported";
                }
                }
                encryptable = status;
                encryptable = status;
                if (status == FS_MGR_MNTALL_DEV_NEEDS_METADATA_ENCRYPTION) {
                    if (!call_vdc(
                            {"cryptfs", "encryptFstab", fstab->recs[attempted_idx].mount_point})) {
                        LERROR << "Encryption failed";
                        return FS_MGR_MNTALL_FAIL;
                    }
                }
            }
            }


            /* Success!  Go get the next one */
            /* Success!  Go get the next one */
@@ -955,7 +981,11 @@ int fs_mgr_mount_all(struct fstab *fstab, int mount_mode)
            encryptable = FS_MGR_MNTALL_DEV_MIGHT_BE_ENCRYPTED;
            encryptable = FS_MGR_MNTALL_DEV_MIGHT_BE_ENCRYPTED;
        } else if (mret && mount_errno != EBUSY && mount_errno != EACCES &&
        } else if (mret && mount_errno != EBUSY && mount_errno != EACCES &&
                   should_use_metadata_encryption(&fstab->recs[attempted_idx])) {
                   should_use_metadata_encryption(&fstab->recs[attempted_idx])) {
            if (!call_vdc({"cryptfs", "mountFstab", fstab->recs[attempted_idx].mount_point})) {
                ++error_count;
            }
            encryptable = FS_MGR_MNTALL_DEV_IS_METADATA_ENCRYPTED;
            encryptable = FS_MGR_MNTALL_DEV_IS_METADATA_ENCRYPTED;
            continue;
        } else {
        } else {
            // fs_options might be null so we cannot use PERROR << directly.
            // fs_options might be null so we cannot use PERROR << directly.
            // Use StringPrintf to output "(null)" instead.
            // Use StringPrintf to output "(null)" instead.
+0 −12
Original line number Original line Diff line number Diff line
@@ -535,12 +535,6 @@ void BatteryMonitor::init(struct healthd_config *hc) {
                                      POWER_SUPPLY_SYSFS_PATH, name);
                                      POWER_SUPPLY_SYSFS_PATH, name);
                    if (access(path, R_OK) == 0) {
                    if (access(path, R_OK) == 0) {
                        mHealthdConfig->batteryVoltagePath = path;
                        mHealthdConfig->batteryVoltagePath = path;
                    } else {
                        path.clear();
                        path.appendFormat("%s/%s/batt_vol",
                                          POWER_SUPPLY_SYSFS_PATH, name);
                        if (access(path, R_OK) == 0)
                            mHealthdConfig->batteryVoltagePath = path;
                    }
                    }
                }
                }


@@ -590,12 +584,6 @@ void BatteryMonitor::init(struct healthd_config *hc) {
                                      name);
                                      name);
                    if (access(path, R_OK) == 0) {
                    if (access(path, R_OK) == 0) {
                        mHealthdConfig->batteryTemperaturePath = path;
                        mHealthdConfig->batteryTemperaturePath = path;
                    } else {
                        path.clear();
                        path.appendFormat("%s/%s/batt_temp",
                                          POWER_SUPPLY_SYSFS_PATH, name);
                        if (access(path, R_OK) == 0)
                            mHealthdConfig->batteryTemperaturePath = path;
                    }
                    }
                }
                }


+6 −4
Original line number Original line Diff line number Diff line
@@ -514,8 +514,9 @@ static Result<Success> queue_fs_event(int code) {
        property_set("ro.crypto.state", "encrypted");
        property_set("ro.crypto.state", "encrypted");
        property_set("ro.crypto.type", "file");
        property_set("ro.crypto.type", "file");


        // defaultcrypto detects file/block encryption. init flow is same for each.
        // Although encrypted, vold has already set the device up, so we do not need to
        ActionManager::GetInstance().QueueEventTrigger("defaultcrypto");
        // do anything different from the nonencrypted case.
        ActionManager::GetInstance().QueueEventTrigger("nonencrypted");
        return Success();
        return Success();
    } else if (code == FS_MGR_MNTALL_DEV_NEEDS_METADATA_ENCRYPTION) {
    } else if (code == FS_MGR_MNTALL_DEV_NEEDS_METADATA_ENCRYPTION) {
        if (e4crypt_install_keyring()) {
        if (e4crypt_install_keyring()) {
@@ -523,8 +524,9 @@ static Result<Success> queue_fs_event(int code) {
        }
        }
        property_set("ro.crypto.type", "file");
        property_set("ro.crypto.type", "file");


        // encrypt detects file/block encryption. init flow is same for each.
        // Although encrypted, vold has already set the device up, so we do not need to
        ActionManager::GetInstance().QueueEventTrigger("encrypt");
        // do anything different from the nonencrypted case.
        ActionManager::GetInstance().QueueEventTrigger("nonencrypted");
        return Success();
        return Success();
    } else if (code > 0) {
    } else if (code > 0) {
        Error() << "fs_mgr_mount_all() returned unexpected error " << code;
        Error() << "fs_mgr_mount_all() returned unexpected error " << code;
+17 −0
Original line number Original line Diff line number Diff line
@@ -19,6 +19,7 @@
#include <dirent.h>
#include <dirent.h>
#include <fcntl.h>
#include <fcntl.h>
#include <paths.h>
#include <paths.h>
#include <pthread.h>
#include <seccomp_policy.h>
#include <seccomp_policy.h>
#include <signal.h>
#include <signal.h>
#include <stdlib.h>
#include <stdlib.h>
@@ -491,6 +492,16 @@ static void HandleSigtermSignal() {
    HandlePowerctlMessage("shutdown,container");
    HandlePowerctlMessage("shutdown,container");
}
}


static void UnblockSigterm() {
    sigset_t mask;
    sigemptyset(&mask);
    sigaddset(&mask, SIGTERM);

    if (sigprocmask(SIG_UNBLOCK, &mask, nullptr) == -1) {
        PLOG(FATAL) << "failed to unblock SIGTERM for PID " << getpid();
    }
}

static void InstallSigtermHandler() {
static void InstallSigtermHandler() {
    sigset_t mask;
    sigset_t mask;
    sigemptyset(&mask);
    sigemptyset(&mask);
@@ -500,6 +511,12 @@ static void InstallSigtermHandler() {
        PLOG(FATAL) << "failed to block SIGTERM";
        PLOG(FATAL) << "failed to block SIGTERM";
    }
    }


    // Register a handler to unblock SIGTERM in the child processes.
    const int result = pthread_atfork(nullptr, nullptr, &UnblockSigterm);
    if (result != 0) {
        LOG(FATAL) << "Failed to register a fork handler: " << strerror(result);
    }

    sigterm_signal_fd = signalfd(-1, &mask, SFD_CLOEXEC);
    sigterm_signal_fd = signalfd(-1, &mask, SFD_CLOEXEC);
    if (sigterm_signal_fd == -1) {
    if (sigterm_signal_fd == -1) {
        PLOG(FATAL) << "failed to create signalfd for SIGTERM";
        PLOG(FATAL) << "failed to create signalfd for SIGTERM";
+1 −1
Original line number Original line Diff line number Diff line
@@ -46,7 +46,7 @@ bool UnwindStackMap::Build() {
  std::vector<std::string> search_libs_{"libart.so", "libartd.so"};
  std::vector<std::string> search_libs_{"libart.so", "libartd.so"};
  jit_debug_.reset(new unwindstack::JitDebug(process_memory_, search_libs_));
  jit_debug_.reset(new unwindstack::JitDebug(process_memory_, search_libs_));
#if !defined(NO_LIBDEXFILE_SUPPORT)
#if !defined(NO_LIBDEXFILE_SUPPORT)
  dex_files_.reset(new unwindstack::DexFiles(process_memory_));
  dex_files_.reset(new unwindstack::DexFiles(process_memory_, search_libs_));
#endif
#endif


  if (!stack_maps_->Parse()) {
  if (!stack_maps_->Parse()) {
Loading