From dcd3bc58a380d50338ac624c3fc05edcb995bd8b Mon Sep 17 00:00:00 2001 From: vvb2060 Date: Sat, 24 Aug 2024 02:46:47 +0800 Subject: [PATCH] app: target api 35 --- .../magisk/ui/superuser/SuperuserViewModel.kt | 4 ++-- .../magisk/ui/surequest/SuRequestViewModel.kt | 2 +- .../java/com/topjohnwu/magisk/core/model/su/SuLog.kt | 11 +++++------ .../com/topjohnwu/magisk/core/su/SuCallbackHandler.kt | 2 +- .../com/topjohnwu/magisk/core/tasks/AppMigration.kt | 5 +++-- buildSrc/src/main/java/Setup.kt | 10 +++++----- 6 files changed, 17 insertions(+), 17 deletions(-) diff --git a/app/apk/src/main/java/com/topjohnwu/magisk/ui/superuser/SuperuserViewModel.kt b/app/apk/src/main/java/com/topjohnwu/magisk/ui/superuser/SuperuserViewModel.kt index af24fdde8..6af21a5a2 100644 --- a/app/apk/src/main/java/com/topjohnwu/magisk/ui/superuser/SuperuserViewModel.kt +++ b/app/apk/src/main/java/com/topjohnwu/magisk/ui/superuser/SuperuserViewModel.kt @@ -78,8 +78,8 @@ class SuperuserViewModel( this@SuperuserViewModel, policy, info.packageName, info.sharedUserId != null, - info.applicationInfo.loadIcon(pm), - info.applicationInfo.getLabel(pm) + info.applicationInfo?.loadIcon(pm) ?: pm.defaultActivityIcon, + info.applicationInfo?.getLabel(pm) ?: info.packageName ) } catch (e: PackageManager.NameNotFoundException) { null diff --git a/app/apk/src/main/java/com/topjohnwu/magisk/ui/surequest/SuRequestViewModel.kt b/app/apk/src/main/java/com/topjohnwu/magisk/ui/surequest/SuRequestViewModel.kt index 2c1663e82..4d1a830f7 100644 --- a/app/apk/src/main/java/com/topjohnwu/magisk/ui/surequest/SuRequestViewModel.kt +++ b/app/apk/src/main/java/com/topjohnwu/magisk/ui/surequest/SuRequestViewModel.kt @@ -111,7 +111,7 @@ class SuRequestViewModel( // shared UID. We have no way to know where this request comes from. icon = pm.defaultActivityIcon title = "[SharedUID] ${info.sharedUserId}" - packageName = info.sharedUserId + packageName = info.sharedUserId.toString() } else { val prefix = if (info.sharedUserId == null) "" else "[SharedUID] " icon = app.loadIcon(pm) diff --git a/app/core/src/main/java/com/topjohnwu/magisk/core/model/su/SuLog.kt b/app/core/src/main/java/com/topjohnwu/magisk/core/model/su/SuLog.kt index f37bc734e..15f688c6d 100644 --- a/app/core/src/main/java/com/topjohnwu/magisk/core/model/su/SuLog.kt +++ b/app/core/src/main/java/com/topjohnwu/magisk/core/model/su/SuLog.kt @@ -1,6 +1,6 @@ package com.topjohnwu.magisk.core.model.su -import android.content.pm.PackageInfo +import android.content.pm.ApplicationInfo import android.content.pm.PackageManager import androidx.room.Entity import androidx.room.PrimaryKey @@ -24,7 +24,7 @@ class SuLog( } fun PackageManager.createSuLog( - info: PackageInfo, + info: ApplicationInfo, toUid: Int, fromPid: Int, command: String, @@ -33,13 +33,12 @@ fun PackageManager.createSuLog( context: String, gids: String, ): SuLog { - val appInfo = info.applicationInfo return SuLog( - fromUid = appInfo.uid, + fromUid = info.uid, toUid = toUid, fromPid = fromPid, - packageName = getNameForUid(appInfo.uid)!!, - appName = appInfo.getLabel(this), + packageName = getNameForUid(info.uid)!!, + appName = info.getLabel(this), command = command, action = policy, target = target, diff --git a/app/core/src/main/java/com/topjohnwu/magisk/core/su/SuCallbackHandler.kt b/app/core/src/main/java/com/topjohnwu/magisk/core/su/SuCallbackHandler.kt index 7ef971a33..65f278e08 100644 --- a/app/core/src/main/java/com/topjohnwu/magisk/core/su/SuCallbackHandler.kt +++ b/app/core/src/main/java/com/topjohnwu/magisk/core/su/SuCallbackHandler.kt @@ -64,7 +64,7 @@ object SuCallbackHandler { val pm = context.packageManager val log = runCatching { - pm.getPackageInfo(fromUid, pid)?.let { + pm.getPackageInfo(fromUid, pid)?.applicationInfo?.let { pm.createSuLog(it, toUid, pid, command, policy, target, seContext, gids) } }.getOrNull() ?: createSuLog(fromUid, toUid, pid, command, policy, target, seContext, gids) diff --git a/app/core/src/main/java/com/topjohnwu/magisk/core/tasks/AppMigration.kt b/app/core/src/main/java/com/topjohnwu/magisk/core/tasks/AppMigration.kt index cac9555fe..fec34f203 100644 --- a/app/core/src/main/java/com/topjohnwu/magisk/core/tasks/AppMigration.kt +++ b/app/core/src/main/java/com/topjohnwu/magisk/core/tasks/AppMigration.kt @@ -125,8 +125,9 @@ object AppMigration { apk: File, out: OutputStream, pkg: String, label: CharSequence ): Boolean { - val info = context.packageManager.getPackageArchiveInfo(apk.path, 0) ?: return false - val origLabel = info.applicationInfo.nonLocalizedLabel.toString() + val pm = context.packageManager + val info = pm.getPackageArchiveInfo(apk.path, 0)?.applicationInfo ?: return false + val origLabel = info.nonLocalizedLabel.toString() try { JarMap.open(apk, true).use { jar -> val je = jar.getJarEntry(ANDROID_MANIFEST) diff --git a/buildSrc/src/main/java/Setup.kt b/buildSrc/src/main/java/Setup.kt index 3c107cc10..4181e1156 100644 --- a/buildSrc/src/main/java/Setup.kt +++ b/buildSrc/src/main/java/Setup.kt @@ -69,7 +69,7 @@ private val Project.androidComponents fun Project.setupCommon() { androidBase { - compileSdkVersion(34) + compileSdkVersion(35) buildToolsVersion = "34.0.0" ndkPath = "$sdkDirectory/ndk/magisk" ndkVersion = "27.0.12077973" @@ -79,8 +79,8 @@ fun Project.setupCommon() { } compileOptions { - sourceCompatibility = JavaVersion.VERSION_17 - targetCompatibility = JavaVersion.VERSION_17 + sourceCompatibility = JavaVersion.VERSION_21 + targetCompatibility = JavaVersion.VERSION_21 } packagingOptions { @@ -108,7 +108,7 @@ fun Project.setupCommon() { tasks.withType { compilerOptions { - jvmTarget = JvmTarget.JVM_17 + jvmTarget = JvmTarget.JVM_21 } } } @@ -296,7 +296,7 @@ fun Project.setupAppCommon() { } defaultConfig { - targetSdk = 34 + targetSdk = 35 } buildTypes {