Snap for 10233678 from e4b3b7b4b5ae842864edaaa48e9626719dc3f680 to udc-release
Change-Id: Ia67bbba1f44e5bb2e1a179d9e104b1787da26739
diff --git a/debuggerd/handler/debuggerd_handler.cpp b/debuggerd/handler/debuggerd_handler.cpp
index baa5bfb..c6a535a 100644
--- a/debuggerd/handler/debuggerd_handler.cpp
+++ b/debuggerd/handler/debuggerd_handler.cpp
@@ -566,20 +566,23 @@
process_info = g_callbacks.get_process_info();
}
- // GWP-ASan catches use-after-free and heap-buffer-overflow by using PROT_NONE
- // guard pages, which lead to SEGV. Normally, debuggerd prints a bug report
- // and the process terminates, but in some cases, we actually want to print
- // the bug report and let the signal handler return, and restart the process.
- // In order to do that, we need to disable GWP-ASan's guard pages. The
- // following callbacks handle this case.
- gwp_asan_callbacks_t gwp_asan_callbacks = g_callbacks.get_gwp_asan_callbacks();
- if (signal_number == SIGSEGV && signal_has_si_addr(info) &&
- gwp_asan_callbacks.debuggerd_needs_gwp_asan_recovery &&
- gwp_asan_callbacks.debuggerd_gwp_asan_pre_crash_report &&
- gwp_asan_callbacks.debuggerd_gwp_asan_post_crash_report &&
- gwp_asan_callbacks.debuggerd_needs_gwp_asan_recovery(info->si_addr)) {
- gwp_asan_callbacks.debuggerd_gwp_asan_pre_crash_report(info->si_addr);
- process_info.recoverable_gwp_asan_crash = true;
+ gwp_asan_callbacks_t gwp_asan_callbacks = {};
+ if (g_callbacks.get_gwp_asan_callbacks != nullptr) {
+ // GWP-ASan catches use-after-free and heap-buffer-overflow by using PROT_NONE
+ // guard pages, which lead to SEGV. Normally, debuggerd prints a bug report
+ // and the process terminates, but in some cases, we actually want to print
+ // the bug report and let the signal handler return, and restart the process.
+ // In order to do that, we need to disable GWP-ASan's guard pages. The
+ // following callbacks handle this case.
+ gwp_asan_callbacks = g_callbacks.get_gwp_asan_callbacks();
+ if (signal_number == SIGSEGV && signal_has_si_addr(info) &&
+ gwp_asan_callbacks.debuggerd_needs_gwp_asan_recovery &&
+ gwp_asan_callbacks.debuggerd_gwp_asan_pre_crash_report &&
+ gwp_asan_callbacks.debuggerd_gwp_asan_post_crash_report &&
+ gwp_asan_callbacks.debuggerd_needs_gwp_asan_recovery(info->si_addr)) {
+ gwp_asan_callbacks.debuggerd_gwp_asan_pre_crash_report(info->si_addr);
+ process_info.recoverable_gwp_asan_crash = true;
+ }
}
// If sival_int is ~0, it means that the fallback handler has been called
@@ -764,6 +767,7 @@
bool debuggerd_handle_signal(int signal_number, siginfo_t* info, void* context) {
if (signal_number != SIGSEGV || !signal_has_si_addr(info)) return false;
+ if (g_callbacks.get_gwp_asan_callbacks == nullptr) return false;
gwp_asan_callbacks_t gwp_asan_callbacks = g_callbacks.get_gwp_asan_callbacks();
if (gwp_asan_callbacks.debuggerd_needs_gwp_asan_recovery == nullptr ||
gwp_asan_callbacks.debuggerd_gwp_asan_pre_crash_report == nullptr ||
diff --git a/healthd/BatteryMonitor.cpp b/healthd/BatteryMonitor.cpp
index f68d65a..bd7955a 100644
--- a/healthd/BatteryMonitor.cpp
+++ b/healthd/BatteryMonitor.cpp
@@ -244,6 +244,8 @@
value = BatteryHealth::UNSPECIFIED_FAILURE;
else if (status == BatteryMonitor::BH_NOT_AVAILABLE)
value = BatteryHealth::NOT_AVAILABLE;
+ else if (status == BatteryMonitor::BH_INCONSISTENT)
+ value = BatteryHealth::INCONSISTENT;
else
value = BatteryHealth::UNKNOWN;
diff --git a/healthd/include/healthd/BatteryMonitor.h b/healthd/include/healthd/BatteryMonitor.h
index a4c013b..e9998ba 100644
--- a/healthd/include/healthd/BatteryMonitor.h
+++ b/healthd/include/healthd/BatteryMonitor.h
@@ -63,6 +63,7 @@
BH_NEEDS_REPLACEMENT,
BH_FAILED,
BH_NOT_AVAILABLE,
+ BH_INCONSISTENT,
};
BatteryMonitor();