Skip to content

Commit 3c5d848

Browse files
author
Memfault Inc.
committed
Memfault BORT SDK 5.4.0 (Build 3192053)
1 parent a0b794e commit 3c5d848

File tree

124 files changed

+4433
-916
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

124 files changed

+4433
-916
lines changed

Android.mk

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,6 @@ bort-sepolicy-canary-check: selinux_policy $(shell test $(PLATFORM_SDK_VERSION)
88
echo " that definitions from vendor/memfault/bort/BoardConfig.mk" 1>&2; \
99
echo " are correctly included and not overwritten." 1>&2; \
1010
echo "See https://mflt.io/android-sepolicy" 1>&2; \
11-
exit 1; ) \
12-
&& grep bort_app_data_file $(TARGET_OUT_INTERMEDIATES)/ETC/*_seapp_contexts_intermediates/*_seapp_contexts > /dev/null || ( \
13-
echo "==========" 1>&2; \
14-
echo "ERROR: bort_app_data_file not found in sepolicy contexts" 1>&2; \
15-
echo " this usually indicates an integration issue. Please ensure" 1>&2; \
16-
echo " that definitions from vendor/memfault/bort/BoardConfig.mk" 1>&2; \
17-
echo " are correctly included and not overwritten." 1>&2; \
18-
echo "See https://mflt.io/android-sepolicy" 1>&2; \
1911
exit 1; ))
2012

2113
.PHONY: bort-sepolicy-canary-check

BoardConfig.mk

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,13 @@
11
BORT_PATH := vendor/memfault/bort
22

3-
BORT_BOARD_SEPOLICY_DIR := $(BORT_PATH)/sepolicy
3+
4+
ifeq ($(shell test $(PLATFORM_SDK_VERSION) -eq 27 && echo true),true)
5+
BORT_BOARD_SEPOLICY_DIR := $(BORT_PATH)/sepolicy/common
46
ifeq (,$(findstring $(BORT_BOARD_SEPOLICY_DIR),$(BOARD_SEPOLICY_DIRS)))
57
BOARD_SEPOLICY_DIRS += $(BORT_BOARD_SEPOLICY_DIR)
68
endif
7-
8-
BORT_SEPOLICY_VENDOR_DIR := $(BORT_PATH)/sepolicy/vendor-$(PLATFORM_SDK_VERSION)
9-
ifneq (,$(wildcard $(BORT_SEPOLICY_VENDOR_DIR)))
10-
ifeq (,$(findstring $(BORT_SEPOLICY_VENDOR_DIR),$(BOARD_SEPOLICY_DIRS)))
11-
BOARD_SEPOLICY_DIRS += $(BORT_SEPOLICY_VENDOR_DIR)
12-
endif
139
endif
1410

15-
16-
1711
BORT_BOARD_SEPOLICY_M4DEF := memfault_platform_sdk_version=${PLATFORM_SDK_VERSION}
1812
ifeq (,$(findstring $(BORT_BOARD_SEPOLICY_M4DEF),$(BOARD_SEPOLICY_M4DEFS)))
1913
BOARD_SEPOLICY_M4DEFS += $(BORT_BOARD_SEPOLICY_M4DEF)

CHANGELOG.md

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,98 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
66
This project currently does not attempt to adhere to Semantic Versioning, but
77
breaking changes are avoided unless absolutely necessary.
88

9+
## [Unreleased]
10+
11+
### :rocket: New Features
12+
13+
- Added 3 more logs-to-metrics parser types.
14+
- `sum_matching` captures 1 integer, and sums all captured values in the
15+
heartbeat.
16+
- `distribution_minmeanmax` captures 1 double, and generates a min/mean/max
17+
distribution for all captured values in the heartbeat.
18+
- `string_property` captures 1 string, and reports the latest value for that
19+
string.
20+
- Added tracking of the metered, temporarily unmetered, and roaming network
21+
capabilities in HRT.
22+
- Added a `connectivity.metered.latest` heartbeat metric for tracking metered
23+
network usage.
24+
- Added new disk wear and disk write Device Vital heartbeat metrics. eMMC/UFS
25+
lifetime estimation and version stats are collected from the Health HAL
26+
implementation, falling back to a hardcoded UFS or eMMC filepath if not
27+
implemented. Bytes written each heartbeat is collected by reading the sectors
28+
written value from `/proc/diskstats` for matching physical devices in
29+
`/sys/block` multiplied by the sector size to get a value in bytes.
30+
- `disk_wear.<source>.lifetime_remaining_pct.latest` captures the lifetime
31+
remaining estimation for type A flash in increments of 10%. The source can
32+
be one of: "mmc0", "624000.ufshc", or "HealthHAL".
33+
- `disk_wear.<source>.lifetime_b_remaining_pct.latest` captures the lifetime
34+
remaining estimation for type B flash in increments of 10%. The source can
35+
be one of: "mmc0", "624000.ufshc", or "HealthHAL".
36+
- `disk_wear.pre_eol.latest` captures the pre-EOL status of consumed reserved
37+
blocks, as "Normal", "Warning", or "Urgent".
38+
- `disk_wear.version.latest` captures the version as described from the vendor
39+
implementation of the Health HAL.
40+
- `disk_wear.vdc.bytes_written` captures the bytes written for that heartbeat.
41+
- Added per-app CPU usage metrics. The CPU usage percentage for each heartbeat
42+
is collected by parsing `/proc/<pid>/stat/` for system and user time
43+
(`stime` + `utime`) divided by the total usage (sum of all fields from
44+
`/proc/stat`).
45+
- By default, the SDK will only create heartbeat metrics for a defined set of
46+
"interesting" processes. Please reach out to customer support to configure
47+
this set.
48+
- Otherwise, the top 10 processes exceeding the 50% CPU usage threshold will
49+
also be recorded. Please reach out to customer support to configure these
50+
thresholds.
51+
- Added support for Android 15.
52+
53+
### :chart_with_upwards_trend: Improvements
54+
55+
- Added parsers for more HRT batterystats data.
56+
- `screen_doze` captures whether the display is dozing in a low power state
57+
([link](https://cs.android.com/android/platform/superproject/main/+/main:frameworks/base/core/java/android/view/Display.java;l=491;drc=61197364367c9e404c7da6900658f1b16c42d0da;bpv=1;bpt=1?q=isDozeState)).
58+
- `flashlight` captures whether the flashlight was turned on.
59+
- `bluetooth` captures whether Bluetooth was enabled.
60+
- `usb_data` captures whether a USB connection was established (as reported by
61+
`android.hardware.usb.action.USB_STATE`).
62+
- `cellular_high_tx_power` captures whether the modem spent more of its time
63+
at the highest power level versus any other level.
64+
- `nr_state` captures the service level of the 5G network that's connected
65+
([link](https://cs.android.com/android/platform/superproject/main/+/main:frameworks/base/telephony/java/android/telephony/NetworkRegistrationInfo.java;l=147)).
66+
- Updated comments on various batterystats fields. More improvements to come in
67+
clarifying the name and use of batterystats metrics!
68+
- Dumped any existing logs when continuous logging starts, to retain logs
69+
captured from before a reboot.
70+
- Added control over the maximum age of sampled data, to match the controls over
71+
unsampled data.
72+
- Added support for parsing the binary log buffers (events, security, stats)
73+
with continuous logs.
74+
- Modified dumpstate to write bugreports to /data/misc/MemfaultBugReports
75+
instead of to Bort's app dir. This is necessary for Android 15 support and CTS
76+
compliance to work around neverallow sepolicy rules. This also allowed
77+
deleting the custom `bort_app_data_file` app label for the Bort app.
78+
79+
### :construction: Fixes
80+
81+
- Added explicit Android System AID mappings for more consistent system UID
82+
attribution in tombstone and network stats parsing.
83+
- Added VPN and USB as explicitly defined network types using
84+
`connectivity.network`.
85+
- Fixed a bug in PhoneState where the unknown `???` state was reported as
86+
`null`.
87+
- Added exponential backoff for EAGAIN errors in continuous logs. Each write is
88+
fsync'd immediately after write to reduce the likelihood of data loss.
89+
- Added missing ignore.cil files for SDKs 32, 33, and 34.
90+
91+
### :house: Internal
92+
93+
- Stopped running unit tests on release sources.
94+
- Migrated the SDK to communicate over a named domain (\*.memfault.test) rather
95+
than localhost for local development.
96+
- Removed unneeded mockk init calls.
97+
- Added some tests for unknown fields in device config.
98+
- Refactored the unsampled holding area logic into a single class.
99+
- Differentiated some continuous logging logs for easier debugging.
100+
9101
## v5.3.0 - February 14, 2025
10102

11103
### :rocket: New Features

MemfaultDumpstateRunner/MemfaultDumpstateRunner.cpp

Lines changed: 2 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
#define TARGET_APP_ID STRINGIFY(BORT_APPLICATION_ID)
5757
#define TARGET_COMPONENT_CLASS "com.memfault.bort.receivers.BugReportReceiver"
5858
#define TARGET_COMPONENT TARGET_APP_ID "/" TARGET_COMPONENT_CLASS
59-
#define TARGET_DIR "/data/data/" TARGET_APP_ID "/files/bugreports/"
59+
#define TARGET_DIR "/data/misc/MemfaultBugReports/"
6060

6161
using android::os::dumpstate::CommandOptions;
6262
using android::os::dumpstate::RunCommandToFd;
@@ -283,54 +283,12 @@ void CleanupDumpstateLogs(void) {
283283
free(log_files);
284284
}
285285

286-
// Based on https://cs.android.com/android/_/android/platform/frameworks/native/+/0f58ab624b96f7f2e49a606ee8ce0cedeb10004d:cmds/dumpstate/dumpstate.cpp;l=3650;drc=f2a15e8742cf33e37e6c96f4731c298c6749bb68
287-
bool createParentDirs(uint32_t targetUid) {
288-
char path[sizeof(TARGET_DIR)];
289-
memcpy(path, TARGET_DIR, sizeof(TARGET_DIR));
290-
291-
char *chp = const_cast<char *> (path);
292-
bool success = true;
293-
294-
/* skip initial slash */
295-
if (chp[0] == '/') {
296-
chp++;
297-
}
298-
299-
/* create leading directories, if necessary */
300-
struct stat dir_stat;
301-
while (chp && chp[0]) {
302-
chp = strchr(chp, '/');
303-
if (chp) {
304-
*chp = 0;
305-
if (stat(path, &dir_stat) == -1 || !S_ISDIR(dir_stat.st_mode)) {
306-
ALOGD("Creating directory %s\n", path);
307-
if (mkdir(path, 0770)) { /* drwxrwx--- */
308-
ALOGE("Unable to create directory %s: %s\n", path, strerror(errno));
309-
success = false;
310-
} else if (chown(path, targetUid, targetUid)) {
311-
ALOGE("Unable to change ownership of dir %s: %s\n", path, strerror(errno));
312-
success = false;
313-
}
314-
}
315-
*chp++ = '/';
316-
}
317-
}
318-
319-
return success;
320-
}
321-
322-
323286
} // namespace
324287

