diff options
7 files changed, 68 insertions, 40 deletions
diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/NativeLibrary.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/NativeLibrary.kt index 07f1b4842..ed8fe6c3f 100644 --- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/NativeLibrary.kt +++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/NativeLibrary.kt | |||
| @@ -462,12 +462,12 @@ object NativeLibrary { | |||
| 462 | } | 462 | } |
| 463 | 463 | ||
| 464 | fun setEmulationActivity(emulationActivity: EmulationActivity?) { | 464 | fun setEmulationActivity(emulationActivity: EmulationActivity?) { |
| 465 | Log.verbose("[NativeLibrary] Registering EmulationActivity.") | 465 | Log.debug("[NativeLibrary] Registering EmulationActivity.") |
| 466 | sEmulationActivity = WeakReference(emulationActivity) | 466 | sEmulationActivity = WeakReference(emulationActivity) |
| 467 | } | 467 | } |
| 468 | 468 | ||
| 469 | fun clearEmulationActivity() { | 469 | fun clearEmulationActivity() { |
| 470 | Log.verbose("[NativeLibrary] Unregistering EmulationActivity.") | 470 | Log.debug("[NativeLibrary] Unregistering EmulationActivity.") |
| 471 | sEmulationActivity.clear() | 471 | sEmulationActivity.clear() |
| 472 | } | 472 | } |
| 473 | 473 | ||
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 ed2a5cb55..4720daec4 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 a193e82a4..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 | |||
| @@ -3,38 +3,17 @@ | |||
| 3 | 3 | ||
| 4 | package org.yuzu.yuzu_emu.utils | 4 | package org.yuzu.yuzu_emu.utils |
| 5 | 5 | ||
| 6 | import android.util.Log | ||
| 7 | import org.yuzu.yuzu_emu.BuildConfig | ||
| 8 | |||
| 9 | /** | ||
| 10 | * Contains methods that call through to [android.util.Log], but | ||
| 11 | * with the same TAG automatically provided. Also no-ops VERBOSE and DEBUG log | ||
| 12 | * levels in release builds. | ||
| 13 | */ | ||
| 14 | object Log { | 6 | object Log { |
| 15 | private const val TAG = "Yuzu Frontend" | 7 | // Tracks whether we should share the old log or the current log |
| 8 | var gameLaunched = false | ||
| 16 | 9 | ||
| 17 | fun verbose(message: String) { | 10 | external fun debug(message: String) |
| 18 | if (BuildConfig.DEBUG) { | ||
| 19 | Log.v(TAG, message) | ||
| 20 | } | ||
| 21 | } | ||
| 22 | 11 | ||
| 23 | fun debug(message: String) { | 12 | external fun warning(message: String) |
| 24 | if (BuildConfig.DEBUG) { | ||
| 25 | Log.d(TAG, message) | ||
| 26 | } | ||
| 27 | } | ||
| 28 | 13 | ||
| 29 | fun info(message: String) { | 14 | external fun info(message: String) |
| 30 | Log.i(TAG, message) | ||
| 31 | } | ||
| 32 | 15 | ||
| 33 | fun warning(message: String) { | 16 | external fun error(message: String) |
| 34 | Log.w(TAG, message) | ||
| 35 | } | ||
| 36 | 17 | ||
| 37 | fun error(message: String) { | 18 | external fun critical(message: String) |
| 38 | Log.e(TAG, message) | ||
| 39 | } | ||
| 40 | } | 19 | } |
diff --git a/src/android/app/src/main/jni/CMakeLists.txt b/src/android/app/src/main/jni/CMakeLists.txt index 1c36661f5..88a570f68 100644 --- a/src/android/app/src/main/jni/CMakeLists.txt +++ b/src/android/app/src/main/jni/CMakeLists.txt | |||
| @@ -18,6 +18,7 @@ add_library(yuzu-android SHARED | |||
| 18 | native_config.cpp | 18 | native_config.cpp |
| 19 | uisettings.cpp | 19 | uisettings.cpp |
| 20 | game_metadata.cpp | 20 | game_metadata.cpp |
| 21 | native_log.cpp | ||
| 21 | ) | 22 | ) |
| 22 | 23 | ||
| 23 | set_property(TARGET yuzu-android PROPERTY IMPORTED_LOCATION ${FFmpeg_LIBRARY_DIR}) | 24 | set_property(TARGET yuzu-android PROPERTY IMPORTED_LOCATION ${FFmpeg_LIBRARY_DIR}) |
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 | ||
diff --git a/src/android/app/src/main/jni/native_log.cpp b/src/android/app/src/main/jni/native_log.cpp new file mode 100644 index 000000000..33d691dc8 --- /dev/null +++ b/src/android/app/src/main/jni/native_log.cpp | |||
| @@ -0,0 +1,31 @@ | |||
| 1 | // SPDX-FileCopyrightText: 2023 yuzu Emulator Project | ||
| 2 | // SPDX-License-Identifier: GPL-2.0-or-later | ||
| 3 | |||
| 4 | #include <common/logging/log.h> | ||
| 5 | #include <jni.h> | ||
| 6 | |||
| 7 | #include "android_common/android_common.h" | ||
| 8 | |||
| 9 | extern "C" { | ||
| 10 | |||
| 11 | void Java_org_yuzu_yuzu_1emu_utils_Log_debug(JNIEnv* env, jobject obj, jstring jmessage) { | ||
| 12 | LOG_DEBUG(Frontend, "{}", GetJString(env, jmessage)); | ||
| 13 | } | ||
| 14 | |||
| 15 | void Java_org_yuzu_yuzu_1emu_utils_Log_warning(JNIEnv* env, jobject obj, jstring jmessage) { | ||
| 16 | LOG_WARNING(Frontend, "{}", GetJString(env, jmessage)); | ||
| 17 | } | ||
| 18 | |||
| 19 | void Java_org_yuzu_yuzu_1emu_utils_Log_info(JNIEnv* env, jobject obj, jstring jmessage) { | ||
| 20 | LOG_INFO(Frontend, "{}", GetJString(env, jmessage)); | ||
| 21 | } | ||
| 22 | |||
| 23 | void Java_org_yuzu_yuzu_1emu_utils_Log_error(JNIEnv* env, jobject obj, jstring jmessage) { | ||
| 24 | LOG_ERROR(Frontend, "{}", GetJString(env, jmessage)); | ||
| 25 | } | ||
| 26 | |||
| 27 | void Java_org_yuzu_yuzu_1emu_utils_Log_critical(JNIEnv* env, jobject obj, jstring jmessage) { | ||
| 28 | LOG_CRITICAL(Frontend, "{}", GetJString(env, jmessage)); | ||
| 29 | } | ||
| 30 | |||
| 31 | } // extern "C" | ||