Search in sources :

Example 1 with App

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;
    }
}
Also used : App(org.fdroid.fdroid.data.App) ContentResolver(android.content.ContentResolver)

Example 2 with App

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);
}
Also used : App(org.fdroid.fdroid.data.App)

Example 3 with App

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));
            }
        }
    }
}
Also used : App(org.fdroid.fdroid.data.App) ArrayList(java.util.ArrayList)

Example 4 with App

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);
    }
}
Also used : App(org.fdroid.fdroid.data.App)

Example 5 with App

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());
}
Also used : App(org.fdroid.fdroid.data.App) IndexV1Updater(org.fdroid.fdroid.IndexV1Updater) Repo(org.fdroid.fdroid.data.Repo) InputStream(java.io.InputStream) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) JarFile(java.util.jar.JarFile) JarEntry(java.util.jar.JarEntry) FDroidProviderTest(org.fdroid.fdroid.data.FDroidProviderTest) Test(org.junit.Test)

Aggregations

App (org.fdroid.fdroid.data.App)38 Apk (org.fdroid.fdroid.data.Apk)7 ArrayList (java.util.ArrayList)5 FDroidApp (org.fdroid.fdroid.FDroidApp)5 FDroidProviderTest (org.fdroid.fdroid.data.FDroidProviderTest)5 Test (org.junit.Test)5 PendingIntent (android.app.PendingIntent)4 Intent (android.content.Intent)4 NotificationCompat (android.support.v4.app.NotificationCompat)4 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)4 PackageManager (android.content.pm.PackageManager)3 JsonFactory (com.fasterxml.jackson.core.JsonFactory)3 JsonParser (com.fasterxml.jackson.core.JsonParser)3 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)3 List (java.util.List)3 Repo (org.fdroid.fdroid.data.Repo)3 RepoPushRequest (org.fdroid.fdroid.data.RepoPushRequest)3 ContentResolver (android.content.ContentResolver)2 ContentValues (android.content.ContentValues)2 Bitmap (android.graphics.Bitmap)2