Skip to content

Open-source Android PDF and document toolkit with PDF tools, Office viewing, XLSX editing, scanning, and image editing. Built with Kotlin and Jetpack Compose.

Drop the storage and phone-state permissions a library implied

chethan6168205f6b7cd0e
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index ed5ac30..85e78ac 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -81,6 +81,18 @@ jobs:
working-directory: android
run: gradle assembleDebug testDebugUnitTest -Partefact.abis=x86_64 --no-daemon --no-configuration-cache
+ # Artefact is offline: the built app must ask for no network access, nor for the storage and
+ # phone-state permissions a library's manifest can drag in unasked
+ - name: The app stays offline
+ run: |
+ aapt2="$(ls -d "$ANDROID_HOME"/build-tools/*/ | sort -V | tail -n 1)aapt2"
+ perms="$("$aapt2" dump permissions android/app/build/outputs/apk/debug/*.apk)"
+ echo "$perms"
+ if grep -E "INTERNET|NETWORK_STATE|WIFI_STATE|READ_PHONE_STATE|EXTERNAL_STORAGE" <<<"$perms"; then
+ echo "::error::The app asks for a permission it must not have (see above)"
+ exit 1
+ fi
+
- uses: actions/upload-artifact@v7
with:
name: debug-apk
diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml
index e32c34b..d50c6e1 100644
--- a/android/app/src/main/AndroidManifest.xml
+++ b/android/app/src/main/AndroidManifest.xml
@@ -1,9 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
-<manifest xmlns:android="http://schemas.android.com/apk/res/android">
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:tools="http://schemas.android.com/tools">
- <!-- No storage permission: files come through the system's pickers (On this device lists the
+ <!-- No network permission, ever: Artefact works wholly on the device.
+
+ No storage permission: files come through the system's pickers (On this device lists the
folders the user picks), and what the app saves goes to Downloads through the media store -->
+ <!-- A library with no target SDK in its manifest (com.kyant.shapes) makes the build add these
+ three on its own, as it does for apps written before Android 1.6. Artefact uses none of
+ them, and an offline document reader has no business with the phone's state: taken out. -->
+ <uses-permission android:name="android.permission.READ_PHONE_STATE" tools:node="remove" />
+ <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" tools:node="remove" />
+ <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" tools:node="remove" />
+
<!-- Comment ▸ Voice: recording a voice comment (asked for when first used) -->
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<!-- Expressive haptics: the vibrator's rich primitives (clicks, ticks, swells) -->