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");
}
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());
}
}
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());
}
}
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);
}
}
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();
}
}
Aggregations