From cf550fdeb733af9417dba68b6bd2db55270a1db5 Mon Sep 17 00:00:00 2001
From: okadan <46291090+okadan@users.noreply.github.com>
Date: Sun, 5 Mar 2023 10:50:25 +0900
Subject: [PATCH] Create v4.0.0 release
---
.gitignore | 1 -
.metadata | 18 +-
CHANGELOG.md | 185 +-
LICENSE | 2 +-
README.md | 83 +-
android/build.gradle | 32 +-
android/src/main/AndroidManifest.xml | 2 +-
.../plugins/nfcmanager/NfcManagerPlugin.kt | 509 ++++
.../dev/flutter/plugins/nfcmanager/Pigeon.kt | 1611 +++++++++++
.../plugins/nfcmanager/NfcManagerPlugin.kt | 348 ---
.../flutter/plugins/nfcmanager/Translator.kt | 150 --
.../nfcmanager/NfcManagerPluginTest.kt | 11 +
example/.gitignore | 1 -
example/README.md | 13 +
example/android/app/build.gradle | 24 +-
.../android/app/src/debug/AndroidManifest.xml | 3 +-
.../android/app/src/main/AndroidManifest.xml | 7 +-
.../plugins/nfcmanagerexample/MainActivity.kt | 6 +
.../plugins/nfcmanagerexample/MainActivity.kt | 21 -
.../app/src/profile/AndroidManifest.xml | 3 +-
example/android/build.gradle | 5 +-
example/android/gradle.properties | 2 +-
.../gradle/wrapper/gradle-wrapper.properties | 2 +-
example/android/settings.gradle | 34 +-
example/ios/Podfile | 3 +
example/ios/Podfile.lock | 6 +-
example/ios/Runner.xcodeproj/project.pbxproj | 266 +-
.../xcshareddata/xcschemes/Runner.xcscheme | 13 +-
.../AppIcon.appiconset/Icon-App-20x20@1x.png | Bin 564 -> 295 bytes
.../AppIcon.appiconset/Icon-App-20x20@2x.png | Bin 1283 -> 406 bytes
.../AppIcon.appiconset/Icon-App-20x20@3x.png | Bin 1588 -> 450 bytes
.../AppIcon.appiconset/Icon-App-29x29@1x.png | Bin 1025 -> 282 bytes
.../AppIcon.appiconset/Icon-App-29x29@2x.png | Bin 1716 -> 462 bytes
.../AppIcon.appiconset/Icon-App-29x29@3x.png | Bin 1920 -> 704 bytes
.../AppIcon.appiconset/Icon-App-40x40@1x.png | Bin 1283 -> 406 bytes
.../AppIcon.appiconset/Icon-App-40x40@2x.png | Bin 1895 -> 586 bytes
.../AppIcon.appiconset/Icon-App-40x40@3x.png | Bin 2665 -> 862 bytes
.../AppIcon.appiconset/Icon-App-60x60@2x.png | Bin 2665 -> 862 bytes
.../AppIcon.appiconset/Icon-App-60x60@3x.png | Bin 3831 -> 1674 bytes
.../AppIcon.appiconset/Icon-App-76x76@1x.png | Bin 1888 -> 762 bytes
.../AppIcon.appiconset/Icon-App-76x76@2x.png | Bin 3294 -> 1226 bytes
.../Icon-App-83.5x83.5@2x.png | Bin 3612 -> 1418 bytes
example/ios/Runner/Base.lproj/Main.storyboard | 13 +-
example/ios/Runner/Info.plist | 12 +-
example/ios/Runner/Runner.entitlements | 10 -
example/ios/RunnerTests/RunnerTests.swift | 9 +
example/lib/main.dart | 135 +-
example/pubspec.lock | 102 +-
example/pubspec.yaml | 4 +-
ios/Classes/NfcManagerPlugin.h | 4 -
ios/Classes/NfcManagerPlugin.m | 15 -
ios/Classes/NfcManagerPlugin.swift | 802 ++++++
ios/Classes/Pigeon.swift | 1804 +++++++++++++
ios/Classes/SwiftNfcManagerPlugin.swift | 767 ------
ios/Classes/Translator.swift | 161 --
ios/nfc_manager.podspec | 2 +-
lib/nfc_manager.dart | 1 -
lib/nfc_manager_android.dart | 12 +
lib/nfc_manager_ios.dart | 6 +
lib/platform_tags.dart | 12 -
lib/src/channel.dart | 3 -
lib/src/nfc_manager/nfc_manager.dart | 236 +-
lib/src/nfc_manager/nfc_ndef.dart | 297 ---
lib/src/nfc_manager_android/nfc_manager.dart | 111 +
.../nfc_manager_platform.dart | 40 +
lib/src/nfc_manager_android/pigeon.dart | 3 +
lib/src/nfc_manager_android/pigeon.g.dart | 2033 ++++++++++++++
lib/src/nfc_manager_android/tags/iso_dep.dart | 81 +
.../tags/mifare_classic.dart | 169 ++
.../tags/mifare_ultralight.dart | 105 +
lib/src/nfc_manager_android/tags/ndef.dart | 120 +
.../tags/ndef_formatable.dart | 65 +
lib/src/nfc_manager_android/tags/nfc_a.dart | 76 +
lib/src/nfc_manager_android/tags/nfc_b.dart | 61 +
.../nfc_manager_android/tags/nfc_barcode.dart | 46 +
lib/src/nfc_manager_android/tags/nfc_f.dart | 76 +
lib/src/nfc_manager_android/tags/nfc_v.dart | 61 +
lib/src/nfc_manager_android/tags/tag.dart | 31 +
lib/src/nfc_manager_ios/nfc_manager.dart | 342 +++
.../nfc_manager_ios/nfc_manager_platform.dart | 33 +
lib/src/nfc_manager_ios/pigeon.dart | 3 +
lib/src/nfc_manager_ios/pigeon.g.dart | 2368 +++++++++++++++++
lib/src/nfc_manager_ios/tags/felica.dart | 315 +++
lib/src/nfc_manager_ios/tags/iso15693.dart | 283 ++
lib/src/nfc_manager_ios/tags/iso7816.dart | 117 +
lib/src/nfc_manager_ios/tags/mifare.dart | 115 +
lib/src/nfc_manager_ios/tags/ndef.dart | 144 +
lib/src/platform_tags/felica.dart | 282 --
lib/src/platform_tags/iso15693.dart | 371 ---
lib/src/platform_tags/iso7816.dart | 97 -
lib/src/platform_tags/iso_dep.dart | 62 -
lib/src/platform_tags/mifare.dart | 97 -
lib/src/platform_tags/mifare_classic.dart | 173 --
lib/src/platform_tags/mifare_ultralight.dart | 81 -
lib/src/platform_tags/ndef_formatable.dart | 51 -
lib/src/platform_tags/nfc_a.dart | 58 -
lib/src/platform_tags/nfc_b.dart | 54 -
lib/src/platform_tags/nfc_f.dart | 58 -
lib/src/platform_tags/nfc_v.dart | 54 -
lib/src/translator.dart | 337 ---
pigeon/android.dart | 231 ++
pigeon/ios.dart | 374 +++
pigeon/pigeon_android.dart | 166 ++
pigeon/pigeon_ios.dart | 266 ++
pubspec.yaml | 16 +-
105 files changed, 13153 insertions(+), 4241 deletions(-)
create mode 100644 android/src/main/kotlin/dev/flutter/plugins/nfcmanager/NfcManagerPlugin.kt
create mode 100644 android/src/main/kotlin/dev/flutter/plugins/nfcmanager/Pigeon.kt
delete mode 100644 android/src/main/kotlin/io/flutter/plugins/nfcmanager/NfcManagerPlugin.kt
delete mode 100644 android/src/main/kotlin/io/flutter/plugins/nfcmanager/Translator.kt
create mode 100644 android/src/test/kotlin/dev/flutter/plugins/nfcmanager/NfcManagerPluginTest.kt
create mode 100644 example/android/app/src/main/kotlin/dev/flutter/plugins/nfcmanagerexample/MainActivity.kt
delete mode 100644 example/android/app/src/main/kotlin/io/flutter/plugins/nfcmanagerexample/MainActivity.kt
delete mode 100644 example/ios/Runner/Runner.entitlements
create mode 100644 example/ios/RunnerTests/RunnerTests.swift
delete mode 100644 ios/Classes/NfcManagerPlugin.h
delete mode 100644 ios/Classes/NfcManagerPlugin.m
create mode 100644 ios/Classes/NfcManagerPlugin.swift
create mode 100644 ios/Classes/Pigeon.swift
delete mode 100644 ios/Classes/SwiftNfcManagerPlugin.swift
delete mode 100644 ios/Classes/Translator.swift
create mode 100644 lib/nfc_manager_android.dart
create mode 100644 lib/nfc_manager_ios.dart
delete mode 100644 lib/platform_tags.dart
delete mode 100644 lib/src/channel.dart
delete mode 100644 lib/src/nfc_manager/nfc_ndef.dart
create mode 100644 lib/src/nfc_manager_android/nfc_manager.dart
create mode 100644 lib/src/nfc_manager_android/nfc_manager_platform.dart
create mode 100644 lib/src/nfc_manager_android/pigeon.dart
create mode 100644 lib/src/nfc_manager_android/pigeon.g.dart
create mode 100644 lib/src/nfc_manager_android/tags/iso_dep.dart
create mode 100644 lib/src/nfc_manager_android/tags/mifare_classic.dart
create mode 100644 lib/src/nfc_manager_android/tags/mifare_ultralight.dart
create mode 100644 lib/src/nfc_manager_android/tags/ndef.dart
create mode 100644 lib/src/nfc_manager_android/tags/ndef_formatable.dart
create mode 100644 lib/src/nfc_manager_android/tags/nfc_a.dart
create mode 100644 lib/src/nfc_manager_android/tags/nfc_b.dart
create mode 100644 lib/src/nfc_manager_android/tags/nfc_barcode.dart
create mode 100644 lib/src/nfc_manager_android/tags/nfc_f.dart
create mode 100644 lib/src/nfc_manager_android/tags/nfc_v.dart
create mode 100644 lib/src/nfc_manager_android/tags/tag.dart
create mode 100644 lib/src/nfc_manager_ios/nfc_manager.dart
create mode 100644 lib/src/nfc_manager_ios/nfc_manager_platform.dart
create mode 100644 lib/src/nfc_manager_ios/pigeon.dart
create mode 100644 lib/src/nfc_manager_ios/pigeon.g.dart
create mode 100644 lib/src/nfc_manager_ios/tags/felica.dart
create mode 100644 lib/src/nfc_manager_ios/tags/iso15693.dart
create mode 100644 lib/src/nfc_manager_ios/tags/iso7816.dart
create mode 100644 lib/src/nfc_manager_ios/tags/mifare.dart
create mode 100644 lib/src/nfc_manager_ios/tags/ndef.dart
delete mode 100644 lib/src/platform_tags/felica.dart
delete mode 100644 lib/src/platform_tags/iso15693.dart
delete mode 100644 lib/src/platform_tags/iso7816.dart
delete mode 100644 lib/src/platform_tags/iso_dep.dart
delete mode 100644 lib/src/platform_tags/mifare.dart
delete mode 100644 lib/src/platform_tags/mifare_classic.dart
delete mode 100644 lib/src/platform_tags/mifare_ultralight.dart
delete mode 100644 lib/src/platform_tags/ndef_formatable.dart
delete mode 100644 lib/src/platform_tags/nfc_a.dart
delete mode 100644 lib/src/platform_tags/nfc_b.dart
delete mode 100644 lib/src/platform_tags/nfc_f.dart
delete mode 100644 lib/src/platform_tags/nfc_v.dart
delete mode 100644 lib/src/translator.dart
create mode 100644 pigeon/android.dart
create mode 100644 pigeon/ios.dart
create mode 100644 pigeon/pigeon_android.dart
create mode 100644 pigeon/pigeon_ios.dart
diff --git a/.gitignore b/.gitignore
index 96486fd..ac5aa98 100644
--- a/.gitignore
+++ b/.gitignore
@@ -26,5 +26,4 @@ migrate_working_dir/
/pubspec.lock
**/doc/api/
.dart_tool/
-.packages
build/
diff --git a/.metadata b/.metadata
index 044504e..63ffe23 100644
--- a/.metadata
+++ b/.metadata
@@ -1,11 +1,11 @@
# This file tracks properties of this Flutter project.
# Used by Flutter tool to assess capabilities and perform upgrades etc.
#
-# This file should be version controlled.
+# This file should be version controlled and should not be manually edited.
version:
- revision: e3c29ec00c9c825c891d75054c63fcc46454dca1
- channel: stable
+ revision: "db7ef5bf9f59442b0e200a90587e8fa5e0c6336a"
+ channel: "stable"
project_type: plugin
@@ -13,14 +13,14 @@ project_type: plugin
migration:
platforms:
- platform: root
- create_revision: e3c29ec00c9c825c891d75054c63fcc46454dca1
- base_revision: e3c29ec00c9c825c891d75054c63fcc46454dca1
+ create_revision: db7ef5bf9f59442b0e200a90587e8fa5e0c6336a
+ base_revision: db7ef5bf9f59442b0e200a90587e8fa5e0c6336a
- platform: android
- create_revision: e3c29ec00c9c825c891d75054c63fcc46454dca1
- base_revision: e3c29ec00c9c825c891d75054c63fcc46454dca1
+ create_revision: db7ef5bf9f59442b0e200a90587e8fa5e0c6336a
+ base_revision: db7ef5bf9f59442b0e200a90587e8fa5e0c6336a
- platform: ios
- create_revision: e3c29ec00c9c825c891d75054c63fcc46454dca1
- base_revision: e3c29ec00c9c825c891d75054c63fcc46454dca1
+ create_revision: db7ef5bf9f59442b0e200a90587e8fa5e0c6336a
+ base_revision: db7ef5bf9f59442b0e200a90587e8fa5e0c6336a
# User provided section
diff --git a/CHANGELOG.md b/CHANGELOG.md
index b58d6d2..ed809a9 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,184 +1 @@
-# 3.2.0
-
-* Fix build issues
-
-# 3.1.1
-
-* Upgrade kotlin version.
-
-# 3.1.0
-
-* Fix Null-Safety related issues. The following properties are now nullable.
-
- * `IsoDep#hiLayerResponse`
- * `IsoDep#historicalBytes`
- * `Iso7816#historicalBytes`
- * `Iso7816#applicationData`
- * `MiFare#historicalBytes`
-
-# 3.0.0+2
-
-* Update doc.
-
-# 3.0.0+1
-
-* Flutter format.
-
-# 3.0.0
-
-* Upgrade to null safety.
-
-# 2.0.3
-
-* Fix type conversion errors in `FeliCa#readWithoutEncryption` and `FeliCa#requestServiceV2`.
-
-# 2.0.2
-
-* Fix a bug in calling `FeliCa.sendFeliCaCommand` method.
-
-# 2.0.1+1
-
-* Update README.
-
-# 2.0.1
-
-* Fix an error when initializing plugin for non-NFC Android devices.
-
-# 2.0.0+2
-
-* Update doc.
-* Flutter format.
-
-# 2.0.0+1
-
-* Update doc.
-
-# 2.0.0
-
-**Has many breaking changes.**
-
-* Remove `startNdefSession` and `NdefDiscoveredCallback`.
-* Rename `startTagSession` to `startSession`.
-* Rename `TagPollingOption` to `NfcPollingOption`.
-* Rename `NfcSessionError` to `NfcError`.
-* Rename `NfcSessionErrorType` to `NfcErrorType`.
-* Rename `TagDiscoveredCallback` to `NfcTagCallback`.
-* Rename `NfcSessionErrorCallback` to `NfcErrorCallback`.
-* Rename `ISO15693` to `Iso15693`.
-* Rename `ISO7816` to `Iso7816`.
-* Rename `fromTag` to `from`. (e.g. `MiFare.fromTag(tag)` -> `MiFare.from(tag)`)
-* Add `NdefTypeNameFormat` enum.
-* Add `NdefFormatable`, `MifareClassic` and `MifareUltralight` classes.
-* Add `Ndef#read` method.
-* Add command-implementations for `FeliCa` and `Iso15693`.
-* Upgrade flutter environment.
-
-# 1.3.2+4
-
-* Update README.
-
-# 1.3.2+3
-
-* Update README.
-
-# 1.3.2+2
-
-* Update README.
-
-# 1.3.2+1
-
-* Update README.
-
-# 1.3.2
-
-* Fix crash on Ndef write and writeLock error.
-
-# 1.3.1
-
-* Fix a bug where the error callback was not called.
-
-# 1.3.0
-
-* Add callback to handle error from session.
-
-# 1.2.0
-
-* Make discovered callback async.
-
-# 1.1.0+1
-
-* Update readme.
-
-# 1.1.0
-
-* Add constants.
-* Fix misspelled name.
-* Fix xcode build warning.
-* Increase the Flutter SDK requirement to ^1.10.0.
-
-# 1.0.1
-
-* Fix error on invoking transceive method.
-
-# 1.0.0
-
-* Add platform-specifc-tag operations.
-* Remove `NfcSessionType` enum.
-* Migrate to pubspec platforms manifest.
-* More consistent naming.
-
-# 0.5.1
-
-* Update flutter project files.
-* Additional fix for migration to AndroidX.
-
-# 0.5.0
-
-* Migrate to AndroidX.
-
-# 0.4.0+2
-
-* Fix typo on README
-
-# 0.4.0+1
-
-* Update README
-
-# 0.4.0
-
-* Rename `NfcNdef#cachedNdef` to `NfcNdef#cachedMessage`.
-* Add `NfcSessionType` enum.
-* Add `NfcTagPollingOption` enum.
-
-# 0.3.0
-
-* Add `NdefRecord#createMimeRecord`.
-* Add optional parameters `alertMessageIOS` and `errorMessageIOS` displayed in iOS system UI.
-* Fix error on deserializing null message on dart side.
-
-# 0.2.0
-
-* Split `startSession` into `startNdefSession` and `startTagSession`.
-* Improve doc.
-
-# 0.1.1
-
-* Fix crash on serializing nil message on ios side.
-* Add example project.
-* Improve doc.
-
-# 0.1.0+2
-
-* Improve doc.
-
-# 0.1.0+1
-
-* Improve doc.
-
-# 0.1.0
-
-* Add iOS 13 features.
-
-# 0.0.1
-
-* Initial release.
+## 4.0.0-dev
diff --git a/LICENSE b/LICENSE
index 52f7a60..2b420f8 100644
--- a/LICENSE
+++ b/LICENSE
@@ -1,6 +1,6 @@
MIT License
-Copyright (c) 2019 Naoki Okada
+Copyright (c) 2019 okadan
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
diff --git a/README.md b/README.md
index e967bae..0a0acb7 100644
--- a/README.md
+++ b/README.md
@@ -1,8 +1,10 @@
# nfc_manager
-Flutter plugin for accessing the NFC features on Android and iOS.
+A Flutter plugin for accessing the NFC features on Android and iOS.
-Note: This plugin depends on `NFCTagReaderSession` (requires iOS 13.0 or later) and `NfcAdapter#enableReaderMode` (requires Android API level 19 or later).
+## Requirements
+
+Android SDK Version >= 19 or iOS >= 13.0.
## Setup
@@ -16,60 +18,75 @@ Note: This plugin depends on `NFCTagReaderSession` (requires iOS 13.0 or later)
* Add [NFCReaderUsageDescription](https://developer.apple.com/documentation/bundleresources/information_property_list/nfcreaderusagedescription) to your `Info.plist`.
-* Add [com.apple.developer.nfc.readersession.felica.systemcodes](https://developer.apple.com/documentation/bundleresources/information_property_list/systemcodes) and [com.apple.developer.nfc.readersession.iso7816.select-identifiers](https://developer.apple.com/documentation/bundleresources/information_property_list/select-identifiers) to your `Info.plist` as needed.
+* Add [com.apple.developer.nfc.readersession.iso7816.select-identifiers](https://developer.apple.com/documentation/bundleresources/information_property_list/select-identifiers) to your `Info.plist`. (Optional)
-## Usage
+* Add [com.apple.developer.nfc.readersession.felica.systemcodes](https://developer.apple.com/documentation/bundleresources/information_property_list/systemcodes) to your `Info.plist`. (Optional but required if you specify the `NfcPollingOptions.iso18092` to the `pollingOptions`)
-**Handling Session**
+## Minimum Usage
```dart
-// Check availability
bool isAvailable = await NfcManager.instance.isAvailable();
-// Start Session
+if (!isAvailable) {
+ print("The NFC features may not be supported on this device.");
+ return;
+}
+
NfcManager.instance.startSession(
+ pollingOptions: ...,
onDiscovered: (NfcTag tag) async {
// Do something with an NfcTag instance.
+
+ // Stop the session when the processing is completed.
+ NfcManager.instance.stopSession();
},
);
-
-// Stop Session
-NfcManager.instance.stopSession();
```
-**Handling Platform Tag**
+## Handling the NfcTag instance.
+
+NfcTag is typically not used directly, but only to obtain an instance of a specific tag type. This plugin provides the following tag types:
-The following platform-tag-classes are available:
+**Android Only**
-* Ndef
-* FeliCa (iOS only)
-* Iso7816 (iOS only)
-* Iso15693 (iOS only)
-* MiFare (iOS only)
-* NfcA (Android only)
-* NfcB (Android only)
-* NfcF (Android only)
-* NfcV (Android only)
-* IsoDep (Android only)
-* MifareClassic (Android only)
-* MifareUtralight (Android only)
-* NdefFormatable (Android only)
+* `NdefAndroid`
+* `NfcAAndroid`
+* `NfcBAndroid`
+* `NfcFAndroid`
+* `NfcVAndroid`
+* `IsoDepAndroid`
+* `MifareClassicAndroid`
+* `MifareUltralightAndroid`
+* `NdefFormatableAndroid`
+* `NfcBarcodeAndroid`
-Obtain an instance by calling the factory constructor `from` on the class. For example:
+**iOS Only**
+
+* `NdefIOS`
+* `MiFareIOS`
+* `FeliCaIOS`
+* `Iso15693IOS`
+* `Iso7618IOS`
+
+**Abstraction between Android and iOS (sub packages)**
+
+* `Ndef` ([nfc_manager_ndef](https://github.com/okadan/flutter-nfc-manager-ndef))
+* `FeliCa` ([nfc_manager_felica](https://github.com/okadan/flutter-nfc-manager-felica))
+* Add more in the future...
+
+Use `from(NfcTag)` static method to obtain an instance of a specific tag type. For example, to instantiate the `Ndef`:
```dart
+import 'package:nfc_manager_ndef/nfc_manager_ndef.dart';
+
Ndef? ndef = Ndef.from(tag);
if (ndef == null) {
- print('Tag is not compatible with NDEF');
+ print("The tag is not compatible with an NDEF.");
return;
}
-// Do something with an Ndef instance
+// Do something with an Ndef instance.
```
-Please see the [API Doc](https://pub.dev/documentation/nfc_manager/latest/) for more details.
-
-## Real-World-App
-
-See [this repo](https://github.com/okadan/flutter-nfc-manager-app) which is a Real-World-App demonstrates how to use this plugin.
+See the [example](#) directory or [Real World App](#) for more details.
diff --git a/android/build.gradle b/android/build.gradle
index dff31fd..da27898 100644
--- a/android/build.gradle
+++ b/android/build.gradle
@@ -1,15 +1,15 @@
-group 'io.flutter.plugins.nfc_manager'
+group 'dev.flutter.plugins.nfcmanager'
version '1.0-SNAPSHOT'
buildscript {
- ext.kotlin_version = '1.6.10'
+ ext.kotlin_version = '1.7.10'
repositories {
google()
mavenCentral()
}
dependencies {
- classpath 'com.android.tools.build:gradle:7.1.2'
+ classpath 'com.android.tools.build:gradle:7.3.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
@@ -25,7 +25,11 @@ apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
android {
- compileSdkVersion 31
+ if (project.android.hasProperty("namespace")) {
+ namespace 'dev.flutter.plugins.nfcmanager'
+ }
+
+ compileSdkVersion 33
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
@@ -38,9 +42,27 @@ android {
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
+ test.java.srcDirs += 'src/test/kotlin'
}
defaultConfig {
- minSdkVersion 16
+ minSdkVersion 19
+ }
+
+ dependencies {
+ testImplementation 'org.jetbrains.kotlin:kotlin-test'
+ testImplementation 'org.mockito:mockito-core:5.0.0'
+ }
+
+ testOptions {
+ unitTests.all {
+ useJUnitPlatform()
+
+ testLogging {
+ events "passed", "skipped", "failed", "standardOut", "standardError"
+ outputs.upToDateWhen {false}
+ showStandardStreams = true
+ }
+ }
}
}
diff --git a/android/src/main/AndroidManifest.xml b/android/src/main/AndroidManifest.xml
index a33fc2e..4728e2e 100644
--- a/android/src/main/AndroidManifest.xml
+++ b/android/src/main/AndroidManifest.xml
@@ -1,3 +1,3 @@
+ package="dev.flutter.plugins.nfcmanager">
diff --git a/android/src/main/kotlin/dev/flutter/plugins/nfcmanager/NfcManagerPlugin.kt b/android/src/main/kotlin/dev/flutter/plugins/nfcmanager/NfcManagerPlugin.kt
new file mode 100644
index 0000000..05c1f07
--- /dev/null
+++ b/android/src/main/kotlin/dev/flutter/plugins/nfcmanager/NfcManagerPlugin.kt
@@ -0,0 +1,509 @@
+package dev.flutter.plugins.nfcmanager
+
+import android.app.Activity
+import android.app.PendingIntent
+import android.content.BroadcastReceiver
+import android.content.Context
+import android.content.Intent
+import android.nfc.NdefMessage
+import android.nfc.NdefRecord
+import android.nfc.NfcAdapter
+import android.nfc.Tag
+import android.nfc.tech.*
+import android.os.Build
+import io.flutter.embedding.engine.plugins.FlutterPlugin
+import io.flutter.embedding.engine.plugins.activity.ActivityAware
+import io.flutter.embedding.engine.plugins.activity.ActivityPluginBinding
+import java.util.*
+
+class NfcManagerPlugin: FlutterPlugin, ActivityAware, PigeonHostApi, BroadcastReceiver() {
+ private lateinit var flutterApi: PigeonFlutterApi
+ private lateinit var activity: Activity
+ private var adapter: NfcAdapter? = null
+ private var cachedTags: MutableMap = mutableMapOf()
+ private var connectedTech: TagTechnology? = null
+
+ override fun onAttachedToEngine(flutterPluginBinding: FlutterPlugin.FlutterPluginBinding) {
+ PigeonHostApi.setUp(flutterPluginBinding.binaryMessenger, this)
+ flutterApi = PigeonFlutterApi(flutterPluginBinding.binaryMessenger)
+ adapter = NfcAdapter.getDefaultAdapter(flutterPluginBinding.applicationContext)
+ }
+
+ override fun onDetachedFromEngine(binding: FlutterPlugin.FlutterPluginBinding) {
+ PigeonHostApi.setUp(binding.binaryMessenger, null)
+ }
+
+ override fun onAttachedToActivity(binding: ActivityPluginBinding) {
+ activity = binding.activity
+ activity.applicationContext.registerReceiver(this, null)
+ }
+
+ override fun onReattachedToActivityForConfigChanges(binding: ActivityPluginBinding) {
+ activity = binding.activity
+ }
+
+ override fun onDetachedFromActivityForConfigChanges() {
+ // noop
+ }
+
+ override fun onDetachedFromActivity() {
+ // noop
+ }
+
+ override fun onReceive(context: Context?, intent: Intent?) {
+ intent ?: run { return }
+ if (intent.action != NfcAdapter.ACTION_ADAPTER_STATE_CHANGED) { return }
+ val state = intent.getIntExtra(NfcAdapter.EXTRA_ADAPTER_STATE, NfcAdapter.STATE_OFF)
+ flutterApi.onAdapterStateChanged(state.toLong()) { /* noop */ }
+ }
+
+ override fun nfcAdapterIsEnabled(): Boolean {
+ val adapter = adapter ?: run { throw Exception("TODO") }
+ return adapter.isEnabled
+ }
+
+ override fun nfcAdapterIsSecureNfcEnabled(): Boolean {
+ if (Build.VERSION.SDK_INT < Build.VERSION_CODES.Q) { throw Exception("TODO") }
+ val adapter = adapter ?: run { throw Exception("TODO") }
+ return adapter.isSecureNfcEnabled
+ }
+
+ override fun nfcAdapterIsSecureNfcSupported(): Boolean {
+ if (Build.VERSION.SDK_INT < Build.VERSION_CODES.Q) { throw Exception("TODO") }
+ val adapter = adapter ?: run { throw Exception("TODO") }
+ return adapter.isSecureNfcSupported
+ }
+
+ override fun nfcAdapterEnableReaderMode(flags: List) {
+ val adapter = adapter ?: run { throw Exception("TODO") }
+ adapter.enableReaderMode(activity, { onTagDiscovered(it) }, toInt(flags), null)
+ }
+
+ override fun nfcAdapterDisableReaderMode() {
+ val adapter = adapter ?: run { throw Exception("TODO") }
+ adapter.disableReaderMode(activity)
+ cachedTags.clear() // FIXME: Consider when to remove the tag.
+ }
+
+ override fun nfcAdapterEnableForegroundDispatch() {
+ val adapter = adapter ?: run { throw Exception("TODO") }
+ val intent = Intent(activity.applicationContext, javaClass).addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP)
+ val pendingIntent = PendingIntent.getActivity(activity.applicationContext, 0, intent, 0)
+ adapter.enableForegroundDispatch(activity, pendingIntent, null, null)
+ }
+
+ override fun nfcAdapterDisableForegroundDispatch() {
+ val adapter = adapter ?: run { throw Exception("TODO") }
+ adapter.disableForegroundDispatch(activity)
+ }
+
+ override fun ndefGetNdefMessage(handle: String): PigeonNdefMessage? {
+ val tech = forceConnect(handle) { Ndef.get(it) }
+ val message = tech.ndefMessage
+ return if (message != null) toPigeonNdefMessage(message) else null
+ }
+
+ override fun ndefWriteNdefMessage(handle: String, message: PigeonNdefMessage) {
+ val tech = forceConnect(handle) { Ndef.get(it) }
+ tech.writeNdefMessage(toNdefMessage(message))
+ }
+
+ override fun ndefMakeReadOnly(handle: String): Boolean {
+ val tech = forceConnect(handle) { Ndef.get(it) }
+ return tech.makeReadOnly()
+ }
+
+ override fun nfcAGetMaxTransceiveLength(handle: String): Long {
+ val tech = forceConnect(handle) { NfcA.get(it) }
+ return tech.maxTransceiveLength.toLong()
+ }
+
+ override fun nfcAGetTimeout(handle: String): Long {
+ val tech = forceConnect(handle) { NfcA.get(it) }
+ return tech.timeout.toLong()
+ }
+
+ override fun nfcASetTimeout(handle: String, timeout: Long) {
+ val tech = forceConnect(handle) { NfcA.get(it) }
+ tech.timeout = timeout.toInt()
+ }
+
+ override fun nfcATransceive(handle: String, bytes: ByteArray): ByteArray {
+ val tech = forceConnect(handle) { NfcA.get(it) }
+ return tech.transceive(bytes)
+ }
+
+ override fun nfcBGetMaxTransceiveLength(handle: String): Long {
+ val tech = forceConnect(handle) { NfcB.get(it) }
+ return tech.maxTransceiveLength.toLong()
+ }
+
+ override fun nfcBTransceive(handle: String, bytes: ByteArray): ByteArray {
+ val tech = forceConnect(handle) { NfcB.get(it) }
+ return tech.transceive(bytes)
+ }
+
+ override fun nfcFGetMaxTransceiveLength(handle: String): Long {
+ val tech = forceConnect(handle) { NfcF.get(it) }
+ return tech.maxTransceiveLength.toLong()
+ }
+
+ override fun nfcFGetTimeout(handle: String): Long {
+ val tech = forceConnect(handle) { NfcF.get(it) }
+ return tech.timeout.toLong()
+ }
+
+ override fun nfcFSetTimeout(handle: String, timeout: Long) {
+ val tech = forceConnect(handle) { NfcF.get(it) }
+ tech.timeout = timeout.toInt()
+ }
+
+ override fun nfcFTransceive(handle: String, bytes: ByteArray): ByteArray {
+ val tech = forceConnect(handle) { NfcF.get(it) }
+ return tech.transceive(bytes)
+ }
+
+ override fun nfcVGetMaxTransceiveLength(handle: String): Long {
+ val tech = forceConnect(handle) { NfcV.get(it) }
+ return tech.maxTransceiveLength.toLong()
+ }
+
+ override fun nfcVTransceive(handle: String, bytes: ByteArray): ByteArray {
+ val tech = forceConnect(handle) { NfcV.get(it) }
+ return tech.transceive(bytes)
+ }
+
+ override fun isoDepGetMaxTransceiveLength(handle: String): Long {
+ val tech = forceConnect(handle) { IsoDep.get(it) }
+ return tech.maxTransceiveLength.toLong()
+ }
+
+ override fun isoDepGetTimeout(handle: String): Long {
+ val tech = forceConnect(handle) { IsoDep.get(it) }
+ return tech.timeout.toLong()
+ }
+
+ override fun isoDepSetTimeout(handle: String, timeout: Long) {
+ val tech = forceConnect(handle) { IsoDep.get(it) }
+ tech.timeout = timeout.toInt()
+ }
+
+ override fun isoDepTransceive(handle: String, bytes: ByteArray): ByteArray {
+ val tech = forceConnect(handle) { IsoDep.get(it) }
+ return tech.transceive(bytes)
+ }
+
+ override fun mifareClassicGetMaxTransceiveLength(handle: String): Long {
+ val tech = forceConnect(handle) { MifareClassic.get(it) }
+ return tech.maxTransceiveLength.toLong()
+ }
+
+ override fun mifareClassicGetTimeout(handle: String): Long {
+ val tech = forceConnect(handle) { MifareClassic.get(it) }
+ return tech.timeout.toLong()
+ }
+
+ override fun mifareClassicSetTimeout(handle: String, timeout: Long) {
+ val tech = forceConnect(handle) { MifareClassic.get(it) }
+ tech.timeout = timeout.toInt()
+ }
+
+ override fun mifareClassicAuthenticateSectorWithKeyA(handle: String, sectorIndex: Long, key: ByteArray): Boolean {
+ val tech = forceConnect(handle) { MifareClassic.get(it) }
+ return tech.authenticateSectorWithKeyA(sectorIndex.toInt(), key)
+ }
+
+ override fun mifareClassicAuthenticateSectorWithKeyB(handle: String, sectorIndex: Long, key: ByteArray): Boolean {
+ val tech = forceConnect(handle) { MifareClassic.get(it) }
+ return tech.authenticateSectorWithKeyB(sectorIndex.toInt(), key)
+ }
+
+ override fun mifareClassicGetBlockCountInSector(handle: String, sectorIndex: Long): Long {
+ val tech = forceConnect(handle) { MifareClassic.get(it) }
+ return tech.getBlockCountInSector(sectorIndex.toInt()).toLong()
+ }
+
+ override fun mifareClassicBlockToSector(handle: String, blockIndex: Long): Long {
+ val tech = forceConnect(handle) { MifareClassic.get(it) }
+ return tech.blockToSector(blockIndex.toInt()).toLong()
+ }
+
+ override fun mifareClassicSectorToBlock(handle: String, sectorIndex: Long): Long {
+ val tech = forceConnect(handle) { MifareClassic.get(it) }
+ return tech.sectorToBlock(sectorIndex.toInt()).toLong()
+ }
+
+ override fun mifareClassicIncrement(handle: String, blockIndex: Long, value: Long) {
+ val tech = forceConnect(handle) { MifareClassic.get(it) }
+ tech.increment(blockIndex.toInt(), value.toInt())
+ }
+
+ override fun mifareClassicDecrement(handle: String, blockIndex: Long, value: Long) {
+ val tech = forceConnect(handle) { MifareClassic.get(it) }
+ tech.decrement(blockIndex.toInt(), value.toInt())
+ }
+
+ override fun mifareClassicRestore(handle: String, blockIndex: Long) {
+ val tech = forceConnect(handle) { MifareClassic.get(it) }
+ tech.restore(blockIndex.toInt())
+ }
+
+ override fun mifareClassicTransfer(handle: String, blockIndex: Long) {
+ val tech = forceConnect(handle) { MifareClassic.get(it) }
+ tech.transfer(blockIndex.toInt())
+ }
+
+ override fun mifareClassicReadBlock(handle: String, blockIndex: Long): ByteArray {
+ val tech = forceConnect(handle) { MifareClassic.get(it) }
+ return tech.readBlock(blockIndex.toInt())
+ }
+
+ override fun mifareClassicWriteBlock(handle: String, blockIndex: Long, data: ByteArray) {
+ val tech = forceConnect(handle) { MifareClassic.get(it) }
+ tech.writeBlock(blockIndex.toInt(), data)
+ }
+
+ override fun mifareClassicTransceive(handle: String, bytes: ByteArray): ByteArray {
+ val tech = forceConnect(handle) { MifareClassic.get(it) }
+ return tech.transceive(bytes)
+ }
+
+ override fun mifareUltralightGetMaxTransceiveLength(handle: String): Long {
+ val tech = forceConnect(handle) { MifareUltralight.get(it) }
+ return tech.maxTransceiveLength.toLong()
+ }
+
+ override fun mifareUltralightGetTimeout(handle: String): Long {
+ val tech = forceConnect(handle) { MifareUltralight.get(it) }
+ return tech.timeout.toLong()
+ }
+
+ override fun mifareUltralightSetTimeout(handle: String, timeout: Long) {
+ val tech = forceConnect(handle) { MifareUltralight.get(it) }
+ tech.timeout = timeout.toInt()
+ }
+
+ override fun mifareUltralightReadPages(handle: String, pageOffset: Long): ByteArray {
+ val tech = forceConnect(handle) { MifareUltralight.get(it) }
+ return tech.readPages(pageOffset.toInt())
+ }
+
+ override fun mifareUltralightWritePage(handle: String, pageOffset: Long, data: ByteArray) {
+ val tech = forceConnect(handle) { MifareUltralight.get(it) }
+ tech.writePage(pageOffset.toInt(), data)
+ }
+
+ override fun mifareUltralightTransceive(handle: String, bytes: ByteArray): ByteArray {
+ val tech = forceConnect(handle) { MifareUltralight.get(it) }
+ return tech.transceive(bytes)
+ }
+
+ override fun ndefFormatableFormat(handle: String, firstMessage: PigeonNdefMessage) {
+ val tech = forceConnect(handle) { NdefFormatable.get(it) }
+ tech.format(toNdefMessage(firstMessage))
+ }
+
+ override fun ndefFormatableFormatReadOnly(handle: String, firstMessage: PigeonNdefMessage) {
+ val tech = forceConnect(handle) { NdefFormatable.get(it) }
+ tech.formatReadOnly(toNdefMessage(firstMessage))
+ }
+
+ private fun onTagDiscovered(tag: Tag) {
+ val handle = UUID.randomUUID().toString()
+ val pigeonTag = toPigeonTag(tag, handle)
+ cachedTags[handle] = tag
+ activity.runOnUiThread { flutterApi.onTagDiscovered(pigeonTag) { /* no op */ } }
+ }
+
+ private fun forceConnect(handle: String, getMethod: (Tag) -> T?): T {
+ val tag = cachedTags[handle] ?: run { throw Exception("TODO") }
+ val tech = getMethod(tag) ?: run { throw Exception("TODO") }
+ val connectedTech = connectedTech ?: run {
+ tech.connect()
+ connectedTech = tech
+ return tech
+ }
+ if (connectedTech.tag != tech.tag || connectedTech::class.java.name != tech::class.java.name) {
+ try { connectedTech.close() } catch (e: Exception) { /* no op */ }
+ tech.connect()
+ this.connectedTech = tech
+ return tech
+ }
+ return tech
+ }
+}
+
+private fun toInt(value: List): Int {
+ return value.fold(0) { p, e -> p or toInt(e)}
+}
+
+private fun toInt(value: String): Int {
+ return when (value) {
+ "nfcA" -> NfcAdapter.FLAG_READER_NFC_A
+ "nfcB" -> NfcAdapter.FLAG_READER_NFC_B
+ "nfcBarcode" -> NfcAdapter.FLAG_READER_NFC_BARCODE
+ "nfcF" -> NfcAdapter.FLAG_READER_NFC_F
+ "nfcV" -> NfcAdapter.FLAG_READER_NFC_V
+ "noPlatformSounds" -> NfcAdapter.FLAG_READER_NO_PLATFORM_SOUNDS
+ "skipNdefCheck" -> NfcAdapter.FLAG_READER_SKIP_NDEF_CHECK
+ else -> throw IllegalArgumentException("$value is Unknown")
+ }
+}
+
+private fun toNdefMessage(value: PigeonNdefMessage): NdefMessage {
+ return NdefMessage(value.records.map { toNdefRecord(it!!) }.toTypedArray())
+}
+
+private fun toPigeonNdefMessage(value: NdefMessage): PigeonNdefMessage {
+ return PigeonNdefMessage(
+ records = value.records.map { toPigeonNdefRecord(it) }
+ )
+}
+
+private fun toNdefRecord(value: PigeonNdefRecord): NdefRecord {
+ return NdefRecord(
+ toShort(value.tnf),
+ value.type,
+ value.id,
+ value.payload,
+ )
+}
+
+private fun toPigeonNdefRecord(value: NdefRecord): PigeonNdefRecord {
+ return PigeonNdefRecord(
+ tnf = toPigeonTypeNameFormat(value.tnf),
+ type = value.type,
+ id = value.id,
+ payload = value.payload,
+ )
+}
+
+private fun toPigeonTag(value: Tag, handle: String): PigeonTag {
+ return PigeonTag(
+ handle = handle,
+ id = value.id,
+ techList = value.techList.toMutableList(),
+ ndef = Ndef.get(value)?.let { toPigeonNdef(it) },
+ nfcA = NfcA.get(value)?.let { toPigeonNfcA(it) },
+ nfcB = NfcB.get(value)?.let { toPigeonNfcB(it) },
+ nfcF = NfcF.get(value)?.let { toPigeonNfcF(it) },
+ nfcV = NfcV.get(value)?.let { toPigeonNfcV(it) },
+ isoDep = IsoDep.get(value)?.let { toPigeonIsoDep(it) },
+ mifareClassic = MifareClassic.get(value)?.let { toPigeonMifareClassic(it) },
+ mifareUltralight = MifareUltralight.get(value)?.let { toPigeonMifareUltralight(it) },
+ ndefFormatable = NdefFormatable.get(value)?.let { "" },
+ nfcBarcode = NfcBarcode.get(value)?.let { toPigeonNfcBarcode(it) },
+ )
+}
+
+private fun toPigeonNdef(value: Ndef): PigeonNdef {
+ return PigeonNdef(
+ type = value.type,
+ isWritable = value.isWritable,
+ maxSize = value.maxSize.toLong(),
+ canMakeReadOnly = value.canMakeReadOnly(),
+ cachedNdefMessage = value.cachedNdefMessage?.let { toPigeonNdefMessage(it) },
+ )
+}
+
+private fun toPigeonNfcA(value: NfcA): PigeonNfcA {
+ return PigeonNfcA(
+ atqa = value.atqa,
+ sak = value.sak.toLong(),
+ )
+}
+
+private fun toPigeonNfcB(value: NfcB): PigeonNfcB {
+ return PigeonNfcB(
+ applicationData = value.applicationData,
+ protocolInfo = value.protocolInfo,
+ )
+}
+
+private fun toPigeonNfcF(value: NfcF): PigeonNfcF {
+ return PigeonNfcF(
+ manufacturer = value.manufacturer,
+ systemCode = value.systemCode,
+ )
+}
+
+private fun toPigeonNfcV(value: NfcV): PigeonNfcV {
+ return PigeonNfcV(
+ dsfId = value.dsfId.toLong(),
+ responseFlags = value.responseFlags.toLong(),
+ )
+}
+
+private fun toPigeonIsoDep(value: IsoDep): PigeonIsoDep {
+ return PigeonIsoDep(
+ hiLayerResponse = value.hiLayerResponse,
+ historicalBytes = value.historicalBytes,
+ isExtendedLengthApduSupported = value.isExtendedLengthApduSupported,
+ )
+}
+
+private fun toPigeonMifareClassic(value: MifareClassic): PigeonMifareClassic {
+ return PigeonMifareClassic(
+ type = toPigeonMifareClassicType(value.type),
+ blockCount = value.blockCount.toLong(),
+ sectorCount = value.sectorCount.toLong(),
+ size = value.size.toLong(),
+ )
+}
+
+private fun toPigeonMifareUltralight(value: MifareUltralight): PigeonMifareUltralight {
+ return PigeonMifareUltralight(
+ type = toPigeonMifareUltralightType(value.type)
+ )
+}
+
+private fun toPigeonNfcBarcode(value: NfcBarcode): PigeonNfcBarcode {
+ return PigeonNfcBarcode(
+ type = value.type.toLong(),
+ barcode = value.barcode,
+ )
+}
+
+private fun toShort(value: PigeonTypeNameFormat): Short {
+ return when (value) {
+ PigeonTypeNameFormat.EMPTY -> NdefRecord.TNF_EMPTY
+ PigeonTypeNameFormat.WELLKNOWN -> NdefRecord.TNF_WELL_KNOWN
+ PigeonTypeNameFormat.MEDIA -> NdefRecord.TNF_MIME_MEDIA
+ PigeonTypeNameFormat.ABSOLUTEURI -> NdefRecord.TNF_ABSOLUTE_URI
+ PigeonTypeNameFormat.EXTERNAL -> NdefRecord.TNF_EXTERNAL_TYPE
+ PigeonTypeNameFormat.UNKNOWN -> NdefRecord.TNF_UNKNOWN
+ PigeonTypeNameFormat.UNCHANGED -> NdefRecord.TNF_UNCHANGED
+ }
+}
+
+private fun toPigeonTypeNameFormat(value: Short): PigeonTypeNameFormat {
+ return when (value) {
+ NdefRecord.TNF_EMPTY -> PigeonTypeNameFormat.EMPTY
+ NdefRecord.TNF_WELL_KNOWN -> PigeonTypeNameFormat.WELLKNOWN
+ NdefRecord.TNF_MIME_MEDIA -> PigeonTypeNameFormat.MEDIA
+ NdefRecord.TNF_ABSOLUTE_URI -> PigeonTypeNameFormat.ABSOLUTEURI
+ NdefRecord.TNF_EXTERNAL_TYPE -> PigeonTypeNameFormat.EXTERNAL
+ NdefRecord.TNF_UNKNOWN -> PigeonTypeNameFormat.UNKNOWN
+ NdefRecord.TNF_UNCHANGED -> PigeonTypeNameFormat.UNCHANGED
+ else -> error("TODO:")
+ }
+}
+
+private fun toPigeonMifareClassicType(value: Int): PigeonMifareClassicType {
+ return when (value) {
+ MifareClassic.TYPE_CLASSIC -> PigeonMifareClassicType.CLASSIC
+ MifareClassic.TYPE_PLUS -> PigeonMifareClassicType.PLUS
+ MifareClassic.TYPE_PRO -> PigeonMifareClassicType.PRO
+ MifareClassic.TYPE_UNKNOWN -> PigeonMifareClassicType.UNKNOWN
+ else -> error("TODO:")
+ }
+}
+
+private fun toPigeonMifareUltralightType(value: Int): PigeonMifareUltralightType {
+ return when (value) {
+ MifareUltralight.TYPE_ULTRALIGHT -> PigeonMifareUltralightType.ULTRALIGHT
+ MifareUltralight.TYPE_ULTRALIGHT_C -> PigeonMifareUltralightType.ULTRALIGHTC
+ MifareUltralight.TYPE_UNKNOWN -> PigeonMifareUltralightType.UNKNOWN
+ else -> error("TODO:")
+ }
+}
diff --git a/android/src/main/kotlin/dev/flutter/plugins/nfcmanager/Pigeon.kt b/android/src/main/kotlin/dev/flutter/plugins/nfcmanager/Pigeon.kt
new file mode 100644
index 0000000..9454b3f
--- /dev/null
+++ b/android/src/main/kotlin/dev/flutter/plugins/nfcmanager/Pigeon.kt
@@ -0,0 +1,1611 @@
+// Autogenerated from Pigeon (v15.0.2), do not edit directly.
+// See also: https://pub.dev/packages/pigeon
+
+package dev.flutter.plugins.nfcmanager
+
+import android.util.Log
+import io.flutter.plugin.common.BasicMessageChannel
+import io.flutter.plugin.common.BinaryMessenger
+import io.flutter.plugin.common.MessageCodec
+import io.flutter.plugin.common.StandardMessageCodec
+import java.io.ByteArrayOutputStream
+import java.nio.ByteBuffer
+
+private fun wrapResult(result: Any?): List {
+ return listOf(result)
+}
+
+private fun wrapError(exception: Throwable): List {
+ if (exception is FlutterError) {
+ return listOf(
+ exception.code,
+ exception.message,
+ exception.details
+ )
+ } else {
+ return listOf(
+ exception.javaClass.simpleName,
+ exception.toString(),
+ "Cause: " + exception.cause + ", Stacktrace: " + Log.getStackTraceString(exception)
+ )
+ }
+}
+
+private fun createConnectionError(channelName: String): FlutterError {
+ return FlutterError("channel-error", "Unable to establish connection on channel: '$channelName'.", "")}
+
+/**
+ * Error class for passing custom error details to Flutter via a thrown PlatformException.
+ * @property code The error code.
+ * @property message The error message.
+ * @property details The error details. Must be a datatype supported by the api codec.
+ */
+class FlutterError (
+ val code: String,
+ override val message: String? = null,
+ val details: Any? = null
+) : Throwable()
+
+enum class PigeonTypeNameFormat(val raw: Int) {
+ EMPTY(0),
+ WELLKNOWN(1),
+ MEDIA(2),
+ ABSOLUTEURI(3),
+ EXTERNAL(4),
+ UNKNOWN(5),
+ UNCHANGED(6);
+
+ companion object {
+ fun ofRaw(raw: Int): PigeonTypeNameFormat? {
+ return values().firstOrNull { it.raw == raw }
+ }
+ }
+}
+
+enum class PigeonMifareClassicType(val raw: Int) {
+ CLASSIC(0),
+ PLUS(1),
+ PRO(2),
+ UNKNOWN(3);
+
+ companion object {
+ fun ofRaw(raw: Int): PigeonMifareClassicType? {
+ return values().firstOrNull { it.raw == raw }
+ }
+ }
+}
+
+enum class PigeonMifareUltralightType(val raw: Int) {
+ ULTRALIGHT(0),
+ ULTRALIGHTC(1),
+ UNKNOWN(2);
+
+ companion object {
+ fun ofRaw(raw: Int): PigeonMifareUltralightType? {
+ return values().firstOrNull { it.raw == raw }
+ }
+ }
+}
+
+/** Generated class from Pigeon that represents data sent in messages. */
+data class PigeonTag (
+ val handle: String,
+ val id: ByteArray,
+ val techList: List,
+ val ndef: PigeonNdef? = null,
+ val nfcA: PigeonNfcA? = null,
+ val nfcB: PigeonNfcB? = null,
+ val nfcF: PigeonNfcF? = null,
+ val nfcV: PigeonNfcV? = null,
+ val isoDep: PigeonIsoDep? = null,
+ val mifareClassic: PigeonMifareClassic? = null,
+ val mifareUltralight: PigeonMifareUltralight? = null,
+ val ndefFormatable: String? = null,
+ val nfcBarcode: PigeonNfcBarcode? = null
+
+) {
+ companion object {
+ @Suppress("UNCHECKED_CAST")
+ fun fromList(list: List): PigeonTag {
+ val handle = list[0] as String
+ val id = list[1] as ByteArray
+ val techList = list[2] as List
+ val ndef: PigeonNdef? = (list[3] as List?)?.let {
+ PigeonNdef.fromList(it)
+ }
+ val nfcA: PigeonNfcA? = (list[4] as List?)?.let {
+ PigeonNfcA.fromList(it)
+ }
+ val nfcB: PigeonNfcB? = (list[5] as List?)?.let {
+ PigeonNfcB.fromList(it)
+ }
+ val nfcF: PigeonNfcF? = (list[6] as List?)?.let {
+ PigeonNfcF.fromList(it)
+ }
+ val nfcV: PigeonNfcV? = (list[7] as List?)?.let {
+ PigeonNfcV.fromList(it)
+ }
+ val isoDep: PigeonIsoDep? = (list[8] as List?)?.let {
+ PigeonIsoDep.fromList(it)
+ }
+ val mifareClassic: PigeonMifareClassic? = (list[9] as List?)?.let {
+ PigeonMifareClassic.fromList(it)
+ }
+ val mifareUltralight: PigeonMifareUltralight? = (list[10] as List?)?.let {
+ PigeonMifareUltralight.fromList(it)
+ }
+ val ndefFormatable = list[11] as String?
+ val nfcBarcode: PigeonNfcBarcode? = (list[12] as List?)?.let {
+ PigeonNfcBarcode.fromList(it)
+ }
+ return PigeonTag(handle, id, techList, ndef, nfcA, nfcB, nfcF, nfcV, isoDep, mifareClassic, mifareUltralight, ndefFormatable, nfcBarcode)
+ }
+ }
+ fun toList(): List {
+ return listOf(
+ handle,
+ id,
+ techList,
+ ndef?.toList(),
+ nfcA?.toList(),
+ nfcB?.toList(),
+ nfcF?.toList(),
+ nfcV?.toList(),
+ isoDep?.toList(),
+ mifareClassic?.toList(),
+ mifareUltralight?.toList(),
+ ndefFormatable,
+ nfcBarcode?.toList(),
+ )
+ }
+}
+
+/** Generated class from Pigeon that represents data sent in messages. */
+data class PigeonNdef (
+ val type: String,
+ val canMakeReadOnly: Boolean,
+ val isWritable: Boolean,
+ val maxSize: Long,
+ val cachedNdefMessage: PigeonNdefMessage? = null
+
+) {
+ companion object {
+ @Suppress("UNCHECKED_CAST")
+ fun fromList(list: List): PigeonNdef {
+ val type = list[0] as String
+ val canMakeReadOnly = list[1] as Boolean
+ val isWritable = list[2] as Boolean
+ val maxSize = list[3].let { if (it is Int) it.toLong() else it as Long }
+ val cachedNdefMessage: PigeonNdefMessage? = (list[4] as List?)?.let {
+ PigeonNdefMessage.fromList(it)
+ }
+ return PigeonNdef(type, canMakeReadOnly, isWritable, maxSize, cachedNdefMessage)
+ }
+ }
+ fun toList(): List {
+ return listOf(
+ type,
+ canMakeReadOnly,
+ isWritable,
+ maxSize,
+ cachedNdefMessage?.toList(),
+ )
+ }
+}
+
+/** Generated class from Pigeon that represents data sent in messages. */
+data class PigeonNfcA (
+ val atqa: ByteArray,
+ val sak: Long
+
+) {
+ companion object {
+ @Suppress("UNCHECKED_CAST")
+ fun fromList(list: List): PigeonNfcA {
+ val atqa = list[0] as ByteArray
+ val sak = list[1].let { if (it is Int) it.toLong() else it as Long }
+ return PigeonNfcA(atqa, sak)
+ }
+ }
+ fun toList(): List {
+ return listOf(
+ atqa,
+ sak,
+ )
+ }
+}
+
+/** Generated class from Pigeon that represents data sent in messages. */
+data class PigeonNfcB (
+ val applicationData: ByteArray,
+ val protocolInfo: ByteArray
+
+) {
+ companion object {
+ @Suppress("UNCHECKED_CAST")
+ fun fromList(list: List): PigeonNfcB {
+ val applicationData = list[0] as ByteArray
+ val protocolInfo = list[1] as ByteArray
+ return PigeonNfcB(applicationData, protocolInfo)
+ }
+ }
+ fun toList(): List {
+ return listOf(
+ applicationData,
+ protocolInfo,
+ )
+ }
+}
+
+/** Generated class from Pigeon that represents data sent in messages. */
+data class PigeonNfcF (
+ val manufacturer: ByteArray,
+ val systemCode: ByteArray
+
+) {
+ companion object {
+ @Suppress("UNCHECKED_CAST")
+ fun fromList(list: List): PigeonNfcF {
+ val manufacturer = list[0] as ByteArray
+ val systemCode = list[1] as ByteArray
+ return PigeonNfcF(manufacturer, systemCode)
+ }
+ }
+ fun toList(): List {
+ return listOf(
+ manufacturer,
+ systemCode,
+ )
+ }
+}
+
+/** Generated class from Pigeon that represents data sent in messages. */
+data class PigeonNfcV (
+ val dsfId: Long,
+ val responseFlags: Long
+
+) {
+ companion object {
+ @Suppress("UNCHECKED_CAST")
+ fun fromList(list: List): PigeonNfcV {
+ val dsfId = list[0].let { if (it is Int) it.toLong() else it as Long }
+ val responseFlags = list[1].let { if (it is Int) it.toLong() else it as Long }
+ return PigeonNfcV(dsfId, responseFlags)
+ }
+ }
+ fun toList(): List {
+ return listOf(
+ dsfId,
+ responseFlags,
+ )
+ }
+}
+
+/** Generated class from Pigeon that represents data sent in messages. */
+data class PigeonIsoDep (
+ val hiLayerResponse: ByteArray? = null,
+ val historicalBytes: ByteArray? = null,
+ val isExtendedLengthApduSupported: Boolean
+
+) {
+ companion object {
+ @Suppress("UNCHECKED_CAST")
+ fun fromList(list: List): PigeonIsoDep {
+ val hiLayerResponse = list[0] as ByteArray?
+ val historicalBytes = list[1] as ByteArray?
+ val isExtendedLengthApduSupported = list[2] as Boolean
+ return PigeonIsoDep(hiLayerResponse, historicalBytes, isExtendedLengthApduSupported)
+ }
+ }
+ fun toList(): List {
+ return listOf(
+ hiLayerResponse,
+ historicalBytes,
+ isExtendedLengthApduSupported,
+ )
+ }
+}
+
+/** Generated class from Pigeon that represents data sent in messages. */
+data class PigeonMifareClassic (
+ val type: PigeonMifareClassicType,
+ val blockCount: Long,
+ val sectorCount: Long,
+ val size: Long
+
+) {
+ companion object {
+ @Suppress("UNCHECKED_CAST")
+ fun fromList(list: List): PigeonMifareClassic {
+ val type = PigeonMifareClassicType.ofRaw(list[0] as Int)!!
+ val blockCount = list[1].let { if (it is Int) it.toLong() else it as Long }
+ val sectorCount = list[2].let { if (it is Int) it.toLong() else it as Long }
+ val size = list[3].let { if (it is Int) it.toLong() else it as Long }
+ return PigeonMifareClassic(type, blockCount, sectorCount, size)
+ }
+ }
+ fun toList(): List {
+ return listOf(
+ type.raw,
+ blockCount,
+ sectorCount,
+ size,
+ )
+ }
+}
+
+/** Generated class from Pigeon that represents data sent in messages. */
+data class PigeonMifareUltralight (
+ val type: PigeonMifareUltralightType
+
+) {
+ companion object {
+ @Suppress("UNCHECKED_CAST")
+ fun fromList(list: List): PigeonMifareUltralight {
+ val type = PigeonMifareUltralightType.ofRaw(list[0] as Int)!!
+ return PigeonMifareUltralight(type)
+ }
+ }
+ fun toList(): List {
+ return listOf(
+ type.raw,
+ )
+ }
+}
+
+/** Generated class from Pigeon that represents data sent in messages. */
+data class PigeonNfcBarcode (
+ val type: Long,
+ val barcode: ByteArray
+
+) {
+ companion object {
+ @Suppress("UNCHECKED_CAST")
+ fun fromList(list: List): PigeonNfcBarcode {
+ val type = list[0].let { if (it is Int) it.toLong() else it as Long }
+ val barcode = list[1] as ByteArray
+ return PigeonNfcBarcode(type, barcode)
+ }
+ }
+ fun toList(): List {
+ return listOf(
+ type,
+ barcode,
+ )
+ }
+}
+
+/** Generated class from Pigeon that represents data sent in messages. */
+data class PigeonNdefMessage (
+ val records: List
+
+) {
+ companion object {
+ @Suppress("UNCHECKED_CAST")
+ fun fromList(list: List): PigeonNdefMessage {
+ val records = list[0] as List
+ return PigeonNdefMessage(records)
+ }
+ }
+ fun toList(): List {
+ return listOf(
+ records,
+ )
+ }
+}
+
+/** Generated class from Pigeon that represents data sent in messages. */
+data class PigeonNdefRecord (
+ val tnf: PigeonTypeNameFormat,
+ val type: ByteArray,
+ val id: ByteArray,
+ val payload: ByteArray
+
+) {
+ companion object {
+ @Suppress("UNCHECKED_CAST")
+ fun fromList(list: List): PigeonNdefRecord {
+ val tnf = PigeonTypeNameFormat.ofRaw(list[0] as Int)!!
+ val type = list[1] as ByteArray
+ val id = list[2] as ByteArray
+ val payload = list[3] as ByteArray
+ return PigeonNdefRecord(tnf, type, id, payload)
+ }
+ }
+ fun toList(): List {
+ return listOf(
+ tnf.raw,
+ type,
+ id,
+ payload,
+ )
+ }
+}
+@Suppress("UNCHECKED_CAST")
+private object PigeonFlutterApiCodec : StandardMessageCodec() {
+ override fun readValueOfType(type: Byte, buffer: ByteBuffer): Any? {
+ return when (type) {
+ 128.toByte() -> {
+ return (readValue(buffer) as? List)?.let {
+ PigeonIsoDep.fromList(it)
+ }
+ }
+ 129.toByte() -> {
+ return (readValue(buffer) as? List)?.let {
+ PigeonMifareClassic.fromList(it)
+ }
+ }
+ 130.toByte() -> {
+ return (readValue(buffer) as? List)?.let {
+ PigeonMifareUltralight.fromList(it)
+ }
+ }
+ 131.toByte() -> {
+ return (readValue(buffer) as? List)?.let {
+ PigeonNdef.fromList(it)
+ }
+ }
+ 132.toByte() -> {
+ return (readValue(buffer) as? List)?.let {
+ PigeonNdefMessage.fromList(it)
+ }
+ }
+ 133.toByte() -> {
+ return (readValue(buffer) as? List)?.let {
+ PigeonNdefRecord.fromList(it)
+ }
+ }
+ 134.toByte() -> {
+ return (readValue(buffer) as? List)?.let {
+ PigeonNfcA.fromList(it)
+ }
+ }
+ 135.toByte() -> {
+ return (readValue(buffer) as? List)?.let {
+ PigeonNfcB.fromList(it)
+ }
+ }
+ 136.toByte() -> {
+ return (readValue(buffer) as? List)?.let {
+ PigeonNfcBarcode.fromList(it)
+ }
+ }
+ 137.toByte() -> {
+ return (readValue(buffer) as? List)?.let {
+ PigeonNfcF.fromList(it)
+ }
+ }
+ 138.toByte() -> {
+ return (readValue(buffer) as? List)?.let {
+ PigeonNfcV.fromList(it)
+ }
+ }
+ 139.toByte() -> {
+ return (readValue(buffer) as? List)?.let {
+ PigeonTag.fromList(it)
+ }
+ }
+ else -> super.readValueOfType(type, buffer)
+ }
+ }
+ override fun writeValue(stream: ByteArrayOutputStream, value: Any?) {
+ when (value) {
+ is PigeonIsoDep -> {
+ stream.write(128)
+ writeValue(stream, value.toList())
+ }
+ is PigeonMifareClassic -> {
+ stream.write(129)
+ writeValue(stream, value.toList())
+ }
+ is PigeonMifareUltralight -> {
+ stream.write(130)
+ writeValue(stream, value.toList())
+ }
+ is PigeonNdef -> {
+ stream.write(131)
+ writeValue(stream, value.toList())
+ }
+ is PigeonNdefMessage -> {
+ stream.write(132)
+ writeValue(stream, value.toList())
+ }
+ is PigeonNdefRecord -> {
+ stream.write(133)
+ writeValue(stream, value.toList())
+ }
+ is PigeonNfcA -> {
+ stream.write(134)
+ writeValue(stream, value.toList())
+ }
+ is PigeonNfcB -> {
+ stream.write(135)
+ writeValue(stream, value.toList())
+ }
+ is PigeonNfcBarcode -> {
+ stream.write(136)
+ writeValue(stream, value.toList())
+ }
+ is PigeonNfcF -> {
+ stream.write(137)
+ writeValue(stream, value.toList())
+ }
+ is PigeonNfcV -> {
+ stream.write(138)
+ writeValue(stream, value.toList())
+ }
+ is PigeonTag -> {
+ stream.write(139)
+ writeValue(stream, value.toList())
+ }
+ else -> super.writeValue(stream, value)
+ }
+ }
+}
+
+/** Generated class from Pigeon that represents Flutter messages that can be called from Kotlin. */
+@Suppress("UNCHECKED_CAST")
+class PigeonFlutterApi(private val binaryMessenger: BinaryMessenger) {
+ companion object {
+ /** The codec used by PigeonFlutterApi. */
+ val codec: MessageCodec by lazy {
+ PigeonFlutterApiCodec
+ }
+ }
+ fun onTagDiscovered(tagArg: PigeonTag, callback: (Result) -> Unit) {
+ val channelName = "dev.flutter.pigeon.nfc_manager.PigeonFlutterApi.onTagDiscovered"
+ val channel = BasicMessageChannel(binaryMessenger, channelName, codec)
+ channel.send(listOf(tagArg)) {
+ if (it is List<*>) {
+ if (it.size > 1) {
+ callback(Result.failure(FlutterError(it[0] as String, it[1] as String, it[2] as String?)))
+ } else {
+ callback(Result.success(Unit))
+ }
+ } else {
+ callback(Result.failure(createConnectionError(channelName)))
+ }
+ }
+ }
+ fun onAdapterStateChanged(stateArg: Long, callback: (Result) -> Unit) {
+ val channelName = "dev.flutter.pigeon.nfc_manager.PigeonFlutterApi.onAdapterStateChanged"
+ val channel = BasicMessageChannel(binaryMessenger, channelName, codec)
+ channel.send(listOf(stateArg)) {
+ if (it is List<*>) {
+ if (it.size > 1) {
+ callback(Result.failure(FlutterError(it[0] as String, it[1] as String, it[2] as String?)))
+ } else {
+ callback(Result.success(Unit))
+ }
+ } else {
+ callback(Result.failure(createConnectionError(channelName)))
+ }
+ }
+ }
+}
+@Suppress("UNCHECKED_CAST")
+private object PigeonHostApiCodec : StandardMessageCodec() {
+ override fun readValueOfType(type: Byte, buffer: ByteBuffer): Any? {
+ return when (type) {
+ 128.toByte() -> {
+ return (readValue(buffer) as? List)?.let {
+ PigeonNdefMessage.fromList(it)
+ }
+ }
+ 129.toByte() -> {
+ return (readValue(buffer) as? List)?.let {
+ PigeonNdefMessage.fromList(it)
+ }
+ }
+ 130.toByte() -> {
+ return (readValue(buffer) as? List)?.let {
+ PigeonNdefRecord.fromList(it)
+ }
+ }
+ else -> super.readValueOfType(type, buffer)
+ }
+ }
+ override fun writeValue(stream: ByteArrayOutputStream, value: Any?) {
+ when (value) {
+ is PigeonNdefMessage -> {
+ stream.write(128)
+ writeValue(stream, value.toList())
+ }
+ is PigeonNdefMessage -> {
+ stream.write(129)
+ writeValue(stream, value.toList())
+ }
+ is PigeonNdefRecord -> {
+ stream.write(130)
+ writeValue(stream, value.toList())
+ }
+ else -> super.writeValue(stream, value)
+ }
+ }
+}
+
+/** Generated interface from Pigeon that represents a handler of messages from Flutter. */
+interface PigeonHostApi {
+ fun nfcAdapterIsEnabled(): Boolean
+ fun nfcAdapterIsSecureNfcEnabled(): Boolean
+ fun nfcAdapterIsSecureNfcSupported(): Boolean
+ fun nfcAdapterEnableReaderMode(flags: List)
+ fun nfcAdapterDisableReaderMode()
+ fun nfcAdapterEnableForegroundDispatch()
+ fun nfcAdapterDisableForegroundDispatch()
+ fun ndefGetNdefMessage(handle: String): PigeonNdefMessage?
+ fun ndefWriteNdefMessage(handle: String, message: PigeonNdefMessage)
+ fun ndefMakeReadOnly(handle: String): Boolean
+ fun nfcAGetMaxTransceiveLength(handle: String): Long
+ fun nfcAGetTimeout(handle: String): Long
+ fun nfcASetTimeout(handle: String, timeout: Long)
+ fun nfcATransceive(handle: String, bytes: ByteArray): ByteArray
+ fun nfcBGetMaxTransceiveLength(handle: String): Long
+ fun nfcBTransceive(handle: String, bytes: ByteArray): ByteArray
+ fun nfcFGetMaxTransceiveLength(handle: String): Long
+ fun nfcFGetTimeout(handle: String): Long
+ fun nfcFSetTimeout(handle: String, timeout: Long)
+ fun nfcFTransceive(handle: String, bytes: ByteArray): ByteArray
+ fun nfcVGetMaxTransceiveLength(handle: String): Long
+ fun nfcVTransceive(handle: String, bytes: ByteArray): ByteArray
+ fun isoDepGetMaxTransceiveLength(handle: String): Long
+ fun isoDepGetTimeout(handle: String): Long
+ fun isoDepSetTimeout(handle: String, timeout: Long)
+ fun isoDepTransceive(handle: String, bytes: ByteArray): ByteArray
+ fun mifareClassicGetMaxTransceiveLength(handle: String): Long
+ fun mifareClassicGetTimeout(handle: String): Long
+ fun mifareClassicSetTimeout(handle: String, timeout: Long)
+ fun mifareClassicBlockToSector(handle: String, blockIndex: Long): Long
+ fun mifareClassicGetBlockCountInSector(handle: String, sectorIndex: Long): Long
+ fun mifareClassicSectorToBlock(handle: String, sectorIndex: Long): Long
+ fun mifareClassicAuthenticateSectorWithKeyA(handle: String, sectorIndex: Long, key: ByteArray): Boolean
+ fun mifareClassicAuthenticateSectorWithKeyB(handle: String, sectorIndex: Long, key: ByteArray): Boolean
+ fun mifareClassicIncrement(handle: String, blockIndex: Long, value: Long)
+ fun mifareClassicDecrement(handle: String, blockIndex: Long, value: Long)
+ fun mifareClassicReadBlock(handle: String, blockIndex: Long): ByteArray
+ fun mifareClassicWriteBlock(handle: String, blockIndex: Long, data: ByteArray)
+ fun mifareClassicRestore(handle: String, blockIndex: Long)
+ fun mifareClassicTransfer(handle: String, blockIndex: Long)
+ fun mifareClassicTransceive(handle: String, bytes: ByteArray): ByteArray
+ fun mifareUltralightGetMaxTransceiveLength(handle: String): Long
+ fun mifareUltralightGetTimeout(handle: String): Long
+ fun mifareUltralightSetTimeout(handle: String, timeout: Long)
+ fun mifareUltralightReadPages(handle: String, pageOffset: Long): ByteArray
+ fun mifareUltralightWritePage(handle: String, pageOffset: Long, data: ByteArray)
+ fun mifareUltralightTransceive(handle: String, bytes: ByteArray): ByteArray
+ fun ndefFormatableFormat(handle: String, firstMessage: PigeonNdefMessage)
+ fun ndefFormatableFormatReadOnly(handle: String, firstMessage: PigeonNdefMessage)
+
+ companion object {
+ /** The codec used by PigeonHostApi. */
+ val codec: MessageCodec by lazy {
+ PigeonHostApiCodec
+ }
+ /** Sets up an instance of `PigeonHostApi` to handle messages through the `binaryMessenger`. */
+ @Suppress("UNCHECKED_CAST")
+ fun setUp(binaryMessenger: BinaryMessenger, api: PigeonHostApi?) {
+ run {
+ val channel = BasicMessageChannel(binaryMessenger, "dev.flutter.pigeon.nfc_manager.PigeonHostApi.nfcAdapterIsEnabled", codec)
+ if (api != null) {
+ channel.setMessageHandler { _, reply ->
+ var wrapped: List
+ try {
+ wrapped = listOf(api.nfcAdapterIsEnabled())
+ } catch (exception: Throwable) {
+ wrapped = wrapError(exception)
+ }
+ reply.reply(wrapped)
+ }
+ } else {
+ channel.setMessageHandler(null)
+ }
+ }
+ run {
+ val channel = BasicMessageChannel(binaryMessenger, "dev.flutter.pigeon.nfc_manager.PigeonHostApi.nfcAdapterIsSecureNfcEnabled", codec)
+ if (api != null) {
+ channel.setMessageHandler { _, reply ->
+ var wrapped: List
+ try {
+ wrapped = listOf(api.nfcAdapterIsSecureNfcEnabled())
+ } catch (exception: Throwable) {
+ wrapped = wrapError(exception)
+ }
+ reply.reply(wrapped)
+ }
+ } else {
+ channel.setMessageHandler(null)
+ }
+ }
+ run {
+ val channel = BasicMessageChannel(binaryMessenger, "dev.flutter.pigeon.nfc_manager.PigeonHostApi.nfcAdapterIsSecureNfcSupported", codec)
+ if (api != null) {
+ channel.setMessageHandler { _, reply ->
+ var wrapped: List
+ try {
+ wrapped = listOf(api.nfcAdapterIsSecureNfcSupported())
+ } catch (exception: Throwable) {
+ wrapped = wrapError(exception)
+ }
+ reply.reply(wrapped)
+ }
+ } else {
+ channel.setMessageHandler(null)
+ }
+ }
+ run {
+ val channel = BasicMessageChannel(binaryMessenger, "dev.flutter.pigeon.nfc_manager.PigeonHostApi.nfcAdapterEnableReaderMode", codec)
+ if (api != null) {
+ channel.setMessageHandler { message, reply ->
+ val args = message as List
+ val flagsArg = args[0] as List
+ var wrapped: List
+ try {
+ api.nfcAdapterEnableReaderMode(flagsArg)
+ wrapped = listOf(null)
+ } catch (exception: Throwable) {
+ wrapped = wrapError(exception)
+ }
+ reply.reply(wrapped)
+ }
+ } else {
+ channel.setMessageHandler(null)
+ }
+ }
+ run {
+ val channel = BasicMessageChannel(binaryMessenger, "dev.flutter.pigeon.nfc_manager.PigeonHostApi.nfcAdapterDisableReaderMode", codec)
+ if (api != null) {
+ channel.setMessageHandler { _, reply ->
+ var wrapped: List
+ try {
+ api.nfcAdapterDisableReaderMode()
+ wrapped = listOf(null)
+ } catch (exception: Throwable) {
+ wrapped = wrapError(exception)
+ }
+ reply.reply(wrapped)
+ }
+ } else {
+ channel.setMessageHandler(null)
+ }
+ }
+ run {
+ val channel = BasicMessageChannel(binaryMessenger, "dev.flutter.pigeon.nfc_manager.PigeonHostApi.nfcAdapterEnableForegroundDispatch", codec)
+ if (api != null) {
+ channel.setMessageHandler { _, reply ->
+ var wrapped: List
+ try {
+ api.nfcAdapterEnableForegroundDispatch()
+ wrapped = listOf(null)
+ } catch (exception: Throwable) {
+ wrapped = wrapError(exception)
+ }
+ reply.reply(wrapped)
+ }
+ } else {
+ channel.setMessageHandler(null)
+ }
+ }
+ run {
+ val channel = BasicMessageChannel(binaryMessenger, "dev.flutter.pigeon.nfc_manager.PigeonHostApi.nfcAdapterDisableForegroundDispatch", codec)
+ if (api != null) {
+ channel.setMessageHandler { _, reply ->
+ var wrapped: List
+ try {
+ api.nfcAdapterDisableForegroundDispatch()
+ wrapped = listOf(null)
+ } catch (exception: Throwable) {
+ wrapped = wrapError(exception)
+ }
+ reply.reply(wrapped)
+ }
+ } else {
+ channel.setMessageHandler(null)
+ }
+ }
+ run {
+ val channel = BasicMessageChannel(binaryMessenger, "dev.flutter.pigeon.nfc_manager.PigeonHostApi.ndefGetNdefMessage", codec)
+ if (api != null) {
+ channel.setMessageHandler { message, reply ->
+ val args = message as List
+ val handleArg = args[0] as String
+ var wrapped: List
+ try {
+ wrapped = listOf(api.ndefGetNdefMessage(handleArg))
+ } catch (exception: Throwable) {
+ wrapped = wrapError(exception)
+ }
+ reply.reply(wrapped)
+ }
+ } else {
+ channel.setMessageHandler(null)
+ }
+ }
+ run {
+ val channel = BasicMessageChannel(binaryMessenger, "dev.flutter.pigeon.nfc_manager.PigeonHostApi.ndefWriteNdefMessage", codec)
+ if (api != null) {
+ channel.setMessageHandler { message, reply ->
+ val args = message as List
+ val handleArg = args[0] as String
+ val messageArg = args[1] as PigeonNdefMessage
+ var wrapped: List
+ try {
+ api.ndefWriteNdefMessage(handleArg, messageArg)
+ wrapped = listOf(null)
+ } catch (exception: Throwable) {
+ wrapped = wrapError(exception)
+ }
+ reply.reply(wrapped)
+ }
+ } else {
+ channel.setMessageHandler(null)
+ }
+ }
+ run {
+ val channel = BasicMessageChannel(binaryMessenger, "dev.flutter.pigeon.nfc_manager.PigeonHostApi.ndefMakeReadOnly", codec)
+ if (api != null) {
+ channel.setMessageHandler { message, reply ->
+ val args = message as List
+ val handleArg = args[0] as String
+ var wrapped: List
+ try {
+ wrapped = listOf(api.ndefMakeReadOnly(handleArg))
+ } catch (exception: Throwable) {
+ wrapped = wrapError(exception)
+ }
+ reply.reply(wrapped)
+ }
+ } else {
+ channel.setMessageHandler(null)
+ }
+ }
+ run {
+ val channel = BasicMessageChannel(binaryMessenger, "dev.flutter.pigeon.nfc_manager.PigeonHostApi.nfcAGetMaxTransceiveLength", codec)
+ if (api != null) {
+ channel.setMessageHandler { message, reply ->
+ val args = message as List
+ val handleArg = args[0] as String
+ var wrapped: List
+ try {
+ wrapped = listOf(api.nfcAGetMaxTransceiveLength(handleArg))
+ } catch (exception: Throwable) {
+ wrapped = wrapError(exception)
+ }
+ reply.reply(wrapped)
+ }
+ } else {
+ channel.setMessageHandler(null)
+ }
+ }
+ run {
+ val channel = BasicMessageChannel(binaryMessenger, "dev.flutter.pigeon.nfc_manager.PigeonHostApi.nfcAGetTimeout", codec)
+ if (api != null) {
+ channel.setMessageHandler { message, reply ->
+ val args = message as List
+ val handleArg = args[0] as String
+ var wrapped: List
+ try {
+ wrapped = listOf(api.nfcAGetTimeout(handleArg))
+ } catch (exception: Throwable) {
+ wrapped = wrapError(exception)
+ }
+ reply.reply(wrapped)
+ }
+ } else {
+ channel.setMessageHandler(null)
+ }
+ }
+ run {
+ val channel = BasicMessageChannel(binaryMessenger, "dev.flutter.pigeon.nfc_manager.PigeonHostApi.nfcASetTimeout", codec)
+ if (api != null) {
+ channel.setMessageHandler { message, reply ->
+ val args = message as List
+ val handleArg = args[0] as String
+ val timeoutArg = args[1].let { if (it is Int) it.toLong() else it as Long }
+ var wrapped: List
+ try {
+ api.nfcASetTimeout(handleArg, timeoutArg)
+ wrapped = listOf(null)
+ } catch (exception: Throwable) {
+ wrapped = wrapError(exception)
+ }
+ reply.reply(wrapped)
+ }
+ } else {
+ channel.setMessageHandler(null)
+ }
+ }
+ run {
+ val channel = BasicMessageChannel(binaryMessenger, "dev.flutter.pigeon.nfc_manager.PigeonHostApi.nfcATransceive", codec)
+ if (api != null) {
+ channel.setMessageHandler { message, reply ->
+ val args = message as List
+ val handleArg = args[0] as String
+ val bytesArg = args[1] as ByteArray
+ var wrapped: List
+ try {
+ wrapped = listOf(api.nfcATransceive(handleArg, bytesArg))
+ } catch (exception: Throwable) {
+ wrapped = wrapError(exception)
+ }
+ reply.reply(wrapped)
+ }
+ } else {
+ channel.setMessageHandler(null)
+ }
+ }
+ run {
+ val channel = BasicMessageChannel(binaryMessenger, "dev.flutter.pigeon.nfc_manager.PigeonHostApi.nfcBGetMaxTransceiveLength", codec)
+ if (api != null) {
+ channel.setMessageHandler { message, reply ->
+ val args = message as List
+ val handleArg = args[0] as String
+ var wrapped: List
+ try {
+ wrapped = listOf(api.nfcBGetMaxTransceiveLength(handleArg))
+ } catch (exception: Throwable) {
+ wrapped = wrapError(exception)
+ }
+ reply.reply(wrapped)
+ }
+ } else {
+ channel.setMessageHandler(null)
+ }
+ }
+ run {
+ val channel = BasicMessageChannel(binaryMessenger, "dev.flutter.pigeon.nfc_manager.PigeonHostApi.nfcBTransceive", codec)
+ if (api != null) {
+ channel.setMessageHandler { message, reply ->
+ val args = message as List
+ val handleArg = args[0] as String
+ val bytesArg = args[1] as ByteArray
+ var wrapped: List
+ try {
+ wrapped = listOf(api.nfcBTransceive(handleArg, bytesArg))
+ } catch (exception: Throwable) {
+ wrapped = wrapError(exception)
+ }
+ reply.reply(wrapped)
+ }
+ } else {
+ channel.setMessageHandler(null)
+ }
+ }
+ run {
+ val channel = BasicMessageChannel(binaryMessenger, "dev.flutter.pigeon.nfc_manager.PigeonHostApi.nfcFGetMaxTransceiveLength", codec)
+ if (api != null) {
+ channel.setMessageHandler { message, reply ->
+ val args = message as List
+ val handleArg = args[0] as String
+ var wrapped: List
+ try {
+ wrapped = listOf(api.nfcFGetMaxTransceiveLength(handleArg))
+ } catch (exception: Throwable) {
+ wrapped = wrapError(exception)
+ }
+ reply.reply(wrapped)
+ }
+ } else {
+ channel.setMessageHandler(null)
+ }
+ }
+ run {
+ val channel = BasicMessageChannel(binaryMessenger, "dev.flutter.pigeon.nfc_manager.PigeonHostApi.nfcFGetTimeout", codec)
+ if (api != null) {
+ channel.setMessageHandler { message, reply ->
+ val args = message as List
+ val handleArg = args[0] as String
+ var wrapped: List
+ try {
+ wrapped = listOf(api.nfcFGetTimeout(handleArg))
+ } catch (exception: Throwable) {
+ wrapped = wrapError(exception)
+ }
+ reply.reply(wrapped)
+ }
+ } else {
+ channel.setMessageHandler(null)
+ }
+ }
+ run {
+ val channel = BasicMessageChannel(binaryMessenger, "dev.flutter.pigeon.nfc_manager.PigeonHostApi.nfcFSetTimeout", codec)
+ if (api != null) {
+ channel.setMessageHandler { message, reply ->
+ val args = message as List
+ val handleArg = args[0] as String
+ val timeoutArg = args[1].let { if (it is Int) it.toLong() else it as Long }
+ var wrapped: List
+ try {
+ api.nfcFSetTimeout(handleArg, timeoutArg)
+ wrapped = listOf(null)
+ } catch (exception: Throwable) {
+ wrapped = wrapError(exception)
+ }
+ reply.reply(wrapped)
+ }
+ } else {
+ channel.setMessageHandler(null)
+ }
+ }
+ run {
+ val channel = BasicMessageChannel(binaryMessenger, "dev.flutter.pigeon.nfc_manager.PigeonHostApi.nfcFTransceive", codec)
+ if (api != null) {
+ channel.setMessageHandler { message, reply ->
+ val args = message as List
+ val handleArg = args[0] as String
+ val bytesArg = args[1] as ByteArray
+ var wrapped: List
+ try {
+ wrapped = listOf(api.nfcFTransceive(handleArg, bytesArg))
+ } catch (exception: Throwable) {
+ wrapped = wrapError(exception)
+ }
+ reply.reply(wrapped)
+ }
+ } else {
+ channel.setMessageHandler(null)
+ }
+ }
+ run {
+ val channel = BasicMessageChannel(binaryMessenger, "dev.flutter.pigeon.nfc_manager.PigeonHostApi.nfcVGetMaxTransceiveLength", codec)
+ if (api != null) {
+ channel.setMessageHandler { message, reply ->
+ val args = message as List
+ val handleArg = args[0] as String
+ var wrapped: List
+ try {
+ wrapped = listOf(api.nfcVGetMaxTransceiveLength(handleArg))
+ } catch (exception: Throwable) {
+ wrapped = wrapError(exception)
+ }
+ reply.reply(wrapped)
+ }
+ } else {
+ channel.setMessageHandler(null)
+ }
+ }
+ run {
+ val channel = BasicMessageChannel(binaryMessenger, "dev.flutter.pigeon.nfc_manager.PigeonHostApi.nfcVTransceive", codec)
+ if (api != null) {
+ channel.setMessageHandler { message, reply ->
+ val args = message as List
+ val handleArg = args[0] as String
+ val bytesArg = args[1] as ByteArray
+ var wrapped: List
+ try {
+ wrapped = listOf(api.nfcVTransceive(handleArg, bytesArg))
+ } catch (exception: Throwable) {
+ wrapped = wrapError(exception)
+ }
+ reply.reply(wrapped)
+ }
+ } else {
+ channel.setMessageHandler(null)
+ }
+ }
+ run {
+ val channel = BasicMessageChannel(binaryMessenger, "dev.flutter.pigeon.nfc_manager.PigeonHostApi.isoDepGetMaxTransceiveLength", codec)
+ if (api != null) {
+ channel.setMessageHandler { message, reply ->
+ val args = message as List
+ val handleArg = args[0] as String
+ var wrapped: List
+ try {
+ wrapped = listOf(api.isoDepGetMaxTransceiveLength(handleArg))
+ } catch (exception: Throwable) {
+ wrapped = wrapError(exception)
+ }
+ reply.reply(wrapped)
+ }
+ } else {
+ channel.setMessageHandler(null)
+ }
+ }
+ run {
+ val channel = BasicMessageChannel(binaryMessenger, "dev.flutter.pigeon.nfc_manager.PigeonHostApi.isoDepGetTimeout", codec)
+ if (api != null) {
+ channel.setMessageHandler { message, reply ->
+ val args = message as List
+ val handleArg = args[0] as String
+ var wrapped: List
+ try {
+ wrapped = listOf(api.isoDepGetTimeout(handleArg))
+ } catch (exception: Throwable) {
+ wrapped = wrapError(exception)
+ }
+ reply.reply(wrapped)
+ }
+ } else {
+ channel.setMessageHandler(null)
+ }
+ }
+ run {
+ val channel = BasicMessageChannel(binaryMessenger, "dev.flutter.pigeon.nfc_manager.PigeonHostApi.isoDepSetTimeout", codec)
+ if (api != null) {
+ channel.setMessageHandler { message, reply ->
+ val args = message as List
+ val handleArg = args[0] as String
+ val timeoutArg = args[1].let { if (it is Int) it.toLong() else it as Long }
+ var wrapped: List
+ try {
+ api.isoDepSetTimeout(handleArg, timeoutArg)
+ wrapped = listOf(null)
+ } catch (exception: Throwable) {
+ wrapped = wrapError(exception)
+ }
+ reply.reply(wrapped)
+ }
+ } else {
+ channel.setMessageHandler(null)
+ }
+ }
+ run {
+ val channel = BasicMessageChannel(binaryMessenger, "dev.flutter.pigeon.nfc_manager.PigeonHostApi.isoDepTransceive", codec)
+ if (api != null) {
+ channel.setMessageHandler { message, reply ->
+ val args = message as List
+ val handleArg = args[0] as String
+ val bytesArg = args[1] as ByteArray
+ var wrapped: List
+ try {
+ wrapped = listOf(api.isoDepTransceive(handleArg, bytesArg))
+ } catch (exception: Throwable) {
+ wrapped = wrapError(exception)
+ }
+ reply.reply(wrapped)
+ }
+ } else {
+ channel.setMessageHandler(null)
+ }
+ }
+ run {
+ val channel = BasicMessageChannel(binaryMessenger, "dev.flutter.pigeon.nfc_manager.PigeonHostApi.mifareClassicGetMaxTransceiveLength", codec)
+ if (api != null) {
+ channel.setMessageHandler { message, reply ->
+ val args = message as List
+ val handleArg = args[0] as String
+ var wrapped: List
+ try {
+ wrapped = listOf(api.mifareClassicGetMaxTransceiveLength(handleArg))
+ } catch (exception: Throwable) {
+ wrapped = wrapError(exception)
+ }
+ reply.reply(wrapped)
+ }
+ } else {
+ channel.setMessageHandler(null)
+ }
+ }
+ run {
+ val channel = BasicMessageChannel(binaryMessenger, "dev.flutter.pigeon.nfc_manager.PigeonHostApi.mifareClassicGetTimeout", codec)
+ if (api != null) {
+ channel.setMessageHandler { message, reply ->
+ val args = message as List
+ val handleArg = args[0] as String
+ var wrapped: List
+ try {
+ wrapped = listOf(api.mifareClassicGetTimeout(handleArg))
+ } catch (exception: Throwable) {
+ wrapped = wrapError(exception)
+ }
+ reply.reply(wrapped)
+ }
+ } else {
+ channel.setMessageHandler(null)
+ }
+ }
+ run {
+ val channel = BasicMessageChannel(binaryMessenger, "dev.flutter.pigeon.nfc_manager.PigeonHostApi.mifareClassicSetTimeout", codec)
+ if (api != null) {
+ channel.setMessageHandler { message, reply ->
+ val args = message as List
+ val handleArg = args[0] as String
+ val timeoutArg = args[1].let { if (it is Int) it.toLong() else it as Long }
+ var wrapped: List
+ try {
+ api.mifareClassicSetTimeout(handleArg, timeoutArg)
+ wrapped = listOf(null)
+ } catch (exception: Throwable) {
+ wrapped = wrapError(exception)
+ }
+ reply.reply(wrapped)
+ }
+ } else {
+ channel.setMessageHandler(null)
+ }
+ }
+ run {
+ val channel = BasicMessageChannel(binaryMessenger, "dev.flutter.pigeon.nfc_manager.PigeonHostApi.mifareClassicBlockToSector", codec)
+ if (api != null) {
+ channel.setMessageHandler { message, reply ->
+ val args = message as List
+ val handleArg = args[0] as String
+ val blockIndexArg = args[1].let { if (it is Int) it.toLong() else it as Long }
+ var wrapped: List
+ try {
+ wrapped = listOf(api.mifareClassicBlockToSector(handleArg, blockIndexArg))
+ } catch (exception: Throwable) {
+ wrapped = wrapError(exception)
+ }
+ reply.reply(wrapped)
+ }
+ } else {
+ channel.setMessageHandler(null)
+ }
+ }
+ run {
+ val channel = BasicMessageChannel(binaryMessenger, "dev.flutter.pigeon.nfc_manager.PigeonHostApi.mifareClassicGetBlockCountInSector", codec)
+ if (api != null) {
+ channel.setMessageHandler { message, reply ->
+ val args = message as List
+ val handleArg = args[0] as String
+ val sectorIndexArg = args[1].let { if (it is Int) it.toLong() else it as Long }
+ var wrapped: List
+ try {
+ wrapped = listOf(api.mifareClassicGetBlockCountInSector(handleArg, sectorIndexArg))
+ } catch (exception: Throwable) {
+ wrapped = wrapError(exception)
+ }
+ reply.reply(wrapped)
+ }
+ } else {
+ channel.setMessageHandler(null)
+ }
+ }
+ run {
+ val channel = BasicMessageChannel(binaryMessenger, "dev.flutter.pigeon.nfc_manager.PigeonHostApi.mifareClassicSectorToBlock", codec)
+ if (api != null) {
+ channel.setMessageHandler { message, reply ->
+ val args = message as List
+ val handleArg = args[0] as String
+ val sectorIndexArg = args[1].let { if (it is Int) it.toLong() else it as Long }
+ var wrapped: List
+ try {
+ wrapped = listOf(api.mifareClassicSectorToBlock(handleArg, sectorIndexArg))
+ } catch (exception: Throwable) {
+ wrapped = wrapError(exception)
+ }
+ reply.reply(wrapped)
+ }
+ } else {
+ channel.setMessageHandler(null)
+ }
+ }
+ run {
+ val channel = BasicMessageChannel(binaryMessenger, "dev.flutter.pigeon.nfc_manager.PigeonHostApi.mifareClassicAuthenticateSectorWithKeyA", codec)
+ if (api != null) {
+ channel.setMessageHandler { message, reply ->
+ val args = message as List
+ val handleArg = args[0] as String
+ val sectorIndexArg = args[1].let { if (it is Int) it.toLong() else it as Long }
+ val keyArg = args[2] as ByteArray
+ var wrapped: List
+ try {
+ wrapped = listOf(api.mifareClassicAuthenticateSectorWithKeyA(handleArg, sectorIndexArg, keyArg))
+ } catch (exception: Throwable) {
+ wrapped = wrapError(exception)
+ }
+ reply.reply(wrapped)
+ }
+ } else {
+ channel.setMessageHandler(null)
+ }
+ }
+ run {
+ val channel = BasicMessageChannel(binaryMessenger, "dev.flutter.pigeon.nfc_manager.PigeonHostApi.mifareClassicAuthenticateSectorWithKeyB", codec)
+ if (api != null) {
+ channel.setMessageHandler { message, reply ->
+ val args = message as List
+ val handleArg = args[0] as String
+ val sectorIndexArg = args[1].let { if (it is Int) it.toLong() else it as Long }
+ val keyArg = args[2] as ByteArray
+ var wrapped: List
+ try {
+ wrapped = listOf(api.mifareClassicAuthenticateSectorWithKeyB(handleArg, sectorIndexArg, keyArg))
+ } catch (exception: Throwable) {
+ wrapped = wrapError(exception)
+ }
+ reply.reply(wrapped)
+ }
+ } else {
+ channel.setMessageHandler(null)
+ }
+ }
+ run {
+ val channel = BasicMessageChannel(binaryMessenger, "dev.flutter.pigeon.nfc_manager.PigeonHostApi.mifareClassicIncrement", codec)
+ if (api != null) {
+ channel.setMessageHandler { message, reply ->
+ val args = message as List
+ val handleArg = args[0] as String
+ val blockIndexArg = args[1].let { if (it is Int) it.toLong() else it as Long }
+ val valueArg = args[2].let { if (it is Int) it.toLong() else it as Long }
+ var wrapped: List
+ try {
+ api.mifareClassicIncrement(handleArg, blockIndexArg, valueArg)
+ wrapped = listOf(null)
+ } catch (exception: Throwable) {
+ wrapped = wrapError(exception)
+ }
+ reply.reply(wrapped)
+ }
+ } else {
+ channel.setMessageHandler(null)
+ }
+ }
+ run {
+ val channel = BasicMessageChannel(binaryMessenger, "dev.flutter.pigeon.nfc_manager.PigeonHostApi.mifareClassicDecrement", codec)
+ if (api != null) {
+ channel.setMessageHandler { message, reply ->
+ val args = message as List
+ val handleArg = args[0] as String
+ val blockIndexArg = args[1].let { if (it is Int) it.toLong() else it as Long }
+ val valueArg = args[2].let { if (it is Int) it.toLong() else it as Long }
+ var wrapped: List
+ try {
+ api.mifareClassicDecrement(handleArg, blockIndexArg, valueArg)
+ wrapped = listOf(null)
+ } catch (exception: Throwable) {
+ wrapped = wrapError(exception)
+ }
+ reply.reply(wrapped)
+ }
+ } else {
+ channel.setMessageHandler(null)
+ }
+ }
+ run {
+ val channel = BasicMessageChannel(binaryMessenger, "dev.flutter.pigeon.nfc_manager.PigeonHostApi.mifareClassicReadBlock", codec)
+ if (api != null) {
+ channel.setMessageHandler { message, reply ->
+ val args = message as List
+ val handleArg = args[0] as String
+ val blockIndexArg = args[1].let { if (it is Int) it.toLong() else it as Long }
+ var wrapped: List
+ try {
+ wrapped = listOf(api.mifareClassicReadBlock(handleArg, blockIndexArg))
+ } catch (exception: Throwable) {
+ wrapped = wrapError(exception)
+ }
+ reply.reply(wrapped)
+ }
+ } else {
+ channel.setMessageHandler(null)
+ }
+ }
+ run {
+ val channel = BasicMessageChannel(binaryMessenger, "dev.flutter.pigeon.nfc_manager.PigeonHostApi.mifareClassicWriteBlock", codec)
+ if (api != null) {
+ channel.setMessageHandler { message, reply ->
+ val args = message as List
+ val handleArg = args[0] as String
+ val blockIndexArg = args[1].let { if (it is Int) it.toLong() else it as Long }
+ val dataArg = args[2] as ByteArray
+ var wrapped: List
+ try {
+ api.mifareClassicWriteBlock(handleArg, blockIndexArg, dataArg)
+ wrapped = listOf(null)
+ } catch (exception: Throwable) {
+ wrapped = wrapError(exception)
+ }
+ reply.reply(wrapped)
+ }
+ } else {
+ channel.setMessageHandler(null)
+ }
+ }
+ run {
+ val channel = BasicMessageChannel(binaryMessenger, "dev.flutter.pigeon.nfc_manager.PigeonHostApi.mifareClassicRestore", codec)
+ if (api != null) {
+ channel.setMessageHandler { message, reply ->
+ val args = message as List
+ val handleArg = args[0] as String
+ val blockIndexArg = args[1].let { if (it is Int) it.toLong() else it as Long }
+ var wrapped: List
+ try {
+ api.mifareClassicRestore(handleArg, blockIndexArg)
+ wrapped = listOf(null)
+ } catch (exception: Throwable) {
+ wrapped = wrapError(exception)
+ }
+ reply.reply(wrapped)
+ }
+ } else {
+ channel.setMessageHandler(null)
+ }
+ }
+ run {
+ val channel = BasicMessageChannel(binaryMessenger, "dev.flutter.pigeon.nfc_manager.PigeonHostApi.mifareClassicTransfer", codec)
+ if (api != null) {
+ channel.setMessageHandler { message, reply ->
+ val args = message as List
+ val handleArg = args[0] as String
+ val blockIndexArg = args[1].let { if (it is Int) it.toLong() else it as Long }
+ var wrapped: List
+ try {
+ api.mifareClassicTransfer(handleArg, blockIndexArg)
+ wrapped = listOf(null)
+ } catch (exception: Throwable) {
+ wrapped = wrapError(exception)
+ }
+ reply.reply(wrapped)
+ }
+ } else {
+ channel.setMessageHandler(null)
+ }
+ }
+ run {
+ val channel = BasicMessageChannel(binaryMessenger, "dev.flutter.pigeon.nfc_manager.PigeonHostApi.mifareClassicTransceive", codec)
+ if (api != null) {
+ channel.setMessageHandler { message, reply ->
+ val args = message as List
+ val handleArg = args[0] as String
+ val bytesArg = args[1] as ByteArray
+ var wrapped: List
+ try {
+ wrapped = listOf(api.mifareClassicTransceive(handleArg, bytesArg))
+ } catch (exception: Throwable) {
+ wrapped = wrapError(exception)
+ }
+ reply.reply(wrapped)
+ }
+ } else {
+ channel.setMessageHandler(null)
+ }
+ }
+ run {
+ val channel = BasicMessageChannel(binaryMessenger, "dev.flutter.pigeon.nfc_manager.PigeonHostApi.mifareUltralightGetMaxTransceiveLength", codec)
+ if (api != null) {
+ channel.setMessageHandler { message, reply ->
+ val args = message as List
+ val handleArg = args[0] as String
+ var wrapped: List
+ try {
+ wrapped = listOf(api.mifareUltralightGetMaxTransceiveLength(handleArg))
+ } catch (exception: Throwable) {
+ wrapped = wrapError(exception)
+ }
+ reply.reply(wrapped)
+ }
+ } else {
+ channel.setMessageHandler(null)
+ }
+ }
+ run {
+ val channel = BasicMessageChannel(binaryMessenger, "dev.flutter.pigeon.nfc_manager.PigeonHostApi.mifareUltralightGetTimeout", codec)
+ if (api != null) {
+ channel.setMessageHandler { message, reply ->
+ val args = message as List
+ val handleArg = args[0] as String
+ var wrapped: List
+ try {
+ wrapped = listOf(api.mifareUltralightGetTimeout(handleArg))
+ } catch (exception: Throwable) {
+ wrapped = wrapError(exception)
+ }
+ reply.reply(wrapped)
+ }
+ } else {
+ channel.setMessageHandler(null)
+ }
+ }
+ run {
+ val channel = BasicMessageChannel(binaryMessenger, "dev.flutter.pigeon.nfc_manager.PigeonHostApi.mifareUltralightSetTimeout", codec)
+ if (api != null) {
+ channel.setMessageHandler { message, reply ->
+ val args = message as List
+ val handleArg = args[0] as String
+ val timeoutArg = args[1].let { if (it is Int) it.toLong() else it as Long }
+ var wrapped: List
+ try {
+ api.mifareUltralightSetTimeout(handleArg, timeoutArg)
+ wrapped = listOf(null)
+ } catch (exception: Throwable) {
+ wrapped = wrapError(exception)
+ }
+ reply.reply(wrapped)
+ }
+ } else {
+ channel.setMessageHandler(null)
+ }
+ }
+ run {
+ val channel = BasicMessageChannel(binaryMessenger, "dev.flutter.pigeon.nfc_manager.PigeonHostApi.mifareUltralightReadPages", codec)
+ if (api != null) {
+ channel.setMessageHandler { message, reply ->
+ val args = message as List
+ val handleArg = args[0] as String
+ val pageOffsetArg = args[1].let { if (it is Int) it.toLong() else it as Long }
+ var wrapped: List
+ try {
+ wrapped = listOf(api.mifareUltralightReadPages(handleArg, pageOffsetArg))
+ } catch (exception: Throwable) {
+ wrapped = wrapError(exception)
+ }
+ reply.reply(wrapped)
+ }
+ } else {
+ channel.setMessageHandler(null)
+ }
+ }
+ run {
+ val channel = BasicMessageChannel(binaryMessenger, "dev.flutter.pigeon.nfc_manager.PigeonHostApi.mifareUltralightWritePage", codec)
+ if (api != null) {
+ channel.setMessageHandler { message, reply ->
+ val args = message as List