Skip to content
This repository has been archived by the owner on Dec 30, 2023. It is now read-only.

Commit

Permalink
bring back upstream code for release APK check
Browse files Browse the repository at this point in the history
Upstream code checks whether the current APK was signed with the release
key for various reasons:
- in order to show/hide the "Updates" settings menu
- in order to make the "Updates" settings menu searchable or not
- in order to check/not check for updates at the application start

This behavior was removed in NewPipe SponsorBlock fork, but it probably
shouldn't have been:

- the newer APK installation won't work if the locally installed APK
  wasn't signed with the same key
- `isReleaseApk` function was still invoked in NewPipe SponsorBlock to
  allow searching "Updates" settings from settings menu. But as the
  fingerprint wasn't correct (see 25575ea), the update settings
  would not be searchable which is a bug
- this is a requirement for F-Droid inclusion as they sign their APKs
  with their own keys (so the updater wouldn't work) and they explicitly
  forbid auto-updaters by policy (see also
  polymorphicshade#8)
  • Loading branch information
gilbsgilbs committed May 1, 2022
1 parent 25575ea commit b2ace08
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
6 changes: 6 additions & 0 deletions app/src/main/java/org/schabi/newpipe/NewVersionWorker.kt
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import org.schabi.newpipe.extractor.downloader.Response
import org.schabi.newpipe.extractor.exceptions.ReCaptchaException
import org.schabi.newpipe.util.ReleaseVersionUtil.coerceUpdateCheckExpiry
import org.schabi.newpipe.util.ReleaseVersionUtil.isLastUpdateCheckExpired
import org.schabi.newpipe.util.ReleaseVersionUtil.isReleaseApk
import org.schabi.newpipe.util.Version
import java.io.IOException

Expand Down Expand Up @@ -69,6 +70,11 @@ class NewVersionWorker(

@Throws(IOException::class, ReCaptchaException::class)
private fun checkNewVersion() {
// Check if the current apk is a github one or not.
if (!isReleaseApk()) {
return
}

val prefs = PreferenceManager.getDefaultSharedPreferences(applicationContext)
// Check if the last request has happened a certain time ago
// to reduce the number of API requests.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

import org.schabi.newpipe.MainActivity;
import org.schabi.newpipe.R;
import org.schabi.newpipe.util.ReleaseVersionUtil;

public class MainSettingsFragment extends BasePreferenceFragment {
public static final boolean DEBUG = MainActivity.DEBUG;
Expand All @@ -21,6 +22,14 @@ public void onCreatePreferences(final Bundle savedInstanceState, final String ro

setHasOptionsMenu(true); // Otherwise onCreateOptionsMenu is not called

// Check if the app is updatable
if (!ReleaseVersionUtil.isReleaseApk()) {
getPreferenceScreen().removePreference(
findPreference(getString(R.string.update_pref_screen_key)));

defaultPreferences.edit().putBoolean(getString(R.string.update_app_key), false).apply();
}

// Hide debug preferences in RELEASE build variant
if (!DEBUG) {
getPreferenceScreen().removePreference(
Expand Down

0 comments on commit b2ace08

Please sign in to comment.