[app] request update ownership for newly installed apps

This way, when trying to update the app with another "store", the user will need to confirm a scary warning.
This commit is contained in:
Torsten Grote
2024-03-25 10:03:05 -03:00
committed by Hans-Christoph Steiner
parent dc4648b740
commit 2c394e4a99
2 changed files with 9 additions and 0 deletions

View File

@@ -60,6 +60,7 @@
android:name="android.permission.QUERY_ALL_PACKAGES"
tools:ignore="QueryAllPackagesPermission" />
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
<uses-permission android:name="android.permission.ENFORCE_UPDATE_OWNERSHIP" />
<application
android:name=".FDroidApp"

View File

@@ -107,6 +107,14 @@ public class SessionInstallManager extends BroadcastReceiver {
if (Build.VERSION.SDK_INT >= 33) {
params.setPackageSource(PackageInstaller.PACKAGE_SOURCE_STORE);
}
if (Build.VERSION.SDK_INT >= 34) {
// Once the update ownership enforcement is enabled,
// the other installers will need the user action to update the package
// even if the installers have been granted the INSTALL_PACKAGES permission.
// The update ownership enforcement can only be enabled on initial installation.
// Set this to true on package update is a no-op.
params.setRequestUpdateOwnership(true);
}
return params;
}