325288
int main(void) {
326289
const uint32_t targetUid = GetTargetUid();
327290
ALOGI("Target UID: %d", targetUid);
328291

329-
if (!createParentDirs(targetUid)) {
330-
ALOGE("Failed to create output directories. ");
331-
return EXIT_FAILURE;
332-
}
333-
334292
ALOGI("Starting bugreport collecting service");
335293

336294
auto t0 = std::chrono::steady_clock::now();
@@ -366,7 +324,7 @@ int main(void) {
366324
goto cleanup;
367325
}
368326

369-
if (chown(targetPath.c_str(), targetUid, targetUid)) {
327+
if (chown(targetPath.c_str(), targetUid, -1)) {
370328
ALOGE("Unable to change ownership to system of %s: %s\n",
371329
targetPath.c_str(), strerror(errno));
372330
goto cleanup;

MemfaultDumpstateRunner/memfault_init.rc

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,13 @@ service memfault_dumpstatez /system/bin/dumpstate -S -d -z -q \
2020
# it to complete and copy the bugreport.zip into a location that can be accessed by Bort.
2121
# It runs as root and in the "dumpstate" sepolicy domain, because it needs
2222
# to access both the shell-owned bugreport output of dumpstate and it needs to be able to copy it
23-
# into Bort's filesystem sandboxed location. See MemfaultDumpstateRunner.cpp for
23+
# into the bugreport folder in /data/misc/MemfaultBugReports. See MemfaultDumpstateRunner.cpp for
2424
# the source code of the program itself.
2525

26+
on post-fs-data
27+
mkdir /data/misc/MemfaultBugReports/ 0771 system system
28+
wait /data/misc/MemfaultBugReports/
29+
2630
service memfault_dumpstate_runner /system_ext/bin/MemfaultDumpstateRunner
2731
class core
2832
disabled

MemfaultDumpster/Android.mk

Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,56 @@ LOCAL_SHARED_LIBRARIES := \
2424
libservices \
2525
libprotobuf-cpp-full \
2626
libmflt-reporting
27-
LOCAL_PROTOC_OPTIMIZE_TYPE := full
2827
LOCAL_STATIC_LIBRARIES := liblog
28+
29+
# Support for storage wear info from HAL is available from 11+ on
30+
# devices that support it
31+
ifeq ($(call math_gt_or_eq, $(PLATFORM_SDK_VERSION), 30), true)
32+
LOCAL_SHARED_LIBRARIES += \
33+
android.hardware.health@1.0 \
34+
android.hardware.health@2.0
35+
LOCAL_STATIC_LIBRARIES += \
36+
libhealthhalutils \
37+
libhidlbase
38+
39+
# Android 13 and up support AIDL and can wrap HIDL hals in a backward compatible way,
40+
# others are HIDL only
41+
ifeq ($(call math_gt_or_eq, $(PLATFORM_SDK_VERSION), 33), true)
42+
LOCAL_CFLAGS += -DSTORAGE_INFO_PREFER_AIDL
43+
LOCAL_SHARED_LIBRARIES += \
44+
libbinder_ndk \
45+
libvndksupport
46+
LOCAL_STATIC_LIBRARIES += \
47+
android.hardware.health-translate-ndk \
48+
libhealthshim
49+
50+
# Health HAL NDK is used to wrap HIDL health HALs, but has different versions depending on the
51+
# platform release ids
52+
ifeq ($(call math_gt_or_eq, $(PLATFORM_SDK_VERSION), 35), true)
53+
# Android 15 has three point releases (AP3A, AP4A and BP1A) and the health hal NDK
54+
# version differs between them
55+
ifeq ($(findstring BP1A,$(BUILD_ID)),BP1A)
56+
LOCAL_SHARED_LIBRARIES += android.hardware.health-V4-ndk
57+
else
58+
LOCAL_SHARED_LIBRARIES += android.hardware.health-V3-ndk
59+
endif
60+
else ifeq ($(call math_gt_or_eq, $(PLATFORM_SDK_VERSION), 34), true)
61+
# Android 14 has three point releases (UP1A, AP1A and AP2A) and the health hal NDK
62+
# version differs between them
63+
ifeq ($(findstring UP1A,$(BUILD_ID)),UP1A)
64+
LOCAL_SHARED_LIBRARIES += android.hardware.health-V2-ndk
65+
else
66+
LOCAL_SHARED_LIBRARIES += android.hardware.health-V3-ndk
67+
endif
68+
else
69+
LOCAL_SHARED_LIBRARIES += android.hardware.health-V1-ndk
70+
endif
71+
else
72+
LOCAL_CFLAGS += -DSTORAGE_INFO_PREFER_HIDL
73+
endif
74+
endif
75+
76+
LOCAL_PROTOC_OPTIMIZE_TYPE := full
2977
LOCAL_INIT_RC := memfault_dumpster.rc
3078
LOCAL_SYSTEM_EXT_MODULE := true
3179
include $(BUILD_EXECUTABLE)

0 commit comments

Comments
 (0)