Skip to content

Commit

Permalink
Add support for requesting update ownership on Android 14+
Browse files Browse the repository at this point in the history
If update ownership is requested during the initial install (it is a
no-op for updates), then other app stores are not allowed to update the
app without explicit user action. This stops Google Play from updating
Firefox because the versionCode of the APKs published there are always
higher.

Signed-off-by: Andrew Gunnerson <[email protected]>
  • Loading branch information
chenxiaolong committed Jun 5, 2024
1 parent 8550817 commit e39f324
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions ffupdater/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
tools:ignore="ScopedStorage" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_DATA_SYNC" />
<uses-permission android:name="android.permission.ENFORCE_UPDATE_OWNERSHIP" />

<!-- Shizuku needs API 23, but I still want to use API 21-->
<uses-sdk tools:overrideLibrary="rikka.shizuku.api, rikka.shizuku.provider, rikka.shizuku.shared, rikka.shizuku.aidl" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,11 @@ open class SessionInstaller(private val foreground: Boolean) : AppInstaller {
if (DeviceSdkTester.supportsAndroid7Nougat24()) params.setOriginatingUid(android.os.Process.myUid())
if (DeviceSdkTester.supportsAndroid8Oreo26()) params.setInstallReason(PackageManager.INSTALL_REASON_USER)
if (DeviceSdkTester.supportsAndroid12S31()) params.setRequireUserAction(USER_ACTION_NOT_REQUIRED)
if (DeviceSdkTester.supportsAndroid14U34()) params.setDontKillApp(true)
if (DeviceSdkTester.supportsAndroid14U34()) {
params.setDontKillApp(true)
// This only takes effect for initial installs, but is a no-op for updates.
params.setRequestUpdateOwnership(true)
}
allowAppReplacement(params)
return params
}
Expand Down

0 comments on commit e39f324

Please sign in to comment.