forked from MeloNX/MeloNX
android - add option to clear all cache for a game
This commit is contained in:
parent
3ff7b1d32d
commit
330dfdc131
@ -271,21 +271,22 @@ namespace LibRyujinx
|
||||
var stream = OpenFile(descriptor);
|
||||
|
||||
IntPtr stringHandle = 0;
|
||||
string? version = "0.0";
|
||||
|
||||
try
|
||||
{
|
||||
var version = VerifyFirmware(stream, isXci);
|
||||
|
||||
if (version != null)
|
||||
{
|
||||
stringHandle = Marshal.StringToHGlobalAnsi(version.VersionString);
|
||||
}
|
||||
version = VerifyFirmware(stream, isXci)?.VersionString;
|
||||
}
|
||||
catch(Exception _)
|
||||
catch (Exception _)
|
||||
{
|
||||
Logger.Error?.Print(LogClass.Service, $"Unable to verify firmware. Exception: {_}");
|
||||
}
|
||||
|
||||
if (version != null)
|
||||
{
|
||||
stringHandle = Marshal.StringToHGlobalAnsi(version);
|
||||
}
|
||||
|
||||
return stringHandle;
|
||||
}
|
||||
|
||||
@ -304,15 +305,8 @@ namespace LibRyujinx
|
||||
{
|
||||
Logger.Trace?.Print(LogClass.Application, "Jni Function Call");
|
||||
|
||||
var version = GetInstalledFirmwareVersion();
|
||||
IntPtr stringHandle = 0;
|
||||
|
||||
if (version != String.Empty)
|
||||
{
|
||||
stringHandle = Marshal.StringToHGlobalAnsi(version);
|
||||
}
|
||||
|
||||
return stringHandle;
|
||||
var version = GetInstalledFirmwareVersion() ?? "0.0";
|
||||
return Marshal.StringToHGlobalAnsi(version);
|
||||
}
|
||||
|
||||
[UnmanagedCallersOnly(EntryPoint = "graphicsInitialize")]
|
||||
@ -438,13 +432,18 @@ namespace LibRyujinx
|
||||
RunLoop();
|
||||
}
|
||||
|
||||
|
||||
[UnmanagedCallersOnly(EntryPoint = "loggingSetEnabled")]
|
||||
public static void JniSetLoggingEnabledNative(int logLevel, bool enabled)
|
||||
{
|
||||
Logger.SetEnable((LogLevel)logLevel, enabled);
|
||||
}
|
||||
|
||||
[UnmanagedCallersOnly(EntryPoint = "loggingEnabledGraphicsLog")]
|
||||
public static void JniSetLoggingEnabledGraphicsLog(bool enabled)
|
||||
{
|
||||
_enableGraphicsLogging = enabled;
|
||||
}
|
||||
|
||||
[UnmanagedCallersOnly(EntryPoint = "deviceGetGameInfo")]
|
||||
public unsafe static void JniGetGameInfo(int fileDescriptor, IntPtr extension, IntPtr infoPtr)
|
||||
{
|
||||
|
@ -97,6 +97,9 @@ class MainActivity : BaseActivity() {
|
||||
LogLevel.Trace.ordinal,
|
||||
quickSettings.enableTraceLogs
|
||||
)
|
||||
RyujinxNative.jnaInstance.loggingEnabledGraphicsLog(
|
||||
quickSettings.enableTraceLogs
|
||||
)
|
||||
val success =
|
||||
RyujinxNative.jnaInstance.javaInitialize(appPath)
|
||||
|
||||
|
@ -80,6 +80,7 @@ interface RyujinxNativeJna : Library {
|
||||
fun deviceGetGameInfo(fileDescriptor: Int, extension: String, info: GameInfo)
|
||||
fun userGetAllUsers(): Array<String>
|
||||
fun deviceGetDlcContentList(path: String, titleId: Long): Array<String>
|
||||
fun loggingEnabledGraphicsLog(enabled: Boolean)
|
||||
}
|
||||
|
||||
class RyujinxNative {
|
||||
|
@ -319,6 +319,27 @@ class MainViewModel(val activity: MainActivity) {
|
||||
}
|
||||
}
|
||||
|
||||
fun deleteCache(titleId: String) {
|
||||
fun deleteDirectory(directory: File) {
|
||||
if (directory.exists() && directory.isDirectory) {
|
||||
directory.listFiles()?.forEach { file ->
|
||||
if (file.isDirectory) {
|
||||
deleteDirectory(file)
|
||||
} else {
|
||||
file.delete()
|
||||
}
|
||||
}
|
||||
directory.delete()
|
||||
}
|
||||
}
|
||||
if (titleId.isNotEmpty()) {
|
||||
val basePath = MainActivity.AppPath + "/games/$titleId/cache"
|
||||
if (File(basePath).exists()) {
|
||||
deleteDirectory(File(basePath))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun setStatStates(
|
||||
fifo: MutableState<Double>,
|
||||
gameFps: MutableState<Double>,
|
||||
|
@ -29,6 +29,7 @@ class QuickSettings(val activity: Activity) {
|
||||
var enableGuestLogs: Boolean
|
||||
var enableAccessLogs: Boolean
|
||||
var enableTraceLogs: Boolean
|
||||
var enableGraphicsLogs: Boolean
|
||||
|
||||
private var sharedPref: SharedPreferences =
|
||||
PreferenceManager.getDefaultSharedPreferences(activity)
|
||||
@ -57,6 +58,7 @@ class QuickSettings(val activity: Activity) {
|
||||
enableGuestLogs = sharedPref.getBoolean("enableGuestLogs", true)
|
||||
enableAccessLogs = sharedPref.getBoolean("enableAccessLogs", false)
|
||||
enableTraceLogs = sharedPref.getBoolean("enableStubLogs", false)
|
||||
enableGraphicsLogs = sharedPref.getBoolean("enableGraphicsLogs", false)
|
||||
}
|
||||
|
||||
fun save() {
|
||||
@ -85,6 +87,7 @@ class QuickSettings(val activity: Activity) {
|
||||
editor.putBoolean("enableGuestLogs", enableGuestLogs)
|
||||
editor.putBoolean("enableAccessLogs", enableAccessLogs)
|
||||
editor.putBoolean("enableTraceLogs", enableTraceLogs)
|
||||
editor.putBoolean("enableGraphicsLogs", enableGraphicsLogs)
|
||||
|
||||
editor.apply()
|
||||
}
|
||||
|
@ -63,7 +63,8 @@ class SettingsViewModel(var navController: NavHostController, val activity: Main
|
||||
enableErrorLogs: MutableState<Boolean>,
|
||||
enableGuestLogs: MutableState<Boolean>,
|
||||
enableAccessLogs: MutableState<Boolean>,
|
||||
enableTraceLogs: MutableState<Boolean>
|
||||
enableTraceLogs: MutableState<Boolean>,
|
||||
enableGraphicsLogs: MutableState<Boolean>
|
||||
) {
|
||||
|
||||
isHostMapped.value = sharedPref.getBoolean("isHostMapped", true)
|
||||
@ -90,6 +91,7 @@ class SettingsViewModel(var navController: NavHostController, val activity: Main
|
||||
enableGuestLogs.value = sharedPref.getBoolean("enableGuestLogs", true)
|
||||
enableAccessLogs.value = sharedPref.getBoolean("enableAccessLogs", false)
|
||||
enableTraceLogs.value = sharedPref.getBoolean("enableStubLogs", false)
|
||||
enableGraphicsLogs.value = sharedPref.getBoolean("enableGraphicsLogs", false)
|
||||
}
|
||||
|
||||
fun save(
|
||||
@ -114,7 +116,8 @@ class SettingsViewModel(var navController: NavHostController, val activity: Main
|
||||
enableErrorLogs: MutableState<Boolean>,
|
||||
enableGuestLogs: MutableState<Boolean>,
|
||||
enableAccessLogs: MutableState<Boolean>,
|
||||
enableTraceLogs: MutableState<Boolean>
|
||||
enableTraceLogs: MutableState<Boolean>,
|
||||
enableGraphicsLogs: MutableState<Boolean>
|
||||
) {
|
||||
val editor = sharedPref.edit()
|
||||
|
||||
@ -141,6 +144,7 @@ class SettingsViewModel(var navController: NavHostController, val activity: Main
|
||||
editor.putBoolean("enableGuestLogs", enableGuestLogs.value)
|
||||
editor.putBoolean("enableAccessLogs", enableAccessLogs.value)
|
||||
editor.putBoolean("enableTraceLogs", enableTraceLogs.value)
|
||||
editor.putBoolean("enableGraphicsLogs", enableGraphicsLogs.value)
|
||||
|
||||
editor.apply()
|
||||
activity.storageHelper!!.onFolderSelected = previousFolderCallback
|
||||
@ -159,6 +163,7 @@ class SettingsViewModel(var navController: NavHostController, val activity: Main
|
||||
)
|
||||
RyujinxNative.jnaInstance.loggingSetEnabled(LogLevel.Guest.ordinal, enableGuestLogs.value)
|
||||
RyujinxNative.jnaInstance.loggingSetEnabled(LogLevel.Trace.ordinal, enableTraceLogs.value)
|
||||
RyujinxNative.jnaInstance.loggingEnabledGraphicsLog(enableGraphicsLogs.value)
|
||||
}
|
||||
|
||||
fun openGameFolder() {
|
||||
|
@ -488,6 +488,14 @@ class HomeViews {
|
||||
viewModel.mainViewModel.selected?.titleId ?: ""
|
||||
)
|
||||
})
|
||||
DropdownMenuItem(text = {
|
||||
Text(text = "Delete All Cache")
|
||||
}, onClick = {
|
||||
showAppMenu.value = false
|
||||
viewModel.mainViewModel?.deleteCache(
|
||||
viewModel.mainViewModel.selected?.titleId ?: ""
|
||||
)
|
||||
})
|
||||
DropdownMenuItem(text = {
|
||||
Text(text = "Manage Updates")
|
||||
}, onClick = {
|
||||
|
@ -134,6 +134,7 @@ class SettingViews {
|
||||
val enableGuestLogs = remember { mutableStateOf(true) }
|
||||
val enableAccessLogs = remember { mutableStateOf(true) }
|
||||
val enableTraceLogs = remember { mutableStateOf(true) }
|
||||
val enableGraphicsLogs = remember { mutableStateOf(true) }
|
||||
|
||||
if (!loaded.value) {
|
||||
settingsViewModel.initializeState(
|
||||
@ -155,7 +156,8 @@ class SettingViews {
|
||||
enableErrorLogs,
|
||||
enableGuestLogs,
|
||||
enableAccessLogs,
|
||||
enableTraceLogs
|
||||
enableTraceLogs,
|
||||
enableGraphicsLogs
|
||||
)
|
||||
loaded.value = true
|
||||
}
|
||||
@ -189,7 +191,8 @@ class SettingViews {
|
||||
enableErrorLogs,
|
||||
enableGuestLogs,
|
||||
enableAccessLogs,
|
||||
enableTraceLogs
|
||||
enableTraceLogs,
|
||||
enableGraphicsLogs
|
||||
)
|
||||
settingsViewModel.navController.popBackStack()
|
||||
}) {
|
||||
@ -1047,6 +1050,21 @@ class SettingViews {
|
||||
enableTraceLogs.value = !enableTraceLogs.value
|
||||
})
|
||||
}
|
||||
Row(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(8.dp),
|
||||
horizontalArrangement = Arrangement.SpaceBetween,
|
||||
verticalAlignment = Alignment.CenterVertically
|
||||
) {
|
||||
Text(
|
||||
text = "Enable Graphics Debug Logs",
|
||||
modifier = Modifier.align(Alignment.CenterVertically)
|
||||
)
|
||||
Switch(checked = enableGraphicsLogs.value, onCheckedChange = {
|
||||
enableGraphicsLogs.value = !enableGraphicsLogs.value
|
||||
})
|
||||
}
|
||||
Row(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
@ -1083,7 +1101,8 @@ class SettingViews {
|
||||
enableErrorLogs,
|
||||
enableGuestLogs,
|
||||
enableAccessLogs,
|
||||
enableTraceLogs
|
||||
enableTraceLogs,
|
||||
enableGraphicsLogs
|
||||
)
|
||||
settingsViewModel.navController.popBackStack()
|
||||
}
|
||||
|
Reference in New Issue
Block a user