use of org.fdroid.fdroid.data.App in project fdroidclient by f-droid.
the class AppUpdateStatusManager method createAppEntry.
private AppUpdateStatus createAppEntry(Apk apk, Status status, PendingIntent intent) {
synchronized (appMapping) {
ContentResolver resolver = context.getContentResolver();
App app = AppProvider.Helper.findSpecificApp(resolver, apk.packageName, apk.repoId);
AppUpdateStatus ret = new AppUpdateStatus(app, apk, status, intent);
appMapping.put(apk.getUrl(), ret);
return ret;
}
}
use of org.fdroid.fdroid.data.App in project fdroidclient by f-droid.
the class ProperMultiRepoUpdaterTest method assertAdAwayMetadata.
private void assertAdAwayMetadata(Repo repo, @RepoIdentifier String id) {
App adaway = AppProvider.Helper.findSpecificApp(context.getContentResolver(), "org.adaway", repo.getId(), AppMetadataTable.Cols.ALL);
assertAdAwayMetadata(adaway, id);
}
use of org.fdroid.fdroid.data.App in project fdroidclient by f-droid.
the class RepoXMLHandlerTest method checkAntiFeatures.
private void checkAntiFeatures(List<App> apps, Map<String, List<String>> expectedAntiFeatures) {
for (App app : apps) {
if (expectedAntiFeatures.containsKey(app.packageName)) {
List<String> antiFeatures = expectedAntiFeatures.get(app.packageName);
if (antiFeatures.size() == 0) {
assertNull(app.antiFeatures);
} else {
List<String> actualAntiFeatures = new ArrayList<>();
Collections.addAll(actualAntiFeatures, app.antiFeatures);
assertTrue(actualAntiFeatures.containsAll(antiFeatures));
assertTrue(antiFeatures.containsAll(actualAntiFeatures));
}
}
}
}
use of org.fdroid.fdroid.data.App in project fdroidclient by f-droid.
the class RepoXMLHandlerTest method checkIncludedApps.
private void checkIncludedApps(List<App> actualApps, String[] expctedAppIds) {
assertNotNull(actualApps);
assertNotNull(expctedAppIds);
assertEquals(actualApps.size(), expctedAppIds.length);
for (String id : expctedAppIds) {
boolean thisAppMissing = true;
for (App app : actualApps) {
if (TextUtils.equals(app.packageName, id)) {
thisAppMissing = false;
break;
}
}
assertFalse(thisAppMissing);
}
}
use of org.fdroid.fdroid.data.App in project fdroidclient by f-droid.
the class IndexV1UpdaterTest method testIndexV1Processing.
@Test
public void testIndexV1Processing() throws IOException, RepoUpdater.UpdateException {
List<Repo> repos = RepoProvider.Helper.all(context);
for (Repo repo : repos) {
RepoProvider.Helper.remove(context, repo.getId());
}
assertEquals("No repos present", 0, RepoProvider.Helper.all(context).size());
assertEquals("No apps present", 0, AppProvider.Helper.all(context.getContentResolver()).size());
Repo repo = MultiRepoUpdaterTest.createRepo("Testy", TESTY_JAR, context, TESTY_CERT);
repo.timestamp = 1481222110;
IndexV1Updater updater = new IndexV1Updater(context, repo);
JarFile jarFile = new JarFile(TestUtils.copyResourceToTempFile(TESTY_JAR), true);
Log.i(TAG, "jarFile " + jarFile);
JarEntry indexEntry = (JarEntry) jarFile.getEntry(IndexV1Updater.DATA_FILE_NAME);
InputStream indexInputStream = jarFile.getInputStream(indexEntry);
updater.processIndexV1(indexInputStream, indexEntry, "fakeEtag");
IOUtils.closeQuietly(indexInputStream);
List<App> apps = AppProvider.Helper.all(context.getContentResolver());
assertEquals("63 apps present", 63, apps.size());
String[] packages = { "fake.app.one", "org.adaway", "This_does_not_exist" };
for (String id : packages) {
assertEquals("No apks for " + id, 0, ApkProvider.Helper.findByPackageName(context, id).size());
}
for (App app : apps) {
assertTrue("Some apks for " + app.packageName, ApkProvider.Helper.findByPackageName(context, app.packageName).size() > 0);
}
repos = RepoProvider.Helper.all(context);
assertEquals("One repo", 1, repos.size());
Repo repoFromDb = repos.get(0);
assertEquals("repo.timestamp should be set", 1497639511, repoFromDb.timestamp);
assertEquals("repo.address should be the same", repo.address, repoFromDb.address);
assertEquals("repo.name should be set", "non-public test repo", repoFromDb.name);
assertEquals("repo.maxage should be set", 0, repoFromDb.maxage);
assertEquals("repo.version should be set", 18, repoFromDb.version);
assertEquals("repo.icon should be set", "fdroid-icon.png", repoFromDb.icon);
// NOCHECKSTYLE LineLength
String description = "This is a repository of apps to be used with F-Droid. Applications in this repository are either official binaries built by the original application developers, or are binaries built from source by the admin of f-droid.org using the tools on https://gitlab.com/u/fdroid. ";
assertEquals("repo.description should be set", description, repoFromDb.description);
assertEquals("repo.mirrors should have items", 2, repo.mirrors.length);
assertEquals("repo.mirrors first URL", "http://frkcchxlcvnb4m5a.onion/fdroid/repo", repo.mirrors[0]);
assertEquals("repo.mirrors second URL", "http://testy.at.or.at/fdroid/repo", repo.mirrors[1]);
// Make sure the per-apk anti features which are new in index v1 get added correctly.
assertEquals(0, AppProvider.Helper.findInstalledAppsWithKnownVulns(context).size());
InstalledAppTestUtils.install(context, "com.waze", 1019841, "v3.9.5.4", "362488e7be5ea0689b4e97d989ae1404", "cbbdb8c5dafeccd7dd7b642dde0477d3489e18ac366e3c8473d5c07e5f735a95");
assertEquals(1, AppProvider.Helper.findInstalledAppsWithKnownVulns(context).size());
}
Aggregations