Commit d77c83f4 authored by Max Kellermann's avatar Max Kellermann

Main: auto-configure state file on Android

parent 8cf3ac20
...@@ -94,6 +94,7 @@ ...@@ -94,6 +94,7 @@
#include "java/File.hxx" #include "java/File.hxx"
#include "android/Environment.hxx" #include "android/Environment.hxx"
#include "android/Context.hxx" #include "android/Context.hxx"
#include "fs/StandardDirectory.hxx"
#include "org_musicpd_Bridge.h" #include "org_musicpd_Bridge.h"
#endif #endif
...@@ -262,8 +263,20 @@ static bool ...@@ -262,8 +263,20 @@ static bool
glue_state_file_init(Error &error) glue_state_file_init(Error &error)
{ {
auto path_fs = config_get_path(CONF_STATE_FILE, error); auto path_fs = config_get_path(CONF_STATE_FILE, error);
if (path_fs.IsNull()) if (path_fs.IsNull()) {
return !error.IsDefined(); if (error.IsDefined())
return false;
#ifdef ANDROID
const auto cache_dir = GetUserCacheDir();
if (cache_dir.IsNull())
return true;
path_fs = AllocatedPath::Build(cache_dir, "state");
#else
return true;
#endif
}
state_file = new StateFile(std::move(path_fs), state_file = new StateFile(std::move(path_fs),
*instance->partition, *instance->partition,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment