From 7cfeb81a4539ea0e85c4f82aef5a597ff52ba3ad Mon Sep 17 00:00:00 2001 From: Michael W Date: Mon, 19 Apr 2021 12:35:23 +0200 Subject: [PATCH] Updater: Fix exporting updates * getExternalStorageDirectory was deprecated in API level 29 * Use the proposed Context#getExternalFilesDirs(String) instead The following message can be found in the logs, followed by a crash: MediaProvider: Creating a non-default top level directory or deleting an existing one is not allowed! Fixes: https://gitlab.com/LineageOS/issues/android/-/issues/3358 Change-Id: I81412985abc0f64d0fccb0d3069ac57ef6b4ffef --- src/org/lineageos/updater/misc/Utils.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/org/lineageos/updater/misc/Utils.java b/src/org/lineageos/updater/misc/Utils.java index 28f3c4c..0aa5fd5 100644 --- a/src/org/lineageos/updater/misc/Utils.java +++ b/src/org/lineageos/updater/misc/Utils.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2017-2020 The LineageOS Project + * Copyright (C) 2017-2021 The LineageOS Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -66,7 +66,7 @@ public class Utils { } public static File getExportPath(Context context) { - File dir = new File(Environment.getExternalStorageDirectory(), + File dir = new File(context.getExternalFilesDir(null), context.getString(R.string.export_path)); if (!dir.isDirectory()) { if (dir.exists() || !dir.mkdirs()) {