Merge branch 'random-improvements' into 'master'
Random improvements See merge request !262
This commit is contained in:
commit
d902612f41
@ -65,7 +65,7 @@ In order to run the F-Droid test suite, you will need to have either a real devi
|
||||
connected via `adb`, or an emulator running. Then, execute the following from the
|
||||
command line:
|
||||
|
||||
./gradlew connectedCheck
|
||||
./gradlew check
|
||||
|
||||
Note that the CI already runs the tests on an emulator, so you don't
|
||||
necessarily have to do this yourself if you open a merge request as the tests
|
||||
|
@ -210,7 +210,7 @@ pmd {
|
||||
task pmd(type: Pmd, dependsOn: assembleDebug) {
|
||||
ruleSets = [
|
||||
//'java-basic',
|
||||
//'java-unusedcode',
|
||||
'java-unusedcode',
|
||||
'java-android',
|
||||
'java-clone',
|
||||
'java-finalizers',
|
||||
@ -218,7 +218,7 @@ task pmd(type: Pmd, dependsOn: assembleDebug) {
|
||||
'java-migrating',
|
||||
//'java-unnecessary', // too nitpicky with parenthesis
|
||||
]
|
||||
source 'src/main/java'
|
||||
source 'src/main/java', 'src/test/java', 'src/androidTest/java'
|
||||
include '**/*.java'
|
||||
}
|
||||
|
||||
|
@ -27,6 +27,9 @@ import android.os.Build;
|
||||
import android.test.mock.MockContentResolver;
|
||||
import android.test.mock.MockContext;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
/**
|
||||
@ -132,6 +135,7 @@ public abstract class ProviderTestCase2MockContext<T extends ContentProvider> ex
|
||||
* @throws Exception
|
||||
*/
|
||||
@Override
|
||||
@Before
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
|
||||
@ -165,6 +169,7 @@ public abstract class ProviderTestCase2MockContext<T extends ContentProvider> ex
|
||||
* {@link android.content.ContentProvider} represented by mProvider.
|
||||
*/
|
||||
@Override
|
||||
@After
|
||||
protected void tearDown() throws Exception {
|
||||
shutdownProvider();
|
||||
super.tearDown();
|
||||
|
@ -18,7 +18,6 @@ import static org.junit.Assert.fail;
|
||||
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
public class RepoUpdaterTest {
|
||||
private static final String TAG = "RepoUpdaterTest";
|
||||
|
||||
private Context context;
|
||||
private RepoUpdater repoUpdater;
|
||||
|
@ -91,7 +91,6 @@ public class AndroidXMLDecompress {
|
||||
|
||||
while (offset < binaryXml.length) {
|
||||
int tag0 = littleEndianWord(binaryXml, offset);
|
||||
int nameStringIndex = littleEndianWord(binaryXml, offset + 5 * 4);
|
||||
|
||||
if (tag0 == startTag) {
|
||||
int numbAttrs = littleEndianWord(binaryXml, offset + 7 * 4);
|
||||
@ -114,11 +113,10 @@ public class AndroidXMLDecompress {
|
||||
attributes.put(attributeName, attributeValue);
|
||||
}
|
||||
return attributes;
|
||||
} else {
|
||||
}
|
||||
// we only need the first <manifest> start tag
|
||||
break;
|
||||
}
|
||||
}
|
||||
return new HashMap<String, Object>(0);
|
||||
}
|
||||
|
||||
|
@ -79,6 +79,7 @@ public final class Preferences implements SharedPreferences.OnSharedPreferenceCh
|
||||
private static final boolean DEFAULT_EXPERT = false;
|
||||
private static final boolean DEFAULT_ENABLE_PROXY = false;
|
||||
public static final String DEFAULT_THEME = "light";
|
||||
@SuppressWarnings("PMD.AvoidUsingHardCodedIP")
|
||||
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;
|
||||
|
@ -92,6 +92,15 @@ public class RepoUpdater {
|
||||
return hasChanged;
|
||||
}
|
||||
|
||||
private static void cleanupDownloader(Downloader d) {
|
||||
if (d == null || d.outputFile == null) {
|
||||
return;
|
||||
}
|
||||
if (!d.outputFile.delete()) {
|
||||
Log.w(TAG, "Couldn't delete file: " + d.outputFile.getAbsolutePath());
|
||||
}
|
||||
}
|
||||
|
||||
private Downloader downloadIndex() throws UpdateException {
|
||||
Downloader downloader = null;
|
||||
try {
|
||||
@ -106,11 +115,7 @@ public class RepoUpdater {
|
||||
}
|
||||
|
||||
} catch (IOException e) {
|
||||
if (downloader != null && downloader.outputFile != null) {
|
||||
if (!downloader.outputFile.delete()) {
|
||||
Log.w(TAG, "Couldn't delete file: " + downloader.outputFile.getAbsolutePath());
|
||||
}
|
||||
}
|
||||
cleanupDownloader(downloader);
|
||||
|
||||
throw new UpdateException(repo, "Error getting index file", e);
|
||||
} catch (InterruptedException e) {
|
||||
@ -197,13 +202,11 @@ public class RepoUpdater {
|
||||
} finally {
|
||||
FDroidApp.enableSpongyCastleOnLollipop();
|
||||
Utils.closeQuietly(indexInputStream);
|
||||
if (downloadedFile != null) {
|
||||
if (!downloadedFile.delete()) {
|
||||
if (downloadedFile != null && !downloadedFile.delete()) {
|
||||
Log.w(TAG, "Couldn't delete file: " + downloadedFile.getAbsolutePath());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void commitToDb() throws UpdateException {
|
||||
Log.i(TAG, "Repo signature verified, saving app metadata to database.");
|
||||
|
@ -673,14 +673,13 @@ public final class Utils {
|
||||
}
|
||||
|
||||
for (File f : files) {
|
||||
if ((startsWith != null && f.getName().startsWith(startsWith))
|
||||
|| (endsWith != null && f.getName().endsWith(endsWith))) {
|
||||
if (!f.delete()) {
|
||||
if (((startsWith != null && f.getName().startsWith(startsWith))
|
||||
|| (endsWith != null && f.getName().endsWith(endsWith)))
|
||||
&& !f.delete()) {
|
||||
Log.w(TAG, "Couldn't delete cache file " + f);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void debugLog(String tag, String msg) {
|
||||
if (BuildConfig.DEBUG) {
|
||||
|
@ -178,11 +178,9 @@ public abstract class Installer {
|
||||
Map<String, Object> attributes = AndroidXMLDecompress.getManifestHeaderAttributes(apkFile.getAbsolutePath());
|
||||
|
||||
/* This isn't really needed, but might as well since we have the data already */
|
||||
if (attributes.containsKey("packageName")) {
|
||||
if (!TextUtils.equals(packageName, (String) attributes.get("packageName"))) {
|
||||
if (attributes.containsKey("packageName") && !TextUtils.equals(packageName, (String) attributes.get("packageName"))) {
|
||||
throw new InstallFailedException(apkFile + " has packageName that clashes with " + packageName);
|
||||
}
|
||||
}
|
||||
|
||||
if (!attributes.containsKey("versionCode")) {
|
||||
throw new InstallFailedException(apkFile + " is missing versionCode!");
|
||||
|
@ -119,24 +119,18 @@ public final class LocalRepoManager {
|
||||
xmlIndexJar = new SanitizedFile(repoDir, "index.jar");
|
||||
xmlIndexJarUnsigned = new SanitizedFile(repoDir, "index.unsigned.jar");
|
||||
|
||||
if (!fdroidDir.exists()) {
|
||||
if (!fdroidDir.mkdir()) {
|
||||
if (!fdroidDir.exists() && !fdroidDir.mkdir()) {
|
||||
Log.e(TAG, "Unable to create empty base: " + fdroidDir);
|
||||
}
|
||||
}
|
||||
|
||||
if (!repoDir.exists()) {
|
||||
if (!repoDir.mkdir()) {
|
||||
if (!repoDir.exists() && !repoDir.mkdir()) {
|
||||
Log.e(TAG, "Unable to create empty repo: " + repoDir);
|
||||
}
|
||||
}
|
||||
|
||||
if (!iconsDir.exists()) {
|
||||
if (!iconsDir.mkdir()) {
|
||||
if (!iconsDir.exists() && !iconsDir.mkdir()) {
|
||||
Log.e(TAG, "Unable to create icons folder: " + iconsDir);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private String writeFdroidApkToWebroot() {
|
||||
ApplicationInfo appInfo;
|
||||
|
@ -228,8 +228,7 @@ public class LocalHTTPD extends NanoHTTPD {
|
||||
long startFrom = 0;
|
||||
long endAt = -1;
|
||||
String range = header.get("range");
|
||||
if (range != null) {
|
||||
if (range.startsWith("bytes=")) {
|
||||
if (range != null && range.startsWith("bytes=")) {
|
||||
range = range.substring("bytes=".length());
|
||||
int minus = range.indexOf('-');
|
||||
try {
|
||||
@ -240,7 +239,6 @@ public class LocalHTTPD extends NanoHTTPD {
|
||||
} catch (NumberFormatException ignored) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Change return code and add Content-Range header when skipping is
|
||||
// requested
|
||||
|
@ -266,8 +266,7 @@ public class BluetoothServer extends Thread {
|
||||
long startFrom = 0;
|
||||
long endAt = -1;
|
||||
String range = header.get("range");
|
||||
if (range != null) {
|
||||
if (range.startsWith("bytes=")) {
|
||||
if (range != null && range.startsWith("bytes=")) {
|
||||
range = range.substring("bytes=".length());
|
||||
int minus = range.indexOf('-');
|
||||
try {
|
||||
@ -278,7 +277,6 @@ public class BluetoothServer extends Thread {
|
||||
} catch (NumberFormatException ignored) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Change return code and add Content-Range header when skipping is
|
||||
// requested
|
||||
|
@ -1,12 +0,0 @@
|
||||
package org.fdroid.fdroid.net.bluetooth;
|
||||
|
||||
class UnexpectedResponseException extends Exception {
|
||||
|
||||
UnexpectedResponseException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
UnexpectedResponseException(String message, Throwable cause) {
|
||||
super("Unexpected response from Bluetooth server: '" + message + "'", cause);
|
||||
}
|
||||
}
|
@ -29,8 +29,7 @@ public class InstallExtensionBootReceiver extends BroadcastReceiver {
|
||||
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
if (intent.getAction().equals(Intent.ACTION_BOOT_COMPLETED)) {
|
||||
if (Preferences.get().isPostPrivilegedInstall()) {
|
||||
if (intent.getAction().equals(Intent.ACTION_BOOT_COMPLETED) && Preferences.get().isPostPrivilegedInstall()) {
|
||||
Preferences.get().setPostPrivilegedInstall(false);
|
||||
|
||||
Intent postInstall = new Intent(context.getApplicationContext(), InstallExtensionDialogActivity.class);
|
||||
@ -39,5 +38,4 @@ public class InstallExtensionBootReceiver extends BroadcastReceiver {
|
||||
context.startActivity(postInstall);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -269,11 +269,9 @@ public class AppSecurityPermissions {
|
||||
String permName = strList[i];
|
||||
// If we are only looking at an existing app, then we only
|
||||
// care about permissions that have actually been granted to it.
|
||||
if (installedPkgInfo != null && info == installedPkgInfo) {
|
||||
if ((flagsList[i] & PackageInfo.REQUESTED_PERMISSION_GRANTED) == 0) {
|
||||
if (installedPkgInfo != null && info == installedPkgInfo && (flagsList[i] & PackageInfo.REQUESTED_PERMISSION_GRANTED) == 0) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
try {
|
||||
PermissionInfo tmpPermInfo = mPm.getPermissionInfo(permName, 0);
|
||||
if (tmpPermInfo == null) {
|
||||
|
@ -9,9 +9,8 @@ public class AvailableAppListAdapter extends AppListAdapter {
|
||||
public static AvailableAppListAdapter create(Context context, Cursor cursor, int flags) {
|
||||
if (Build.VERSION.SDK_INT >= 11) {
|
||||
return new AvailableAppListAdapter(context, cursor, flags);
|
||||
} else {
|
||||
return new AvailableAppListAdapter(context, cursor);
|
||||
}
|
||||
return new AvailableAppListAdapter(context, cursor);
|
||||
}
|
||||
|
||||
private AvailableAppListAdapter(Context context, Cursor c) {
|
||||
|
@ -9,9 +9,8 @@ public class CanUpdateAppListAdapter extends AppListAdapter {
|
||||
public static CanUpdateAppListAdapter create(Context context, Cursor cursor, int flags) {
|
||||
if (Build.VERSION.SDK_INT >= 11) {
|
||||
return new CanUpdateAppListAdapter(context, cursor, flags);
|
||||
} else {
|
||||
return new CanUpdateAppListAdapter(context, cursor);
|
||||
}
|
||||
return new CanUpdateAppListAdapter(context, cursor);
|
||||
}
|
||||
|
||||
private CanUpdateAppListAdapter(Context context, Cursor c) {
|
||||
|
@ -9,9 +9,8 @@ public class InstalledAppListAdapter extends AppListAdapter {
|
||||
public static InstalledAppListAdapter create(Context context, Cursor cursor, int flags) {
|
||||
if (Build.VERSION.SDK_INT >= 11) {
|
||||
return new InstalledAppListAdapter(context, cursor, flags);
|
||||
} else {
|
||||
return new InstalledAppListAdapter(context, cursor);
|
||||
}
|
||||
return new InstalledAppListAdapter(context, cursor);
|
||||
}
|
||||
|
||||
private InstalledAppListAdapter(Context context, Cursor c) {
|
||||
|
@ -26,9 +26,8 @@ public class RepoAdapter extends CursorAdapter {
|
||||
public static RepoAdapter create(Context context, Cursor cursor, int flags) {
|
||||
if (Build.VERSION.SDK_INT >= 11) {
|
||||
return new RepoAdapter(context, cursor, flags);
|
||||
} else {
|
||||
return new RepoAdapter(context, cursor);
|
||||
}
|
||||
return new RepoAdapter(context, cursor);
|
||||
}
|
||||
|
||||
private RepoAdapter(Context context, Cursor c, int flags) {
|
||||
|
@ -290,12 +290,10 @@ public class SwapWorkflowActivity extends AppCompatActivity {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!forceReload) {
|
||||
if (container.getVisibility() == View.GONE || currentView != null && currentView.getStep() == service.getStep()) {
|
||||
if (!forceReload && (container.getVisibility() == View.GONE || currentView != null && currentView.getStep() == service.getStep())) {
|
||||
// Already showing the correct step, so don't bother changing anything.
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
switch (service.getStep()) {
|
||||
case SwapService.STEP_INTRO:
|
||||
|
@ -7,7 +7,3 @@ buildscript {
|
||||
classpath files('libs/gradle-witness.jar')
|
||||
}
|
||||
}
|
||||
|
||||
task wrapper(type: Wrapper) {
|
||||
gradleVersion = '2.11'
|
||||
}
|
||||
|
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Binary file not shown.
5
gradle/wrapper/gradle-wrapper.properties
vendored
5
gradle/wrapper/gradle-wrapper.properties
vendored
@ -1,7 +1,6 @@
|
||||
#Mon Feb 15 16:30:29 GMT 2016
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-2.11-bin.zip
|
||||
distributionSha256Sum=8d7437082356c9fd6309a4479c8db307673965546daea445c6c72759cd6b1ed6
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-2.12-bin.zip
|
||||
distributionSha256Sum=e77064981906cd0476ff1e0de3e6fef747bd18e140960f1915cca8ff6c33ab5c
|
||||
|
Loading…
x
Reference in New Issue
Block a user