Skip to content

Commit 2c942da

Browse files
authored
Add patch version to device metadata (#2345)
* feat(metadata) added patch version to device meta data * test(metadata) patch version in device meta data * feat(metadata) patch version in device meta data
1 parent 5957cba commit 2c942da

8 files changed

Lines changed: 22 additions & 1 deletion

File tree

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
### Enhancements
66

7+
* Added the OS security patch version to the reported device metadata
8+
[#2345](https://github.com/bugsnag/bugsnag-android/pull/2345)
79
* Added `ErrorCaptureOptions.CAPTURE_ALL` field to more easily change only the captured metadata when specifying `ErrorOptions`
810
[#2358](https://github.com/bugsnag/bugsnag-android/pull/2358)
911

bugsnag-android-core/src/androidTest/java/com/bugsnag/android/ClientTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ public void testPopulateDeviceMetadata() {
191191
client = generateClient();
192192
Map<String, Object> metadata = client.getDeviceDataCollector().getDeviceMetadata();
193193

194-
assertEquals(9, metadata.size());
194+
assertEquals(10, metadata.size());
195195
assertNotNull(metadata.get("batteryLevel"));
196196
assertNotNull(metadata.get("charging"));
197197
assertNotNull(metadata.get("locationStatus"));
@@ -201,6 +201,7 @@ public void testPopulateDeviceMetadata() {
201201
assertNotNull(metadata.get("dpi"));
202202
assertNotNull(metadata.get("emulator"));
203203
assertNotNull(metadata.get("screenResolution"));
204+
assertNotNull(metadata.get("securityPatch"));
204205
}
205206

206207
@Test

bugsnag-android-core/src/main/java/com/bugsnag/android/DeviceDataCollector.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,9 @@ internal class DeviceDataCollector(
115115
map["dpi"] = dpi
116116
map["emulator"] = emulator
117117
map["screenResolution"] = screenResolution
118+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
119+
map["securityPatch"] = Build.VERSION.SECURITY_PATCH
120+
}
118121
return map
119122
}
120123

bugsnag-plugin-android-ndk/src/main/jni/metadata.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,14 @@ static void populate_device_metadata(JNIEnv *env, bugsnag_event *event,
239239
sizeof(screen_resolution));
240240
bugsnag_event_add_metadata_string(event, "device", "screenResolution",
241241
screen_resolution);
242+
243+
char security_patch[64] = {0};
244+
copy_map_value_string(env, data, "securityPatch", security_patch,
245+
sizeof(security_patch));
246+
if (security_patch[0] != 0) {
247+
bugsnag_event_add_metadata_string(event, "device", "securityPatch",
248+
security_patch);
249+
}
242250
}
243251

244252
static void populate_device_data(JNIEnv *env, bugsnag_event *event) {

features/smoke_tests/01_anr.feature

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ Feature: ANR smoke test
6969
And the event "metaData.device.dpi" is not null
7070
And the event "metaData.device.screenResolution" is not null
7171
And the event "metaData.device.brand" is not null
72+
And the event "metaData.device.securityPatch" is not null
7273

7374
# User
7475
And the event "user.id" is not null

features/smoke_tests/02_handled.feature

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ Feature: Handled smoke tests
7979
And the event "metaData.device.screenResolution" is not null
8080
And the event "metaData.device.brand" is not null
8181
And the event "metaData.device.batteryLevel" is not null
82+
And the event "metaData.device.securityPatch" is not null
8283

8384
# User
8485
And the event "user.id" is not null

features/smoke_tests/03_sessions.feature

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ Feature: Session functionality smoke tests
5656
And the event "session.events.handled" equals 1
5757
And the event "session.events.unhandled" equals 0
5858
And the event "severityReason.unhandledOverridden" is false
59+
And the event "metaData.device.securityPatch" is not null
5960

6061
And the event has a "state" breadcrumb named "SecondActivity#onCreate()"
6162
And the breadcrumb named "SecondActivity#onCreate()" has "metaData.action" equal to "com.bugsnag.android.mazerunner.UPDATE_CONTEXT"

features/smoke_tests/04_unhandled.feature

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ Feature: Unhandled smoke tests
8282
And the event "metaData.device.screenResolution" is not null
8383
And the event "metaData.device.brand" is not null
8484
And the event "metaData.device.batteryLevel" is not null
85+
And the event "metaData.device.securityPatch" is not null
8586

8687
# User
8788
And the event "user.id" is not null
@@ -170,6 +171,7 @@ Feature: Unhandled smoke tests
170171
And the event "metaData.device.dpi" is not null
171172
And the event "metaData.device.screenResolution" is not null
172173
And the event "metaData.device.brand" is not null
174+
And the event "metaData.device.securityPatch" is not null
173175

174176
# User
175177
And the event "user.id" equals "ABC"
@@ -286,6 +288,7 @@ Feature: Unhandled smoke tests
286288
And the error payload field "events.0.device.totalMemory" is greater than 0
287289
And the event "device.orientation" matches "(portrait|landscape)"
288290
And the event "device.time" is a timestamp
291+
And the event "metaData.device.securityPatch" is not null
289292

290293
# Metadata
291294
And the event "metaData.device.locationStatus" is not null
@@ -295,6 +298,7 @@ Feature: Unhandled smoke tests
295298
And the event "metaData.device.dpi" is not null
296299
And the event "metaData.device.screenResolution" is not null
297300
And the event "metaData.device.brand" is not null
301+
And the event "metaData.device.securityPatch" is not null
298302

299303
# Context
300304
And the event "context" equals "Everest"

0 commit comments

Comments
 (0)