diff options
author | Zephyron <zephyron@citron-emu.orgq> | 2025-02-28 16:15:10 +1000 |
---|---|---|
committer | Zephyron <zephyron@citron-emu.orgq> | 2025-02-28 16:15:10 +1000 |
commit | 84e5fbc0899bb838ae2c813edee30b32735f4a5f (patch) | |
tree | 82b19cd571cf314a50bf132d36821ac15c860e4c /src/android | |
parent | a442078ee4c257e8c013a6edeec72de2267eb9da (diff) |
feat: Make firmware mandatory for title launching
This commit implements a requirement for firmware to be installed before titles
can be launched, similar to how keys are required.
Changes include:
- Add IsFirmwareAvailable method to KeyManager to check for essential keys
- Add CheckFirmwarePresence method to verify actual firmware files (NCAs)
- Add firmware checks in game loading process for both desktop and Android
- Add error messages when firmware is missing
- Add strings for firmware-related error messages
The implementation checks for both essential keys and the presence of system
applets like Mii Edit and Home Menu to ensure proper firmware is installed.
Games will not launch if firmware is missing, and users will be shown an
appropriate error message.
Diffstat (limited to 'src/android')
3 files changed, 48 insertions, 0 deletions
diff --git a/src/android/app/src/main/java/org/citron/citron_emu/activities/EmulationActivity.kt b/src/android/app/src/main/java/org/citron/citron_emu/activities/EmulationActivity.kt index bef01f156..164e85b49 100644 --- a/src/android/app/src/main/java/org/citron/citron_emu/activities/EmulationActivity.kt +++ b/src/android/app/src/main/java/org/citron/citron_emu/activities/EmulationActivity.kt @@ -4,6 +4,7 @@ package org.citron.citron_emu.activities import android.annotation.SuppressLint +import android.app.AlertDialog import android.app.PendingIntent import android.app.PictureInPictureParams import android.app.RemoteAction @@ -80,6 +81,19 @@ class EmulationActivity : AppCompatActivity(), SensorEventListener { super.onCreate(savedInstanceState) + // Check if firmware is available + if (!NativeLibrary.isFirmwareAvailable() || !NativeLibrary.checkFirmwarePresence()) { + AlertDialog.Builder(this) + .setTitle(R.string.firmware_missing_title) + .setMessage(R.string.firmware_missing_message) + .setPositiveButton(R.string.ok) { _, _ -> + finish() + } + .setCancelable(false) + .show() + return + } + // Add license verification at the start LicenseVerifier.verifyLicense(this) diff --git a/src/android/app/src/main/jni/native_library.cpp b/src/android/app/src/main/jni/native_library.cpp new file mode 100644 index 000000000..41152ef41 --- /dev/null +++ b/src/android/app/src/main/jni/native_library.cpp @@ -0,0 +1,31 @@ +#include "core/crypto/key_manager.h" +#include "core/hle/service/am/am.h" +#include "core/file_sys/registered_cache.h" +#include "core/file_sys/content_archive.h" +#include "core/system.h" + +extern "C" { + +JNIEXPORT jboolean JNICALL Java_org_citron_citron_1emu_NativeLibrary_isFirmwareAvailable( + JNIEnv* env, jobject obj) { + return Core::Crypto::KeyManager::Instance().IsFirmwareAvailable(); +} + +JNIEXPORT jboolean JNICALL Java_org_citron_citron_1emu_NativeLibrary_checkFirmwarePresence( + JNIEnv* env, jobject obj) { + constexpr u64 MiiEditId = 0x0100000000001009; // Mii Edit applet ID + constexpr u64 QLaunchId = 0x0100000000001000; // Home Menu applet ID + + auto& system = Core::System::GetInstance(); + auto bis_system = system.GetFileSystemController().GetSystemNANDContents(); + if (!bis_system) { + return false; + } + + auto mii_applet_nca = bis_system->GetEntry(MiiEditId, FileSys::ContentRecordType::Program); + auto qlaunch_nca = bis_system->GetEntry(QLaunchId, FileSys::ContentRecordType::Program); + + return (mii_applet_nca != nullptr && qlaunch_nca != nullptr); +} + +} // extern "C"
\ No newline at end of file diff --git a/src/android/app/src/main/res/values/strings.xml b/src/android/app/src/main/res/values/strings.xml index ce2b21bf1..355384ab4 100644 --- a/src/android/app/src/main/res/values/strings.xml +++ b/src/android/app/src/main/res/values/strings.xml @@ -23,6 +23,9 @@ <string name="keys">Keys</string> <string name="keys_description">Select your <b>prod.keys</b> file with the button below.</string> <string name="select_keys">Select Keys</string> + <string name="firmware_missing_title">Missing Firmware</string> + <string name="firmware_missing_message">Firmware is required to launch games.\n\nPlease install firmware by placing your Switch firmware files in the appropriate location.</string> + <string name="ok">OK</string> <string name="games">Games</string> <string name="games_description">Select your <b>Games</b> folder with the button below.</string> <string name="done">Done</string> |