mirror of
https://github.com/Aviortheking/Neo-Store.git
synced 2025-07-24 20:59:51 +00:00
Fix install prompt notification, further automate updates/installs.
Fixes "tap to install" notification not launching an activity. Install notifications moved to InstallerService so that we only show them for apps that need intervention (and lets us preserve our install session). All installs go to the installer, allowing for downloads to jump straight into installation if possible (auto updates or showing prompt on A9 and earlier). If a prompt is needed, the notification is still shown. Additional utility function checks if app is in the foreground. Used to ensure that we do not launch a prompt that cannot be launched. Miscellaneous comments have been added and improved.
This commit is contained in:
@ -1,9 +1,15 @@
|
||||
package com.looker.droidify
|
||||
|
||||
import android.app.PendingIntent
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.content.pm.PackageInstaller
|
||||
import android.net.Uri
|
||||
import com.looker.droidify.ContextWrapperX.Companion.wrap
|
||||
import com.looker.droidify.installer.InstallerService
|
||||
import com.looker.droidify.screen.ScreenActivity
|
||||
import com.looker.droidify.utility.extension.android.Android
|
||||
import kotlinx.coroutines.withContext
|
||||
|
||||
class MainActivity : ScreenActivity() {
|
||||
companion object {
|
||||
@ -16,12 +22,35 @@ class MainActivity : ScreenActivity() {
|
||||
override fun handleIntent(intent: Intent?) {
|
||||
when (intent?.action) {
|
||||
ACTION_UPDATES -> handleSpecialIntent(SpecialIntent.Updates)
|
||||
ACTION_INSTALL -> handleSpecialIntent(
|
||||
SpecialIntent.Install(
|
||||
intent.packageName,
|
||||
intent.getStringExtra(EXTRA_CACHE_FILE_NAME)
|
||||
)
|
||||
)
|
||||
ACTION_INSTALL -> {
|
||||
// continue install prompt
|
||||
val promptIntent: Intent? = intent.getParcelableExtra(Intent.EXTRA_INTENT)
|
||||
|
||||
promptIntent?.let {
|
||||
it.putExtra(Intent.EXTRA_NOT_UNKNOWN_SOURCE, true)
|
||||
it.putExtra(Intent.EXTRA_INSTALLER_PACKAGE_NAME, BuildConfig.APPLICATION_ID)
|
||||
it.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK )
|
||||
|
||||
startActivity(it)
|
||||
}
|
||||
|
||||
// TODO: send this back to the InstallerService to free up the UI
|
||||
// prepare prompt intent
|
||||
// val name = intent.getStringExtra(PackageInstaller.EXTRA_PACKAGE_NAME)
|
||||
//
|
||||
// val pending = PendingIntent.getService(
|
||||
// this,
|
||||
// 0,
|
||||
// Intent(this, InstallerService::class.java)
|
||||
// .setData(Uri.parse("package:$name"))
|
||||
// .putExtra(Intent.EXTRA_INTENT, promptIntent)
|
||||
// .setFlags(Intent.FLAG_ACTIVITY_NEW_TASK),
|
||||
// if (Android.sdk(23)) PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE
|
||||
// else PendingIntent.FLAG_UPDATE_CURRENT
|
||||
// )
|
||||
//
|
||||
// pending.send()
|
||||
}
|
||||
else -> super.handleIntent(intent)
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user