Skip to content

Android: auto-grant MANAGE_EXTERNAL_STORAGE for faster dev testing - #14366

Merged
Frenzie merged 1 commit into
koreader:masterfrom
Frenzie:android-permission
Sep 27, 2025
Merged

Frenzie merged 1 commit into
koreader:masterfrom
Frenzie:android-permission

Conversation

@Frenzie

@Frenzie Frenzie commented Sep 27, 2025 •

Copy link
Copy Markdown
Member

This change is Reviewable

@Frenzie Frenzie added this to the 2025.10 milestone Sep 27, 2025
@Frenzie

Frenzie commented Sep 27, 2025

Copy link
Copy Markdown
Member Author

@benoit-pierre As an aside, I see this comment here says something about not recreating the archive from scratch, but I always get archive creation even if I didn't change anything.

koreader/make/android.mk

Lines 90 to 92 in d71d134

# Note: do not remove the module directory so there's no need
# for `mk7z.sh` to always recreate `koreader.7z` from scratch.
rm -rf $(ANDROID_LIBS)

[*] Install data files
--- old
+++ new
@@ -917,7 +917,7 @@
 plugins/keepalive.koplugin/main.lua 2435 D88E288B
 plugins/klondike.koplugin.zip 4688 4B91D015
 plugins/klondike.koplugin/
-plugins/klondike.koplugin/main.lua/
+plugins/klondike.koplugin/main.lua 0 00000000
 plugins/kosync.koplugin/
 plugins/kosync.koplugin/KOSyncClient.lua 5546 6036F054
 plugins/kosync.koplugin/_meta.lua 199 E561ED97

7-Zip 24.09 (x64) : Copyright (c) 1999-2024 Igor Pavlov : 2024-11-29
 64-bit locale=C.UTF-8 Threads:16 OPEN_MAX:102400, ASM

Scanning the drive:
172 folders, 997 files, 60300474 bytes (58 MiB)

Creating archive: /home/frans/src/kobo/koreader/koreader-android-x86_64-unknown-linux-android21-debug/luajit-launcher/assets/module/koreader.7z

Add new data to archive: 172 folders, 997 files, 60300474 bytes (58 MiB)

Comment thread make/android.mk
# install
adb install $(ADB_INSTALL_FLAGS) '$(ANDROID_APK)'
# speed up testing, auto-grant permission
adb shell appops set --uid $(ANDROID_APP_ID) MANAGE_EXTERNAL_STORAGE allow

@Frenzie Frenzie Sep 27, 2025 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would matter an awful lot less if newer Android (15 and 16, possibly older as well) didn't get into a state where you couldn't grant the permission in the dialog with the way this is scripted. I suspect something about the uninstall may have been made asynchronous? But simply adding in a sleep 2 or something doesn't change the situation.

Screen_recording_20250927_122815.webm

@Frenzie

Frenzie commented Sep 27, 2025 •

Copy link
Copy Markdown
Member Author

The comment was copied from the old code, but #11798 added those lines that always remove it:

koreader/make/android.mk

Lines 93 to 94 in d71d134

# Remove old in-tree build artifacts that could conflict.
rm -rf $(ANDROID_LAUNCHER_DIR)/assets/{libs,module}

The issue is the misleading comment more than anything, though I wouldn't object to saving a few seconds. In theory changing things in Kotlin shouldn't affect the resource bundle after all. :-) But hey, it's still faster than all the other Gradle stuff anyway.

@benoit-pierre

Copy link
Copy Markdown
Member

The comment was copied from the old code, but #11798 added those lines that always remove it:

koreader/make/android.mk

Lines 93 to 94 in d71d134

# Remove old in-tree build artifacts that could conflict.
rm -rf $(ANDROID_LAUNCHER_DIR)/assets/{libs,module}

The issue is the misleading comment more than anything, though I wouldn't object to saving a few seconds. In theory changing things in Kotlin shouldn't affect the resource bundle after all. :-) But hey, it's still faster than all the other Gradle stuff anyway.

It's not the same directory: that command remove the old in-tree build artifacts (in platform/android/luajit-launcher/assets/), from the older build system. The current build is done out-of-tree: the archive is created in koreader-[…]/luajit-launcher/assets/module.

@benoit-pierre

Copy link
Copy Markdown
Member

[…] I wouldn't object to saving a few seconds.

If your 7z version support it, you can change the compression method, e.g. I use: export ANDROID_ASSETS_COMPRESSION='-m0=zstd -mhc=off -mx=16', which is faster at both compression and decompression.

@benoit-pierre

Copy link
Copy Markdown
Member

@benoit-pierre As an aside, I see this comment here says something about not recreating the archive from scratch, but I always get archive creation even if I didn't change anything.

koreader/make/android.mk

Lines 90 to 92 in d71d134

# Note: do not remove the module directory so there's no need
# for `mk7z.sh` to always recreate `koreader.7z` from scratch.
rm -rf $(ANDROID_LIBS)

[*] Install data files
--- old
+++ new
@@ -917,7 +917,7 @@
 plugins/keepalive.koplugin/main.lua 2435 D88E288B
 plugins/klondike.koplugin.zip 4688 4B91D015
 plugins/klondike.koplugin/
-plugins/klondike.koplugin/main.lua/
+plugins/klondike.koplugin/main.lua 0 00000000
 plugins/kosync.koplugin/
 plugins/kosync.koplugin/KOSyncClient.lua 5546 6036F054
 plugins/kosync.koplugin/_meta.lua 199 E561ED97

And the diff is always the same?

@Frenzie

Frenzie commented Sep 27, 2025

Copy link
Copy Markdown
Member Author

Yes, it's always identical.

@benoit-pierre

Copy link
Copy Markdown
Member

Wait, is that plugins/klondike.koplugin/main.lua file empty? That would trip the directory detection (zero size).

@benoit-pierre

Copy link
Copy Markdown
Member

Yep, that's the issue, I can reproduce locally after: touch frontend/empty.lua.

@Frenzie
Frenzie merged commit edc0203 into koreader:master Sep 27, 2025
1 check passed
@Frenzie
Frenzie deleted the android-permission branch September 27, 2025 22:42
0xstillb pushed a commit to 0xstillb/koreader-thai that referenced this pull request May 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants