mirror of
https://github.com/f-droid/fdroidclient.git
synced 2026-06-02 21:05:41 -04:00
Allow a privileged system app to tell us to update all repos
This is useful for a setup wizard app that wants to ensure the repos are loaded during setup, so a restore from backup can already link to our apps, and we will find them.
This commit is contained in:
@@ -25,6 +25,12 @@
|
||||
<uses-permission android:name="android.permission.ENFORCE_UPDATE_OWNERSHIP" />
|
||||
<uses-permission android:name="android.permission.UPDATE_PACKAGES_WITHOUT_USER_ACTION" />
|
||||
|
||||
<!-- Permission used to externally trigger repository updates -->
|
||||
<permission
|
||||
android:name="${applicationId}.permission.UPDATE_REPOS"
|
||||
android:protectionLevel="signature|privileged" />
|
||||
<uses-permission android:name="${applicationId}.permission.UPDATE_REPOS" />
|
||||
|
||||
<application
|
||||
android:name="org.fdroid.App"
|
||||
android:allowBackup="true"
|
||||
@@ -115,6 +121,17 @@
|
||||
android:screenOrientation="fullSensor"
|
||||
tools:ignore="DiscouragedApi"
|
||||
tools:replace="screenOrientation" />
|
||||
<activity
|
||||
android:name="org.fdroid.ui.repositories.UpdateRepoActivity"
|
||||
android:excludeFromRecents="true"
|
||||
android:exported="true"
|
||||
android:launchMode="singleInstance"
|
||||
android:permission="${applicationId}.permission.UPDATE_REPOS">
|
||||
<intent-filter>
|
||||
<action android:name="org.fdroid.action.UPDATE_REPOS" />
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
<service
|
||||
android:name="org.fdroid.install.AppInstallService"
|
||||
|
||||
@@ -127,6 +127,7 @@ constructor(
|
||||
}
|
||||
try {
|
||||
if (canStartForegroundService(applicationContext)) setForeground(getForegroundInfo())
|
||||
else log.info { "Not using foreground service" }
|
||||
} catch (e: Exception) {
|
||||
log.error(e) { "Error while running setForeground: " }
|
||||
}
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
package org.fdroid.ui.repositories
|
||||
|
||||
import android.os.Bundle
|
||||
import android.util.Log
|
||||
import androidx.activity.ComponentActivity
|
||||
import org.fdroid.repo.RepoUpdateWorker
|
||||
|
||||
private val TAG = UpdateRepoActivity::class.java.simpleName
|
||||
|
||||
/**
|
||||
* This activity allows OS components to trigger a repository update. One known use-case for this is
|
||||
* to do an initial repository update during SetupWizard, so app data is available when needed, e.g.
|
||||
* for restoring app backups.
|
||||
*/
|
||||
class UpdateRepoActivity : ComponentActivity() {
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
if (intent.action != "org.fdroid.action.UPDATE_REPOS") {
|
||||
Log.w(TAG, "Unknown action: ${intent.action}")
|
||||
return
|
||||
}
|
||||
Log.i(TAG, "Intent received, updating repos...")
|
||||
RepoUpdateWorker.updateNow(this)
|
||||
finish()
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user