Skip to content

Commit d701c34

Browse files
authored
Avoid Process.myProcessName() on Android 13 (#6720)
Avoid calling `Process.myProcessName()` on Android 13 because it appears to be missing from some OEM-specific Android 13 builds. It is fine to just let the method fall through to the next, older, method to get the process name. See firebase/firebase-unity-sdk#1059 I have not been able to reproduce this issue locally, but this change is very safe. We should consider refactoring Crashlytics to consume the Sessions `ProcessDetails` data class, instead of the current `@AutoValue` holder.
1 parent ec26a52 commit d701c34

File tree

3 files changed

+16
-5
lines changed

3 files changed

+16
-5
lines changed

firebase-crashlytics/CHANGELOG.md

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,15 @@
11
# Unreleased
2+
* [fixed] Fixed NoSuchMethodError when getting process info on Android 13 [#6720]
3+
4+
# 19.4.1
25
* [changed] Updated `firebase-sessions` dependency to v2.0.9
36

7+
8+
## Kotlin
9+
The Kotlin extensions library transitively includes the updated
10+
`firebase-crashlytics` library. The Kotlin extensions library has no additional
11+
updates.
12+
413
# 19.4.0
514
* [feature] Added an overload for `recordException` that allows logging additional custom
615
keys to the non fatal event [#3551]
@@ -324,10 +333,10 @@ updates.
324333

325334
# 18.2.10
326335
* [fixed] Fixed a bug that could prevent unhandled exceptions from being
327-
propogated to the default handler when the network is unavailable.
336+
propagated to the default handler when the network is unavailable.
328337
* [changed] Internal changes to support on-demand fatal crash reporting for
329338
Flutter apps.
330-
* [fixed] Fixed a bug that prevented [crashlytics] from initalizing on some
339+
* [fixed] Fixed a bug that prevented [crashlytics] from initializing on some
331340
devices in some cases. (#3269)
332341

333342

firebase-crashlytics/src/main/java/com/google/firebase/crashlytics/internal/ProcessDetailsProvider.kt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ import com.google.firebase.crashlytics.internal.model.CrashlyticsReport.Session.
2929
* @hide
3030
*/
3131
internal object ProcessDetailsProvider {
32+
// TODO(mrober): Merge this with [com.google.firebase.sessions.ProcessDetailsProvider].
33+
3234
/** Gets the details for all of this app's running processes. */
3335
fun getAppProcessDetails(context: Context): List<ProcessDetails> {
3436
val appUid = context.applicationInfo.uid
@@ -70,7 +72,7 @@ internal object ProcessDetailsProvider {
7072
processName: String,
7173
pid: Int = 0,
7274
importance: Int = 0,
73-
isDefaultProcess: Boolean = false
75+
isDefaultProcess: Boolean = false,
7476
) =
7577
ProcessDetails.builder()
7678
.setProcessName(processName)
@@ -81,7 +83,7 @@ internal object ProcessDetailsProvider {
8183

8284
/** Gets the app's current process name. If the API is not available, returns an empty string. */
8385
private fun getProcessName(): String =
84-
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
86+
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.TIRAMISU) {
8587
Process.myProcessName()
8688
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
8789
Application.getProcessName() ?: ""

firebase-sessions/src/main/kotlin/com/google/firebase/sessions/ProcessDetailsProvider.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ internal object ProcessDetailsProvider {
7474

7575
/** Gets the app's current process name. If it could not be found, returns an empty string. */
7676
internal fun getProcessName(): String {
77-
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
77+
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.TIRAMISU) {
7878
return Process.myProcessName()
7979
}
8080

0 commit comments

Comments
 (0)