From d527547f6a2edd8b01ec16f82fa6c6ec4d08ba6c Mon Sep 17 00:00:00 2001 From: Jays2Kings Date: Mon, 5 Jul 2021 14:57:09 -0400 Subject: [PATCH] Skip user action requirement when installing extensions on a12 --- .../tachiyomi/extension/util/ExtensionInstallActivity.kt | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/extension/util/ExtensionInstallActivity.kt b/app/src/main/java/eu/kanade/tachiyomi/extension/util/ExtensionInstallActivity.kt index e77f2d4092..6d948674b2 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/extension/util/ExtensionInstallActivity.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/extension/util/ExtensionInstallActivity.kt @@ -1,10 +1,13 @@ package eu.kanade.tachiyomi.extension.util +import android.annotation.SuppressLint import android.app.Activity import android.app.PendingIntent import android.content.Intent import android.content.pm.PackageInstaller import android.content.pm.PackageInstaller.SessionParams +import android.content.pm.PackageInstaller.SessionParams.USER_ACTION_NOT_REQUIRED +import android.os.Build import android.os.Bundle import android.widget.Toast import com.hippo.unifile.UniFile @@ -20,6 +23,7 @@ import uy.kohesive.injekt.injectLazy */ class ExtensionInstallActivity : Activity() { + @SuppressLint("NewApi") override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) try { @@ -37,8 +41,9 @@ class ExtensionInstallActivity : Activity() { ) // TODO: Add once compiling via SDK 31 // if (Build.VERSION.SDK_INT >= 31) { -// params.setRequireUserAction(USER_ACTION_NOT_REQUIRED) -// } + if (Build.VERSION.PREVIEW_SDK_INT + Build.VERSION.SDK_INT >= 31) { + params.setRequireUserAction(USER_ACTION_NOT_REQUIRED) + } val sessionId = packageInstaller.createSession(params) val session = packageInstaller.openSession(sessionId) session.openWrite("package", 0, -1).use { packageInSession ->