service: nfc: Implement amiibo encryption and appdata (#6340)
This commit is contained in:
parent
ca2d87e5e3
commit
3d0a3c2c45
16 changed files with 3016 additions and 323 deletions
|
@ -585,7 +585,7 @@ public final class NativeLibrary {
|
|||
/// Notifies that the activity is now in foreground and camera devices can now be reloaded
|
||||
public static native void ReloadCameraDevices();
|
||||
|
||||
public static native boolean LoadAmiibo(byte[] bytes);
|
||||
public static native boolean LoadAmiibo(String path);
|
||||
|
||||
public static native void RemoveAmiibo();
|
||||
|
||||
|
|
|
@ -570,15 +570,7 @@ public final class EmulationActivity extends AppCompatActivity {
|
|||
}
|
||||
|
||||
private void onAmiiboSelected(String selectedFile) {
|
||||
boolean success = false;
|
||||
try {
|
||||
Uri uri = Uri.parse(selectedFile);
|
||||
DocumentFile file = DocumentFile.fromSingleUri(this, uri);
|
||||
byte[] bytes = FileUtil.getBytesFromFile(this, file);
|
||||
success = NativeLibrary.LoadAmiibo(bytes);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
boolean success = NativeLibrary.LoadAmiibo(selectedFile);
|
||||
|
||||
if (!success) {
|
||||
new MaterialAlertDialogBuilder(this)
|
||||
|
|
|
@ -569,20 +569,16 @@ void Java_org_citra_citra_1emu_NativeLibrary_ReloadCameraDevices(JNIEnv* env, jc
|
|||
}
|
||||
|
||||
jboolean Java_org_citra_citra_1emu_NativeLibrary_LoadAmiibo(JNIEnv* env, jclass clazz,
|
||||
jbyteArray bytes) {
|
||||
jstring j_file) {
|
||||
std::string filepath = GetJString(env, j_file);
|
||||
Core::System& system{Core::System::GetInstance()};
|
||||
Service::SM::ServiceManager& sm = system.ServiceManager();
|
||||
auto nfc = sm.GetService<Service::NFC::Module::Interface>("nfc:u");
|
||||
if (nfc == nullptr || env->GetArrayLength(bytes) != sizeof(Service::NFC::AmiiboData)) {
|
||||
if (nfc == nullptr) {
|
||||
return static_cast<jboolean>(false);
|
||||
}
|
||||
|
||||
Service::NFC::AmiiboData amiibo_data{};
|
||||
env->GetByteArrayRegion(bytes, 0, sizeof(Service::NFC::AmiiboData),
|
||||
reinterpret_cast<jbyte*>(&amiibo_data));
|
||||
|
||||
nfc->LoadAmiibo(amiibo_data);
|
||||
return static_cast<jboolean>(true);
|
||||
return static_cast<jboolean>(nfc->LoadAmiibo(filepath));
|
||||
}
|
||||
|
||||
void Java_org_citra_citra_1emu_NativeLibrary_RemoveAmiibo(JNIEnv* env, jclass clazz) {
|
||||
|
|
|
@ -142,7 +142,7 @@ JNIEXPORT void JNICALL Java_org_citra_citra_1emu_NativeLibrary_ReloadCameraDevic
|
|||
jclass clazz);
|
||||
|
||||
JNIEXPORT jboolean Java_org_citra_citra_1emu_NativeLibrary_LoadAmiibo(JNIEnv* env, jclass clazz,
|
||||
jbyteArray bytes);
|
||||
jstring j_file);
|
||||
|
||||
JNIEXPORT void Java_org_citra_citra_1emu_NativeLibrary_RemoveAmiibo(JNIEnv* env, jclass clazz);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue