mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-10-21 18:29:05 +02:00
- Scoped storage no longer flips on while no activity is registered: whether legacy storage was preserved is fixed per install, so it's asked once. - Free space reads as unknown (-1), not 0 bytes, without an activity. - Strings from Java (file listings and info, crash history, the camera list, the input debug string) go through GetJavaString, so names with characters outside the BMP aren't mangled, and a null string can't crash the crash history. - Requests (inputbox, browse_*) whose command can't be delivered are failed instead of left waiting forever. - A font that fails to load uses the default typeface (-1) instead of font 0, and is retried later if there was no activity yet. Missing exception checks added in the text renderer. - Method IDs and the storage callbacks are looked up once in JNI_OnLoad. - Unknown permissions are logged correctly. Also removes what was left of Moga support, the unused backbuffer format and a stray MessageBox macro, and tidies System_GetCameraDeviceList. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
98 lines
4.3 KiB
C++
98 lines
4.3 KiB
C++
#pragma once
|
|
|
|
#include <vector>
|
|
#include <string>
|
|
#include <string_view>
|
|
|
|
#include "Common/File/DirListing.h"
|
|
|
|
// To emphasize that Android storage mode strings are different, let's just use
|
|
// an enum.
|
|
enum class Android_OpenContentUriMode {
|
|
READ = 0, // "r"
|
|
READ_WRITE = 1, // "rw"
|
|
READ_WRITE_TRUNCATE = 2, // "rwt"
|
|
};
|
|
|
|
// Matches the constants in PpssppActivity.java.
|
|
enum class StorageError {
|
|
SUCCESS = 0,
|
|
UNKNOWN = -1,
|
|
NOT_FOUND = -2,
|
|
DISK_FULL = -3,
|
|
ALREADY_EXISTS = -4,
|
|
};
|
|
|
|
inline StorageError StorageErrorFromInt(int ival) {
|
|
if (ival >= 0) {
|
|
return StorageError::SUCCESS;
|
|
} else {
|
|
return (StorageError)ival;
|
|
}
|
|
}
|
|
|
|
extern std::string g_extFilesDir;
|
|
extern std::string g_externalDir;
|
|
|
|
// Note that we don't use string_view much here because NewStringUTF doesn't have a size parameter.
|
|
|
|
#if PPSSPP_PLATFORM(ANDROID) && !defined(__LIBRETRO__)
|
|
|
|
#include <jni.h>
|
|
|
|
void Android_StorageSetActivity(jobject nativeActivity);
|
|
|
|
bool Android_IsContentUri(std::string_view uri);
|
|
int Android_OpenContentUriFd(std::string_view uri, const Android_OpenContentUriMode mode);
|
|
StorageError Android_CreateDirectory(const std::string &parentTreeUri, const std::string &dirName);
|
|
StorageError Android_CreateFile(const std::string &parentTreeUri, const std::string &fileName);
|
|
StorageError Android_MoveFile(const std::string &fileUri, const std::string &srcParentUri, const std::string &destParentUri);
|
|
StorageError Android_CopyFile(const std::string &fileUri, const std::string &destParentUri);
|
|
|
|
// WARNING: This is very powerful, it will delete directories recursively!
|
|
StorageError Android_RemoveFile(const std::string &fileUri);
|
|
|
|
StorageError Android_RenameFileTo(const std::string &fileUri, const std::string &newName);
|
|
bool Android_GetFileInfo(const std::string &fileUri, File::FileInfo *info);
|
|
bool Android_FileExists(const std::string &fileUri);
|
|
int64_t Android_ComputeRecursiveDirectorySize(const std::string &fileUri);
|
|
int64_t Android_GetFreeSpaceByContentUri(const std::string &uri);
|
|
int64_t Android_GetFreeSpaceByFilePath(const std::string &filePath);
|
|
bool Android_IsExternalStoragePreservedLegacy();
|
|
const char *Android_ErrorToString(StorageError error);
|
|
|
|
// TODO: prefix doesn't do anything yet.
|
|
std::vector<File::FileInfo> Android_ListContentUri(const std::string &uri, const std::string &prefix, bool *exists);
|
|
|
|
// Don't need to add this below, it's only used from app-android.cpp. Call once, from JNI_OnLoad.
|
|
void Android_RegisterStorageCallbacks(JNIEnv *env);
|
|
|
|
#else
|
|
|
|
// Stub out the Android Storage wrappers, so that we can avoid ifdefs everywhere.
|
|
|
|
// See comments for the corresponding functions above.
|
|
|
|
inline bool Android_IsContentUri(std::string_view uri) { return false; }
|
|
inline int Android_OpenContentUriFd(std::string_view uri, const Android_OpenContentUriMode mode) { return -1; }
|
|
inline StorageError Android_CreateDirectory(const std::string &parentTreeUri, const std::string &dirName) { return StorageError::UNKNOWN; }
|
|
inline StorageError Android_CreateFile(const std::string &parentTreeUri, const std::string &fileName) { return StorageError::UNKNOWN; }
|
|
inline StorageError Android_MoveFile(const std::string &fileUri, const std::string &srcParentUri, const std::string &destParentUri) { return StorageError::UNKNOWN; }
|
|
inline StorageError Android_CopyFile(const std::string &fileUri, const std::string &destParentUri) { return StorageError::UNKNOWN; }
|
|
inline StorageError Android_RemoveFile(const std::string &fileUri) { return StorageError::UNKNOWN; }
|
|
inline StorageError Android_RenameFileTo(const std::string &fileUri, const std::string &newName) { return StorageError::UNKNOWN; }
|
|
inline bool Android_GetFileInfo(const std::string &fileUri, File::FileInfo *info) { return false; }
|
|
inline bool Android_FileExists(const std::string &fileUri) { return false; }
|
|
inline int64_t Android_ComputeRecursiveDirectorySize(const std::string &fileUri) { return -1; }
|
|
inline int64_t Android_GetFreeSpaceByContentUri(const std::string &uri) { return -1; }
|
|
inline int64_t Android_GetFreeSpaceByFilePath(const std::string &filePath) { return -1; }
|
|
inline bool Android_IsExternalStoragePreservedLegacy() { return false; }
|
|
inline const char *Android_ErrorToString(StorageError error) { return ""; }
|
|
|
|
inline std::vector<File::FileInfo> Android_ListContentUri(const std::string &uri, const std::string &prefix, bool *exists) {
|
|
*exists = false;
|
|
return std::vector<File::FileInfo>();
|
|
}
|
|
|
|
#endif
|