Skip to content

Commit

Permalink
Merge pull request #14224 from hrydgard/scoped-storage-prep
Browse files Browse the repository at this point in the history
Add a Storage tab to System Information with some path info
  • Loading branch information
hrydgard authored Feb 27, 2021
2 parents c7d3448 + 26eab06 commit 35ad310
Show file tree
Hide file tree
Showing 8 changed files with 48 additions and 3 deletions.
3 changes: 3 additions & 0 deletions Common/System/System.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,9 @@ enum SystemProperty {
SYSPROP_SUPPORTS_PERMISSIONS,
SYSPROP_SUPPORTS_SUSTAINED_PERF_MODE,

// Android-specific.
SYSPROP_ANDROID_SCOPED_STORAGE,

SYSPROP_CAN_JIT,
};

Expand Down
1 change: 1 addition & 0 deletions Core/Config.h
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,7 @@ struct Config {
// Volatile development settings
bool bShowFrameProfiler;

// Various directories. Autoconfigured, not read from ini.
std::string currentDirectory;
std::string externalDirectory;
std::string memStickDirectory;
Expand Down
24 changes: 24 additions & 0 deletions UI/DevScreens.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,12 @@
int GetD3DCompilerVersion();
#endif

#if PPSSPP_PLATFORM(ANDROID)

#include "android/jni/app-android.h"

#endif

static const char *logLevelList[] = {
"Notice",
"Error",
Expand Down Expand Up @@ -574,6 +580,24 @@ void SystemInfoScreen::CreateViews() {
deviceSpecs->Add(new InfoItem("Moga", moga));
#endif

ViewGroup *storageScroll = new ScrollView(ORIENT_VERTICAL, new LinearLayoutParams(FILL_PARENT, FILL_PARENT));
storageScroll->SetTag("DevSystemInfoBuildConfig");
LinearLayout *storage = new LinearLayout(ORIENT_VERTICAL);
storage->SetSpacing(0);
storageScroll->Add(storage);
tabHolder->AddTab(si->T("Storage"), storageScroll);

storage->Add(new ItemHeader(si->T("Directories")));
// Intentionally non-translated
storage->Add(new InfoItem("MemStickDirectory", g_Config.memStickDirectory));
storage->Add(new InfoItem("InternalDataDirectory", g_Config.internalDataDirectory));
storage->Add(new InfoItem("AppCacheDir", g_Config.appCacheDirectory));
storage->Add(new InfoItem("ExtStorageDir", g_Config.externalDirectory));

#if PPSSPP_PLATFORM(ANDROID)
storage->Add(new InfoItem("ExtFilesDir", g_extFilesDir));
#endif

ViewGroup *buildConfigScroll = new ScrollView(ORIENT_VERTICAL, new LinearLayoutParams(FILL_PARENT, FILL_PARENT));
buildConfigScroll->SetTag("DevSystemInfoBuildConfig");
LinearLayout *buildConfig = new LinearLayout(ORIENT_VERTICAL);
Expand Down
2 changes: 2 additions & 0 deletions UI/NativeApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -492,6 +492,8 @@ void NativeInit(int argc, const char *argv[], const char *savegame_dir, const ch
g_Config.externalDirectory = external_dir;

#if defined(__ANDROID__)
// TODO: This needs to change in Android 12.
//
// Maybe there should be an option to use internal memory instead, but I think
// that for most people, using external memory (SDCard/USB Storage) makes the
// most sense.
Expand Down
13 changes: 12 additions & 1 deletion android/jni/app-android.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,9 @@ struct JNIEnv {};

bool useCPUThread = true;

// We'll turn this on when we target Android 12.
bool useScopedStorageIfRequired = false;

enum class EmuThreadState {
DISABLED,
START_REQUESTED,
Expand Down Expand Up @@ -124,6 +127,8 @@ std::string langRegion;
std::string mogaVersion;
std::string boardName;

std::string g_extFilesDir;

std::vector<std::string> g_additionalStorageDirs;

static float left_joystick_x_async;
Expand Down Expand Up @@ -445,6 +450,9 @@ bool System_GetPropertyBool(SystemProperty prop) {
#endif
case SYSPROP_CAN_JIT:
return true;
case SYSPROP_ANDROID_SCOPED_STORAGE:
if (useScopedStorageIfRequired && androidVersion >= 28)
return true;
default:
return false;
}
Expand Down Expand Up @@ -560,7 +568,7 @@ static void parse_args(std::vector<std::string> &args, const std::string value)

extern "C" void Java_org_ppsspp_ppsspp_NativeApp_init
(JNIEnv *env, jclass, jstring jmodel, jint jdeviceType, jstring jlangRegion, jstring japkpath,
jstring jdataDir, jstring jexternalStorageDir, jstring jadditionalStorageDirs, jstring jlibraryDir, jstring jcacheDir, jstring jshortcutParam,
jstring jdataDir, jstring jexternalStorageDir, jstring jexternalFilesDir, jstring jadditionalStorageDirs, jstring jlibraryDir, jstring jcacheDir, jstring jshortcutParam,
jint jAndroidVersion, jstring jboard) {
setCurrentThreadName("androidInit");

Expand Down Expand Up @@ -592,6 +600,9 @@ extern "C" void Java_org_ppsspp_ppsspp_NativeApp_init

std::string externalStorageDir = GetJavaString(env, jexternalStorageDir);
std::string additionalStorageDirsString = GetJavaString(env, jadditionalStorageDirs);
std::string externalFilesDir = GetJavaString(env, jexternalFilesDir);

g_extFilesDir = externalFilesDir;

if (!additionalStorageDirsString.empty()) {
SplitString(additionalStorageDirsString, ':', g_additionalStorageDirs);
Expand Down
2 changes: 2 additions & 0 deletions android/jni/app-android.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,5 @@ class AndroidLogger : public LogListener {
public:
void Log(const LogMessage &message) override;
};

extern std::string g_extFilesDir;
4 changes: 3 additions & 1 deletion android/src/org/ppsspp/ppsspp/NativeActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -402,8 +402,10 @@ public void Initialize() {

String extStorageState = Environment.getExternalStorageState();
String extStorageDir = Environment.getExternalStorageDirectory().getAbsolutePath();
String externalFilesDir = this.getExternalFilesDir(null).getAbsolutePath();

Log.i(TAG, "Ext storage: " + extStorageState + " " + extStorageDir);
Log.i(TAG, "Ext files dir: " + externalFilesDir);

String additionalStorageDirs = "";
try {
Expand Down Expand Up @@ -442,7 +444,7 @@ public void Initialize() {
overrideShortcutParam = null;

NativeApp.audioConfig(optimalFramesPerBuffer, optimalSampleRate);
NativeApp.init(model, deviceType, languageRegion, apkFilePath, dataDir, extStorageDir, additionalStorageDirs, libraryDir, cacheDir, shortcut, Build.VERSION.SDK_INT, Build.BOARD);
NativeApp.init(model, deviceType, languageRegion, apkFilePath, dataDir, extStorageDir, externalFilesDir, additionalStorageDirs, libraryDir, cacheDir, shortcut, Build.VERSION.SDK_INT, Build.BOARD);

// Allow C++ to tell us to use JavaGL or not.
javaGL = "true".equalsIgnoreCase(NativeApp.queryConfig("androidJavaGL"));
Expand Down
2 changes: 1 addition & 1 deletion android/src/org/ppsspp/ppsspp/NativeApp.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public class NativeApp {
public static final int DEVICE_TYPE_TV = 1;
public static final int DEVICE_TYPE_DESKTOP = 2;

public static native void init(String model, int deviceType, String languageRegion, String apkPath, String dataDir, String externalStorageDir, String additionalStorageDirs, String libraryDir, String cacheDir, String shortcutParam, int androidVersion, String board);
public static native void init(String model, int deviceType, String languageRegion, String apkPath, String dataDir, String externalStorageDir, String extFilesDir, String additionalStorageDirs, String libraryDir, String cacheDir, String shortcutParam, int androidVersion, String board);
public static native void audioInit();
public static native void audioShutdown();
public static native void audioConfig(int optimalFramesPerBuffer, int optimalSampleRate);
Expand Down

0 comments on commit 35ad310

Please sign in to comment.