Search in sources :

Example 61 with Apk

use of org.fdroid.fdroid.data.Apk in project fdroidclient by f-droid.

the class ProperMultiIndexUpdaterTest method assertMainRepo.

/**
 * + 2048 (com.uberspot.a2048)
 * - Version 1.96 (19)
 * - Version 1.95 (18)
 * + AdAway (org.adaway)
 * - Version 3.0.2 (54)
 * - Version 3.0.1 (53)
 * - Version 3.0 (52)
 * + adbWireless (siir.es.adbWireless)
 * - Version 1.5.4 (12)
 */
private void assertMainRepo(List<Repo> allRepos) {
    Repo repo = findRepo(REPO_MAIN, allRepos);
    List<Apk> apks = ApkProvider.Helper.findByRepo(context, repo, Schema.ApkTable.Cols.ALL);
    assertEquals("Apks for main repo", apks.size(), 6);
    assertApksExist(apks, "com.uberspot.a2048", new int[] { 18, 19 });
    assertApksExist(apks, "org.adaway", new int[] { 52, 53, 54 });
    assertApksExist(apks, "siir.es.adbWireless", new int[] { 12 });
    assert2048Metadata(repo, "Normal");
    assertAdAwayMetadata(repo, "Normal");
    assertAdbMetadata(repo, "Normal");
}
Also used : Repo(org.fdroid.fdroid.data.Repo) Apk(org.fdroid.fdroid.data.Apk)

Example 62 with Apk

use of org.fdroid.fdroid.data.Apk in project fdroidclient by f-droid.

the class ProperMultiIndexUpdaterTest method assertConflictingRepo.

/**
 * + AdAway (org.adaway)
 * - Version 3.0.1 (53) *
 * - Version 3.0 (52) *
 * - Version 2.9.2 (51) *
 * - Version 2.2.1 (50) *
 * + Add to calendar (org.dgtale.icsimport)
 * - Version 1.2 (3)
 * - Version 1.1 (2)
 */
private void assertConflictingRepo(List<Repo> allRepos) {
    Repo repo = findRepo(REPO_CONFLICTING, allRepos);
    List<Apk> apks = ApkProvider.Helper.findByRepo(context, repo, Schema.ApkTable.Cols.ALL);
    assertEquals("Apks for conflicting repo", 6, apks.size());
    assertApksExist(apks, "org.adaway", new int[] { 50, 51, 52, 53 });
    assertApksExist(apks, "org.dgtale.icsimport", new int[] { 2, 3 });
    assertAdAwayMetadata(repo, "Conflicting");
    assertCalendarMetadata(repo, "Conflicting");
}
Also used : Repo(org.fdroid.fdroid.data.Repo) Apk(org.fdroid.fdroid.data.Apk)

Example 63 with Apk

use of org.fdroid.fdroid.data.Apk in project fdroidclient by f-droid.

the class SwapRepoTest method testSwap.

/**
 * @see WifiStateChangeService.WifiInfoThread#run()
 */
