Format to make checkstyle happy. Remove unused code.
This commit is contained in:
parent
938c992023
commit
12d5c5c7b4
@ -34,13 +34,13 @@ public class RepoPersister {
|
|||||||
* values changed in the index, some fields should not be updated. Rather, they should be
|
* values changed in the index, some fields should not be updated. Rather, they should be
|
||||||
* ignored, because they were explicitly set by the user, and hence can't be automatically
|
* ignored, because they were explicitly set by the user, and hence can't be automatically
|
||||||
* overridden by the index.
|
* overridden by the index.
|
||||||
*
|
* <p/>
|
||||||
* NOTE: In the future, these attributes will be moved to a join table, so that the app table
|
* NOTE: In the future, these attributes will be moved to a join table, so that the app table
|
||||||
* is essentially completely transient, and can be nuked at any time.
|
* is essentially completely transient, and can be nuked at any time.
|
||||||
*/
|
*/
|
||||||
private static final String[] APP_FIELDS_TO_IGNORE = {
|
private static final String[] APP_FIELDS_TO_IGNORE = {
|
||||||
AppProvider.DataColumns.IGNORE_ALLUPDATES,
|
AppProvider.DataColumns.IGNORE_ALLUPDATES,
|
||||||
AppProvider.DataColumns.IGNORE_THISUPDATE,
|
AppProvider.DataColumns.IGNORE_THISUPDATE,
|
||||||
};
|
};
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@ -129,9 +129,9 @@ public class RepoPersister {
|
|||||||
List<Apk> toRemove = new ArrayList<>();
|
List<Apk> toRemove = new ArrayList<>();
|
||||||
|
|
||||||
final String[] fields = {
|
final String[] fields = {
|
||||||
ApkProvider.DataColumns.APK_ID,
|
ApkProvider.DataColumns.APK_ID,
|
||||||
ApkProvider.DataColumns.VERSION_CODE,
|
ApkProvider.DataColumns.VERSION_CODE,
|
||||||
ApkProvider.DataColumns.VERSION,
|
ApkProvider.DataColumns.VERSION,
|
||||||
};
|
};
|
||||||
|
|
||||||
for (final Repo repo : updatedRepos) {
|
for (final Repo repo : updatedRepos) {
|
||||||
@ -175,14 +175,14 @@ public class RepoPersister {
|
|||||||
List<ContentProviderOperation> operations,
|
List<ContentProviderOperation> operations,
|
||||||
int currentCount,
|
int currentCount,
|
||||||
int totalUpdateCount)
|
int totalUpdateCount)
|
||||||
throws RemoteException, OperationApplicationException {
|
throws RemoteException, OperationApplicationException {
|
||||||
int i = 0;
|
int i = 0;
|
||||||
while (i < operations.size()) {
|
while (i < operations.size()) {
|
||||||
int count = Math.min(operations.size() - i, 100);
|
int count = Math.min(operations.size() - i, 100);
|
||||||
ArrayList<ContentProviderOperation> o = new ArrayList<>(operations.subList(i, i + count));
|
ArrayList<ContentProviderOperation> o = new ArrayList<>(operations.subList(i, i + count));
|
||||||
UpdateService.sendStatus(context, UpdateService.STATUS_INFO, context.getString(
|
UpdateService.sendStatus(context, UpdateService.STATUS_INFO, context.getString(
|
||||||
R.string.status_inserting,
|
R.string.status_inserting,
|
||||||
(int) ((double) (currentCount + i) / totalUpdateCount * 100)));
|
(int) ((double) (currentCount + i) / totalUpdateCount * 100)));
|
||||||
context.getContentResolver().applyBatch(providerAuthority, o);
|
context.getContentResolver().applyBatch(providerAuthority, o);
|
||||||
i += 100;
|
i += 100;
|
||||||
}
|
}
|
||||||
@ -193,9 +193,9 @@ public class RepoPersister {
|
|||||||
*/
|
*/
|
||||||
private List<Apk> getKnownApks(List<Apk> apks) {
|
private List<Apk> getKnownApks(List<Apk> apks) {
|
||||||
final String[] fields = {
|
final String[] fields = {
|
||||||
ApkProvider.DataColumns.APK_ID,
|
ApkProvider.DataColumns.APK_ID,
|
||||||
ApkProvider.DataColumns.VERSION,
|
ApkProvider.DataColumns.VERSION,
|
||||||
ApkProvider.DataColumns.VERSION_CODE,
|
ApkProvider.DataColumns.VERSION_CODE,
|
||||||
};
|
};
|
||||||
return ApkProvider.Helper.knownApks(context, apks, fields);
|
return ApkProvider.Helper.knownApks(context, apks, fields);
|
||||||
}
|
}
|
||||||
|
@ -1,23 +0,0 @@
|
|||||||
package org.fdroid.fdroid;
|
|
||||||
|
|
||||||
import org.fdroid.fdroid.data.AppProvider;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Class that makes available all ContentProviders that F-Droid owns.
|
|
||||||
*/
|
|
||||||
public abstract class FDroidTestWithAllProviders extends FDroidProviderTest<AppProvider> {
|
|
||||||
|
|
||||||
public FDroidTestWithAllProviders(Class<AppProvider> providerClass, String providerAuthority) {
|
|
||||||
super(providerClass, providerAuthority);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected String[] getMinimalProjection() {
|
|
||||||
return new String[] {
|
|
||||||
AppProvider.DataColumns._ID,
|
|
||||||
AppProvider.DataColumns.APP_ID,
|
|
||||||
AppProvider.DataColumns.NAME,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -17,7 +17,6 @@ import android.util.Log;
|
|||||||
import org.fdroid.fdroid.RepoUpdater.UpdateException;
|
import org.fdroid.fdroid.RepoUpdater.UpdateException;
|
||||||
import org.fdroid.fdroid.data.Apk;
|
import org.fdroid.fdroid.data.Apk;
|
||||||
import org.fdroid.fdroid.data.ApkProvider;
|
import org.fdroid.fdroid.data.ApkProvider;
|
||||||
import org.fdroid.fdroid.data.App;
|
|
||||||
import org.fdroid.fdroid.data.AppProvider;
|
import org.fdroid.fdroid.data.AppProvider;
|
||||||
import org.fdroid.fdroid.data.Repo;
|
import org.fdroid.fdroid.data.Repo;
|
||||||
import org.fdroid.fdroid.data.RepoProvider;
|
import org.fdroid.fdroid.data.RepoProvider;
|
||||||
@ -42,7 +41,7 @@ public class MultiRepoUpdaterTest extends InstrumentationTestCase {
|
|||||||
private RepoPersister persister;
|
private RepoPersister persister;
|
||||||
|
|
||||||
private static final String PUB_KEY =
|
private static final String PUB_KEY =
|
||||||
"3082050b308202f3a003020102020420d8f212300d06092a864886f70d01010b050030363110300e0603" +
|
"3082050b308202f3a003020102020420d8f212300d06092a864886f70d01010b050030363110300e0603" +
|
||||||
"55040b1307462d44726f69643122302006035504031319657073696c6f6e2e70657465722e7365727779" +
|
"55040b1307462d44726f69643122302006035504031319657073696c6f6e2e70657465722e7365727779" +
|
||||||
"6c6f2e636f6d301e170d3135303931323233313632315a170d3433303132383233313632315a30363110" +
|
"6c6f2e636f6d301e170d3135303931323233313632315a170d3433303132383233313632315a30363110" +
|
||||||
"300e060355040b1307462d44726f69643122302006035504031319657073696c6f6e2e70657465722e73" +
|
"300e060355040b1307462d44726f69643122302006035504031319657073696c6f6e2e70657465722e73" +
|
||||||
@ -180,31 +179,31 @@ public class MultiRepoUpdaterTest extends InstrumentationTestCase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void assertApp2048() {
|
private void assertApp2048() {
|
||||||
assertApp("com.uberspot.a2048", new int[]{ 19, 18 });
|
assertApp("com.uberspot.a2048", new int[]{19, 18});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void assertAppAdaway() {
|
private void assertAppAdaway() {
|
||||||
assertApp("org.adaway", new int[]{ 54, 53, 52, 51, 50, 49, 48, 47, 46, 45, 42, 40, 38, 37, 36, 35 });
|
assertApp("org.adaway", new int[]{54, 53, 52, 51, 50, 49, 48, 47, 46, 45, 42, 40, 38, 37, 36, 35});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void assertAppAdbWireless() {
|
private void assertAppAdbWireless() {
|
||||||
assertApp("siir.es.adbWireless", new int[]{ 12 });
|
assertApp("siir.es.adbWireless", new int[]{12});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void assertAppIcsImport() {
|
private void assertAppIcsImport() {
|
||||||
assertApp("org.dgtale.icsimport", new int[] { 3, 2 });
|
assertApp("org.dgtale.icsimport", new int[]{3, 2});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* + 2048 (com.uberspot.a2048)
|
* + 2048 (com.uberspot.a2048)
|
||||||
* - Version 1.96 (19)
|
* - Version 1.96 (19)
|
||||||
* - Version 1.95 (18)
|
* - Version 1.95 (18)
|
||||||
* + AdAway (org.adaway)
|
* + AdAway (org.adaway)
|
||||||
* - Version 3.0.2 (54)
|
* - Version 3.0.2 (54)
|
||||||
* - Version 3.0.1 (53)
|
* - Version 3.0.1 (53)
|
||||||
* - Version 3.0 (52)
|
* - Version 3.0 (52)
|
||||||
* + adbWireless (siir.es.adbWireless)
|
* + adbWireless (siir.es.adbWireless)
|
||||||
* - Version 1.5.4 (12)
|
* - Version 1.5.4 (12)
|
||||||
*/
|
*/
|
||||||
private void assertMainRepo(List<Repo> allRepos) {
|
private void assertMainRepo(List<Repo> allRepos) {
|
||||||
Repo repo = findRepo(REPO_MAIN, allRepos);
|
Repo repo = findRepo(REPO_MAIN, allRepos);
|
||||||
@ -217,38 +216,38 @@ public class MultiRepoUpdaterTest extends InstrumentationTestCase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* + AdAway (org.adaway)
|
* + AdAway (org.adaway)
|
||||||
* - Version 2.9.2 (51)
|
* - Version 2.9.2 (51)
|
||||||
* - Version 2.9.1 (50)
|
* - Version 2.9.1 (50)
|
||||||
* - Version 2.9 (49)
|
* - Version 2.9 (49)
|
||||||
* - Version 2.8.1 (48)
|
* - Version 2.8.1 (48)
|
||||||
* - Version 2.8 (47)
|
* - Version 2.8 (47)
|
||||||
* - Version 2.7 (46)
|
* - Version 2.7 (46)
|
||||||
* - Version 2.6 (45)
|
* - Version 2.6 (45)
|
||||||
* - Version 2.3 (42)
|
* - Version 2.3 (42)
|
||||||
* - Version 2.1 (40)
|
* - Version 2.1 (40)
|
||||||
* - Version 1.37 (38)
|
* - Version 1.37 (38)
|
||||||
* - Version 1.36 (37)
|
* - Version 1.36 (37)
|
||||||
* - Version 1.35 (36)
|
* - Version 1.35 (36)
|
||||||
* - Version 1.34 (35)
|
* - Version 1.34 (35)
|
||||||
*/
|
*/
|
||||||
private void assertMainArchiveRepo(List<Repo> allRepos) {
|
private void assertMainArchiveRepo(List<Repo> allRepos) {
|
||||||
Repo repo = findRepo(REPO_ARCHIVE, allRepos);
|
Repo repo = findRepo(REPO_ARCHIVE, allRepos);
|
||||||
|
|
||||||
List<Apk> apks = ApkProvider.Helper.findByRepo(context, repo, ApkProvider.DataColumns.ALL);
|
List<Apk> apks = ApkProvider.Helper.findByRepo(context, repo, ApkProvider.DataColumns.ALL);
|
||||||
assertEquals("Apks for main archive repo", 13, apks.size());
|
assertEquals("Apks for main archive repo", 13, apks.size());
|
||||||
assertApksExist(apks, "org.adaway", new int[] { 35, 36, 37, 38, 40, 42, 45, 46, 47, 48, 49, 50, 51 });
|
assertApksExist(apks, "org.adaway", new int[]{35, 36, 37, 38, 40, 42, 45, 46, 47, 48, 49, 50, 51});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* + AdAway (org.adaway)
|
* + AdAway (org.adaway)
|
||||||
* - Version 3.0.1 (53) *
|
* - Version 3.0.1 (53) *
|
||||||
* - Version 3.0 (52) *
|
* - Version 3.0 (52) *
|
||||||
* - Version 2.9.2 (51) *
|
* - Version 2.9.2 (51) *
|
||||||
* - Version 2.2.1 (50) *
|
* - Version 2.2.1 (50) *
|
||||||
* + Add to calendar (org.dgtale.icsimport)
|
* + Add to calendar (org.dgtale.icsimport)
|
||||||
* - Version 1.2 (3)
|
* - Version 1.2 (3)
|
||||||
* - Version 1.1 (2)
|
* - Version 1.1 (2)
|
||||||
*/
|
*/
|
||||||
private void assertConflictingRepo(List<Repo> allRepos) {
|
private void assertConflictingRepo(List<Repo> allRepos) {
|
||||||
Repo repo = findRepo(REPO_CONFLICTING, allRepos);
|
Repo repo = findRepo(REPO_CONFLICTING, allRepos);
|
||||||
@ -294,9 +293,9 @@ public class MultiRepoUpdaterTest extends InstrumentationTestCase {
|
|||||||
assertEquals("No apps present", 0, AppProvider.Helper.all(context.getContentResolver()).size());
|
assertEquals("No apps present", 0, AppProvider.Helper.all(context.getContentResolver()).size());
|
||||||
|
|
||||||
String[] packages = {
|
String[] packages = {
|
||||||
"com.uberspot.a2048",
|
"com.uberspot.a2048",
|
||||||
"org.adaway",
|
"org.adaway",
|
||||||
"siir.es.adbWireless",
|
"siir.es.adbWireless",
|
||||||
};
|
};
|
||||||
|
|
||||||
for (String id : packages) {
|
for (String id : packages) {
|
||||||
@ -308,7 +307,7 @@ public class MultiRepoUpdaterTest extends InstrumentationTestCase {
|
|||||||
persister.save(new ArrayList<Repo>(0));
|
persister.save(new ArrayList<Repo>(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* At time fo writing, the following tests did not pass. This is because the multi-repo support
|
/* At time fo writing, the following tests did not pass. This is because the multi-repo support
|
||||||
in F-Droid was not sufficient. When working on proper multi repo support than this should be
|
in F-Droid was not sufficient. When working on proper multi repo support than this should be
|
||||||
ucommented and all these tests should pass:
|
ucommented and all these tests should pass:
|
||||||
|
|
||||||
@ -360,7 +359,7 @@ public class MultiRepoUpdaterTest extends InstrumentationTestCase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public void testAcceptableConflictingThenMainThenArchive() throws UpdateException {
|
public void testAcceptableConflictingThenMainThenArchive() throws UpdateException {
|
||||||
assertEmpty();
|
assertEmpty();
|
||||||
|
@ -68,10 +68,10 @@ public class TestUtils {
|
|||||||
if (actualList.size() != expectedContains.size()) {
|
if (actualList.size() != expectedContains.size()) {
|
||||||
String message =
|
String message =
|
||||||
"List sizes don't match.\n" +
|
"List sizes don't match.\n" +
|
||||||
"Expected: " +
|
"Expected: " +
|
||||||
listToString(expectedContains) + "\n" +
|
listToString(expectedContains) + "\n" +
|
||||||
"Actual: " +
|
"Actual: " +
|
||||||
listToString(actualList);
|
listToString(actualList);
|
||||||
throw new AssertionFailedError(message);
|
throw new AssertionFailedError(message);
|
||||||
}
|
}
|
||||||
for (T required : expectedContains) {
|
for (T required : expectedContains) {
|
||||||
@ -85,10 +85,10 @@ public class TestUtils {
|
|||||||
if (!containsRequired) {
|
if (!containsRequired) {
|
||||||
String message =
|
String message =
|
||||||
"List doesn't contain \"" + required + "\".\n" +
|
"List doesn't contain \"" + required + "\".\n" +
|
||||||
"Expected: " +
|
"Expected: " +
|
||||||
listToString(expectedContains) + "\n" +
|
listToString(expectedContains) + "\n" +
|
||||||
"Actual: " +
|
"Actual: " +
|
||||||
listToString(actualList);
|
listToString(actualList);
|
||||||
throw new AssertionFailedError(message);
|
throw new AssertionFailedError(message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -151,8 +151,8 @@ public class TestUtils {
|
|||||||
* "installed apps" table in the database.
|
* "installed apps" table in the database.
|
||||||
*/
|
*/
|
||||||
public static void installAndBroadcast(
|
public static void installAndBroadcast(
|
||||||
MockContextSwappableComponents context, MockInstallablePackageManager pm,
|
MockContextSwappableComponents context, MockInstallablePackageManager pm,
|
||||||
String appId, int versionCode, String versionName) {
|
String appId, int versionCode, String versionName) {
|
||||||
|
|
||||||
context.setPackageManager(pm);
|
context.setPackageManager(pm);
|
||||||
pm.install(appId, versionCode, versionName);
|
pm.install(appId, versionCode, versionName);
|
||||||
@ -166,8 +166,8 @@ public class TestUtils {
|
|||||||
* @see org.fdroid.fdroid.TestUtils#installAndBroadcast(mock.MockContextSwappableComponents, mock.MockInstallablePackageManager, String, int, String)
|
* @see org.fdroid.fdroid.TestUtils#installAndBroadcast(mock.MockContextSwappableComponents, mock.MockInstallablePackageManager, String, int, String)
|
||||||
*/
|
*/
|
||||||
public static void upgradeAndBroadcast(
|
public static void upgradeAndBroadcast(
|
||||||
MockContextSwappableComponents context, MockInstallablePackageManager pm,
|
MockContextSwappableComponents context, MockInstallablePackageManager pm,
|
||||||
String appId, int versionCode, String versionName) {
|
String appId, int versionCode, String versionName) {
|
||||||
/*
|
/*
|
||||||
removeAndBroadcast(context, pm, appId);
|
removeAndBroadcast(context, pm, appId);
|
||||||
installAndBroadcast(context, pm, appId, versionCode, versionName);
|
installAndBroadcast(context, pm, appId, versionCode, versionName);
|
||||||
@ -214,18 +214,6 @@ public class TestUtils {
|
|||||||
return tempFile;
|
return tempFile;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static File getWriteableDir(Context context) {
|
|
||||||
File[] dirsToTry = new File[] {
|
|
||||||
context.getCacheDir(),
|
|
||||||
context.getFilesDir(),
|
|
||||||
context.getExternalCacheDir(),
|
|
||||||
context.getExternalFilesDir(null),
|
|
||||||
Environment.getExternalStorageDirectory()
|
|
||||||
};
|
|
||||||
|
|
||||||
return getWriteableDir(dirsToTry);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Prefer internal over external storage, because external tends to be FAT filesystems,
|
* Prefer internal over external storage, because external tends to be FAT filesystems,
|
||||||
* which don't support symlinks (which we test using this method).
|
* which don't support symlinks (which we test using this method).
|
||||||
@ -235,16 +223,16 @@ public class TestUtils {
|
|||||||
Context targetContext = instrumentation.getTargetContext();
|
Context targetContext = instrumentation.getTargetContext();
|
||||||
|
|
||||||
|
|
||||||
File[] dirsToTry = new File[] {
|
File[] dirsToTry = new File[]{
|
||||||
context.getCacheDir(),
|
context.getCacheDir(),
|
||||||
context.getFilesDir(),
|
context.getFilesDir(),
|
||||||
targetContext.getCacheDir(),
|
targetContext.getCacheDir(),
|
||||||
targetContext.getFilesDir(),
|
targetContext.getFilesDir(),
|
||||||
context.getExternalCacheDir(),
|
context.getExternalCacheDir(),
|
||||||
context.getExternalFilesDir(null),
|
context.getExternalFilesDir(null),
|
||||||
targetContext.getExternalCacheDir(),
|
targetContext.getExternalCacheDir(),
|
||||||
targetContext.getExternalFilesDir(null),
|
targetContext.getExternalFilesDir(null),
|
||||||
Environment.getExternalStorageDirectory()
|
Environment.getExternalStorageDirectory(),
|
||||||
};
|
};
|
||||||
|
|
||||||
return getWriteableDir(dirsToTry);
|
return getWriteableDir(dirsToTry);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user