From 9b5af77a229a22466cfe8ed41a21d081beeae960 Mon Sep 17 00:00:00 2001 From: oSumAtrIX Date: Mon, 12 Jun 2023 04:37:44 +0200 Subject: [PATCH] fix(syncforreddit/change-oauth-client-id): use downloads directory This fixes permission errors on Android --- dummy/src/main/java/android/os/Environment.java | 4 +++- .../syncforreddit/api/patch/ChangeOAuthClientIdPatch.kt | 5 ++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/dummy/src/main/java/android/os/Environment.java b/dummy/src/main/java/android/os/Environment.java index 5d58fc31..7db13dcb 100644 --- a/dummy/src/main/java/android/os/Environment.java +++ b/dummy/src/main/java/android/os/Environment.java @@ -3,7 +3,9 @@ package android.os; import java.io.File; public final class Environment { - public static File getExternalStorageDirectory() { + public static String DIRECTORY_DOWNLOADS = "Download"; + + public static File getExternalStoragePublicDirectory(final String type) { throw new UnsupportedOperationException("Stub"); } } diff --git a/src/main/kotlin/app/revanced/patches/syncforreddit/api/patch/ChangeOAuthClientIdPatch.kt b/src/main/kotlin/app/revanced/patches/syncforreddit/api/patch/ChangeOAuthClientIdPatch.kt index 3afcd9c2..dae98e69 100644 --- a/src/main/kotlin/app/revanced/patches/syncforreddit/api/patch/ChangeOAuthClientIdPatch.kt +++ b/src/main/kotlin/app/revanced/patches/syncforreddit/api/patch/ChangeOAuthClientIdPatch.kt @@ -34,7 +34,10 @@ class ChangeOAuthClientIdPatch : BytecodePatch( return PatchResultError("No client ID provided") } - File(Environment.getExternalStorageDirectory(), "reddit_client_id_revanced.txt").also { + File( + Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS), + "reddit_client_id_revanced.txt" + ).also { if (it.exists()) return@also val error = """