summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Selim Cinek <cinek@google.com> 2022-01-12 11:48:52 +0100
committer Selim Cinek <cinek@google.com> 2022-01-12 11:15:57 +0000
commit05ee93d30f6cf1199f492eb3cbaacf38d589c1d4 (patch)
tree9179d35d8c9f4286c688594b7d1a69fef5520f62
parent531458f8ff61f4fed634d11d489fd55c2a0bd828 (diff)
Fixed a crash when dragging down on the NotificationShelf
The logging code was wrongly casting an ExpandableView to a row, but it can also be a Shelf. Fixes: 213969909 Tests: atest SystemUITests Change-Id: Id5847d44d313d57cade46a6ccb9109d86145499b
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/phone/LSShadeTransitionLogger.kt8
-rw-r--r--packages/SystemUI/tests/src/com/android/systemui/statusbar/LSShadeTransitionLoggerTest.kt44
2 files changed, 48 insertions, 4 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/LSShadeTransitionLogger.kt b/packages/SystemUI/src/com/android/systemui/statusbar/phone/LSShadeTransitionLogger.kt
index 4de78f5d6190..868efa027f40 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/LSShadeTransitionLogger.kt
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/LSShadeTransitionLogger.kt
@@ -34,7 +34,7 @@ class LSShadeTransitionLogger @Inject constructor(
private val displayMetrics: DisplayMetrics
) {
fun logUnSuccessfulDragDown(startingChild: View?) {
- val entry = (startingChild as ExpandableNotificationRow?)?.entry
+ val entry = (startingChild as? ExpandableNotificationRow)?.entry
buffer.log(TAG, LogLevel.INFO, {
str1 = entry?.key ?: "no entry"
}, {
@@ -49,7 +49,7 @@ class LSShadeTransitionLogger @Inject constructor(
}
fun logDragDownStarted(startingChild: ExpandableView?) {
- val entry = (startingChild as ExpandableNotificationRow?)?.entry
+ val entry = (startingChild as? ExpandableNotificationRow)?.entry
buffer.log(TAG, LogLevel.INFO, {
str1 = entry?.key ?: "no entry"
}, {
@@ -58,7 +58,7 @@ class LSShadeTransitionLogger @Inject constructor(
}
fun logDraggedDownLockDownShade(startingChild: View?) {
- val entry = (startingChild as ExpandableNotificationRow?)?.entry
+ val entry = (startingChild as? ExpandableNotificationRow)?.entry
buffer.log(TAG, LogLevel.INFO, {
str1 = entry?.key ?: "no entry"
}, {
@@ -67,7 +67,7 @@ class LSShadeTransitionLogger @Inject constructor(
}
fun logDraggedDown(startingChild: View?, dragLengthY: Int) {
- val entry = (startingChild as ExpandableNotificationRow?)?.entry
+ val entry = (startingChild as? ExpandableNotificationRow)?.entry
buffer.log(TAG, LogLevel.INFO, {
str1 = entry?.key ?: "no entry"
}, {
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/LSShadeTransitionLoggerTest.kt b/packages/SystemUI/tests/src/com/android/systemui/statusbar/LSShadeTransitionLoggerTest.kt
new file mode 100644
index 000000000000..6971c63ed6d4
--- /dev/null
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/LSShadeTransitionLoggerTest.kt
@@ -0,0 +1,44 @@
+package com.android.systemui.statusbar
+
+import android.testing.AndroidTestingRunner
+import android.util.DisplayMetrics
+import androidx.test.filters.SmallTest
+import com.android.systemui.SysuiTestCase
+import com.android.systemui.log.LogBuffer
+import com.android.systemui.statusbar.notification.row.ExpandableView
+import com.android.systemui.statusbar.phone.LSShadeTransitionLogger
+import com.android.systemui.statusbar.phone.LockscreenGestureLogger
+import com.android.systemui.util.mockito.mock
+import org.junit.Before
+import org.junit.Rule
+import org.junit.Test
+import org.junit.runner.RunWith
+import org.mockito.Mock
+import org.mockito.junit.MockitoJUnit
+
+@RunWith(AndroidTestingRunner::class)
+@SmallTest
+class LSShadeTransitionLoggerTest : SysuiTestCase() {
+ lateinit var logger: LSShadeTransitionLogger
+ @Mock
+ lateinit var gestureLogger: LockscreenGestureLogger
+ @Mock
+ lateinit var displayMetrics: DisplayMetrics
+ @JvmField @Rule
+ val mockito = MockitoJUnit.rule()
+
+ @Before
+ fun setup() {
+ logger = LSShadeTransitionLogger(
+ LogBuffer("Test", 10, 10, mock()),
+ gestureLogger,
+ displayMetrics)
+ }
+
+ @Test
+ fun testLogDragDownStarted() {
+ val view: ExpandableView = mock()
+ // log a non-null, non row, ensure no crash
+ logger.logDragDownStarted(view)
+ }
+} \ No newline at end of file