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

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

Snap for 4439972 from b7d8c86b to pi-release

Change-Id: I89c5684308484ba8f0aa98d9a53468d2bde66b9f
parents 040c5965 b7d8c86b
Loading
Loading
Loading
Loading
+21 −0
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

#include <err.h>
#include <fcntl.h>
#include <stdlib.h>
#include <sys/capability.h>
#include <sys/prctl.h>
#include <sys/ptrace.h>
@@ -298,6 +299,26 @@ TEST_F(CrasherTest, smoke) {
  ASSERT_MATCH(result, R"(signal 11 \(SIGSEGV\), code 1 \(SEGV_MAPERR\), fault addr 0xdead)");
}

TEST_F(CrasherTest, LD_PRELOAD) {
  int intercept_result;
  unique_fd output_fd;
  StartProcess([]() {
    setenv("LD_PRELOAD", "nonexistent.so", 1);
    *reinterpret_cast<volatile char*>(0xdead) = '1';
  });

  StartIntercept(&output_fd);
  FinishCrasher();
  AssertDeath(SIGSEGV);
  FinishIntercept(&intercept_result);

  ASSERT_EQ(1, intercept_result) << "tombstoned reported failure";

  std::string result;
  ConsumeFd(std::move(output_fd), &result);
  ASSERT_MATCH(result, R"(signal 11 \(SIGSEGV\), code 1 \(SEGV_MAPERR\), fault addr 0xdead)");
}

TEST_F(CrasherTest, abort) {
  int intercept_result;
  unique_fd output_fd;
+2 −2
Original line number Diff line number Diff line
@@ -330,8 +330,8 @@ static int debuggerd_dispatch_pseudothread(void* arg) {
    async_safe_format_buffer(debuggerd_dump_type, sizeof(debuggerd_dump_type), "%d",
                             get_dump_type(thread_info));

    execl(CRASH_DUMP_PATH, CRASH_DUMP_NAME, main_tid, pseudothread_tid, debuggerd_dump_type,
          nullptr);
    execle(CRASH_DUMP_PATH, CRASH_DUMP_NAME, main_tid, pseudothread_tid, debuggerd_dump_type,
           nullptr, nullptr);

    fatal_errno("exec failed");
  } else {
+3 −12
Original line number Diff line number Diff line
@@ -120,7 +120,7 @@ Return<Result> Health::update() {
    }

    // Retrieve all information and call healthd_mode_ops->battery_update, which calls
    // updateAndNotify.
    // notifyListeners.
    bool chargerOnline = battery_monitor_->update();

    // adjust uevent / wakealarm periods
@@ -129,19 +129,10 @@ Return<Result> Health::update() {
    return Result::SUCCESS;
}

void Health::updateAndNotify(HealthInfo* info) {
    // update 2.0 specific fields
    struct BatteryProperty prop;
    if (battery_monitor_->getProperty(BATTERY_PROP_CURRENT_AVG, &prop) == OK)
        info->batteryCurrentAverage = static_cast<int32_t>(prop.valueInt64);
    if (battery_monitor_->getProperty(BATTERY_PROP_CAPACITY, &prop) == OK)
        info->batteryCapacity = static_cast<int32_t>(prop.valueInt64);
    if (battery_monitor_->getProperty(BATTERY_PROP_ENERGY_COUNTER, &prop) == OK)
        info->energyCounter = prop.valueInt64;

void Health::notifyListeners(const HealthInfo& info) {
    std::lock_guard<std::mutex> _lock(callbacks_lock_);
    for (auto it = callbacks_.begin(); it != callbacks_.end();) {
        auto ret = (*it)->healthInfoChanged(*info);
        auto ret = (*it)->healthInfoChanged(info);
        if (!ret.isOk() && ret.isDeadObject()) {
            it = callbacks_.erase(it);
        } else {
+4 −4
Original line number Diff line number Diff line
@@ -28,8 +28,8 @@

using android::hardware::IPCThreadState;
using android::hardware::configureRpcThreadpool;
using android::hardware::health::V1_0::HealthInfo;
using android::hardware::health::V1_0::hal_conversion::convertToHealthInfo;
using android::hardware::health::V2_0::HealthInfo;
using android::hardware::health::V2_0::IHealth;
using android::hardware::health::V2_0::implementation::Health;

@@ -89,9 +89,9 @@ void healthd_mode_service_2_0_battery_update(struct android::BatteryProperties*
    // Implementation-defined update logic goes here. An implementation
    // can make modifications to prop before broadcasting it to all callbacks.

    HealthInfo info{};
    convertToHealthInfo(prop, info.legacy);
    static_cast<Health*>(gHealth.get())->updateAndNotify(&info);
    HealthInfo info;
    convertToHealthInfo(prop, info);
    static_cast<Health*>(gHealth.get())->notifyListeners(info);
}

static struct healthd_mode_ops healthd_mode_service_2_0_ops = {
+2 −1
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@ namespace V2_0 {
namespace implementation {

using V1_0::BatteryStatus;
using V1_0::HealthInfo;

using ::android::hidl::base::V1_0::IBase;

@@ -24,7 +25,7 @@ struct Health : public IHealth, hidl_death_recipient {
    Health(struct healthd_config* c);

    // TODO(b/62229583): clean up and hide these functions.
    void updateAndNotify(HealthInfo* info);
    void notifyListeners(const HealthInfo& info);

    // Methods from IHealth follow.
    Return<Result> registerCallback(const sp<IHealthInfoCallback>& callback) override;
Loading