Skip to content

Commit 95ab10f

Browse files
committed
Bug 1942584: Check that root window insets are non-null before using them. This should fix a NPE crash observed in the play store. r=android-reviewers,petru
Differential Revision: https://phabricator.services.mozilla.com/D234873
1 parent ee12db0 commit 95ab10f

File tree

1 file changed

+11
-12
lines changed
  • mobile/android/android-components/components/feature/prompts/src/main/java/mozilla/components/feature/prompts/dialog

1 file changed

+11
-12
lines changed

mobile/android/android-components/components/feature/prompts/src/main/java/mozilla/components/feature/prompts/dialog/GestureNavUtils.kt

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,15 @@ object GestureNavUtils {
2727
* @param window The containing [Window] of the current `Activity`.
2828
* @return true if the device supports gesture navigation and gestures are enabled.
2929
*/
30-
fun isInGestureNavigationMode(window: Window): Boolean =
31-
(
32-
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
33-
WindowInsetsCompat
34-
.toWindowInsetsCompat(
35-
window.decorView.rootWindowInsets,
36-
).getInsets(WindowInsetsCompat.Type.systemGestures())
37-
.left
38-
} else {
39-
0
40-
}
41-
) > 0
30+
fun isInGestureNavigationMode(window: Window): Boolean {
31+
val inset = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
32+
val rootWindowInsets = window.decorView.rootWindowInsets ?: return false
33+
WindowInsetsCompat.toWindowInsetsCompat(
34+
rootWindowInsets,
35+
).getInsets(WindowInsetsCompat.Type.systemGestures()).left
36+
} else {
37+
0
38+
}
39+
return inset > 0
40+
}
4241
}

0 commit comments

Comments
 (0)