From 692d2e2b1af3ab08d5b1ae523eca2a650fb57faf Mon Sep 17 00:00:00 2001 From: ibrahim-iqbal Date: Mon, 21 Sep 2026 13:04:19 +0530 Subject: [PATCH] fix: guard startSyncFolderOperation against a null folder (#4738) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `ReceiveExternalFilesViewModel.refreshFolderUseCase(folderToSync: OCFile)` is a Kotlin function with a non-null parameter. `ReceiveExternalFilesActivity` was passing the result of `getCurrentDir()` — which returns null whenever the storage manager cannot resolve the current folder — straight through without a null check, so the Kotlin platform-type check tripped the NPE that shows up in the Play console stack in issue #4738. Short-circuit `startSyncFolderOperation` when the folder is null and log the skip via Timber. All other callers already null-check the folder they pass in; the crash path was the `getCurrentDir()` handoff. Signed-off-by: ibrahim-iqbal --- changelog/unreleased/4738 | 10 ++++++++++ .../ui/activity/ReceiveExternalFilesActivity.java | 8 ++++++++ 2 files changed, 18 insertions(+) create mode 100644 changelog/unreleased/4738 diff --git a/changelog/unreleased/4738 b/changelog/unreleased/4738 new file mode 100644 index 00000000000..1b500d52d7b --- /dev/null +++ b/changelog/unreleased/4738 @@ -0,0 +1,10 @@ +Bugfix: Prevent NullPointerException when returning from external-file receive screen + +The share-into flow's `ReceiveExternalFilesActivity` forwarded a folder to +`ReceiveExternalFilesViewModel.refreshFolderUseCase` without guarding for null, +so any code path where `getCurrentDir()` resolved to `null` — such as leaving +the screen before the storage manager had loaded the parent folder — crashed +with a Kotlin platform-type NPE. The activity now skips the sync when the +folder cannot be resolved and logs the reason instead of crashing. + +https://github.com/owncloud/android/issues/4738 diff --git a/owncloudApp/src/main/java/com/owncloud/android/ui/activity/ReceiveExternalFilesActivity.java b/owncloudApp/src/main/java/com/owncloud/android/ui/activity/ReceiveExternalFilesActivity.java index 2d0af9aeca0..c585e2f7ff2 100644 --- a/owncloudApp/src/main/java/com/owncloud/android/ui/activity/ReceiveExternalFilesActivity.java +++ b/owncloudApp/src/main/java/com/owncloud/android/ui/activity/ReceiveExternalFilesActivity.java @@ -628,6 +628,14 @@ public void onSavedCertificate() { } private void startSyncFolderOperation(OCFile folder) { + // getCurrentDir() and other callers can hand us a null folder when the + // storage manager cannot resolve the parent path yet; forwarding that + // to the Kotlin use case would trip the platform-type null check and + // crash as reported in issue #4738. + if (folder == null) { + Timber.w("startSyncFolderOperation called with a null folder; skipping sync"); + return; + } mSyncInProgress = true;