mirror of
https://github.com/f-droid/fdroidclient.git
synced 2026-06-16 03:39:56 -04:00
Log when we updated ourselves
so we can test if it is feasible to auto-restart the app
This commit is contained in:
@@ -161,6 +161,14 @@
|
||||
<action android:name="android.intent.action.UNARCHIVE_PACKAGE" />
|
||||
</intent-filter>
|
||||
</receiver>
|
||||
|
||||
<receiver
|
||||
android:name="org.fdroid.install.AppUpdateReceiver"
|
||||
android:exported="false">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MY_PACKAGE_REPLACED" />
|
||||
</intent-filter>
|
||||
</receiver>
|
||||
</application>
|
||||
|
||||
</manifest>
|
||||
|
||||
22
app/src/main/kotlin/org/fdroid/install/AppUpdateReceiver.kt
Normal file
22
app/src/main/kotlin/org/fdroid/install/AppUpdateReceiver.kt
Normal file
@@ -0,0 +1,22 @@
|
||||
package org.fdroid.install
|
||||
|
||||
import android.content.BroadcastReceiver
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.content.Intent.ACTION_MY_PACKAGE_REPLACED
|
||||
import androidx.annotation.RequiresApi
|
||||
import mu.KotlinLogging
|
||||
|
||||
class AppUpdateReceiver : BroadcastReceiver() {
|
||||
|
||||
private val log = KotlinLogging.logger {}
|
||||
|
||||
@RequiresApi(35)
|
||||
override fun onReceive(context: Context, intent: Intent) {
|
||||
if (intent.action != ACTION_MY_PACKAGE_REPLACED) {
|
||||
log.warn { "Unknown action: ${intent.action}" }
|
||||
return
|
||||
}
|
||||
log.info { "Intent received, we just updated ourselves!" }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user