0
0
Fork 0
mirror of https://github.com/YTVanced/VancedManager synced 2024-11-24 20:25:13 +00:00

android 12 crash fixes

This commit is contained in:
X1nto 2021-10-08 15:05:46 +04:00
parent 715eb9cf7a
commit 1cd0294801
3 changed files with 12 additions and 4 deletions

View file

@ -113,6 +113,7 @@ dependencies {
implementation("androidx.navigation:navigation-ui-ktx:2.3.5") implementation("androidx.navigation:navigation-ui-ktx:2.3.5")
implementation("androidx.preference:preference-ktx:1.1.1") implementation("androidx.preference:preference-ktx:1.1.1")
implementation("androidx.swiperefreshlayout:swiperefreshlayout:1.1.0") implementation("androidx.swiperefreshlayout:swiperefreshlayout:1.1.0")
implementation("androidx.work:work-runtime-ktx:2.7.0-rc01")
// Compose // Compose

View file

@ -1,5 +1,6 @@
package com.vanced.manager.utils package com.vanced.manager.utils
import android.app.PendingIntent
import android.os.Build import android.os.Build
fun getArch(): String = when { fun getArch(): String = when {
@ -7,3 +8,9 @@ fun getArch(): String = when {
Build.SUPPORTED_ABIS.contains("arm64-v8a") -> "arm64_v8a" Build.SUPPORTED_ABIS.contains("arm64-v8a") -> "arm64_v8a"
else -> "armeabi_v7a" else -> "armeabi_v7a"
} }
val intentFlags =
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S)
PendingIntent.FLAG_MUTABLE
else
0

View file

@ -159,7 +159,7 @@ object PackageHelper {
fun uninstallApk(pkg: String, context: Context) { fun uninstallApk(pkg: String, context: Context) {
val callbackIntent = Intent(context, AppUninstallerService::class.java) val callbackIntent = Intent(context, AppUninstallerService::class.java)
callbackIntent.putExtra("pkg", pkg) callbackIntent.putExtra("pkg", pkg)
val pendingIntent = PendingIntent.getService(context, 0, callbackIntent, 0) val pendingIntent = PendingIntent.getService(context, 0, callbackIntent, intentFlags)
try { try {
context.packageManager.packageInstaller.uninstall(pkg, pendingIntent.intentSender) context.packageManager.packageInstaller.uninstall(pkg, pendingIntent.intentSender)
} catch (e: Exception) { } catch (e: Exception) {
@ -169,7 +169,7 @@ object PackageHelper {
fun install(path: String, context: Context) { fun install(path: String, context: Context) {
val callbackIntent = Intent(context, AppInstallerService::class.java) val callbackIntent = Intent(context, AppInstallerService::class.java)
val pendingIntent = PendingIntent.getService(context, 0, callbackIntent, 0) val pendingIntent = PendingIntent.getService(context, 0, callbackIntent, intentFlags)
val packageInstaller = context.packageManager.packageInstaller val packageInstaller = context.packageManager.packageInstaller
val params = val params =
PackageInstaller.SessionParams(PackageInstaller.SessionParams.MODE_FULL_INSTALL) PackageInstaller.SessionParams(PackageInstaller.SessionParams.MODE_FULL_INSTALL)
@ -289,7 +289,7 @@ object PackageHelper {
val sessionParams = val sessionParams =
PackageInstaller.SessionParams(PackageInstaller.SessionParams.MODE_FULL_INSTALL) PackageInstaller.SessionParams(PackageInstaller.SessionParams.MODE_FULL_INSTALL)
val callbackIntent = Intent(context, AppInstallerService::class.java) val callbackIntent = Intent(context, AppInstallerService::class.java)
val pendingIntent = PendingIntent.getService(context, 0, callbackIntent, 0) val pendingIntent = PendingIntent.getService(context, 0, callbackIntent, intentFlags)
try { try {
sessionId = packageInstaller.createSession(sessionParams) sessionId = packageInstaller.createSession(sessionParams)
session = packageInstaller.openSession(sessionId) session = packageInstaller.openSession(sessionId)