@Test
public void testSwap() throws IOException, LocalRepoKeyStore.InitException, IndexUpdater.UpdateException, InterruptedException {
    PackageManager packageManager = context.getPackageManager();
    ApplicationInfo appInfo = new ApplicationInfo();
    appInfo.flags = 0;
    appInfo.packageName = context.getPackageName();
    appInfo.minSdkVersion = 10;
    appInfo.targetSdkVersion = 23;
    appInfo.sourceDir = getClass().getClassLoader().getResource("F-Droid.apk").getPath();
    appInfo.publicSourceDir = getClass().getClassLoader().getResource("F-Droid.apk").getPath();
    System.out.println("appInfo.sourceDir " + appInfo.sourceDir);
    appInfo.name = "F-Droid";
    PackageInfo packageInfo = new PackageInfo();
    packageInfo.packageName = appInfo.packageName;
    packageInfo.applicationInfo = appInfo;
    packageInfo.versionCode = 1002001;
    packageInfo.versionName = "1.2-fake";
    shadowOf(packageManager).addPackage(packageInfo);
    try {
        FDroidApp.initWifiSettings();
        FDroidApp.ipAddressString = "127.0.0.1";
        FDroidApp.subnetInfo = new SubnetUtils("127.0.0.0/8").getInfo();
        FDroidApp.repo.name = "test";
        FDroidApp.repo.address = "http://" + FDroidApp.ipAddressString + ":" + FDroidApp.port + "/fdroid/repo";
        LocalRepoService.runProcess(context, new String[] { context.getPackageName() });
        File indexJarFile = LocalRepoManager.get(context).getIndexJar();
        System.out.println("indexJarFile:" + indexJarFile);
        assertTrue(indexJarFile.isFile());
        localHttpd = new LocalHTTPD(context, FDroidApp.ipAddressString, FDroidApp.port, LocalRepoManager.get(context).getWebRoot(), false);
        localHttpd.start();
        // give the server some tine to start.
        Thread.sleep(100);
        assertTrue(localHttpd.isAlive());
        LocalRepoKeyStore localRepoKeyStore = LocalRepoKeyStore.get(context);
        Certificate localCert = localRepoKeyStore.getCertificate();
        String signingCert = Hasher.hex(localCert);
        assertFalse(TextUtils.isEmpty(signingCert));
        assertFalse(TextUtils.isEmpty(Utils.calcFingerprint(localCert)));
        Repo repo = MultiIndexUpdaterTest.createRepo(FDroidApp.repo.name, FDroidApp.repo.address, context, signingCert);
        IndexUpdater updater = new IndexUpdater(context, repo);
        updater.update();
        assertTrue(updater.hasChanged());
        updater.processDownloadedFile(indexJarFile);
        boolean foundRepo = false;
        for (Repo repoFromDb : RepoProvider.Helper.all(context)) {
            if (TextUtils.equals(repo.address, repoFromDb.address)) {
                foundRepo = true;
                repo = repoFromDb;
            }
        }
        assertTrue(foundRepo);
        assertNotEquals(-1, repo.getId());
        List<Apk> apks = ApkProvider.Helper.findByRepo(context, repo, Schema.ApkTable.Cols.ALL);
        assertEquals(1, apks.size());
        for (Apk apk : apks) {
            System.out.println(apk);
        }
        // MultiIndexUpdaterTest.assertApksExist(apks, context.getPackageName(), new int[]{BuildConfig.VERSION_CODE});
        Thread.sleep(10000);
    } finally {
        if (localHttpd != null) {
            localHttpd.stop();
        }
    }
}
Also used : SubnetUtils(org.apache.commons.net.util.SubnetUtils) LocalHTTPD(org.fdroid.fdroid.nearby.LocalHTTPD) PackageInfo(android.content.pm.PackageInfo) ApplicationInfo(android.content.pm.ApplicationInfo) LocalRepoKeyStore(org.fdroid.fdroid.nearby.LocalRepoKeyStore) PackageManager(android.content.pm.PackageManager) Repo(org.fdroid.fdroid.data.Repo) File(java.io.File) Apk(org.fdroid.fdroid.data.Apk) IndexUpdater(org.fdroid.fdroid.IndexUpdater) Certificate(java.security.cert.Certificate) Test(org.junit.Test)

Aggregations

Apk (org.fdroid.fdroid.data.Apk)63 Test (org.junit.Test)17 Uri (android.net.Uri)16 File (java.io.File)12 Intent (android.content.Intent)11 App (org.fdroid.fdroid.data.App)10 Repo (org.fdroid.fdroid.data.Repo)10 ArrayList (java.util.ArrayList)8 PendingIntent (android.app.PendingIntent)7 Context (android.content.Context)7 PackageInfo (android.content.pm.PackageInfo)7 FileCompatTest (org.fdroid.fdroid.compat.FileCompatTest)7 BroadcastReceiver (android.content.BroadcastReceiver)6 PackageManager (android.content.pm.PackageManager)5 IOException (java.io.IOException)4 HashSet (java.util.HashSet)4 FDroidProviderTest (org.fdroid.fdroid.data.FDroidProviderTest)4 LocalBroadcastManager (androidx.localbroadcastmanager.content.LocalBroadcastManager)3 RepoDetails (org.fdroid.fdroid.mock.RepoDetails)3 SuppressLint (android.annotation.SuppressLint)2