From 10db4c503aba0e5d8f7da0ce429f98e88b538359 Mon Sep 17 00:00:00 2001 From: Linus Rath <139418639+rathlinus@users.noreply.github.com> Date: Sun, 26 Apr 2026 20:27:30 +0200 Subject: [PATCH] feat: update APK installation process to use expo-intent-launcher and improve versioning --- package-lock.json | 15 +++++++++++++-- package.json | 1 + src/lib/install-update.ts | 21 +++++++++++++-------- 3 files changed, 27 insertions(+), 10 deletions(-) diff --git a/package-lock.json b/package-lock.json index 3c902deb..56359100 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,13 @@ { "name": "bulwark-mobile", - "version": "1.0.0", + "version": "0.1.2", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "bulwark-mobile", - "version": "1.0.0", + "version": "0.1.2", + "license": "AGPL-3.0-only", "dependencies": { "@react-native-async-storage/async-storage": "2.2.0", "@react-native-community/datetimepicker": "8.4.4", @@ -17,6 +18,7 @@ "expo": "~54.0.33", "expo-file-system": "~19.0.21", "expo-image-picker": "~17.0.10", + "expo-intent-launcher": "~13.0.8", "expo-secure-store": "~15.0.8", "expo-sharing": "~14.0.8", "expo-status-bar": "~3.0.9", @@ -5234,6 +5236,15 @@ "expo": "*" } }, + "node_modules/expo-intent-launcher": { + "version": "13.0.8", + "resolved": "https://registry.npmjs.org/expo-intent-launcher/-/expo-intent-launcher-13.0.8.tgz", + "integrity": "sha512-sgGFotttKKN6dIatjOEJT8M6Arfakus7vIxgshg5VkxarVhZBGJzOJam7rbUlB1O/gQ8em9G8vhEU9AfjEIe7A==", + "license": "MIT", + "peerDependencies": { + "expo": "*" + } + }, "node_modules/expo-modules-autolinking": { "version": "3.0.24", "resolved": "https://registry.npmjs.org/expo-modules-autolinking/-/expo-modules-autolinking-3.0.24.tgz", diff --git a/package.json b/package.json index e4d26be9..ec493496 100644 --- a/package.json +++ b/package.json @@ -21,6 +21,7 @@ "expo": "~54.0.33", "expo-file-system": "~19.0.21", "expo-image-picker": "~17.0.10", + "expo-intent-launcher": "~13.0.8", "expo-secure-store": "~15.0.8", "expo-sharing": "~14.0.8", "expo-status-bar": "~3.0.9", diff --git a/src/lib/install-update.ts b/src/lib/install-update.ts index 23aa51d1..8a57b8e8 100644 --- a/src/lib/install-update.ts +++ b/src/lib/install-update.ts @@ -1,21 +1,26 @@ import { Platform } from 'react-native'; import { File, Paths } from 'expo-file-system'; -import * as Sharing from 'expo-sharing'; +import * as FileSystemLegacy from 'expo-file-system/legacy'; +import * as IntentLauncher from 'expo-intent-launcher'; import type { ReleaseAsset } from '../api/updates'; +const FLAG_GRANT_READ_URI_PERMISSION = 0x00000001; +const FLAG_ACTIVITY_NEW_TASK = 0x10000000; + export async function downloadAndInstallApk(asset: ReleaseAsset): Promise { if (Platform.OS !== 'android') { throw new Error('APK install is only supported on Android'); } + const dest = new File(Paths.cache, asset.name); if (dest.exists) dest.delete(); const downloaded = await File.downloadFileAsync(asset.browser_download_url, dest); - if (!(await Sharing.isAvailableAsync())) { - throw new Error('Sharing is not available on this device'); - } - await Sharing.shareAsync(downloaded.uri, { - mimeType: 'application/vnd.android.package-archive', - dialogTitle: 'Install update', - UTI: 'com.android.package-archive', + + const contentUri = await FileSystemLegacy.getContentUriAsync(downloaded.uri); + + await IntentLauncher.startActivityAsync('android.intent.action.VIEW', { + data: contentUri, + type: 'application/vnd.android.package-archive', + flags: FLAG_GRANT_READ_URI_PERMISSION | FLAG_ACTIVITY_NEW_TASK, }); }