diff options
| author | 2023-11-01 01:26:10 -0400 | |
|---|---|---|
| committer | 2023-11-01 14:41:19 -0400 | |
| commit | 398e8814288cbf71e2620ff22648d3002f7908b6 (patch) | |
| tree | fab934d5340a3ebc6c9e3e0f8f162cbcd462e3df /src | |
| parent | android: Use yuzu logging system (diff) | |
| download | yuzu-398e8814288cbf71e2620ff22648d3002f7908b6.tar.gz yuzu-398e8814288cbf71e2620ff22648d3002f7908b6.tar.xz yuzu-398e8814288cbf71e2620ff22648d3002f7908b6.zip | |
android: Adjust log lifecycle
Now logging will start when the frontend starts like qt does. This also adjusts the share log button to follow where we share the current log if we just returned from a game or return the old log if we haven't started a game yet.
Diffstat (limited to 'src')
4 files changed, 30 insertions, 10 deletions
diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/activities/EmulationActivity.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/activities/EmulationActivity.kt index f37875ffe..da98d4ef5 100644 --- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/activities/EmulationActivity.kt +++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/activities/EmulationActivity.kt | |||
| @@ -47,6 +47,7 @@ import org.yuzu.yuzu_emu.model.EmulationViewModel | |||
| 47 | import org.yuzu.yuzu_emu.model.Game | 47 | import org.yuzu.yuzu_emu.model.Game |
| 48 | import org.yuzu.yuzu_emu.utils.ForegroundService | 48 | import org.yuzu.yuzu_emu.utils.ForegroundService |
| 49 | import org.yuzu.yuzu_emu.utils.InputHandler | 49 | import org.yuzu.yuzu_emu.utils.InputHandler |
| 50 | import org.yuzu.yuzu_emu.utils.Log | ||
| 50 | import org.yuzu.yuzu_emu.utils.MemoryUtil | 51 | import org.yuzu.yuzu_emu.utils.MemoryUtil |
| 51 | import org.yuzu.yuzu_emu.utils.NfcReader | 52 | import org.yuzu.yuzu_emu.utils.NfcReader |
| 52 | import org.yuzu.yuzu_emu.utils.ThemeHelper | 53 | import org.yuzu.yuzu_emu.utils.ThemeHelper |
| @@ -80,6 +81,7 @@ class EmulationActivity : AppCompatActivity(), SensorEventListener { | |||
| 80 | } | 81 | } |
| 81 | 82 | ||
| 82 | override fun onCreate(savedInstanceState: Bundle?) { | 83 | override fun onCreate(savedInstanceState: Bundle?) { |
| 84 | Log.gameLaunched = true | ||
| 83 | ThemeHelper.setTheme(this) | 85 | ThemeHelper.setTheme(this) |
| 84 | 86 | ||
| 85 | super.onCreate(savedInstanceState) | 87 | super.onCreate(savedInstanceState) |
diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/HomeSettingsFragment.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/HomeSettingsFragment.kt index 6e19fc6c0..8ed4b482e 100644 --- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/HomeSettingsFragment.kt +++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/HomeSettingsFragment.kt | |||
| @@ -42,6 +42,7 @@ import org.yuzu.yuzu_emu.model.HomeViewModel | |||
| 42 | import org.yuzu.yuzu_emu.ui.main.MainActivity | 42 | import org.yuzu.yuzu_emu.ui.main.MainActivity |
| 43 | import org.yuzu.yuzu_emu.utils.FileUtil | 43 | import org.yuzu.yuzu_emu.utils.FileUtil |
| 44 | import org.yuzu.yuzu_emu.utils.GpuDriverHelper | 44 | import org.yuzu.yuzu_emu.utils.GpuDriverHelper |
| 45 | import org.yuzu.yuzu_emu.utils.Log | ||
| 45 | 46 | ||
| 46 | class HomeSettingsFragment : Fragment() { | 47 | class HomeSettingsFragment : Fragment() { |
| 47 | private var _binding: FragmentHomeSettingsBinding? = null | 48 | private var _binding: FragmentHomeSettingsBinding? = null |
| @@ -312,19 +313,32 @@ class HomeSettingsFragment : Fragment() { | |||
| 312 | } | 313 | } |
| 313 | } | 314 | } |
| 314 | 315 | ||
| 316 | // Share the current log if we just returned from a game but share the old log | ||
| 317 | // if we just started the app and the old log exists. | ||
| 315 | private fun shareLog() { | 318 | private fun shareLog() { |
| 316 | val file = DocumentFile.fromSingleUri( | 319 | val currentLog = DocumentFile.fromSingleUri( |
| 317 | mainActivity, | 320 | mainActivity, |
| 318 | DocumentsContract.buildDocumentUri( | 321 | DocumentsContract.buildDocumentUri( |
| 319 | DocumentProvider.AUTHORITY, | 322 | DocumentProvider.AUTHORITY, |
| 320 | "${DocumentProvider.ROOT_ID}/log/yuzu_log.txt" | 323 | "${DocumentProvider.ROOT_ID}/log/yuzu_log.txt" |
| 321 | ) | 324 | ) |
| 322 | )!! | 325 | )!! |
| 323 | if (file.exists()) { | 326 | val oldLog = DocumentFile.fromSingleUri( |
| 324 | val intent = Intent(Intent.ACTION_SEND) | 327 | mainActivity, |
| 325 | .setDataAndType(file.uri, FileUtil.TEXT_PLAIN) | 328 | DocumentsContract.buildDocumentUri( |
| 326 | .addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION) | 329 | DocumentProvider.AUTHORITY, |
| 327 | .putExtra(Intent.EXTRA_STREAM, file.uri) | 330 | "${DocumentProvider.ROOT_ID}/log/yuzu_log.txt.old.txt" |
| 331 | ) | ||
| 332 | )!! | ||
| 333 | |||
| 334 | val intent = Intent(Intent.ACTION_SEND) | ||
| 335 | .setDataAndType(currentLog.uri, FileUtil.TEXT_PLAIN) | ||
| 336 | .addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION) | ||
| 337 | if (!Log.gameLaunched && oldLog.exists()) { | ||
| 338 | intent.putExtra(Intent.EXTRA_STREAM, oldLog.uri) | ||
| 339 | startActivity(Intent.createChooser(intent, getText(R.string.share_log))) | ||
| 340 | } else if (currentLog.exists()) { | ||
| 341 | intent.putExtra(Intent.EXTRA_STREAM, currentLog.uri) | ||
| 328 | startActivity(Intent.createChooser(intent, getText(R.string.share_log))) | 342 | startActivity(Intent.createChooser(intent, getText(R.string.share_log))) |
| 329 | } else { | 343 | } else { |
| 330 | Toast.makeText( | 344 | Toast.makeText( |
diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/utils/Log.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/utils/Log.kt index 1d3c7dce3..fb682c344 100644 --- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/utils/Log.kt +++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/utils/Log.kt | |||
| @@ -4,6 +4,9 @@ | |||
| 4 | package org.yuzu.yuzu_emu.utils | 4 | package org.yuzu.yuzu_emu.utils |
| 5 | 5 | ||
| 6 | object Log { | 6 | object Log { |
| 7 | // Tracks whether we should share the old log or the current log | ||
| 8 | var gameLaunched = false | ||
| 9 | |||
| 7 | external fun debug(message: String) | 10 | external fun debug(message: String) |
| 8 | 11 | ||
| 9 | external fun warning(message: String) | 12 | external fun warning(message: String) |
diff --git a/src/android/app/src/main/jni/native.cpp b/src/android/app/src/main/jni/native.cpp index 0e458df38..294e41045 100644 --- a/src/android/app/src/main/jni/native.cpp +++ b/src/android/app/src/main/jni/native.cpp | |||
| @@ -248,6 +248,11 @@ void EmulationSession::ConfigureFilesystemProvider(const std::string& filepath) | |||
| 248 | } | 248 | } |
| 249 | 249 | ||
| 250 | void EmulationSession::InitializeSystem() { | 250 | void EmulationSession::InitializeSystem() { |
| 251 | // Initialize logging system | ||
| 252 | Common::Log::Initialize(); | ||
| 253 | Common::Log::SetColorConsoleBackendEnabled(true); | ||
| 254 | Common::Log::Start(); | ||
| 255 | |||
| 251 | // Initialize filesystem. | 256 | // Initialize filesystem. |
| 252 | m_system.SetFilesystem(m_vfs); | 257 | m_system.SetFilesystem(m_vfs); |
| 253 | m_system.GetUserChannel().clear(); | 258 | m_system.GetUserChannel().clear(); |
| @@ -462,10 +467,6 @@ void EmulationSession::OnEmulationStopped(Core::SystemResultStatus result) { | |||
| 462 | } | 467 | } |
| 463 | 468 | ||
| 464 | static Core::SystemResultStatus RunEmulation(const std::string& filepath) { | 469 | static Core::SystemResultStatus RunEmulation(const std::string& filepath) { |
| 465 | Common::Log::Initialize(); | ||
| 466 | Common::Log::SetColorConsoleBackendEnabled(true); | ||
| 467 | Common::Log::Start(); | ||
| 468 | |||
| 469 | MicroProfileOnThreadCreate("EmuThread"); | 470 | MicroProfileOnThreadCreate("EmuThread"); |
| 470 | SCOPE_EXIT({ MicroProfileShutdown(); }); | 471 | SCOPE_EXIT({ MicroProfileShutdown(); }); |
| 471 | 472 | ||