post-install Intent to tell OsmAnd to import "installed" OBF

OsmAnd will import map files from a file:// URL pointing to an OBF file,
but this currently only works for file:// and not the proper content://.
This uses a hack to disable the warning about file:// URIs but only for the
final stage of installing the .obf file.

Hopefully in the future, this can be changed to use a proper content:// URL
as I suggested to them in this merge request:
https://github.com/osmandapp/OsmAnd/pull/10043
This commit is contained in:
Hans-Christoph Steiner
2020-10-19 16:59:32 +02:00
parent 8cf267ea6c
commit b316eab85d
4 changed files with 60 additions and 7 deletions

View File

@@ -2,7 +2,6 @@ package org.fdroid.fdroid.data;
import android.content.ContextWrapper;
import android.os.Environment;
import android.util.Log;
import android.webkit.MimeTypeMap;
import androidx.test.core.app.ApplicationProvider;
import org.apache.commons.io.FileUtils;
@@ -58,6 +57,16 @@ public class ApkTest {
assertEquals(new File(context.getApplicationInfo().dataDir + "/ota"), path);
}
@Test
public void testGetMediaInstallPathWithObf() {
Apk apk = new Apk();
apk.apkName = "Norway_bouvet_europe_2.obf";
apk.repoAddress = "https://example.com/fdroid/repo";
assertFalse(apk.isApk());
File path = apk.getMediaInstallPath(context);
assertEquals(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS), path);
}
@Test
public void testGetMediaInstallPathWithObfZip() throws IOException {
Apk apk = new Apk();

View File

@@ -54,5 +54,9 @@ public class ApkCacheTest {
new File(cacheDir, "example.com--1/Norway_bouvet_europe_2.obf.zip"),
ApkCache.getApkDownloadPath(context,
"https://example.com/fdroid/repo/Norway_bouvet_europe_2.obf.zip"));
assertEquals("Should work for OBF files also",
new File(cacheDir, "example.com--1/Norway_bouvet_europe_2.obf"),
ApkCache.getApkDownloadPath(context,
"https://example.com/fdroid/repo/Norway_bouvet_europe_2.obf"));
}
}