android - add button to open ryujinx app folder

This commit is contained in:
Emmanuel Hansen 2023-12-10 09:18:54 +00:00
parent e7ac8bf333
commit 3bc415053e
8 changed files with 53 additions and 24 deletions

View File

@ -1,4 +1,4 @@
using LibRyujinx.Jni; using LibRyujinx.Jni;
using LibRyujinx.Jni.Pointers; using LibRyujinx.Jni.Pointers;
using LibRyujinx.Jni.Primitives; using LibRyujinx.Jni.Primitives;
using LibRyujinx.Jni.References; using LibRyujinx.Jni.References;
@ -84,7 +84,7 @@ namespace LibRyujinx
} }
[UnmanagedCallersOnly(EntryPoint = "Java_org_ryujinx_android_RyujinxNative_initialize")] [UnmanagedCallersOnly(EntryPoint = "Java_org_ryujinx_android_RyujinxNative_initialize")]
public static JBoolean JniInitialize(JEnvRef jEnv, JObjectLocalRef jObj, JLong jpathId, JBoolean enableDebugLogs) public static JBoolean JniInitialize(JEnvRef jEnv, JObjectLocalRef jObj, JLong jpathId)
{ {
Logger.Trace?.Print(LogClass.Application, "Jni Function Call"); Logger.Trace?.Print(LogClass.Application, "Jni Function Call");
PlatformInfo.IsBionic = true; PlatformInfo.IsBionic = true;
@ -98,7 +98,7 @@ namespace LibRyujinx
var path = GetStoredString(jpathId); var path = GetStoredString(jpathId);
var init = Initialize(path, enableDebugLogs); var init = Initialize(path);
_surfaceEvent?.Set(); _surfaceEvent?.Set();
@ -413,6 +413,13 @@ namespace LibRyujinx
RunLoop(); RunLoop();
} }
[UnmanagedCallersOnly(EntryPoint = "Java_org_ryujinx_android_RyujinxNative_loggingSetEnabled")]
public static void JniSetLoggingEnabledNative(JEnvRef jEnv, JObjectLocalRef jObj, JInt logLevel, JBoolean enabled)
{
Logger.SetEnable((LogLevel)(int)logLevel, enabled);
}
[UnmanagedCallersOnly(EntryPoint = "Java_org_ryujinx_android_RyujinxNative_deviceGetGameInfoFromPath")] [UnmanagedCallersOnly(EntryPoint = "Java_org_ryujinx_android_RyujinxNative_deviceGetGameInfoFromPath")]
public static JObjectLocalRef JniGetGameInfo(JEnvRef jEnv, JObjectLocalRef jObj, JStringLocalRef path) public static JObjectLocalRef JniGetGameInfo(JEnvRef jEnv, JObjectLocalRef jObj, JStringLocalRef path)
{ {

View File

@ -1,4 +1,4 @@
// State class for the library // State class for the library
using Ryujinx.HLE.FileSystem; using Ryujinx.HLE.FileSystem;
using Ryujinx.HLE.HOS.Services.Account.Acc; using Ryujinx.HLE.HOS.Services.Account.Acc;
using Ryujinx.HLE.HOS; using Ryujinx.HLE.HOS;
@ -56,7 +56,7 @@ namespace LibRyujinx
return res; return res;
} }
public static bool Initialize(string? basePath, bool enableDebugLogs = false) public static bool Initialize(string? basePath)
{ {
if (SwitchDevice != null) if (SwitchDevice != null)
{ {
@ -70,15 +70,6 @@ namespace LibRyujinx
ConfigurationState.Initialize(); ConfigurationState.Initialize();
LoggerModule.Initialize(); LoggerModule.Initialize();
Logger.SetEnable(LogLevel.Debug, enableDebugLogs);
Logger.SetEnable(LogLevel.Stub, false);
Logger.SetEnable(LogLevel.Info, true);
Logger.SetEnable(LogLevel.Warning, true);
Logger.SetEnable(LogLevel.Error, true);
Logger.SetEnable(LogLevel.Trace, false);
Logger.SetEnable(LogLevel.Guest, true);
Logger.SetEnable(LogLevel.AccessLog, false);
Logger.AddTarget(new AsyncLogTargetWrapper( Logger.AddTarget(new AsyncLogTargetWrapper(
new FileLogTarget(AppDataManager.BaseDirPath, "file"), new FileLogTarget(AppDataManager.BaseDirPath, "file"),
1000, 1000,

View File

@ -51,7 +51,7 @@
</provider> </provider>
<provider <provider
android:name=".providers.DocumentProvider" android:name=".providers.DocumentProvider"
android:authorities="org.ryujinx.android.provider" android:authorities="org.ryujinx.android.providers"
android:exported="true" android:exported="true"
android:grantUriPermissions="true" android:grantUriPermissions="true"
android:permission="android.permission.MANAGE_DOCUMENTS"> android:permission="android.permission.MANAGE_DOCUMENTS">

View File

@ -1,16 +1,9 @@
package org.ryujinx.android package org.ryujinx.android
import android.os.Bundle
import android.os.PersistableBundle
import androidx.activity.ComponentActivity import androidx.activity.ComponentActivity
abstract class BaseActivity : ComponentActivity() { abstract class BaseActivity : ComponentActivity() {
companion object{ companion object{
val crashHandler = CrashHandler() val crashHandler = CrashHandler()
} }
override fun onCreate(savedInstanceState: Bundle?, persistentState: PersistableBundle?) {
Thread.setDefaultUncaughtExceptionHandler(crashHandler)
super.onCreate(savedInstanceState, persistentState)
}
} }

View File

@ -80,6 +80,7 @@ class MainActivity : BaseActivity() {
} }
override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
Thread.setDefaultUncaughtExceptionHandler(crashHandler)
if( if(
!Environment.isExternalStorageManager() !Environment.isExternalStorageManager()

View File

@ -7,6 +7,7 @@ import android.os.ParcelFileDescriptor
import android.provider.DocumentsContract import android.provider.DocumentsContract
import android.provider.DocumentsProvider import android.provider.DocumentsProvider
import android.webkit.MimeTypeMap import android.webkit.MimeTypeMap
import org.ryujinx.android.BuildConfig
import org.ryujinx.android.R import org.ryujinx.android.R
import org.ryujinx.android.RyujinxApplication import org.ryujinx.android.RyujinxApplication
import java.io.File import java.io.File
@ -40,7 +41,7 @@ class DocumentProvider : DocumentsProvider() {
DocumentsContract.Document.COLUMN_SIZE DocumentsContract.Document.COLUMN_SIZE
) )
const val AUTHORITY : String = "org.ryujinx.android.providers" const val AUTHORITY : String = BuildConfig.APPLICATION_ID + ".providers"
const val ROOT_ID : String = "root" const val ROOT_ID : String = "root"
} }

View File

@ -1,6 +1,9 @@
package org.ryujinx.android.views package org.ryujinx.android.views
import android.annotation.SuppressLint import android.annotation.SuppressLint
import android.content.ActivityNotFoundException
import android.content.Intent
import android.provider.DocumentsContract
import androidx.activity.compose.BackHandler import androidx.activity.compose.BackHandler
import androidx.compose.animation.AnimatedVisibility import androidx.compose.animation.AnimatedVisibility
import androidx.compose.animation.core.MutableTransitionState import androidx.compose.animation.core.MutableTransitionState
@ -56,6 +59,7 @@ import androidx.documentfile.provider.DocumentFile
import com.anggrayudi.storage.file.extension import com.anggrayudi.storage.file.extension
import org.ryujinx.android.Helpers import org.ryujinx.android.Helpers
import org.ryujinx.android.MainActivity import org.ryujinx.android.MainActivity
import org.ryujinx.android.providers.DocumentProvider
import org.ryujinx.android.viewmodels.MainViewModel import org.ryujinx.android.viewmodels.MainViewModel
import org.ryujinx.android.viewmodels.SettingsViewModel import org.ryujinx.android.viewmodels.SettingsViewModel
import org.ryujinx.android.viewmodels.VulkanDriverViewModel import org.ryujinx.android.viewmodels.VulkanDriverViewModel
@ -207,6 +211,37 @@ class SettingViews {
Text(text = "Choose Folder") Text(text = "Choose Folder")
} }
} }
Button(onClick = {
fun createIntent(action: String) : Intent{
val intent = Intent(action)
intent.addCategory(Intent.CATEGORY_DEFAULT)
intent.data = DocumentsContract.buildRootUri(DocumentProvider.AUTHORITY, DocumentProvider.ROOT_ID)
intent.addFlags(Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION or Intent.FLAG_GRANT_PREFIX_URI_PERMISSION or Intent.FLAG_GRANT_WRITE_URI_PERMISSION)
return intent
}
try {
mainViewModel.activity.startActivity(createIntent(Intent.ACTION_VIEW))
return@Button
}
catch (_: ActivityNotFoundException){}
try {
mainViewModel.activity.startActivity(createIntent("android.provider.action.BROWSE"))
return@Button
}
catch (_: ActivityNotFoundException){}
try {
mainViewModel.activity.startActivity(createIntent("com.google.android.documentsui"))
return@Button
}
catch (_: ActivityNotFoundException){}
try {
mainViewModel.activity.startActivity(createIntent("com.android.documentsui"))
return@Button
}
catch (_: ActivityNotFoundException){}
}) {
Text(text = "Open App Folder")
}
} }
} }
ExpandableView(onCardArrowClick = { }, title = "System") { ExpandableView(onCardArrowClick = { }, title = "System") {

View File

@ -24,7 +24,7 @@ android.nonTransitiveRClass=true
# Build configuration # Build configuration
# It needs to be set to either "debug" or "release" and can also be overriden on a per build basis # It needs to be set to either "debug" or "release" and can also be overriden on a per build basis
# by adding -Dorg.ryujinx.config=NAME to the command line. # by adding -Dorg.ryujinx.config=NAME to the command line.
org.ryujinx.config=debug org.ryujinx.config=release
# Controls stripping of symbols from libryujinx # Controls stripping of symbols from libryujinx
# Setting this property to auto causes symbols to be stripped for release builds, # Setting this property to auto causes symbols to be stripped for release builds,
# but not for debug builds. # but not for debug builds.
@ -33,3 +33,4 @@ org.ryujinx.config=debug
org.ryujinx.symbols.strip=auto org.ryujinx.symbols.strip=auto
# Output path of libryujinx.so # Output path of libryujinx.so
org.ryujinx.publish.path=app/src/main/jniLibs/arm64-v8a org.ryujinx.publish.path=app/src/main/jniLibs/arm64-v8a
org.ryujinx.llvm.toolchain.path=C\:\\Android\\android-sdk\\ndk\\25.1.8937393\\toolchains\\llvm\\prebuilt\\windows-x86_64\\bin