Search in sources :

Example 6 with Apk

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

the class ProperMultiIndexUpdaterTest method assertMainArchiveRepoMetadata.

/**
 * + AdAway (org.adaway)
 * - Version 2.9.2 (51)
 * - Version 2.9.1 (50)
 * - Version 2.9 (49)
 * - Version 2.8.1 (48)
 * - Version 2.8 (47)
 * - Version 2.7 (46)
 * - Version 2.6 (45)
 * - Version 2.3 (42)
 * - Version 2.1 (40)
 * - Version 1.37 (38)
 * - Version 1.36 (37)
 * - Version 1.35 (36)
 * - Version 1.34 (35)
 */
private void assertMainArchiveRepoMetadata(List<Repo> allRepos) {
    Repo repo = findRepo(REPO_ARCHIVE, allRepos);
    List<Apk> apks = ApkProvider.Helper.findByRepo(context, repo, Schema.ApkTable.Cols.ALL);
    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 });
    assertAdAwayMetadata(repo, "Normal");
}
Also used : Repo(org.fdroid.fdroid.data.Repo) Apk(org.fdroid.fdroid.data.Apk)

Example 7 with Apk

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

the class InstallerFactoryTest method testApkInstallerInstance.

@Test
public void testApkInstallerInstance() {
    for (String filename : new String[] { "test.apk", "A.APK", "b.ApK" }) {
        Apk apk = new Apk();
        apk.apkName = filename;
        apk.packageName = "test";
        Installer installer = InstallerFactory.create(context, apk);
        assertEquals(filename + " should use a DefaultInstaller", DefaultInstaller.class, installer.getClass());
    }
}
Also used : Apk(org.fdroid.fdroid.data.Apk) Test(org.junit.Test)

Example 8 with Apk

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

the class InstallerFactoryTest method testFileInstallerInstance.

@Test
public void testFileInstallerInstance() {
    for (String filename : new String[] { "org.fdroid.fdroid.privileged.ota_2110.zip", "test.ZIP" }) {
        Apk apk = new Apk();
        apk.apkName = filename;
        apk.packageName = "cafe0088";
        Installer installer = InstallerFactory.create(context, apk);
        assertEquals("should be a FileInstaller", FileInstaller.class, installer.getClass());
    }
}
Also used : Apk(org.fdroid.fdroid.data.Apk) Test(org.junit.Test)

Example 9 with Apk

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

the class InstallHistoryService method onHandleIntent.

@Override
protected void onHandleIntent(Intent intent) {
    Utils.debugLog(TAG, "onHandleIntent " + intent);
    if (intent == null) {
        return;
    }
    Process.setThreadPriority(Process.THREAD_PRIORITY_LOWEST);
    long timestamp = System.currentTimeMillis();
    Apk apk = intent.getParcelableExtra(Installer.EXTRA_APK);
    String packageName = apk.packageName;
    int versionCode = apk.versionCode;
    List<String> values = new ArrayList<>(4);
    values.add(String.valueOf(timestamp));
    values.add(packageName);
    values.add(String.valueOf(versionCode));
    values.add(intent.getAction());
    File logFile = getInstallHistoryFile(this);
    FileWriter fw = null;
    PrintWriter out = null;
    try {
        fw = new FileWriter(logFile, true);
        out = new PrintWriter(fw);
        out.println(TextUtils.join(",", values));
    } catch (IOException e) {
        Utils.debugLog(TAG, e.getMessage());
    } finally {
        Utils.closeQuietly(out);
        Utils.closeQuietly(fw);
    }
}
Also used : FileWriter(java.io.FileWriter) ArrayList(java.util.ArrayList) IOException(java.io.IOException) Apk(org.fdroid.fdroid.data.Apk) File(java.io.File) PrintWriter(java.io.PrintWriter)

Example 10 with Apk

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

the class InstallerService method onHandleWork.

@Override
protected void onHandleWork(@NonNull Intent intent) {
    final Apk apk = intent.getParcelableExtra(Installer.EXTRA_APK);
    if (apk == null) {
        return;
    }
    Installer installer = InstallerFactory.create(this, apk);
    if (ACTION_INSTALL.equals(intent.getAction())) {
        Uri uri = intent.getData();
        Uri canonicalUri = Uri.parse(intent.getStringExtra(org.fdroid.fdroid.net.Downloader.EXTRA_CANONICAL_URL));
        installer.installPackage(uri, canonicalUri);
    } else if (ACTION_UNINSTALL.equals(intent.getAction())) {
        installer.uninstallPackage();
        new Thread() {

            @Override
            public void run() {
                setPriority(MIN_PRIORITY);
                File mainObbFile = apk.getMainObbFile();
                if (mainObbFile == null) {
                    return;
                }
                File obbDir = mainObbFile.getParentFile();
                if (obbDir == null) {
                    return;
                }
                FileFilter filter = new WildcardFileFilter("*.obb");
                File[] obbFiles = obbDir.listFiles(filter);
                if (obbFiles == null) {
                    return;
                }
                for (File f : obbFiles) {
                    Utils.debugLog(TAG, "Uninstalling OBB " + f);
                    FileUtils.deleteQuietly(f);
                }
            }
        }.start();
    }
}
Also used : FileFilter(java.io.FileFilter) WildcardFileFilter(org.apache.commons.io.filefilter.WildcardFileFilter) Apk(org.fdroid.fdroid.data.Apk) Uri(android.net.Uri) File(java.io.File) WildcardFileFilter(org.apache.commons.io.filefilter.WildcardFileFilter)

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