Bump minSdkVersion to 10, remove all compat code
Summary of changes: * Remove compat apply() * Remove compat setReadable() * Remove pre-10 compat code in swap * Remove pre-10 compat code in PRNGFixes Fixes #663.
This commit is contained in:
parent
1bfd3425c9
commit
cd1c213fb2
@ -1,12 +1,10 @@
|
||||
package org.fdroid.fdroid.data;
|
||||
|
||||
import android.annotation.TargetApi;
|
||||
import android.content.ContentValues;
|
||||
import android.content.Context;
|
||||
import android.content.res.Resources;
|
||||
import android.database.Cursor;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.provider.ContactsContract;
|
||||
import android.test.ProviderTestCase2MockContext;
|
||||
|
||||
@ -64,7 +62,6 @@ public abstract class FDroidProviderTest<T extends FDroidProvider> extends Provi
|
||||
|
||||
}
|
||||
|
||||
@TargetApi(Build.VERSION_CODES.ECLAIR)
|
||||
public void testObviouslyInvalidUris() {
|
||||
assertInvalidUri("http://www.google.com");
|
||||
assertInvalidUri(ContactsContract.AUTHORITY_URI);
|
||||
|
@ -4,7 +4,7 @@
|
||||
android:installLocation="auto">
|
||||
|
||||
<uses-sdk
|
||||
android:minSdkVersion="8"
|
||||
android:minSdkVersion="10"
|
||||
android:targetSdkVersion="23"
|
||||
/>
|
||||
|
||||
|
@ -79,7 +79,6 @@ import com.nostra13.universalimageloader.core.assist.ImageScaleType;
|
||||
|
||||
import org.fdroid.fdroid.Utils.CommaSeparatedList;
|
||||
import org.fdroid.fdroid.compat.PackageManagerCompat;
|
||||
import org.fdroid.fdroid.compat.PreferencesCompat;
|
||||
import org.fdroid.fdroid.data.Apk;
|
||||
import org.fdroid.fdroid.data.ApkProvider;
|
||||
import org.fdroid.fdroid.data.App;
|
||||
@ -470,9 +469,10 @@ public class AppDetails extends AppCompatActivity {
|
||||
super.onPause();
|
||||
visiblePackageName = null;
|
||||
// save the active URL for this app in case we come back
|
||||
PreferencesCompat.apply(getPreferences(MODE_PRIVATE)
|
||||
.edit()
|
||||
.putString(getPackageNameFromIntent(getIntent()), activeDownloadUrlString));
|
||||
getPreferences(MODE_PRIVATE)
|
||||
.edit()
|
||||
.putString(getPackageNameFromIntent(getIntent()), activeDownloadUrlString)
|
||||
.apply();
|
||||
if (app != null && (app.ignoreAllUpdates != startingIgnoreAll
|
||||
|| app.ignoreThisUpdate != startingIgnoreThis)) {
|
||||
Utils.debugLog(TAG, "Updating 'ignore updates', as it has changed since we started the activity...");
|
||||
@ -614,7 +614,7 @@ public class AppDetails extends AppCompatActivity {
|
||||
activeDownloadUrlString = urlString;
|
||||
} else {
|
||||
// this URL is no longer active, remove it
|
||||
PreferencesCompat.apply(getPreferences(MODE_PRIVATE).edit().remove(packageName));
|
||||
getPreferences(MODE_PRIVATE).edit().remove(packageName).apply();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -28,7 +28,6 @@ import android.content.Intent;
|
||||
import android.content.res.Configuration;
|
||||
import android.database.ContentObserver;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
@ -291,10 +290,6 @@ public class FDroid extends AppCompatActivity implements SearchView.OnQueryTextL
|
||||
MenuItem btItem = menu.findItem(R.id.action_bluetooth_apk);
|
||||
btItem.setVisible(false);
|
||||
}
|
||||
if (Build.VERSION.SDK_INT < 10) {
|
||||
MenuItem menuItem = menu.findItem(R.id.action_swap);
|
||||
menuItem.setVisible(false);
|
||||
}
|
||||
|
||||
SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
|
||||
searchMenuItem = menu.findItem(R.id.action_search);
|
||||
|
@ -176,11 +176,10 @@ public class FDroidApp extends Application {
|
||||
applyLanguage();
|
||||
}
|
||||
|
||||
@TargetApi(9)
|
||||
@Override
|
||||
public void onCreate() {
|
||||
super.onCreate();
|
||||
if (Build.VERSION.SDK_INT >= 9 && BuildConfig.DEBUG) {
|
||||
if (BuildConfig.DEBUG) {
|
||||
StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder()
|
||||
.detectAll()
|
||||
.penaltyLog()
|
||||
|
@ -6,8 +6,6 @@ import android.os.Build;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.util.Log;
|
||||
|
||||
import org.fdroid.fdroid.compat.PreferencesCompat;
|
||||
|
||||
import java.net.InetSocketAddress;
|
||||
import java.net.Proxy;
|
||||
import java.net.SocketAddress;
|
||||
@ -40,8 +38,9 @@ public final class Preferences implements SharedPreferences.OnSharedPreferenceCh
|
||||
preferences = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
preferences.registerOnSharedPreferenceChangeListener(this);
|
||||
if (preferences.getString(PREF_LOCAL_REPO_NAME, null) == null) {
|
||||
PreferencesCompat.apply(preferences.edit()
|
||||
.putString(PREF_LOCAL_REPO_NAME, getDefaultLocalRepoName()));
|
||||
preferences.edit()
|
||||
.putString(PREF_LOCAL_REPO_NAME, getDefaultLocalRepoName())
|
||||
.apply();
|
||||
}
|
||||
}
|
||||
|
||||
@ -122,7 +121,7 @@ public final class Preferences implements SharedPreferences.OnSharedPreferenceCh
|
||||
}
|
||||
|
||||
public void setPrivilegedInstallerEnabled(boolean enable) {
|
||||
PreferencesCompat.apply(preferences.edit().putBoolean(PREF_PRIVILEGED_INSTALLER, enable));
|
||||
preferences.edit().putBoolean(PREF_PRIVILEGED_INSTALLER, enable).apply();
|
||||
}
|
||||
|
||||
public boolean isFirstTime() {
|
||||
@ -130,7 +129,7 @@ public final class Preferences implements SharedPreferences.OnSharedPreferenceCh
|
||||
}
|
||||
|
||||
public void setFirstTime(boolean firstTime) {
|
||||
PreferencesCompat.apply(preferences.edit().putBoolean(PREF_FIRST_TIME, firstTime));
|
||||
preferences.edit().putBoolean(PREF_FIRST_TIME, firstTime).apply();
|
||||
}
|
||||
|
||||
public boolean isPostPrivilegedInstall() {
|
||||
@ -138,7 +137,7 @@ public final class Preferences implements SharedPreferences.OnSharedPreferenceCh
|
||||
}
|
||||
|
||||
public void setPostPrivilegedInstall(boolean postInstall) {
|
||||
PreferencesCompat.apply(preferences.edit().putBoolean(PREF_POST_PRIVILEGED_INSTALL, postInstall));
|
||||
preferences.edit().putBoolean(PREF_POST_PRIVILEGED_INSTALL, postInstall).apply();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -159,7 +158,7 @@ public final class Preferences implements SharedPreferences.OnSharedPreferenceCh
|
||||
SharedPreferences.Editor editor = preferences.edit();
|
||||
editor.remove(PREF_CACHE_APK);
|
||||
editor.putString(PREF_KEEP_CACHE_TIME, value);
|
||||
PreferencesCompat.apply(editor);
|
||||
editor.apply();
|
||||
}
|
||||
|
||||
try {
|
||||
@ -182,7 +181,7 @@ public final class Preferences implements SharedPreferences.OnSharedPreferenceCh
|
||||
}
|
||||
|
||||
public void setShowNfcDuringSwap(boolean show) {
|
||||
PreferencesCompat.apply(preferences.edit().putBoolean(PREF_SHOW_NFC_DURING_SWAP, show));
|
||||
preferences.edit().putBoolean(PREF_SHOW_NFC_DURING_SWAP, show).apply();
|
||||
}
|
||||
|
||||
public boolean expertMode() {
|
||||
|
@ -41,7 +41,6 @@ import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.widget.Toast;
|
||||
|
||||
import org.fdroid.fdroid.compat.PreferencesCompat;
|
||||
import org.fdroid.fdroid.data.Apk;
|
||||
import org.fdroid.fdroid.data.ApkProvider;
|
||||
import org.fdroid.fdroid.data.App;
|
||||
@ -386,7 +385,7 @@ public class UpdateService extends IntentService {
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getBaseContext());
|
||||
SharedPreferences.Editor e = prefs.edit();
|
||||
e.putLong(STATE_LAST_UPDATED, System.currentTimeMillis());
|
||||
PreferencesCompat.apply(e);
|
||||
e.apply();
|
||||
|
||||
if (errorRepos == 0) {
|
||||
if (changes) {
|
||||
|
@ -86,43 +86,4 @@ public class FileCompat {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a {@link SanitizedFile} readable by all if {@code readable} is {@code true}.
|
||||
*
|
||||
* @return {@code true} if the operation succeeded
|
||||
*/
|
||||
@TargetApi(9)
|
||||
public static boolean setReadable(SanitizedFile file, boolean readable) {
|
||||
if (Build.VERSION.SDK_INT >= 9) {
|
||||
return file.setReadable(readable, false);
|
||||
}
|
||||
if (readable) {
|
||||
return setMode(file, "0644");
|
||||
} else {
|
||||
return setMode(file, "0000");
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean setMode(SanitizedFile file, String mode) {
|
||||
|
||||
// The "file" must be a sanitized file, and hence only contain A-Za-z0-9.-_ already,
|
||||
// but it makes no assurances about the parent directory.
|
||||
final String[] args = {
|
||||
FDroidApp.SYSTEM_DIR_NAME + "/bin/chmod",
|
||||
mode,
|
||||
file.getAbsolutePath(),
|
||||
};
|
||||
|
||||
try {
|
||||
Utils.debugLog(TAG, "Executing following command: " + args[0] + " " + args[1] + " " + args[2]);
|
||||
Process proc = Runtime.getRuntime().exec(args);
|
||||
Utils.consumeStream(proc.getInputStream());
|
||||
Utils.consumeStream(proc.getErrorStream());
|
||||
return true;
|
||||
} catch (IOException e) {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -300,28 +300,13 @@ public final class PRNGFixes {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the hardware serial number of this device.
|
||||
*
|
||||
* @return serial number or {@code null} if not available.
|
||||
*/
|
||||
private static String getDeviceSerialNumber() {
|
||||
// We're using the Reflection API because Build.SERIAL is only available
|
||||
// since API Level 9 (Gingerbread, Android 2.3).
|
||||
try {
|
||||
return (String) Build.class.getField("SERIAL").get(null);
|
||||
} catch (Exception ignored) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private static byte[] getBuildFingerprintAndDeviceSerial() {
|
||||
StringBuilder result = new StringBuilder();
|
||||
String fingerprint = Build.FINGERPRINT;
|
||||
if (fingerprint != null) {
|
||||
result.append(fingerprint);
|
||||
}
|
||||
String serial = getDeviceSerialNumber();
|
||||
String serial = Build.SERIAL;
|
||||
if (serial != null) {
|
||||
result.append(serial);
|
||||
}
|
||||
|
@ -1,15 +0,0 @@
|
||||
package org.fdroid.fdroid.compat;
|
||||
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Build;
|
||||
|
||||
public class PreferencesCompat {
|
||||
|
||||
public static void apply(SharedPreferences.Editor e) {
|
||||
if (Build.VERSION.SDK_INT < 9) {
|
||||
e.commit();
|
||||
} else {
|
||||
e.apply();
|
||||
}
|
||||
}
|
||||
}
|
@ -1,6 +1,5 @@
|
||||
package org.fdroid.fdroid.data;
|
||||
|
||||
import android.annotation.TargetApi;
|
||||
import android.content.ContentValues;
|
||||
import android.content.Context;
|
||||
import android.content.pm.ApplicationInfo;
|
||||
@ -272,7 +271,6 @@ public class App extends ValueObject implements Comparable<App> {
|
||||
initApkFromApkFile(context, this.installedApk, packageInfo, apkFile);
|
||||
}
|
||||
|
||||
@TargetApi(9)
|
||||
private void setFromPackageInfo(PackageManager pm, PackageInfo packageInfo)
|
||||
throws CertificateEncodingException, IOException, PackageManager.NameNotFoundException {
|
||||
|
||||
|
@ -33,7 +33,6 @@ import org.fdroid.fdroid.BuildConfig;
|
||||
import org.fdroid.fdroid.Hasher;
|
||||
import org.fdroid.fdroid.Preferences;
|
||||
import org.fdroid.fdroid.Utils;
|
||||
import org.fdroid.fdroid.compat.FileCompat;
|
||||
import org.fdroid.fdroid.data.Apk;
|
||||
import org.fdroid.fdroid.data.ApkProvider;
|
||||
import org.fdroid.fdroid.data.SanitizedFile;
|
||||
@ -222,7 +221,7 @@ public abstract class Installer {
|
||||
// have access is insecure, because apps with permission to write to the external
|
||||
// storage can overwrite the app between F-Droid asking for it to be installed and
|
||||
// the installer actually installing it.
|
||||
FileCompat.setReadable(apkToInstall, true);
|
||||
apkToInstall.setReadable(true, false);
|
||||
installPackageInternal(apkToInstall);
|
||||
|
||||
NotificationManager nm = (NotificationManager)
|
||||
|
@ -1,6 +1,5 @@
|
||||
package org.fdroid.fdroid.net;
|
||||
|
||||
import android.annotation.TargetApi;
|
||||
import android.app.IntentService;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
@ -8,7 +7,6 @@ import android.net.DhcpInfo;
|
||||
import android.net.NetworkInfo;
|
||||
import android.net.wifi.WifiInfo;
|
||||
import android.net.wifi.WifiManager;
|
||||
import android.os.Build;
|
||||
import android.support.v4.content.LocalBroadcastManager;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
@ -188,7 +186,6 @@ public class WifiStateChangeService extends IntentService {
|
||||
}
|
||||
}
|
||||
|
||||
@TargetApi(9)
|
||||
private void setIpInfoFromNetworkInterface() {
|
||||
try {
|
||||
for (Enumeration<NetworkInterface> networkInterfaces = NetworkInterface.getNetworkInterfaces(); networkInterfaces.hasMoreElements();) {
|
||||
@ -203,10 +200,6 @@ public class WifiStateChangeService extends IntentService {
|
||||
|| netIf.getDisplayName().contains("eth0")
|
||||
|| netIf.getDisplayName().contains("ap0")) {
|
||||
FDroidApp.ipAddressString = inetAddress.getHostAddress();
|
||||
if (Build.VERSION.SDK_INT < 9) {
|
||||
return;
|
||||
}
|
||||
// the following methods were not added until android-9/Gingerbread
|
||||
for (InterfaceAddress address : netIf.getInterfaceAddresses()) {
|
||||
short networkPrefixLength = address.getNetworkPrefixLength();
|
||||
if (networkPrefixLength > 32) {
|
||||
|
@ -1,6 +1,5 @@
|
||||
package org.fdroid.fdroid.net.bluetooth;
|
||||
|
||||
import android.annotation.TargetApi;
|
||||
import android.bluetooth.BluetoothAdapter;
|
||||
import android.bluetooth.BluetoothDevice;
|
||||
import android.bluetooth.BluetoothSocket;
|
||||
@ -22,7 +21,6 @@ public class BluetoothClient {
|
||||
device = BluetoothAdapter.getDefaultAdapter().getRemoteDevice(macAddress);
|
||||
}
|
||||
|
||||
@TargetApi(10)
|
||||
public BluetoothConnection openConnection() throws IOException {
|
||||
|
||||
BluetoothSocket socket = null;
|
||||
|
@ -1,6 +1,5 @@
|
||||
package org.fdroid.fdroid.net.bluetooth;
|
||||
|
||||
import android.annotation.TargetApi;
|
||||
import android.bluetooth.BluetoothAdapter;
|
||||
import android.bluetooth.BluetoothServerSocket;
|
||||
import android.bluetooth.BluetoothSocket;
|
||||
@ -62,7 +61,6 @@ public class BluetoothServer extends Thread {
|
||||
}
|
||||
}
|
||||
|
||||
@TargetApi(10)
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
@ -175,14 +173,7 @@ public class BluetoothServer extends Thread {
|
||||
.build();
|
||||
|
||||
} catch (Exception e) {
|
||||
/*
|
||||
if (Build.VERSION.SDK_INT <= 9) {
|
||||
// Would like to use the specific IOException below with a "cause", but it is
|
||||
// only supported on SDK 9, so I guess this is the next most useful thing.
|
||||
throw e;
|
||||
} else {
|
||||
throw new IOException("Error getting file " + request.getPath() + " from local repo proxy - " + e.getMessage(), e);
|
||||
}*/
|
||||
// throw new IOException("Error getting file " + request.getPath() + " from local repo proxy - " + e.getMessage(), e);
|
||||
|
||||
Log.e(TAG, "error processing request; sending 500 response", e);
|
||||
|
||||
|
@ -154,11 +154,7 @@ public class RepoDetailsActivity extends ActionBarActivity {
|
||||
setIntent(i);
|
||||
}
|
||||
|
||||
@TargetApi(9)
|
||||
void processIntent(Intent i) {
|
||||
if (Build.VERSION.SDK_INT < 9) {
|
||||
return;
|
||||
}
|
||||
if (NfcAdapter.ACTION_NDEF_DISCOVERED.equals(i.getAction())) {
|
||||
Parcelable[] rawMsgs =
|
||||
i.getParcelableArrayExtra(NfcAdapter.EXTRA_NDEF_MESSAGES);
|
||||
|
@ -24,7 +24,6 @@ import org.fdroid.fdroid.Preferences;
|
||||
import org.fdroid.fdroid.R;
|
||||
import org.fdroid.fdroid.UpdateService;
|
||||
import org.fdroid.fdroid.Utils;
|
||||
import org.fdroid.fdroid.compat.PreferencesCompat;
|
||||
import org.fdroid.fdroid.data.App;
|
||||
import org.fdroid.fdroid.data.AppProvider;
|
||||
import org.fdroid.fdroid.views.AppListAdapter;
|
||||
@ -146,7 +145,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.");
|
||||
PreferencesCompat.apply(prefs.edit().putBoolean(triedEmptyUpdate, true));
|
||||
prefs.edit().putBoolean(triedEmptyUpdate, true).apply();
|
||||
UpdateService.updateNow(getActivity());
|
||||
return true;
|
||||
}
|
||||
|
@ -25,7 +25,6 @@ import org.fdroid.fdroid.R;
|
||||
import org.fdroid.fdroid.Utils;
|
||||
import org.fdroid.fdroid.compat.ArrayAdapterCompat;
|
||||
import org.fdroid.fdroid.compat.CursorAdapterCompat;
|
||||
import org.fdroid.fdroid.compat.PreferencesCompat;
|
||||
import org.fdroid.fdroid.data.AppProvider;
|
||||
import org.fdroid.fdroid.views.AppListAdapter;
|
||||
import org.fdroid.fdroid.views.AvailableAppListAdapter;
|
||||
@ -232,7 +231,7 @@ public class AvailableAppsFragment extends AppListFragment implements
|
||||
Context.MODE_PRIVATE);
|
||||
SharedPreferences.Editor e = p.edit();
|
||||
e.putString(CATEGORY_KEY, currentCategory);
|
||||
PreferencesCompat.apply(e);
|
||||
e.apply();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -19,7 +19,6 @@ import org.fdroid.fdroid.FDroidApp;
|
||||
import org.fdroid.fdroid.Preferences;
|
||||
import org.fdroid.fdroid.PreferencesActivity;
|
||||
import org.fdroid.fdroid.R;
|
||||
import org.fdroid.fdroid.compat.PreferencesCompat;
|
||||
import org.fdroid.fdroid.installer.PrivilegedInstaller;
|
||||
|
||||
import info.guardianproject.netcipher.NetCipher;
|
||||
@ -205,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);
|
||||
PreferencesCompat.apply(editor);
|
||||
editor.apply();
|
||||
pref.setChecked(true);
|
||||
} else {
|
||||
// privileged permission not available
|
||||
SharedPreferences.Editor editor = pref.getSharedPreferences().edit();
|
||||
editor.putBoolean(Preferences.PREF_PRIVILEGED_INSTALLER, false);
|
||||
PreferencesCompat.apply(editor);
|
||||
editor.apply();
|
||||
pref.setChecked(false);
|
||||
|
||||
AlertDialog.Builder alertBuilder = new AlertDialog.Builder(getActivity());
|
||||
@ -249,7 +248,7 @@ public class PreferencesFragment extends PreferenceFragment
|
||||
} else {
|
||||
SharedPreferences.Editor editor = pref.getSharedPreferences().edit();
|
||||
editor.putBoolean(Preferences.PREF_PRIVILEGED_INSTALLER, false);
|
||||
PreferencesCompat.apply(editor);
|
||||
editor.apply();
|
||||
pref.setChecked(false);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user