Commit 77a275cb authored by vvb2060's avatar vvb2060 Committed by John Wu

Show notification when stub is updated to full

parent 3956cbe2
...@@ -61,7 +61,6 @@ object Config : PreferenceModel, DBConfig { ...@@ -61,7 +61,6 @@ object Config : PreferenceModel, DBConfig {
const val BOOT_ID = "boot_id" const val BOOT_ID = "boot_id"
const val ASKED_HOME = "asked_home" const val ASKED_HOME = "asked_home"
const val DOH = "doh" const val DOH = "doh"
const val SHOW_UPDATE_DONE = "update_done"
} }
object Value { object Value {
...@@ -134,7 +133,6 @@ object Config : PreferenceModel, DBConfig { ...@@ -134,7 +133,6 @@ object Config : PreferenceModel, DBConfig {
var suTapjack by preference(Key.SU_TAPJACK, true) var suTapjack by preference(Key.SU_TAPJACK, true)
var checkUpdate by preference(Key.CHECK_UPDATES, true) var checkUpdate by preference(Key.CHECK_UPDATES, true)
var doh by preference(Key.DOH, false) var doh by preference(Key.DOH, false)
var showUpdateDone by preference(Key.SHOW_UPDATE_DONE, false)
var showSystemApp by preference(Key.SHOW_SYSTEM_APP, false) var showSystemApp by preference(Key.SHOW_SYSTEM_APP, false)
var customChannelUrl by preference(Key.CUSTOM_CHANNEL, "") var customChannelUrl by preference(Key.CUSTOM_CHANNEL, "")
......
...@@ -47,9 +47,10 @@ open class Receiver : BaseReceiver() { ...@@ -47,9 +47,10 @@ open class Receiver : BaseReceiver() {
} }
Intent.ACTION_LOCALE_CHANGED -> Shortcuts.setupDynamic(context) Intent.ACTION_LOCALE_CHANGED -> Shortcuts.setupDynamic(context)
Intent.ACTION_MY_PACKAGE_REPLACED -> { Intent.ACTION_MY_PACKAGE_REPLACED -> {
if (Config.showUpdateDone) { @Suppress("DEPRECATION")
val installer = context.packageManager.getInstallerPackageName(context.packageName)
if (installer == context.packageName) {
Notifications.updateDone(context) Notifications.updateDone(context)
Config.showUpdateDone = false
} }
} }
} }
......
...@@ -75,11 +75,6 @@ class DownloadService : NotificationService() { ...@@ -75,11 +75,6 @@ class DownloadService : NotificationService() {
} }
} }
private fun APKInstall.Session.open(): OutputStream {
Config.showUpdateDone = true
return openStream(this@DownloadService)
}
private suspend fun handleApp(stream: InputStream, subject: Subject.App) { private suspend fun handleApp(stream: InputStream, subject: Subject.App) {
fun writeTee(output: OutputStream) { fun writeTee(output: OutputStream) {
val uri = MediaStoreUtils.getFile("${subject.title}.apk").uri val uri = MediaStoreUtils.getFile("${subject.title}.apk").uri
...@@ -115,7 +110,7 @@ class DownloadService : NotificationService() { ...@@ -115,7 +110,7 @@ class DownloadService : NotificationService() {
// Install // Install
val session = APKInstall.startSession(this) val session = APKInstall.startSession(this)
patched.inputStream().copyAndClose(session.open()) patched.inputStream().copyAndClose(session.openStream(this))
subject.intent = session.waitIntent() subject.intent = session.waitIntent()
patched.delete() patched.delete()
...@@ -137,7 +132,7 @@ class DownloadService : NotificationService() { ...@@ -137,7 +132,7 @@ class DownloadService : NotificationService() {
} }
} else { } else {
val session = APKInstall.startSession(this) val session = APKInstall.startSession(this)
writeTee(session.open()) writeTee(session.openStream(this))
subject.intent = session.waitIntent() subject.intent = session.waitIntent()
} }
} }
......
...@@ -51,7 +51,6 @@ class MainActivity : BaseMainActivity<ActivityMainMd2Binding>() { ...@@ -51,7 +51,6 @@ class MainActivity : BaseMainActivity<ActivityMainMd2Binding>() {
setContentView() setContentView()
showUnsupportedMessage() showUnsupportedMessage()
askForHomeShortcut() askForHomeShortcut()
Config.showUpdateDone = false
window.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE) window.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE)
......
...@@ -52,6 +52,7 @@ object Notifications { ...@@ -52,6 +52,7 @@ object Notifications {
@SuppressLint("InlinedApi") @SuppressLint("InlinedApi")
fun updateDone(context: Context) { fun updateDone(context: Context) {
setup(context)
val flag = PendingIntent.FLAG_IMMUTABLE or PendingIntent.FLAG_UPDATE_CURRENT val flag = PendingIntent.FLAG_IMMUTABLE or PendingIntent.FLAG_UPDATE_CURRENT
val pending = PendingIntent.getActivity(context, 0, selfLaunchIntent(context), flag) val pending = PendingIntent.getActivity(context, 0, selfLaunchIntent(context), flag)
val builder = if (SDK_INT >= 26) { val builder = if (SDK_INT >= 26) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment