Skip to content

Commit 01befd4

Browse files
author
Memfault Inc.
committed
Memfault BORT SDK 4.18.0 (Build 2216845)
1 parent 3f39669 commit 01befd4

File tree

59 files changed

+1902
-683
lines changed

Some content is hidden

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

59 files changed

+1902
-683
lines changed

CHANGELOG.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,37 @@
11
# Memfault Bort Changelog
22

3+
## v4.18.0 - July 1, 2024
4+
5+
### :rocket: New Features
6+
7+
- Battery device vitals are automatically added to
8+
[Sessions](https://mflt.io/android-sessions), to enable seeing how the Session
9+
affected battery life: `battery_discharge_duration_ms`,
10+
`battery_soc_pct_drop`.
11+
- Added battery charge cycle count metric: `battery.charge_cycle_count` - this
12+
tracks the total number of charge cycles the battery has been through (if the
13+
device supports this and writes it to
14+
`/sys/class/power_supply/battery/cycle_count`).
15+
- Added `startSession`/`finishSession` native APIs for Sessions
16+
17+
### :chart_with_upwards_trend: Improvements
18+
19+
- Removed legacy settings endpoint support (this had not been used for ~2
20+
years - replaced by `device-config`).
21+
- Added rate-limiter for Sessions.
22+
- Catch a `SocketTimeoutException` during settings update, so that it doesn't
23+
fail the job.
24+
- Changed the jitter for settings update, so that it evenly distributes requests
25+
throughout the fleet. Also removed any jitter from the very first settings
26+
update on a fresh device.
27+
- Updated gradle to version 8.8 (fixed a build failure we saw internally).
28+
29+
### :house: Internal
30+
31+
- Changed network security config in the debug variant of the Bort app, for our
32+
internal CI configuration.
33+
- Added internal metrics to track the size of Bort's databases.
34+
335
## v4.17.0 - June 24, 2024
436

537
### :rocket: New Features

MemfaultDumpster/MemfaultDumpster.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,9 @@ namespace {
8686
case IDumpster::CMD_ID_SET_STRUCTURED_ENABLED_PROPERTY_DISABLED: return {
8787
"/system/bin/setprop", STRUCTURED_ENABLED_PROPERTY, "0"
8888
};
89+
case IDumpster::CMD_ID_CYCLE_COUNT: return {
90+
"cat", "/sys/class/power_supply/battery/cycle_count"
91+
};
8992

9093

9194
default: return {};

MemfaultDumpster/com/memfault/dumpster/IDumpster.aidl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,12 @@ interface IDumpster {
99
const int VERSION_GETPROP_TYPES = 3;
1010
const int VERSION_BORT_CONTINUOUS_LOGGING = 4;
1111
const int VERSION_BORT_CONTINUOUS_FIXES = 5;
12+
const int VERSION_CYCLE_COUNT = 6;
1213

1314
/**
1415
* Current version of the service.
1516
*/
16-
const int VERSION = 5;
17+
const int VERSION = 6;
1718

1819
/**
1920
* Gets the version of the MemfaultDumpster service.
@@ -26,6 +27,7 @@ interface IDumpster {
2627
const int CMD_ID_SET_STRUCTURED_ENABLED_PROPERTY_ENABLED = 4;
2728
const int CMD_ID_SET_STRUCTURED_ENABLED_PROPERTY_DISABLED = 5;
2829
const int CMD_ID_GETPROP_TYPES = 6;
30+
const int CMD_ID_CYCLE_COUNT = 7;
2931

3032
/**
3133
* Runs a basic command and calls the listener with the string output.

MemfaultPackages/bort-ota/src/debug/res/xml/network_security_config.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,5 @@
33
<domain-config cleartextTrafficPermitted="true">
44
<domain includeSubdomains="true">127.0.0.1</domain>
55
<domain includeSubdomains="true">localhost</domain>
6-
<domain includeSubdomains="true">minio</domain>
76
</domain-config>
87
</network-security-config>

MemfaultPackages/bort-shared/src/main/java/com/memfault/bort/Dispatchers.kt

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,14 @@
11
package com.memfault.bort
22

33
import javax.inject.Qualifier
4-
import kotlin.annotation.AnnotationTarget.FIELD
5-
import kotlin.annotation.AnnotationTarget.FUNCTION
6-
import kotlin.annotation.AnnotationTarget.PROPERTY_GETTER
7-
import kotlin.annotation.AnnotationTarget.PROPERTY_SETTER
8-
import kotlin.annotation.AnnotationTarget.VALUE_PARAMETER
94

105
@Qualifier
11-
@Retention(AnnotationRetention.RUNTIME)
12-
@Target(FIELD, VALUE_PARAMETER, FUNCTION, PROPERTY_GETTER, PROPERTY_SETTER)
136
annotation class Main
147

158
@Qualifier
16-
@Retention(AnnotationRetention.RUNTIME)
17-
@Target(FIELD, VALUE_PARAMETER, FUNCTION, PROPERTY_GETTER, PROPERTY_SETTER)
189
annotation class IO
1910

2011
@Qualifier
21-
@Retention(AnnotationRetention.RUNTIME)
22-
@Target(FIELD, VALUE_PARAMETER, FUNCTION, PROPERTY_GETTER, PROPERTY_SETTER)
2312
/*
2413
* You probably want the IO or Main dispatcher instead of the Default dispatcher. For one-off longer computation
2514
* tasks, we should use the IO dispatcher, which will run the task on a large pool of threads. For short tasks that

MemfaultPackages/bort-shared/src/main/java/com/memfault/bort/DumpsterClient.kt

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,6 @@ import kotlinx.coroutines.withTimeoutOrNull
2020
import javax.inject.Inject
2121
import javax.inject.Qualifier
2222
import javax.inject.Singleton
23-
import kotlin.annotation.AnnotationRetention.RUNTIME
24-
import kotlin.annotation.AnnotationTarget.FIELD
25-
import kotlin.annotation.AnnotationTarget.FUNCTION
26-
import kotlin.annotation.AnnotationTarget.PROPERTY_GETTER
27-
import kotlin.annotation.AnnotationTarget.PROPERTY_SETTER
28-
import kotlin.annotation.AnnotationTarget.VALUE_PARAMETER
2923
import kotlin.coroutines.resume
3024
import kotlin.time.Duration
3125
import kotlin.time.Duration.Companion.seconds
@@ -107,8 +101,6 @@ private class WrappedService(val service: IDumpster, val basicCommandTimeout: Lo
107101
}
108102

109103
@Qualifier
110-
@Retention(RUNTIME)
111-
@Target(FIELD, VALUE_PARAMETER, FUNCTION, PROPERTY_GETTER, PROPERTY_SETTER)
112104
annotation class BasicCommandTimeout
113105

114106
class DumpsterClient @Inject constructor(
@@ -230,6 +222,11 @@ class DumpsterClient @Inject constructor(
230222
}
231223
}
232224

225+
suspend fun getChargeCycleCount(): Int? =
226+
withService<Int?>(minimumVersion = IDumpster.VERSION_CYCLE_COUNT) {
227+
return runBasicCommand(IDumpster.CMD_ID_CYCLE_COUNT)?.toIntOrNull()
228+
}
229+
233230
/**
234231
* Gets the available version of the MemfaultDumpster service, or null if the service is not available.
235232
*/

MemfaultPackages/bort-shared/src/main/java/com/memfault/bort/android/BroadcastReceivers.kt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import kotlinx.coroutines.flow.callbackFlow
1010

1111
suspend fun Context.registerForIntents(
1212
vararg actions: String,
13+
sticky: Boolean = false,
1314
): Flow<Intent> {
1415
check(actions.isNotEmpty()) { "Must provide a non-empty list of actions to listen to." }
1516

@@ -24,7 +25,11 @@ suspend fun Context.registerForIntents(
2425
val filter = IntentFilter()
2526
actions.forEach { filter.addAction(it) }
2627

27-
registerReceiver(receiver, filter)
28+
val stickyIntentOrNull = registerReceiver(receiver, filter)
29+
30+
if (sticky && stickyIntentOrNull != null) {
31+
trySend(stickyIntentOrNull)
32+
}
2833

2934
awaitClose { unregisterReceiver(receiver) }
3035
}

MemfaultPackages/bort-shared/src/main/java/com/memfault/bort/android/SharedAndroidModule.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import android.content.ContentResolver
77
import android.content.pm.PackageManager
88
import android.content.res.Resources
99
import android.net.ConnectivityManager
10+
import android.os.BatteryManager
1011
import android.os.DropBoxManager
1112
import android.os.Looper
1213
import com.memfault.bort.Default
@@ -65,4 +66,8 @@ class SharedAndroidModule {
6566
@Provides
6667
fun storageStatsManager(application: Application): StorageStatsManager =
6768
application.getSystemService(StorageStatsManager::class.java)
69+
70+
@Provides
71+
fun batteryManager(application: Application): BatteryManager =
72+
application.getSystemService(BatteryManager::class.java)
6873
}

MemfaultPackages/bort-shared/src/main/java/com/memfault/bort/settings/FetchedSettings.kt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -387,6 +387,13 @@ data class FetchedSettings(
387387
@SerialName("metric_report.daily_heartbeat")
388388
val dailyHeartbeatEnabled: Boolean = false,
389389

390+
@SerialName("metric_report.sessions_rate_limiting_settings")
391+
val metricReportSessionsRateLimitingSettings: RateLimitingSettings = RateLimitingSettings(
392+
defaultCapacity = 125,
393+
defaultPeriod = 24.hours.boxed(),
394+
maxBuckets = 1,
395+
),
396+
390397
@SerialName("storage.apps_size_data_source_enabled")
391398
val storageAppsSizeDataSourceEnabled: Boolean = true,
392399

MemfaultPackages/bort/src/debug/java/com/memfault/bort/receivers/BortTestReceiver.kt

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ import com.memfault.bort.requester.restartPeriodicMetricsCollection
2525
import com.memfault.bort.selftest.SelfTestWorker
2626
import com.memfault.bort.settings.LogcatCollectionMode
2727
import com.memfault.bort.settings.SettingsProvider
28+
import com.memfault.bort.settings.SettingsUpdateRequester
2829
import com.memfault.bort.settings.StoredSettingsPreferenceProvider
2930
import com.memfault.bort.settings.asLoggerSettings
30-
import com.memfault.bort.settings.restartPeriodicSettingsUpdate
3131
import com.memfault.bort.shared.JitterDelayProvider
3232
import com.memfault.bort.shared.Logger
3333
import com.memfault.bort.shared.goAsync
@@ -111,6 +111,8 @@ class BortTestReceiver : FilteringReceiver(
111111

112112
@Inject lateinit var devMode: RealDevMode
113113

114+
@Inject lateinit var settingsUpdateRequester: SettingsUpdateRequester
115+
114116
override fun onIntentReceived(
115117
context: Context,
116118
intent: Intent,
@@ -193,15 +195,12 @@ class BortTestReceiver : FilteringReceiver(
193195
}
194196

195197
"com.memfault.intent.action.TEST_REQUEST_SETTINGS_UPDATE" -> {
196-
restartPeriodicSettingsUpdate(
197-
context = context,
198+
settingsUpdateRequester.restartPeriodicSettingsUpdate(
198199
// Something long to ensure it does not re-run & interfere with tests:
199200
updateInterval = 4.days,
200-
httpApiSettings = settingsProvider.httpApiSettings,
201201
delayAfterSettingsUpdate = false,
202202
testRequest = true,
203203
cancel = true,
204-
jitterDelayProvider = jitterDelayProvider,
205204
)
206205
}
207206

0 commit comments

Comments
 (0)