diff --git a/NEWS b/NEWS index 4c36c9b5d..5c4a394ec 100644 --- a/NEWS +++ b/NEWS @@ -10,6 +10,8 @@ ver 0.23.9 (not yet released) * fix bogus volume levels with multiple partitions * improve iconv detection * macOS: fix macOS 10 build problem (0.23.8 regression) +* Android + - load mpd.conf from app data directory ver 0.23.8 (2022/07/09) * storage diff --git a/doc/user.rst b/doc/user.rst index 85b8ba696..b2831bab4 100644 --- a/doc/user.rst +++ b/doc/user.rst @@ -36,7 +36,9 @@ Installing on Android An experimental Android build is available on Google Play. After installing and launching it, :program:`MPD` will scan the music in your Music directory and you can control it as usual with a :program:`MPD` client. -If you need to tweak the configuration, you can create a file called :file:`mpd.conf` on the data partition (the directory which is returned by Android's :dfn:`getExternalStorageDirectory()` API function). +If you need to tweak the configuration, you can create a file called +:file:`mpd.conf` in MPD's data directory on the external storage +(usually :file:`Android/data/org.musicpd/files/mpd.conf`). ALSA is not available on Android; only the :ref:`OpenSL ES ` output plugin can be used for local playback. diff --git a/src/Main.cxx b/src/Main.cxx index e764baed3..bcbda0bb5 100644 --- a/src/Main.cxx +++ b/src/Main.cxx @@ -607,6 +607,17 @@ TryReadConfigFile(ConfigData &config, Path path) static void LoadConfigFile(JNIEnv *env, ConfigData &config) { + /* try loading mpd.conf from + "Android/data/org.musicpd/files/mpd.conf" (the app specific + data directory) first */ + if (const auto dir = context->GetExternalFilesDir(env); + !dir.IsNull() && + TryReadConfigFile(config, dir / Path::FromFS("mpd.conf"))) + return; + + /* if that fails, attempt to load "mpd.conf" from the root of + the SD card (pre-0.23.9, ceases to work since Android + 12) */ if (const auto dir = Environment::getExternalStorageDirectory(env); !dir.IsNull()) TryReadConfigFile(config, dir / Path::FromFS("mpd.conf"));