diff --git a/android/app/src/main/java/app/organicmaps/SplashActivity.java b/android/app/src/main/java/app/organicmaps/SplashActivity.java index 4480aa4d343e4..6ba79d2dc5aa8 100644 --- a/android/app/src/main/java/app/organicmaps/SplashActivity.java +++ b/android/app/src/main/java/app/organicmaps/SplashActivity.java @@ -2,6 +2,7 @@ import static android.Manifest.permission.ACCESS_COARSE_LOCATION; import static android.Manifest.permission.ACCESS_FINE_LOCATION; +import static app.organicmaps.api.Const.EXTRA_PICK_POINT; import android.content.ComponentName; import android.content.Context; @@ -174,13 +175,15 @@ public void processNavigation() return; } - // Re-use original intent to retain all flags and payload. + // Re-use original intent with the known safe subset of flags to retain security permissions. // https://github.com/organicmaps/organicmaps/issues/6944 final Intent intent = Objects.requireNonNull(getIntent()); intent.setComponent(new ComponentName(this, DownloadResourcesLegacyActivity.class)); - // Flags like FLAG_ACTIVITY_NEW_TASK and FLAG_ACTIVITY_RESET_TASK_IF_NEEDED will break the cold start of the app. + // FLAG_ACTIVITY_NEW_TASK and FLAG_ACTIVITY_RESET_TASK_IF_NEEDED break the cold start. // https://github.com/organicmaps/organicmaps/pull/7287 - intent.setFlags(intent.getFlags() & (Intent.FLAG_ACTIVITY_FORWARD_RESULT | Intent.FLAG_GRANT_READ_URI_PERMISSION)); + // FORWARD_RESULT_FLAG conflicts with the ActivityResultLauncher. + // https://github.com/organicmaps/organicmaps/issues/8984 + intent.setFlags(intent.getFlags() & Intent.FLAG_GRANT_READ_URI_PERMISSION); if (Factory.isStartedForApiResult(intent)) { diff --git a/android/app/src/main/java/app/organicmaps/intent/Factory.java b/android/app/src/main/java/app/organicmaps/intent/Factory.java index d648b453e8ace..2ddf4a28c6b36 100644 --- a/android/app/src/main/java/app/organicmaps/intent/Factory.java +++ b/android/app/src/main/java/app/organicmaps/intent/Factory.java @@ -34,8 +34,11 @@ public class Factory { public static boolean isStartedForApiResult(@NonNull Intent intent) { - return ((intent.getFlags() & Intent.FLAG_ACTIVITY_FORWARD_RESULT) != 0) - || intent.getBooleanExtra(EXTRA_PICK_POINT, false); + // Previously, we relied on the implicit FORWARD_RESULT_FLAG to detect if the caller was + // waiting for a result. However, this approach proved to be less reliable than using + // the explicit EXTRA_PICK_POINT flag. + // https://github.com/organicmaps/organicmaps/pull/8910 + return intent.getBooleanExtra(EXTRA_PICK_POINT, false); } public static class KmzKmlProcessor implements IntentProcessor