OffHostApduService 类
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
OffHostApduService 是一个方便 Service
类,可以扩展这些类来描述驻留在主机外的一个或多个 NFC 应用程序,例如嵌入的安全元素或 UICC。
[Android.Runtime.Register("android/nfc/cardemulation/OffHostApduService", DoNotGenerateAcw=true)]
public abstract class OffHostApduService : Android.App.Service
[<Android.Runtime.Register("android/nfc/cardemulation/OffHostApduService", DoNotGenerateAcw=true)>]
type OffHostApduService = class
inherit Service
- 继承
- 属性
注解
OffHostApduService 是一个方便 Service
类,可以扩展这些类来描述驻留在主机外的一个或多个 NFC 应用程序,例如嵌入的安全元素或 UICC。
<div class=“special reference”><h3>Developer Guide</h3> For a general introduction to the topic of card emulation, please read the NFC card emulation developer guide.
</div>
<h3>NFC 协议</h3>
此类所代表的主机外应用程序基于 NFC-Forum ISO-DEP 协议(基于 ISO/IEC 14443-4),并支持按照 ISO/IEC 7816-4 规范定义的处理命令应用程序协议数据单元(APTU)。
<h3>服务选择</h3>
当远程 NFC 设备想要与主机外 NFC 应用程序通信时,它会发送 ISO/IEC 7816-4 规范中定义的所谓“SELECT AID”APDU。 AID 是在 ISO/IEC 7816-4 中定义的应用程序标识符。
AID 的注册过程在 ISO/IEC 7816-5 规范中定义。 如果不想注册 AID,则可以在专有范围内免费使用 AID:第一个字节中的位 8-5 必须分别设置为“1”。 例如,“0xF00102030405”是专有 AID。 如果确实使用专有的 AID,建议选择至少 6 字节的 AID,以减少与其他可能使用专有 AID 的应用程序冲突的风险。
<h3>AID 组</h3>
在某些情况下,非主机环境可能需要注册多个 AID 来实现特定应用程序,并且需要确保它是所有这些 AID 的默认处理程序(而不是组中的某些 AID 转到另一个服务)。
AID 组是一个 AID 列表,应被视为属于 OS。 对于 AID 组中的所有 AID,OS 将保证以下项之一:<组中的 ul><li>All AID 将路由到组内的非主机执行环境 li>No AID,这些 AID 将路由到非主机执行环境 <</ul> 换句话说,不存在介于两者之间的状态,其中组中的某些 AID 可以路由到此非主机执行环境, 和一些到另一个或基于HostApduService
主机。 <h3>AID 组和类别</h3>
每个 AID 组都可以与一个类别相关联。 这样,Android OS 就可以对服务进行分类,并且允许用户在类别级别而不是 AID 级别设置默认值。
可用于 CardEmulation#isDefaultServiceForCategory(android.content.ComponentName, String)
确定非主机服务是否为类别的默认处理程序。
在此版本的平台中,唯一的已知类别是 CardEmulation#CATEGORY_PAYMENT
和 CardEmulation#CATEGORY_OTHER
。 没有类别或当前平台版本无法识别的类别的 AID 组将自动分组到类别中 CardEmulation#CATEGORY_OTHER
。
<h3>Service AID 注册</h3>
若要告知平台哪些 AID 驻留在主机外并由此服务管理,必须在服务的声明中包括一个 #SERVICE_META_DATA
条目。 OffHostApduService 清单声明的示例如下所示:
<service android:name=".MyOffHostApduService" android:exported="true" android:permission="android.permission.BIND_NFC_SERVICE">
<intent-filter>
<action android:name="android.nfc.cardemulation.action.OFF_HOST_APDU_SERVICE"/>
</intent-filter>
<meta-data android:name="android.nfc.cardemulation.off_host_apdu_ervice" android:resource="@xml/apduservice"/>
</service>
此元数据标记指向apduservice.xml文件。 下面显示了具有单个 AID 组声明的此文件的示例:
<offhost-apdu-service xmlns:android="http://schemas.android.com/apk/res/android"
android:description="@string/servicedesc">
<aid-group android:description="@string/subscription" android:category="other">
<aid-filter android:name="F0010203040506"/>
<aid-filter android:name="F0394148148100"/>
</aid-group>
</offhost-apdu-service>
android.R.styleable#OffHostApduService <offhost-apdu-service>
必须包含一个android.R.styleable#OffHostApduService_description <android:description>
属性,该属性包含可能显示在 UI 中的服务的用户友好说明。
android.R.styleable#OffHostApduService <offhost-apdu-service>
必须包含一个或多个android.R.styleable#AidGroup <aid-group>
标记。 每个 android.R.styleable#AidGroup <aid-group>
标记必须包含一个或多个 android.R.styleable#AidFilter <aid-filter>
标记,每个标记都包含一个 AID。 AID 必须以十六进制格式指定,并且包含偶数字符。
此注册将允许将服务作为作为类别的默认处理程序的选项包含在内。 Android OS 将负责正确将 AID 路由到主机外执行环境,具体取决于用户选择哪个服务作为特定类别的处理程序。
该服务可以定义 Android 命名空间之外的其他操作,这些操作可提供与主机外执行环境的进一步交互。
<p class=“note”>Use of this class requires PackageManager#FEATURE_NFC_HOST_CARD_EMULATION
to be present on the device.
适用于 . 的 android.nfc.cardemulation.OffHostApduService
Java 文档
本页的某些部分是根据 Android 开放源代码项目创建和共享的工作进行的修改,并根据 Creative Commons 2.5 属性许可证中所述的术语使用。
构造函数
OffHostApduService() | |
OffHostApduService(IntPtr, JniHandleOwnership) |
创建 JNI 对象的托管表示形式时使用的构造函数;由运行时调用。 |
字段
AccessibilityService |
|
AccountService |
|
ActivityService |
|
AlarmService |
|
AppOpsService |
用于 |
AppSearchService |
|
AppwidgetService |
|
AudioService |
用于 |
BatteryService |
|
BindAllowActivityStarts |
已过时.
|
BindExternalServiceLong |
的工作方式与 |
BindNotPerceptible |
已过时.
|
BindSharedIsolatedProcess |
已过时.
标志: |
BiometricService |
|
BlobStoreService |
|
BluetoothService |
|
BugreportService |
用于捕获 bug 报告的服务。 (继承自 Context) |
CameraService |
|
CaptioningService |
用于 |
CarrierConfigService |
用于 |
ClipboardService |
|
CompanionDeviceService |
|
ConnectivityDiagnosticsService |
用于 |
ConnectivityService |
用于 |
ConsumerIrService |
用于 |
CredentialService |
|
CrossProfileAppsService |
用于 |
DeviceIdDefault |
默认设备 ID,即主设备(非虚拟)设备的 ID。 (继承自 Context) |
DeviceIdInvalid |
设备 ID 无效。 (继承自 Context) |
DeviceLockService |
|
DevicePolicyService |
|
DisplayHashService |
|
DisplayService |
|
DomainVerificationService |
|
DownloadService |
与 |
DropboxService |
|
EuiccService |
|
FileIntegrityService |
|
FingerprintService |
用于 |
GameService |
|
GrammaticalInflectionService |
|
HardwarePropertiesService |
用于 |
HealthconnectService |
|
InputMethodService |
用于 |
InputService |
|
IpsecService |
|
JobSchedulerService |
|
KeyguardService |
|
LauncherAppsService |
用于 |
LayoutInflaterService |
用于 |
LocaleService |
|
LocationService |
与 |
MediaCommunicationService |
|
MediaMetricsService |
用于 |
MediaProjectionService |
用于 |
MediaRouterService |
|
MediaSessionService |
用于 |
MidiService |
用于 |
NetworkStatsService |
用于 |
NfcService |
|
NotificationService |
与 |
NsdService |
用于 |
OverlayService |
|
PeopleService |
|
PerformanceHintService |
|
PowerService |
|
PrintService |
|
ReceiverExported |
已过时.
|
ReceiverNotExported |
已过时.
|
ReceiverVisibleToInstantApps |
已过时.
标志: |
RestrictionsService |
用于 |
RoleService |
用于 |
SearchService |
|
SensorService |
|
ServiceInterface |
|
ServiceMetaData |
包含有关此服务的详细信息的元数据元素的名称。 |
ShortcutService |
|
StatusBarService |
|
StopForegroundDetach |
已过时.
选择器: |
StopForegroundLegacy |
选择器: |
StopForegroundRemove |
已过时.
选择器: |
StorageService |
用于 |
StorageStatsService |
|
SystemHealthService |
|
TelecomService |
|
TelephonyImsService |
|
TelephonyService |
用于 |
TelephonySubscriptionService |
用于 |
TextClassificationService |
|
TextServicesManagerService |
用于 |
TvInputService |
|
TvInteractiveAppService |
|
UiModeService |
用于 |
UsageStatsService |
|
UsbService |
用于 |
UserService |
用于 |
VibratorManagerService |
用于 |
VibratorService |
用于 |
VirtualDeviceService |
用于 |
VpnManagementService |
|
WallpaperService |
用于 |
WifiAwareService |
用于 |
WifiP2pService |
用于 |
WifiRttRangingService |
与 |
WifiService |
用于 |
WindowService |
|
属性
Application |
返回拥有此服务的应用程序。 (继承自 Service) |
ApplicationContext |
返回当前进程的单个全局 Application 对象的上下文。 (继承自 ContextWrapper) |
ApplicationInfo |
返回此上下文包的完整应用程序信息。 (继承自 ContextWrapper) |
Assets |
返回应用程序的包的 AssetManager 实例。 (继承自 ContextWrapper) |
AttributionSource |
OffHostApduService 是一个方便 |
AttributionTag |
属性可用于复杂应用中,以逻辑方式分隔应用的各个部分。 (继承自 Context) |
BaseContext | (继承自 ContextWrapper) |
CacheDir |
返回文件系统上特定于应用程序的缓存目录的绝对路径。 (继承自 ContextWrapper) |
Class |
返回此 |
ClassLoader |
返回可用于检索此包中的类的类加载程序。 (继承自 ContextWrapper) |
CodeCacheDir |
返回文件系统上用于存储缓存代码的应用程序特定缓存目录的绝对路径。 (继承自 ContextWrapper) |
ContentResolver |
返回应用程序的包的 ContentResolver 实例。 (继承自 ContextWrapper) |
DataDir |
OffHostApduService 是一个方便 |
DeviceId |
获取与此上下文关联的设备 ID。 (继承自 Context) |
Display |
获取与此上下文关联的显示。 (继承自 Context) |
ExternalCacheDir |
返回主外部文件系统上目录的绝对路径(位于应用程序可以放置其拥有的缓存文件的某个位置 ExternalStorageDirectory )。 (继承自 ContextWrapper) |
FilesDir |
返回存储使用 OpenFileOutput(String, FileCreationMode) 文件创建的文件系统上的目录的绝对路径。 (继承自 ContextWrapper) |
ForegroundServiceType |
如果服务已通过调用成为前台服务 |
Handle |
基础 Android 实例的句柄。 (继承自 Object) |
IsDeviceProtectedStorage |
OffHostApduService 是一个方便 |
IsRestricted |
指示此上下文是否受到限制。 (继承自 Context) |
IsUiContext |
如果 |
JniIdentityHashCode |
OffHostApduService 是一个方便 |
JniPeerMembers |
OffHostApduService 是一个方便 |
MainExecutor |
|
MainLooper |
返回当前进程的主线程的 Looper。 (继承自 ContextWrapper) |
NoBackupFilesDir |
返回文件系统上目录的绝对路径,类似于 FilesDir. (继承自 ContextWrapper) |
ObbDir |
返回可在其中找到此应用程序的 OBB 文件(如果有)的主外部存储目录。 (继承自 ContextWrapper) |
OpPackageName |
返回应该用于 |
PackageCodePath |
返回此上下文的主要 Android 包的完整路径。 (继承自 ContextWrapper) |
PackageManager |
返回 PackageManager 实例以查找全局包信息。 (继承自 ContextWrapper) |
PackageName |
返回此应用程序的包的名称。 (继承自 ContextWrapper) |
PackageResourcePath |
返回此上下文的主要 Android 包的完整路径。 (继承自 ContextWrapper) |
Params |
返回创建此上下文时所使用的参数集(如果通过该 |
PeerReference |
OffHostApduService 是一个方便 |
Resources |
返回应用程序的包的资源实例。 (继承自 ContextWrapper) |
Theme |
返回与此上下文关联的 Theme 对象。 (继承自 ContextWrapper) |
ThresholdClass |
此 API 支持 Mono for Android 基础结构,不打算直接从代码使用。 |
ThresholdType |
此 API 支持 Mono for Android 基础结构,不打算直接从代码使用。 |
Wallpaper | (继承自 ContextWrapper) |
WallpaperDesiredMinimumHeight | (继承自 ContextWrapper) |
WallpaperDesiredMinimumWidth | (继承自 ContextWrapper) |
方法
显式接口实现
IJavaPeerable.Disposed() |
OffHostApduService 是一个方便 |
IJavaPeerable.DisposeUnlessReferenced() |
OffHostApduService 是一个方便 |
IJavaPeerable.Finalized() |
OffHostApduService 是一个方便 |
IJavaPeerable.JniManagedPeerState |
OffHostApduService 是一个方便 |
IJavaPeerable.SetJniIdentityHashCode(Int32) |
OffHostApduService 是一个方便 |
IJavaPeerable.SetJniManagedPeerState(JniManagedPeerStates) |
OffHostApduService 是一个方便 |
IJavaPeerable.SetPeerReference(JniObjectReference) |
OffHostApduService 是一个方便 |
扩展方法
JavaCast<TResult>(IJavaObject) |
执行 Android 运行时检查的类型转换。 |
JavaCast<TResult>(IJavaObject) |
OffHostApduService 是一个方便 |
GetJniTypeName(IJavaPeerable) |
OffHostApduService 是一个方便 |