add failsafe pref to disable using new index

If the client fails due to some bug in handling index-v1.jar, then it will
be totally stuck, even if index.jar would have worked.  This creates a new,
temporary "expert" preference to force the client only use the old XML
index file.  Worst comes to worst, we can tell people to enable this to
upgrade.

Once everything proves stable, we can remove this.
This commit is contained in:
Hans-Christoph Steiner 2017-06-07 17:33:37 +02:00
parent ee1871f07e
commit 53a17e6146
4 changed files with 15 additions and 1 deletions

View File

@ -53,6 +53,7 @@ public final class Preferences implements SharedPreferences.OnSharedPreferenceCh
public static final String PREF_UNSTABLE_UPDATES = "unstableUpdates";
public static final String PREF_KEEP_INSTALL_HISTORY = "keepInstallHistory";
public static final String PREF_EXPERT = "expert";
public static final String PREF_FORCE_OLD_INDEX = "forceOldIndex";
public static final String PREF_PRIVILEGED_INSTALLER = "privilegedInstaller";
public static final String PREF_UNINSTALL_PRIVILEGED_APP = "uninstallPrivilegedApp";
public static final String PREF_LOCAL_REPO_NAME = "localRepoName";
@ -82,6 +83,7 @@ public final class Preferences implements SharedPreferences.OnSharedPreferenceCh
public static final String DEFAULT_PROXY_HOST = "127.0.0.1";
public static final int DEFAULT_PROXY_PORT = 8118;
private static final boolean DEFAULT_SHOW_NFC_DURING_SWAP = true;
private static final boolean DEFAULT_FORCE_OLD_INDEX = false;
private static final boolean DEFAULT_POST_PRIVILEGED_INSTALL = false;
public enum Theme {
@ -114,6 +116,10 @@ public final class Preferences implements SharedPreferences.OnSharedPreferenceCh
initialized.put(key, false);
}
public boolean isForceOldIndexEnabled() {
return preferences.getBoolean(PREF_FORCE_OLD_INDEX, DEFAULT_FORCE_OLD_INDEX);
}
/**
* Whether to use the Privileged Installer, based on if it is installed. Only the disabled
* state is stored as a preference since the enabled state is based entirely on the presence

View File

@ -409,7 +409,7 @@ public class UpdateService extends IntentService {
try {
RepoUpdater updater = new IndexV1Updater(this, repo);
//TODO setProgressListeners(updater);
if (!updater.update()) {
if (Preferences.get().isForceOldIndexEnabled() || !updater.update()) {
updater = new RepoUpdater(getBaseContext(), repo);
setProgressListeners(updater);
updater.update();

View File

@ -18,6 +18,8 @@
<string name="unstable_updates_summary">Suggest updates to unstable versions</string>
<string name="keep_install_history">Keep install history</string>
<string name="keep_install_history_summary">Store a log of all installs and uninstalls inside F-Droid</string>
<string name="force_old_index">Force old index format</string>
<string name="force_old_index_summary">In case there are bugs or compatibility issues, use the XML app index</string>
<string name="other">Other</string>
<string name="update_interval">Automatic update interval</string>

View File

@ -111,6 +111,12 @@
android:summary="@string/keep_install_history_summary"
android:defaultValue="false"
android:dependency="expert" />
<CheckBoxPreference
android:key="forceOldIndex"
android:title="@string/force_old_index"
android:summary="@string/force_old_index_summary"
android:defaultValue="false"
android:dependency="expert" />
<CheckBoxPreference android:title="@string/system_installer"
android:defaultValue="false"
android:key="privilegedInstaller"