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
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 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()) {