Merge branch 'random-fixes-from-downloaderservice-hacking' into 'master'
Random fixes from DownloaderService hacking Here are some random fixes that I did in the process of the DownloaderService refactoring. I don't think anything should be controversial. Thanks for your rapid code reviews recently @mvdan :) See merge request !245
This commit is contained in:
commit
41d54f7e92
@ -40,7 +40,7 @@ public final class Preferences implements SharedPreferences.OnSharedPreferenceCh
|
||||
if (preferences.getString(PREF_LOCAL_REPO_NAME, null) == null) {
|
||||
preferences.edit()
|
||||
.putString(PREF_LOCAL_REPO_NAME, getDefaultLocalRepoName())
|
||||
.commit();
|
||||
.apply();
|
||||
}
|
||||
}
|
||||
|
||||
@ -113,7 +113,7 @@ public final class Preferences implements SharedPreferences.OnSharedPreferenceCh
|
||||
}
|
||||
|
||||
public void setPrivilegedInstallerEnabled(boolean enable) {
|
||||
preferences.edit().putBoolean(PREF_PRIVILEGED_INSTALLER, enable).commit();
|
||||
preferences.edit().putBoolean(PREF_PRIVILEGED_INSTALLER, enable).apply();
|
||||
}
|
||||
|
||||
public boolean isFirstTime() {
|
||||
@ -121,7 +121,7 @@ public final class Preferences implements SharedPreferences.OnSharedPreferenceCh
|
||||
}
|
||||
|
||||
public void setFirstTime(boolean firstTime) {
|
||||
preferences.edit().putBoolean(PREF_FIRST_TIME, firstTime).commit();
|
||||
preferences.edit().putBoolean(PREF_FIRST_TIME, firstTime).apply();
|
||||
}
|
||||
|
||||
public boolean isPostPrivilegedInstall() {
|
||||
@ -129,7 +129,7 @@ public final class Preferences implements SharedPreferences.OnSharedPreferenceCh
|
||||
}
|
||||
|
||||
public void setPostPrivilegedInstall(boolean postInstall) {
|
||||
preferences.edit().putBoolean(PREF_POST_PRIVILEGED_INSTALL, postInstall).commit();
|
||||
preferences.edit().putBoolean(PREF_POST_PRIVILEGED_INSTALL, postInstall).apply();
|
||||
}
|
||||
|
||||
public boolean shouldCacheApks() {
|
||||
@ -149,7 +149,7 @@ public final class Preferences implements SharedPreferences.OnSharedPreferenceCh
|
||||
}
|
||||
|
||||
public void setShowNfcDuringSwap(boolean show) {
|
||||
preferences.edit().putBoolean(PREF_SHOW_NFC_DURING_SWAP, show).commit();
|
||||
preferences.edit().putBoolean(PREF_SHOW_NFC_DURING_SWAP, show).apply();
|
||||
}
|
||||
|
||||
public boolean expertMode() {
|
||||
|
@ -406,7 +406,7 @@ public class UpdateService extends IntentService implements ProgressListener {
|
||||
|
||||
SharedPreferences.Editor e = prefs.edit();
|
||||
e.putLong(Preferences.PREF_UPD_LAST, System.currentTimeMillis());
|
||||
e.commit();
|
||||
e.apply();
|
||||
|
||||
if (errorRepos == 0) {
|
||||
if (changes) {
|
||||
|
@ -11,6 +11,12 @@ import org.fdroid.fdroid.data.SanitizedFile;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
/**
|
||||
* This class works only with {@link SanitizedFile} instances to enforce
|
||||
* filtering of the file names from files downloaded from the internet.
|
||||
* This helps prevent things like SQL injection, shell command injection
|
||||
* and other attacks based on putting various characters into filenames.
|
||||
*/
|
||||
public class FileCompat extends Compatibility {
|
||||
|
||||
private static final String TAG = "FileCompat";
|
||||
|
@ -40,7 +40,7 @@ public abstract class Downloader {
|
||||
|
||||
protected abstract InputStream getDownloadersInputStream() throws IOException;
|
||||
|
||||
protected abstract void close() throws IOException;
|
||||
protected abstract void close();
|
||||
|
||||
Downloader(URL url, File destFile)
|
||||
throws FileNotFoundException, MalformedURLException {
|
||||
@ -117,11 +117,6 @@ public abstract class Downloader {
|
||||
}
|
||||
|
||||
/**
|
||||
* In a synchronous download (the usual usage of the Downloader interface),
|
||||
* you will not be able to interrupt this because the thread will block
|
||||
* after you have called download(). However if you use the AsyncDownloadWrapper,
|
||||
* then it will use this mechanism to cancel the download.
|
||||
*
|
||||
* After every network operation that could take a while, we will check if an
|
||||
* interrupt occured during that blocking operation. The goal is to ensure we
|
||||
* don't move onto another slow, network operation if we have cancelled the
|
||||
|
@ -1,5 +1,7 @@
|
||||
package org.fdroid.fdroid.net;
|
||||
|
||||
import org.fdroid.fdroid.Utils;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
@ -10,22 +12,23 @@ import java.net.URL;
|
||||
|
||||
public class LocalFileDownloader extends Downloader {
|
||||
|
||||
private InputStream inputStream;
|
||||
|
||||
LocalFileDownloader(URL url, File destFile) throws FileNotFoundException, MalformedURLException {
|
||||
super(url, destFile);
|
||||
}
|
||||
|
||||
private File getFileToDownload() {
|
||||
return new File(sourceUrl.getPath());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected InputStream getDownloadersInputStream() throws IOException {
|
||||
return new FileInputStream(getFileToDownload());
|
||||
inputStream = new FileInputStream(new File(sourceUrl.getPath()));
|
||||
return inputStream;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void close() throws IOException {
|
||||
// Do nothing.
|
||||
protected void close() {
|
||||
if (inputStream != null) {
|
||||
Utils.closeQuietly(inputStream);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -141,7 +141,7 @@ public abstract class AppListFragment extends ListFragment implements
|
||||
boolean hasTriedEmptyUpdate = prefs.getBoolean(triedEmptyUpdate, false);
|
||||
if (!hasTriedEmptyUpdate) {
|
||||
Utils.debugLog(TAG, "Empty app list, and we haven't done an update yet. Forcing repo update.");
|
||||
prefs.edit().putBoolean(triedEmptyUpdate, true).commit();
|
||||
prefs.edit().putBoolean(triedEmptyUpdate, true).apply();
|
||||
UpdateService.updateNow(getActivity());
|
||||
return true;
|
||||
}
|
||||
|
@ -230,7 +230,7 @@ public class AvailableAppsFragment extends AppListFragment implements
|
||||
Context.MODE_PRIVATE);
|
||||
SharedPreferences.Editor e = p.edit();
|
||||
e.putString(CATEGORY_KEY, currentCategory);
|
||||
e.commit();
|
||||
e.apply();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -204,13 +204,13 @@ public class PreferencesFragment extends PreferenceFragment
|
||||
// privileged permission are granted, i.e. the extension is installed correctly
|
||||
SharedPreferences.Editor editor = pref.getSharedPreferences().edit();
|
||||
editor.putBoolean(Preferences.PREF_PRIVILEGED_INSTALLER, true);
|
||||
editor.commit();
|
||||
editor.apply();
|
||||
pref.setChecked(true);
|
||||
} else {
|
||||
// privileged permission not available
|
||||
SharedPreferences.Editor editor = pref.getSharedPreferences().edit();
|
||||
editor.putBoolean(Preferences.PREF_PRIVILEGED_INSTALLER, false);
|
||||
editor.commit();
|
||||
editor.apply();
|
||||
pref.setChecked(false);
|
||||
|
||||
AlertDialog.Builder alertBuilder = new AlertDialog.Builder(getActivity());
|
||||
@ -248,7 +248,7 @@ public class PreferencesFragment extends PreferenceFragment
|
||||
} else {
|
||||
SharedPreferences.Editor editor = pref.getSharedPreferences().edit();
|
||||
editor.putBoolean(Preferences.PREF_PRIVILEGED_INSTALLER, false);
|
||||
editor.commit();
|
||||
editor.apply();
|
||||
pref.setChecked(false);
|
||||
}
|
||||
|
||||
|
@ -108,7 +108,7 @@
|
||||
<string name="proxy_port_summary">Määritä välityspalvelimesi porttinumero (esim. 8118)</string>
|
||||
<string name="repos_unchanged">Yhdessäkään säilössä ei ole pakettipäivityksiä</string>
|
||||
<string name="all_other_repos_fine">Muut säilöt eivät luoneet virheitä.</string>
|
||||
<string name="global_error_updating_repos">Päivityksenaikainen virhe:</string>
|
||||
<string name="global_error_updating_repos">Päivityksenaikainen virhe: %s</string>
|
||||
<string name="theme">Teema</string>
|
||||
<string name="unverified">Vahvistamaton</string>
|
||||
<string name="repo_not_yet_updated">Tätä säilöä ei ole vielä käytetty.
|
||||
|
@ -63,7 +63,7 @@
|
||||
<string name="status_connecting_to_repo">Jungiamasi prie
|
||||
%1$s</string>
|
||||
<string name="repos_unchanged">Įjungtose saugyklose nėra nieko naujo</string>
|
||||
<string name="global_error_updating_repos">Klaida naujinant:</string>
|
||||
<string name="global_error_updating_repos">Klaida naujinant: %s</string>
|
||||
<string name="theme">Tema</string>
|
||||
<string name="repo_num_apps">Programų kiekis</string>
|
||||
<string name="repo_description">Aprašymas</string>
|
||||
|
@ -184,7 +184,7 @@
|
||||
|
||||
<string name="local_repo_running">F-Droid已准备好交换应用</string>
|
||||
<string name="touch_to_configure_local_repo">触摸可查看详细信息以及允许其他人与你交换应用程序。</string>
|
||||
<string name="adding_apks_format">正在添加 %s 到软件源…</string>
|
||||
<string name="adding_apks_format">正在添加 %s 到软件源…</string>
|
||||
<string name="writing_index_jar">正在写入已签名的索引文件(index.jar)…</string>
|
||||
<string name="failed_to_create_index">创建软件源索引失败!</string>
|
||||
<string name="linking_apks">正在链接APK到软件源……</string>
|
||||
|
Loading…
x
Reference in New Issue
Block a user