Skip to content

Commit 69bd930

Browse files
committed
Fix: Fix weird R8 NPE on Android 6 only: Attempt to get length of null array
Signed-off-by: imknown <imknown@qq.com>
1 parent 94525d1 commit 69bd930

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

app/src/main/java/net/imknown/android/forefrontinfo/ui/others/datasource/FingerprintDataSource.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package net.imknown.android.forefrontinfo.ui.others.datasource
22

33
import android.os.Build
4+
import net.imknown.android.forefrontinfo.base.extension.listOfSafety
45
import net.imknown.android.forefrontinfo.ui.common.getStringProperty
56

67
class FingerprintDataSource {
@@ -13,7 +14,7 @@ class FingerprintDataSource {
1314
fun getPreviewSdkFingerprint() = getStringProperty(PROP_PREVIEW_SDK_FINGERPRINT)
1415

1516
/** [Build.getFingerprintedPartitions] */
16-
fun getPartitions() = listOf(
17+
fun getPartitions() = listOfSafety(
1718
"bootimage", "odm", "odm_dlkm", "oem", "product", "system", "system_dlkm", "system_ext", "vendor", "vendor_dlkm"
1819
)
1920

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
package net.imknown.android.forefrontinfo.base.extension
2+
3+
/** Fix weird R8 NPE on Android 6 only: Attempt to get length of null array */
4+
fun <T> listOfSafety(vararg elements: T) = buildList {
5+
elements.forEach(::add)
6+
}

0 commit comments

Comments
 (0)