Fixed prompt for allow app installs not showing from self updater

Also making it so the silent installer doesn't run if the app is not allowed to install packages
This commit is contained in:
Jays2Kings 2021-07-20 18:06:09 -04:00
parent 7b493fca8f
commit 29c6c892c7
3 changed files with 9 additions and 2 deletions

View File

@ -4,6 +4,7 @@ import android.app.ActivityManager
import android.app.ActivityManager.RunningAppProcessInfo.IMPORTANCE_FOREGROUND
import android.app.ActivityManager.RunningAppProcessInfo.IMPORTANCE_VISIBLE
import android.content.Context
import android.os.Build
import androidx.core.app.NotificationCompat
import androidx.work.Constraints
import androidx.work.CoroutineWorker
@ -24,6 +25,12 @@ class AutoUpdaterJob(private val context: Context, workerParams: WorkerParameter
override suspend fun doWork(): Result = coroutineScope {
try {
if (
Build.VERSION.SDK_INT >= Build.VERSION_CODES.O &&
!context.packageManager.canRequestPackageInstalls()
) {
return@coroutineScope Result.failure()
}
val result = UpdateChecker.getUpdateChecker().checkForUpdate()
if (result is UpdateResult.NewUpdate<*> && !UpdaterService.isRunning()) {
UpdaterNotifier(context).cancel()

View File

@ -17,7 +17,7 @@ class UpdaterBroadcast : BroadcastReceiver() {
when (val status = extras.getInt(PackageInstaller.EXTRA_STATUS)) {
PackageInstaller.STATUS_PENDING_USER_ACTION -> {
val confirmIntent = extras[Intent.EXTRA_INTENT] as? Intent
context.startActivity(confirmIntent)
context.startActivity(confirmIntent?.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK))
}
PackageInstaller.STATUS_SUCCESS -> {
val prefs = PreferenceManager.getDefaultSharedPreferences(context)

View File

@ -97,7 +97,7 @@ object AndroidVersions {
const val minSdk = 23
const val targetSdk = 30
const val versionCode = 77
const val versionName = "1.1.1"
const val versionName = "1.1.0"
const val ndk = "22.0.7026061"
}