Browse Source
[frontend] refactor: extract common firmware & key functions
[frontend] refactor: extract common firmware & key functions
Extracts some firmware version/verification functions into `frontend_common` to reduce duplicate code, especially for the new QML frontend. Additionally adds a check for games that are known to require firmware (e.g. MK8DX) and warns the user if they don't have firmware installed and attempt to run the game. This also makes it easier for us to implement parallel installations in the future. TODO: - [ ] Properly implement installDecryptionKeys on Android - [ ] Deal with amiibo keys :/ - [ ] Properly implement firmware checker on Android - [ ] Implement firmware install/uninstall * [ ] Implement install from zip Signed-off-by: crueter <crueter@eden-emu.dev>pull/38/head
No known key found for this signature in database
GPG Key ID: 425ACD2D4830EBC6
33 changed files with 509 additions and 503 deletions
-
55src/android/app/src/main/java/org/yuzu/yuzu_emu/NativeLibrary.kt
-
2src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/HomeSettingsFragment.kt
-
275src/android/app/src/main/java/org/yuzu/yuzu_emu/ui/main/MainActivity.kt
-
37src/android/app/src/main/jni/native.cpp
-
8src/android/app/src/main/res/values-ar/strings.xml
-
8src/android/app/src/main/res/values-ckb/strings.xml
-
6src/android/app/src/main/res/values-cs/strings.xml
-
8src/android/app/src/main/res/values-de/strings.xml
-
8src/android/app/src/main/res/values-es/strings.xml
-
8src/android/app/src/main/res/values-fa/strings.xml
-
8src/android/app/src/main/res/values-fr/strings.xml
-
8src/android/app/src/main/res/values-he/strings.xml
-
8src/android/app/src/main/res/values-hu/strings.xml
-
8src/android/app/src/main/res/values-id/strings.xml
-
8src/android/app/src/main/res/values-it/strings.xml
-
8src/android/app/src/main/res/values-ja/strings.xml
-
8src/android/app/src/main/res/values-ko/strings.xml
-
8src/android/app/src/main/res/values-nb/strings.xml
-
8src/android/app/src/main/res/values-pl/strings.xml
-
8src/android/app/src/main/res/values-pt-rBR/strings.xml
-
8src/android/app/src/main/res/values-pt-rPT/strings.xml
-
8src/android/app/src/main/res/values-ru/strings.xml
-
8src/android/app/src/main/res/values-sr/strings.xml
-
8src/android/app/src/main/res/values-uk/strings.xml
-
8src/android/app/src/main/res/values-vi/strings.xml
-
8src/android/app/src/main/res/values-zh-rCN/strings.xml
-
8src/android/app/src/main/res/values-zh-rTW/strings.xml
-
6src/android/app/src/main/res/values/arrays.xml
-
23src/android/app/src/main/res/values/strings.xml
-
2src/frontend_common/CMakeLists.txt
-
89src/frontend_common/firmware_manager.cpp
-
145src/frontend_common/firmware_manager.h
-
196src/yuzu/main.cpp
@ -0,0 +1,89 @@ |
|||
#include "firmware_manager.h"
|
|||
#include <filesystem>
|
|||
|
|||
#include "common/fs/fs.h"
|
|||
#include "common/fs/path_util.h"
|
|||
|
|||
#include "common/logging/backend.h"
|
|||
|
|||
#include "core/crypto/key_manager.h"
|
|||
#include "frontend_common/content_manager.h"
|
|||
|
|||
FirmwareManager::KeyInstallResult FirmwareManager::InstallDecryptionKeys(std::string location) |
|||
{ |
|||
LOG_INFO(Frontend, "Installing key files from {}", location); |
|||
|
|||
const std::filesystem::path prod_key_path = location; |
|||
const std::filesystem::path key_source_path = prod_key_path.parent_path(); |
|||
if (!Common::FS::IsDir(key_source_path)) { |
|||
return InvalidDir; |
|||
} |
|||
|
|||
bool prod_keys_found = false; |
|||
std::vector<std::filesystem::path> source_key_files; |
|||
|
|||
if (Common::FS::Exists(prod_key_path)) { |
|||
prod_keys_found = true; |
|||
source_key_files.emplace_back(prod_key_path); |
|||
} |
|||
|
|||
if (Common::FS::Exists(key_source_path / "title.keys")) { |
|||
source_key_files.emplace_back(key_source_path / "title.keys"); |
|||
} |
|||
|
|||
if (Common::FS::Exists(key_source_path / "key_retail.bin")) { |
|||
source_key_files.emplace_back(key_source_path / "key_retail.bin"); |
|||
} |
|||
|
|||
if (source_key_files.empty() || !prod_keys_found) { |
|||
return ErrorWrongFilename; |
|||
} |
|||
|
|||
const auto yuzu_keys_dir = Common::FS::GetEdenPath(Common::FS::EdenPath::KeysDir); |
|||
for (const auto &key_file : source_key_files) { |
|||
std::filesystem::path destination_key_file = yuzu_keys_dir / key_file.filename(); |
|||
if (!std::filesystem::copy_file(key_file, |
|||
destination_key_file, |
|||
std::filesystem::copy_options::overwrite_existing)) { |
|||
LOG_ERROR(Frontend, |
|||
"Failed to copy file {} to {}", |
|||
key_file.string(), |
|||
destination_key_file.string()); |
|||
return ErrorFailedCopy; |
|||
} |
|||
} |
|||
|
|||
// Reinitialize the key manager
|
|||
|
|||
Core::Crypto::KeyManager::Instance().ReloadKeys(); |
|||
|
|||
if (ContentManager::AreKeysPresent()) { |
|||
return Success; |
|||
} |
|||
|
|||
// let the frontend handle checking everything else
|
|||
return ErrorFailedInit; |
|||
} |
|||
|
|||
FirmwareManager::FirmwareCheckResult FirmwareManager::VerifyFirmware(Core::System &system) |
|||
{ |
|||
if (!CheckFirmwarePresence(system)) { |
|||
return ErrorFirmwareMissing; |
|||
} else { |
|||
const auto pair = GetFirmwareVersion(system); |
|||
const auto firmware_data = pair.first; |
|||
const auto result = pair.second; |
|||
|
|||
if (result.IsError()) { |
|||
LOG_INFO(Frontend, "Unable to read firmware"); |
|||
return ErrorFirmwareCorrupted; |
|||
} |
|||
|
|||
// TODO: update this whenever newer firmware is properly supported
|
|||
if (firmware_data.major > 19) { |
|||
return ErrorFirmwareTooNew; |
|||
} |
|||
} |
|||
|
|||
return FirmwareGood; |
|||
} |
|||
145
src/frontend_common/firmware_manager.h
File diff suppressed because it is too large
View File
File diff suppressed because it is too large
View File
Write
Preview
Loading…
Cancel
Save
Reference in new issue