From 2d016ab6438965a0452b9a117bf7c06b7ee35cbe Mon Sep 17 00:00:00 2001 From: Mygod Date: Sat, 8 Apr 2023 15:05:57 -0400 Subject: [PATCH] Fix a crash on Android 13 --- app/build.gradle.kts | 4 ++-- build.gradle.kts | 6 +++--- lib/build.gradle.kts | 1 + lib/src/main/java/be/mygod/librootkotlinx/Utils.kt | 14 ++++++++------ 4 files changed, 14 insertions(+), 11 deletions(-) diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 25e1924..1d16e88 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -25,8 +25,8 @@ android { dependencies { implementation(project(":lib")) - implementation("androidx.activity:activity:1.6.1") - implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.6.0") + implementation("androidx.activity:activity:1.7.0") + implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.6.1") testImplementation("junit:junit:4.13.2") androidTestImplementation("androidx.test:runner:1.5.2") androidTestImplementation("androidx.test.espresso:espresso-core:3.5.1") diff --git a/build.gradle.kts b/build.gradle.kts index efb5692..11140f5 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -2,12 +2,12 @@ plugins { val androidGradleVersion = "7.4.2" id("com.android.application") version androidGradleVersion apply false id("com.android.library") version androidGradleVersion apply false - id("com.github.ben-manes.versions") version "0.44.0" - id("org.jetbrains.kotlin.android") version "1.8.10" apply false + id("com.github.ben-manes.versions") version "0.46.0" + id("org.jetbrains.kotlin.android") version "1.8.20" apply false } buildscript { dependencies { - classpath("com.vanniktech:gradle-maven-publish-plugin:0.24.0") + classpath("com.vanniktech:gradle-maven-publish-plugin:0.25.1") } } diff --git a/lib/build.gradle.kts b/lib/build.gradle.kts index 3d60575..2b58190 100644 --- a/lib/build.gradle.kts +++ b/lib/build.gradle.kts @@ -23,6 +23,7 @@ android { dependencies { api("androidx.collection:collection-ktx:1.2.0") + api("androidx.core:core:1.10.0") api("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.4") testImplementation("junit:junit:4.13.2") androidTestImplementation("androidx.test:runner:1.5.2") diff --git a/lib/src/main/java/be/mygod/librootkotlinx/Utils.kt b/lib/src/main/java/be/mygod/librootkotlinx/Utils.kt index d4aa2a0..a35a0cb 100644 --- a/lib/src/main/java/be/mygod/librootkotlinx/Utils.kt +++ b/lib/src/main/java/be/mygod/librootkotlinx/Utils.kt @@ -4,16 +4,20 @@ package be.mygod.librootkotlinx import android.annotation.SuppressLint import android.content.Context -import android.os.Build import android.os.Parcel import android.os.Parcelable import android.system.ErrnoException import android.system.OsConstants -import android.util.* +import android.util.Size +import android.util.SizeF +import android.util.SparseBooleanArray +import android.util.SparseIntArray +import android.util.SparseLongArray import androidx.annotation.RequiresApi +import androidx.core.os.ParcelCompat import kotlinx.parcelize.Parcelize import java.io.IOException -import java.util.* +import java.util.Locale class NoShellException(cause: Throwable) : Exception("Root missing", cause) @@ -250,9 +254,7 @@ inline fun ByteArray.toParcelable(classLoader: ClassLoa useParcel { p -> p.unmarshall(this, 0, size) p.setDataPosition(0) - if (Build.VERSION.SDK_INT < 33) @Suppress("DEPRECATION") { - p.readParcelable(classLoader) - } else p.readParcelable(classLoader, T::class.java) + ParcelCompat.readParcelable(p, classLoader, T::class.java) } // Stream closed caused in NullOutputStream