Skip to content

Commit

Permalink
Add full support for Android scoped storage.
Browse files Browse the repository at this point in the history
This was done by refactoring directory and file access handling for the Android platform so that any general filesystem access type go through the Android layer.
This allows us to validate whether the access is unrestricted, or whether it falls under scoped storage and thus act appropriately.
  • Loading branch information
m4gr3d committed Jun 26, 2022
1 parent ff78e2d commit 24e3b3b
Show file tree
Hide file tree
Showing 40 changed files with 2,361 additions and 301 deletions.
4 changes: 4 additions & 0 deletions core/os/dir_access.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,10 @@ Error DirAccess::make_dir_recursive(String p_dir) {
return OK;
}

DirAccess::AccessType DirAccess::get_access_type() const {
return _access_type;
}

String DirAccess::fix_path(String p_path) const {
switch (_access_type) {
case ACCESS_RESOURCES: {
Expand Down
1 change: 1 addition & 0 deletions core/os/dir_access.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ class DirAccess {
String _get_root_path() const;
String _get_root_string() const;

AccessType get_access_type() const;
String fix_path(String p_path) const;
bool next_is_dir;

Expand Down
4 changes: 0 additions & 4 deletions drivers/unix/dir_access_unix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,6 @@
#include <mntent.h>
#endif

DirAccess *DirAccessUnix::create_fs() {
return memnew(DirAccessUnix);
}

Error DirAccessUnix::list_dir_begin() {
list_dir_end(); //close any previous dir opening!

Expand Down
4 changes: 1 addition & 3 deletions drivers/unix/dir_access_unix.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,11 @@
class DirAccessUnix : public DirAccess {
DIR *dir_stream;

static DirAccess *create_fs();

String current_dir;
bool _cisdir;
bool _cishidden;

protected:
String current_dir;
virtual String fix_unicode_name(const char *p_name) const { return String::utf8(p_name); }
virtual bool is_hidden(const String &p_name);

Expand Down
4 changes: 0 additions & 4 deletions drivers/unix/file_access_unix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -335,10 +335,6 @@ Error FileAccessUnix::_set_unix_permissions(const String &p_file, uint32_t p_per
return FAILED;
}

FileAccess *FileAccessUnix::create_libc() {
return memnew(FileAccessUnix);
}

CloseNotificationFunc FileAccessUnix::close_notification_func = nullptr;

FileAccessUnix::FileAccessUnix() :
Expand Down
2 changes: 0 additions & 2 deletions drivers/unix/file_access_unix.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,6 @@ class FileAccessUnix : public FileAccess {
String path;
String path_src;

static FileAccess *create_libc();

public:
static CloseNotificationFunc close_notification_func;

Expand Down
1 change: 1 addition & 0 deletions platform/android/SCsub
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ android_files = [
"os_android.cpp",
"android_input_handler.cpp",
"file_access_android.cpp",
"file_access_filesystem_jandroid.cpp",
"audio_driver_opensl.cpp",
"dir_access_jandroid.cpp",
"thread_jandroid.cpp",
Expand Down
Loading

0 comments on commit 24e3b3b

Please sign in to comment.