From eda2d6f9fa9efadc6196258628e3a33107675a11 Mon Sep 17 00:00:00 2001
From: PabloMK7
Date: Fri, 28 Mar 2025 12:10:59 +0100
Subject: [PATCH] Mark console as "linked" when using the azahar artic setup
tool (#833)
* Mark console as "linked" when using the azahar artic setup tool
* Updated strings related to console linking
---------
Co-authored-by: OpenSauce04
---
.../java/org/citra/citra_emu/NativeLibrary.kt | 4 +
.../fragments/SystemFilesFragment.kt | 17 ++
src/android/app/src/main/jni/native.cpp | 9 +
.../main/res/layout/fragment_system_files.xml | 7 +
.../app/src/main/res/values/strings.xml | 4 +-
src/citra_qt/citra_qt.cpp | 19 +-
.../configuration/configure_system.cpp | 33 +++
src/citra_qt/configuration/configure_system.h | 1 +
.../configuration/configure_system.ui | 253 ++++++++++--------
src/core/hw/unique_data.cpp | 27 ++
src/core/hw/unique_data.h | 3 +
src/core/loader/artic.cpp | 27 +-
src/core/loader/artic.h | 2 +-
13 files changed, 285 insertions(+), 121 deletions(-)
diff --git a/src/android/app/src/main/java/org/citra/citra_emu/NativeLibrary.kt b/src/android/app/src/main/java/org/citra/citra_emu/NativeLibrary.kt
index c8b3d8fee..583e59863 100644
--- a/src/android/app/src/main/java/org/citra/citra_emu/NativeLibrary.kt
+++ b/src/android/app/src/main/java/org/citra/citra_emu/NativeLibrary.kt
@@ -182,6 +182,10 @@ object NativeLibrary {
external fun uninstallSystemFiles(old3DS: Boolean)
+ external fun isFullConsoleLinked(): Boolean
+
+ external fun unlinkConsole()
+
private var coreErrorAlertResult = false
private val coreErrorAlertLock = Object()
diff --git a/src/android/app/src/main/java/org/citra/citra_emu/fragments/SystemFilesFragment.kt b/src/android/app/src/main/java/org/citra/citra_emu/fragments/SystemFilesFragment.kt
index 1f8328a74..7b76149d3 100644
--- a/src/android/app/src/main/java/org/citra/citra_emu/fragments/SystemFilesFragment.kt
+++ b/src/android/app/src/main/java/org/citra/citra_emu/fragments/SystemFilesFragment.kt
@@ -4,6 +4,7 @@
package org.citra.citra_emu.fragments
+import android.content.DialogInterface
import android.os.Bundle
import android.text.method.LinkMovementMethod
import android.view.Gravity
@@ -157,6 +158,22 @@ class SystemFilesFragment : Fragment() {
movementMethod = LinkMovementMethod.getInstance()
}
+ binding.buttonUnlinkConsoleData.isEnabled = NativeLibrary.isFullConsoleLinked()
+ binding.buttonUnlinkConsoleData.setOnClickListener {
+ MaterialAlertDialogBuilder(requireContext())
+ .setTitle(R.string.delete_system_files)
+ .setMessage(HtmlCompat.fromHtml(
+ requireContext().getString(R.string.delete_system_files_description),
+ HtmlCompat.FROM_HTML_MODE_COMPACT
+ ))
+ .setPositiveButton(android.R.string.ok) { _: DialogInterface, _: Int ->
+ NativeLibrary.unlinkConsole()
+ binding.buttonUnlinkConsoleData.isEnabled = NativeLibrary.isFullConsoleLinked()
+ }
+ .setNegativeButton(android.R.string.cancel, null)
+ .show()
+ }
+
binding.buttonSetUpSystemFiles.setOnClickListener {
val inflater = LayoutInflater.from(context)
val inputBinding = DialogSoftwareKeyboardBinding.inflate(inflater)
diff --git a/src/android/app/src/main/jni/native.cpp b/src/android/app/src/main/jni/native.cpp
index a88a4036c..02cc329af 100644
--- a/src/android/app/src/main/jni/native.cpp
+++ b/src/android/app/src/main/jni/native.cpp
@@ -36,6 +36,7 @@
#include "core/frontend/camera/factory.h"
#include "core/hle/service/am/am.h"
#include "core/hle/service/nfc/nfc.h"
+#include "core/hw/unique_data.h"
#include "core/loader/loader.h"
#include "core/savestate.h"
#include "core/system_titles.h"
@@ -772,4 +773,12 @@ void Java_org_citra_citra_1emu_NativeLibrary_logDeviceInfo([[maybe_unused]] JNIE
LOG_INFO(Frontend, "Host OS: Android API level {}", android_get_device_api_level());
}
+jboolean Java_org_citra_citra_1emu_NativeLibrary_isFullConsoleLinked(JNIEnv* env, jobject obj) {
+ return HW::UniqueData::IsFullConsoleLinked();
+}
+
+void Java_org_citra_citra_1emu_NativeLibrary_unlinkConsole(JNIEnv* env, jobject obj) {
+ HW::UniqueData::UnlinkConsole();
+}
+
} // extern "C"
diff --git a/src/android/app/src/main/res/layout/fragment_system_files.xml b/src/android/app/src/main/res/layout/fragment_system_files.xml
index 32e8b5358..bae1cda1c 100644
--- a/src/android/app/src/main/res/layout/fragment_system_files.xml
+++ b/src/android/app/src/main/res/layout/fragment_system_files.xml
@@ -61,6 +61,13 @@
android:layout_height="wrap_content"
android:text="@string/setup_tool_connect" />
+
+
System Files
Perform system file operations such as installing system files or booting the Home MenuConnect to Artic Setup Tool
- Azahar Artic Setup Tool. Notes:
This operation will install console unique files to Azahar, do not share your user or nand folders after performing the setup process!
Old 3DS setup is needed for the New 3DS setup to work.
Both setup modes will work regardless of the model of the console running the setup tool.
]]>
+ Azahar Artic Setup Tool. Notes:
This operation will install console unique data to Azahar, do not share your user or nand folders after performing the setup process!
While doing the setup process, Azahar will link to the console running the setup tool. You can unlink the console later from the System Files tab in the emulator options menu.
Do not go online with both Azahar and your 3DS console at the same time after setting up system files, as this could cause issues.
Old 3DS setup is needed for the New 3DS setup to work (setting up both is recommended).
Both setup modes will work regardless of the model of the console running the setup tool.
]]>Fetching current system files status, please wait...
+ Unlink Console Unique Data
+
Your OTP, SecureInfo and LocalFriendCodeSeed will be removed from Azahar.
Your friend list will reset and you will be logged out of your NNID/PNID account.
System files and eshop titles obtained through Azahar will become inaccessible until the same console is linked again using the setup tool (save data will not be lost).
This operation will install console unique "
- "files "
- "to Azahar, do not share your user or nand folders after performing the setup "
- "process!
Old 3DS setup is needed for the New 3DS setup to "
- "work.
Both setup modes will work regardless of the model of the console "
- "running the setup tool.
"),
+ "Artic Setup Tool Notes:
This operation will install console unique "
+ "data to Azahar, do not share your user or nand folders after performing the setup "
+ "process!
While doing the setup process, Azahar will link to the console "
+ "running the setup tool. You can unlink the console later from the System tab in the "
+ "emulator configuration menu.
Do not go online with both Azahar and your 3DS "
+ "console at the same time after setting up system files, as it could cause "
+ "issues.
Old 3DS setup is needed for the New 3DS setup to work (doing both "
+ "setup modes is recommended).
Both setup modes will work regardless of the "
+ "model of the console running the setup tool.
"),
&dialog);
label_description.setOpenExternalLinks(true);
layout.addWidget(&label_description);
diff --git a/src/citra_qt/configuration/configure_system.cpp b/src/citra_qt/configuration/configure_system.cpp
index 005ebe394..2f097aaa3 100644
--- a/src/citra_qt/configuration/configure_system.cpp
+++ b/src/citra_qt/configuration/configure_system.cpp
@@ -238,6 +238,8 @@ ConfigureSystem::ConfigureSystem(Core::System& system_, QWidget* parent)
connect(ui->button_regenerate_console_id, &QPushButton::clicked, this,
&ConfigureSystem::RefreshConsoleID);
connect(ui->button_regenerate_mac, &QPushButton::clicked, this, &ConfigureSystem::RefreshMAC);
+ connect(ui->button_linked_console, &QPushButton::clicked, this,
+ &ConfigureSystem::UnlinkConsole);
connect(ui->button_secure_info, &QPushButton::clicked, this, [this] {
ui->button_secure_info->setEnabled(false);
@@ -561,6 +563,25 @@ void ConfigureSystem::RefreshMAC() {
ui->label_mac->setText(tr("MAC: %1").arg(QString::fromStdString(mac_address)));
}
+void ConfigureSystem::UnlinkConsole() {
+ QMessageBox::StandardButton reply;
+ QString warning_text =
+ tr("This action will unlink your real console from Azahar, with the following "
+ "consequences:
Your OTP, SecureInfo and LocalFriendCodeSeed will be removed "
+ "from Azahar.
Your friend list will reset and you will be logged out of your "
+ "NNID/PNID account.
System files and eshop titles obtained through Azahar will "
+ "become inaccessible until the same console is linked again (save data will not be "
+ "lost).