Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Docs
提交
2d0f8b70
D
Docs
项目概览
OpenHarmony
/
Docs
大约 2 年 前同步成功
通知
161
Star
293
Fork
28
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
Docs
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
2d0f8b70
编写于
6月 07, 2023
作者:
Z
zha wei
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
description: OMA接口文档第一次review整改
Signed-off-by:
N
zha wei
<
zhawei@kaihong.com
>
上级
62cd9ebc
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
284 addition
and
488 deletion
+284
-488
zh-cn/application-dev/reference/apis/js-apis-secureElement.md
...n/application-dev/reference/apis/js-apis-secureElement.md
+271
-473
zh-cn/application-dev/reference/errorcodes/errorcode-se.md
zh-cn/application-dev/reference/errorcodes/errorcode-se.md
+13
-15
未找到文件。
zh-cn/application-dev/reference/apis/js-apis-secureElement.md
浏览文件 @
2d0f8b70
# @ohos.secureElement(
SE服务管理&SE Reader管理& 基础和逻辑
通道管理)
# @ohos.secureElement(
安全单元的
通道管理)
本模块主要用于
本模块主要用于操作及管理安全单元SE,SE是SecureElement简称 ,文档中出现的SE服务为SEService实例,参见
[
newSEService
](
#secureElement.newSEService
)
。
对于文档中出现以下类型说明:
| 类型 | 说明 |
| ------- | ---------------------------------------------- |
| Session | 此类的实例表示与设备上可用的某个SE的连接会话。 |
| Reader | 此类的实例表示该设备支持的SE Reader。 |
| Channel | 此类的实例表示向SE打开的ISO/IEC 7816-4通道。 |
> **说明:**
> **说明:**
>
>
...
@@ -12,7 +20,7 @@
...
@@ -12,7 +20,7 @@
import
secureElement
from
'
@ohos.secureElement
'
;
import
secureElement
from
'
@ohos.secureElement
'
;
```
```
## ServiceState
##
secureElement.
ServiceState
定义不同的SE 服务状态值。
定义不同的SE 服务状态值。
...
@@ -25,87 +33,74 @@ import secureElement from '@ohos.secureElement';
...
@@ -25,87 +33,74 @@ import secureElement from '@ohos.secureElement';
## secureElement.newSEService
## secureElement.newSEService
newSEService(type: 'serviceState', callback: Callback
<
[
ServiceState
](
#
ServiceState
)
>
):
[
SEService
](
#SEService
)
newSEService(type: 'serviceState', callback: Callback
<
[
ServiceState
](
#
secureElement.ServiceState
)
>
): SEService
建立一个可用于连接到系统中所有可用SE的新连接(服务)。连接过程可能很长,所以它是以异步方式进行的。
仅当
建立一个可用于连接到系统中所有可用SE的新连接(服务)。连接过程可能很长,所以它是以异步方式进行的。
指定的回调或者如果
[
isConnected
](
#SEService.isConnected
)
返回true时,该返回
[
SEService
](
#SEService
)
对象是可用的。
仅当指定的回调或者如果
[
isConnected
](
#SEService.isConnected
)
方法返回true时,该返回SEService对象是可用的。
> **说明:**
> 从 API version10 开始支持
**系统能力:**
SystemCapability.Communication.SecureElement
**系统能力:**
SystemCapability.Communication.SecureElement
**参数:**
**参数:**
|
**参数名**
|
**类型**
|
**说明**
|
|
**参数名**
|
**类型**
|
**说明**
|
| ---------- | ---------------------------------------
| --
-------------------- |
| ---------- | ---------------------------------------
-------------- |
-------------------- |
| type | string | 'serviceState' |
| type | string | 'serviceState' |
| callback | Callback
<
[
ServiceState
](
#
ServiceState
)
>
| 返回service
状态的回调 |
| callback | Callback
<
[
ServiceState
](
#
secureElement.ServiceState
)
>
| 返回SE服务
状态的回调 |
**返回值:**
**返回值:**
|
**类型**
|
**说明**
|
|
**类型**
|
**说明**
|
| :-------- | :----------------------------------------------------------- |
| :-------- | :--------- |
| SEService | 仅当callback状态是
[
ServiceState
](
#ServiceState
)
.CONNECTED或
[
isConnected
](
#SEService.isConnected
)
接口返回值是true时,该service可用。 失败抛出异常 |
| SEService | SE服务实例 |
**错误码:**
错误码的详细介绍请参见
[
SE错误码
](
../errorcodes/errorcode-se.md
)
。
**示例:**
**示例:**
```
js
```
js
import
secureElement
from
'
@ohos.secureElement
'
;
import
secureElement
from
'
@ohos.secureElement
'
;
@
State
result
:
string
=
''
@
State
result
:
string
=
''
;
@
State
nfcSEService
:
secureElement
.
SEService
=
null
;
@
State
nfcSEService
:
secureElement
.
SEService
=
null
;
this
.
result
=
"
获取SEService结果:
"
;
this
.
result
=
"
Service state is Unkown
"
;
try
{
try
{
this
.
nfcSEService
=
secureElement
.
newSEService
(
"
serviceState
"
,
(
state
)
=>
this
.
nfcSEService
=
secureElement
.
newSEService
(
"
serviceState
"
,
(
state
)
=>
{
{
if
(
state
==
secureElement
.
ServiceState
.
DISCONNECTED
)
{
if
(
state
==
secureElement
.
ServiceState
.
DISCONNECTED
)
{
this
.
result
=
"
Service state is Disconnected
"
;
this
.
result
=
"
Service state is Disconnected
"
;
}
else
{
}
else
{
this
.
result
=
"
Service state is
c
onnected
"
;
this
.
result
=
"
Service state is
C
onnected
"
;
}
}
});
});
}
catch
(
e
)
{
}
catch
(
e
)
{
this
.
result
+=
"
newSEService出现异常
:
"
+
e
.
message
;
this
.
result
=
"
newSEService occurs exception
:
"
+
e
.
message
;
}
}
```
```
## SEService.getReaders
## SEService.getReaders
getReaders():
[
Reader
](
#Reader
)
[]
getReaders():
Reader
[]
返回可用SE
[
Reader
](
#Reader
)
的数组。返回的数组中不能有重复的对象。即使没有插入卡,也应列出所有可用的reader
返回可用SE Reader的数组。返回的数组中不能有重复的对象。即使没有插入卡,也应列出所有可用的reader。
> **说明:**
> 从 API version 10
**系统能力:**
SystemCapability.Communication.SecureElement
**系统能力:**
SystemCapability.Communication.SecureElement
**返回值:**
**返回值:**
|
**类型**
|
**说明**
|
|
**类型**
|
**说明**
|
| :------------------ | :-------------------------------- |
| :------- | :--------------------- |
|
[
Reader
](
#Reader
)[]
| 返回可用
[
Reader
](
#Reader
)
对象数组 |
| Reader[] | 返回可用Reader对象数组 |
**错误码:**
错误码的详细介绍请参见
[
SE错误码
](
../errorcodes/errorcode-se.md
)
。
**示例:**
**示例:**
```
js
```
js
import
secureElement
from
'
@ohos.secureElement
'
;
import
secureElement
from
'
@ohos.secureElement
'
;
@
State
result
:
string
=
''
@
State
result
:
string
=
''
;
@
State
nfcSEService
:
secureElement
.
SEService
=
null
;
@
State
nfcSEService
:
secureElement
.
SEService
=
null
;
@
State
nfcServiceState
:
secureElement
.
ServiceState
=
null
;
@
State
nfcServiceState
:
secureElement
.
ServiceState
=
null
;
@
State
nfcOmaReader
:
secureElement
.
Reader
=
null
;
@
State
nfcOmaReader
:
secureElement
.
Reader
=
null
;
@
State
nfcOmaReaderList
:
secureElement
.
Reader
[]
=
null
;
// get SEService
// get SEService
try
{
try
{
...
@@ -114,22 +109,23 @@ try {
...
@@ -114,22 +109,23 @@ try {
if
(
state
==
secureElement
.
ServiceState
.
DISCONNECTED
)
{
if
(
state
==
secureElement
.
ServiceState
.
DISCONNECTED
)
{
this
.
result
=
"
Service state is Disconnected
"
;
this
.
result
=
"
Service state is Disconnected
"
;
}
else
{
}
else
{
this
.
result
=
"
Service state is
c
onnected
"
;
this
.
result
=
"
Service state is
C
onnected
"
;
}
}
});
});
}
catch
(
e
)
{
}
catch
(
e
)
{
this
.
result
+=
"
newSEService出现异常
:
"
+
e
.
message
;
this
.
result
=
"
newSEService excpetion
:
"
+
e
.
message
;
}
}
try
{
try
{
this
.
nfcOmaReader
=
this
.
nfcSEService
.
getReaders
()[
0
];
this
.
nfcOmaReaderList
=
this
.
nfcSEService
.
getReaders
();
if
(
this
.
nfcOmaReader
)
{
if
(
this
.
nfcOmaReaderList
)
{
this
.
result
=
"
获取reader成功
"
;
this
.
nfcOmaReader
=
this
.
nfcOmaReaderList
[
0
];
this
.
result
=
"
get reader successfully
"
;
}
else
{
}
else
{
this
.
result
=
"
获取reader失败
"
;
this
.
result
=
"
get reader failed
"
;
}
}
}
catch
(
e
)
{
}
catch
(
e
)
{
this
.
result
=
"
getReaders
异常:
"
+
e
.
message
;
this
.
result
=
"
getReaders
exception:
"
+
e
.
message
;
}
}
```
```
...
@@ -144,12 +140,8 @@ isConnected(): boolean
...
@@ -144,12 +140,8 @@ isConnected(): boolean
**返回值:**
**返回值:**
|
**类型**
|
**说明**
|
|
**类型**
|
**说明**
|
| :------- | :----------------------------------------------------------- |
| :------- | :--------------------------------------------- |
| boolean | true:SE 服务状态
[
ServiceState
](
#ServiceState
)
.CONNECTED false:SE服务状态
[
ServiceState
](
#ServiceState
)
.DISCONNECTED |
| boolean | true:SE 服务状态已连接 false:SE服务状态已断开 |
**错误码:**
错误码的详细介绍请参见
[
SE错误码
](
../errorcodes/errorcode-se.md
)
。
**示例:**
**示例:**
...
@@ -161,15 +153,15 @@ import secureElement from '@ohos.secureElement';
...
@@ -161,15 +153,15 @@ import secureElement from '@ohos.secureElement';
try {
try {
let ret: boolean;
let ret: boolean;
//
有效this.nfcSEService,获取方式参考newSEService
//
refer to newSEService for this.nfcSEService
ret = this.nfcSEService.isConnected();
ret = this.nfcSEService.isConnected();
if (ret) {
if (ret) {
this.result = '
获取连接状态:
connected';
this.result = '
get state:
connected';
} else {
} else {
this.result = '
获取连接状态:
not connected';
this.result = '
get state:
not connected';
}
}
} catch (e) {
} catch (e) {
this.result = "isConnected
异常:
" + e.message;
this.result = "isConnected
exception:
" + e.message;
}
}
```
```
...
@@ -179,21 +171,8 @@ shutdown(): void
...
@@ -179,21 +171,8 @@ shutdown(): void
释放该service分配的所有SE资源。此后
[
isConnected
](
#SEService.isConnected
)
将返回false。
释放该service分配的所有SE资源。此后
[
isConnected
](
#SEService.isConnected
)
将返回false。
> **说明:**
> 从 API version 10 开始支持。
**系统能力:**
SystemCapability.Communication.SecureElement
**系统能力:**
SystemCapability.Communication.SecureElement
**返回值:**
|
**类型**
|
**说明**
|
| -------- | ------------ |
| void | 失败抛出异常 |
**错误码:**
错误码的详细介绍请参见
[
SE错误码
](
../errorcodes/errorcode-se.md
)
。
**示例:**
**示例:**
```
js
```
js
...
@@ -203,11 +182,11 @@ import secureElement from '@ohos.secureElement';
...
@@ -203,11 +182,11 @@ import secureElement from '@ohos.secureElement';
@
State
nfcSEService
:
secureElement
.
SEService
=
null
;
@
State
nfcSEService
:
secureElement
.
SEService
=
null
;
try
{
try
{
//
有效this.nfcSEService,获取方式参考newSEService
//
refer to newSEService for this.nfcSEService
this
.
nfcSEService
.
shutdown
();
this
.
nfcSEService
.
shutdown
();
this
.
result
=
"
shutdown
成功
"
;
this
.
result
=
"
shutdown
successfully
"
;
}
catch
(
e
)
{
}
catch
(
e
)
{
this
.
result
=
"
shutdown
异常:
"
+
e
.
message
;
this
.
result
=
"
shutdown
exception:
"
+
e
.
message
;
}
}
```
```
...
@@ -215,22 +194,15 @@ try {
...
@@ -215,22 +194,15 @@ try {
getVersion(): string
getVersion(): string
返回此实现所基于的OMA规范的版本号
返回此实现所基于的OMA规范的版本号。
> **说明:**
> 从 API version 10 开始支持。
**系统能力:**
SystemCapability.Communication.SecureElement
**系统能力:**
SystemCapability.Communication.SecureElement
**返回值:**
**返回值:**
|
**类型**
|
**说明**
|
|
**类型**
|
**说明**
|
| -------- | ------------------------------------------------------------ |
| -------- | -------------------------------------------------- |
| string | OMA版本号(例如,“3.3”表示开放移动API规范版本3.3),失败抛出异常。 |
| string | OMA版本号(例如,“3.3”表示开放移动API规范版本3.3) |
**错误码:**
错误码的详细介绍请参见
[
SE错误码
](
../errorcodes/errorcode-se.md
)
。
**示例:**
**示例:**
...
@@ -240,12 +212,12 @@ import secureElement from '@ohos.secureElement';
...
@@ -240,12 +212,12 @@ import secureElement from '@ohos.secureElement';
@State result: string = '';
@State result: string = '';
@State nfcSEService: secureElement.SEService = null;
@State nfcSEService: secureElement.SEService = null;
this.result = "
版本名称:
"
this.result = "
version:
"
try {
try {
//
有效this.nfcSEService,获取方式参考newSEService
//
refer to newSEService for this.nfcSEService
this.result += this.nfcSEService.getVersion();
this.result += this.nfcSEService.getVersion();
} catch (e) {
} catch (e) {
this.result
+= "getVersion异常:
" + e.message;
this.result
= "getVersion exception:
" + e.message;
}
}
```
```
...
@@ -253,10 +225,7 @@ try {
...
@@ -253,10 +225,7 @@ try {
getName(): string
getName(): string
返回此reader的名称。如果此读卡器是SIM reader,则其名称必须为“SIM[Slot]”。如果读卡器是嵌入式SE reader,则其名称须为“eSE[slot]”
返回此reader的名称。如果此读卡器是SIM reader,则其名称必须为“SIM[Slot]”。如果读卡器是嵌入式SE reader,则其名称须为“eSE[slot]”。
> **说明:**
> 从 API version 10 开始支持。
**系统能力:**
SystemCapability.Communication.SecureElement
**系统能力:**
SystemCapability.Communication.SecureElement
...
@@ -266,23 +235,19 @@ getName(): string
...
@@ -266,23 +235,19 @@ getName(): string
| -------- | ---------- |
| -------- | ---------- |
| string | reader名称 |
| string | reader名称 |
**错误码:**
错误码的详细介绍请参见
[
SE错误码
](
../errorcodes/errorcode-se.md
)
。
**示例:**
**示例:**
```
js
```
js
import
secureElement
from
'
@ohos.secureElement
'
;
import
secureElement
from
'
@ohos.secureElement
'
;
@
State
result
:
string
=
''
@
State
result
:
string
=
''
;
@
State
nfcOmaReader
:
secureElement
.
Reader
=
null
;
@
State
nfcOmaReader
:
secureElement
.
Reader
=
null
;
try
{
try
{
//
this.nfcOmaReader有效的Reader,获取方式参考SEService.getReaders
//
refer to SEService.getReaders for this.nfcOmaReader
this
.
result
=
this
.
nfcOmaReader
.
getName
();
this
.
result
=
this
.
nfcOmaReader
.
getName
();
}
catch
(
e
)
{
}
catch
(
e
)
{
this
.
result
=
"
getName
异常:
"
+
e
.
message
;
this
.
result
=
"
getName
exception:
"
+
e
.
message
;
}
}
```
```
...
@@ -290,18 +255,15 @@ try {
...
@@ -290,18 +255,15 @@ try {
isSecureElementPresent(): boolean
isSecureElementPresent(): boolean
检查reader中是否存在SE。
检查当前Reader所对应的安全单元是否可用。
> **说明:**
> 从 API version 10 开始支持。
**系统能力:**
SystemCapability.Communication.SecureElement
**系统能力:**
SystemCapability.Communication.SecureElement
**返回值:**
**返回值:**
|
**类型**
|
**说明**
|
|
**类型**
|
**说明**
|
| -------- | ------------------------------------- |
| -------- | -------------------------------------
-------
|
| boolean |
当前reader的SE存在返回true,否则false
|
| boolean |
true: 安全单元可用, false: 安全单元不可用。
|
**错误码:**
**错误码:**
...
@@ -316,37 +278,34 @@ isSecureElementPresent(): boolean
...
@@ -316,37 +278,34 @@ isSecureElementPresent(): boolean
```
js
```
js
import
secureElement
from
'
@ohos.secureElement
'
;
import
secureElement
from
'
@ohos.secureElement
'
;
@
State
result
:
string
=
''
@
State
result
:
string
=
''
;
@
State
nfcOmaReader
:
secureElement
.
Reader
=
null
;
@
State
nfcOmaReader
:
secureElement
.
Reader
=
null
;
try
{
try
{
//
this.nfcOmaReader有效的Reader,获取方式参考SEService.getReaders
//
refer to SEService.getReaders for this.nfcOmaReader
if
(
this
.
nfcOmaReader
.
isSecureElementPresent
())
{
if
(
this
.
nfcOmaReader
.
isSecureElementPresent
())
{
this
.
result
=
"
isSecureElementPresent
返回
TRUE
"
;
this
.
result
=
"
isSecureElementPresent
TRUE
"
;
}
else
{
}
else
{
this
.
result
=
"
isSecureElementPresent
返回
FALSE
"
;
this
.
result
=
"
isSecureElementPresent
FALSE
"
;
}
}
}
catch
(
e
)
{
}
catch
(
e
)
{
this
.
result
=
"
isSecureElementPresent
异常:
"
+
e
.
message
;
this
.
result
=
"
isSecureElementPresent
exception:
"
+
e
.
message
;
}
}
```
```
## Reader.openSession
## Reader.openSession
openSession():
[
Session
](
#Session
)
openSession():
Session
连接到此reader中的SE。此方法在返回会话对象之前准备(初始化)SE进行通信。同一reader上可能同时打开多个会话。
连接到此reader中的SE。此方法在返回会话对象之前准备(初始化)SE进行通信。同一reader上可能同时打开多个会话。
> **说明:**
> 从 API version 10 开始支持。
**系统能力:**
SystemCapability.Communication.SecureElement
**系统能力:**
SystemCapability.Communication.SecureElement
**返回值:**
**返回值:**
|
**类型**
|
**说明**
|
|
**类型**
|
**说明**
|
| --------
----------- | ------------
------------------------------ |
| --------
|
------------------------------ |
|
[
Session
](
#Session
)
| 用于创建channel的
[
Session
](
#Session
)
对象。 |
|
Session | 用于创建channel的Session
对象。 |
**错误码:**
**错误码:**
...
@@ -362,20 +321,20 @@ try {
...
@@ -362,20 +321,20 @@ try {
```
js
```
js
import
secureElement
from
'
@ohos.secureElement
'
;
import
secureElement
from
'
@ohos.secureElement
'
;
@
State
result
:
string
=
''
@
State
result
:
string
=
''
;
@
State
nfcOmaReader
:
secureElement
.
Reader
=
null
;
@
State
nfcOmaReader
:
secureElement
.
Reader
=
null
;
@
State
nfcOmaSession
:
secureElement
.
Session
=
null
;
@
State
nfcOmaSession
:
secureElement
.
Session
=
null
;
try
{
try
{
//
this.nfcOmaReader有效的Reader,获取方式参考SEService.getReaders
//
refer to SEService.getReaders for this.nfcOmaReader
this
.
nfcOmaSession
=
this
.
nfcOmaReader
.
openSession
();
this
.
nfcOmaSession
=
this
.
nfcOmaReader
.
openSession
();
if
(
this
.
nfcOmaSession
)
{
if
(
this
.
nfcOmaSession
)
{
this
.
result
=
"
获取session成功
"
;
this
.
result
=
"
get session successfully
"
;
}
else
{
}
else
{
this
.
result
=
"
获取session失败
"
;
this
.
result
=
"
get session failed
"
;
}
}
}
catch
(
e
)
{
}
catch
(
e
)
{
this
.
result
=
"
OpenSession
异常:
"
+
e
.
message
;
this
.
result
=
"
OpenSession
exception:
"
+
e
.
message
;
}
}
```
```
...
@@ -385,17 +344,8 @@ try {
...
@@ -385,17 +344,8 @@ try {
关闭在此reader上打开的所有session。所有这些session打开的所有channel都将关闭。
关闭在此reader上打开的所有session。所有这些session打开的所有channel都将关闭。
> **说明:**
> 从 API version 10 开始支持。
**系统能力:**
SystemCapability.Communication.SecureElement
**系统能力:**
SystemCapability.Communication.SecureElement
**返回值:**
|
**类型**
|
**说明**
|
| -------- | ------------ |
| void | 失败抛出异常 |
**错误码:**
**错误码:**
错误码的详细介绍请参见
[
SE错误码
](
../errorcodes/errorcode-se.md
)
。
错误码的详细介绍请参见
[
SE错误码
](
../errorcodes/errorcode-se.md
)
。
...
@@ -409,58 +359,51 @@ try {
...
@@ -409,58 +359,51 @@ try {
```
js
```
js
import
secureElement
from
'
@ohos.secureElement
'
;
import
secureElement
from
'
@ohos.secureElement
'
;
@
State
result
:
string
=
''
@
State
result
:
string
=
''
;
@
State
nfcOmaReader
:
secureElement
.
Reader
=
null
;
@
State
nfcOmaReader
:
secureElement
.
Reader
=
null
;
try
{
try
{
//
this.nfcOmaReader有效的Reader,获取方式参考SEService.getReaders
//
refer to SEService.getReaders for this.nfcOmaReader
this
.
nfcOmaReader
.
closeSessions
();
this
.
nfcOmaReader
.
closeSessions
();
this
.
result
=
"
关闭Sessions成功
"
;
this
.
result
=
"
close Sessions successfully
"
;
}
catch
(
e
)
{
}
catch
(
e
)
{
this
.
result
=
"
closeSessions
异常:
"
+
e
.
message
;
this
.
result
=
"
closeSessions
exception:
"
+
e
.
message
;
}
}
```
```
## Session.getReader
## Session.getReader
getReader():
[
Reader
](
#Reader
)
getReader():
Reader
获取提供此session的reader
获取提供此session的reader。
> **说明:**
> 从 API version 10 开始支持。
**系统能力:**
SystemCapability.Communication.SecureElement
**系统能力:**
SystemCapability.Communication.SecureElement
**返回值:**
**返回值:**
|
**类型**
|
**说明**
|
|
**类型**
|
**说明**
|
| ----------------- | ------------------------------------ |
| -------- | --------------------------- |
|
[
Reader
](
#Reader
)
| 返回此session的
[
Reader
](
#Reader
)
对象 |
| Reader | 返回此session的Reader对象。 |
**错误码:**
错误码的详细介绍请参见
[
SE错误码
](
../errorcodes/errorcode-se.md
)
。
**示例:**
**示例:**
```
js
```
js
import
secureElement
from
'
@ohos.secureElement
'
;
import
secureElement
from
'
@ohos.secureElement
'
;
@
State
result
:
string
=
''
@
State
result
:
string
=
''
;
@
State
nfcOmaReader
:
secureElement
.
Reader
=
null
;
@
State
nfcOmaReader
:
secureElement
.
Reader
=
null
;
@
State
nfcOmaSession
:
secureElement
.
Session
=
null
;
@
State
nfcOmaSession
:
secureElement
.
Session
=
null
;
try
{
try
{
//
this.nfcOmaSession:有效的Session,获取方式参考Reader.open
Session
//
refer to Reader.openSession for this.nfcOma
Session
this
.
nfcOmaReader
=
this
.
nfcOmaSession
.
getReader
();
this
.
nfcOmaReader
=
this
.
nfcOmaSession
.
getReader
();
if
(
this
.
nfcOmaReader
)
{
if
(
this
.
nfcOmaReader
)
{
this
.
result
=
"
获取reader成功
"
;
this
.
result
=
"
get reader successfully
"
;
}
else
{
}
else
{
this
.
result
=
"
获取reader失败
"
;
this
.
result
=
"
get reader failed
"
;
}
}
}
catch
(
e
)
{
}
catch
(
e
)
{
this
.
result
=
"
getReader
出现异常
:
"
+
e
.
message
;
this
.
result
=
"
getReader
exception
:
"
+
e
.
message
;
}
}
```
```
...
@@ -470,16 +413,13 @@ getATR(): number[]
...
@@ -470,16 +413,13 @@ getATR(): number[]
获取该SE的ATR。如果该SE的ATR不可用,则应返回空数组。
获取该SE的ATR。如果该SE的ATR不可用,则应返回空数组。
> **说明:**
> 从 API version 10 开始支持。
**系统能力:**
SystemCapability.Communication.SecureElement
**系统能力:**
SystemCapability.Communication.SecureElement
**返回值:**
**返回值:**
|
**类型**
|
**说明**
|
|
**类型**
|
**说明**
|
| -------- | ------------------------------------------ |
| -------- | ------------------------------------------
--
|
| number[] | 返回SE的ATR,SE的ATR不可用时,返回空的数组 |
| number[] | 返回SE的ATR,SE的ATR不可用时,返回空的数组
。
|
**错误码:**
**错误码:**
...
@@ -494,24 +434,24 @@ getATR(): number[]
...
@@ -494,24 +434,24 @@ getATR(): number[]
```
js
```
js
import
secureElement
from
'
@ohos.secureElement
'
;
import
secureElement
from
'
@ohos.secureElement
'
;
@
State
result
:
string
=
''
@
State
result
:
string
=
''
;
@
State
nfcOmaSession
:
secureElement
.
Session
=
null
;
@
State
nfcOmaSession
:
secureElement
.
Session
=
null
;
try
{
try
{
//
this.nfcOmaSession:有效的Session,获取方式参考Reader.open
Session
//
refer to Reader.openSession for this.nfcOma
Session
let
ret
=
this
.
nfcOmaSession
.
getATR
();
let
ret
=
this
.
nfcOmaSession
.
getATR
();
if
(
ret
)
{
if
(
ret
)
{
this
.
result
=
"
getATR
结果
:[
"
;
this
.
result
=
"
getATR
result
:[
"
;
for
(
let
i
=
0
;
i
<
ret
.
length
;
++
i
)
{
for
(
let
i
=
0
;
i
<
ret
.
length
;
++
i
)
{
this
.
result
+=
ret
[
i
];
this
.
result
+=
ret
[
i
];
this
.
result
+=
'
'
;
this
.
result
+=
'
'
;
}
}
this
.
result
+=
'
]
'
this
.
result
+=
'
]
'
;
}
else
{
}
else
{
this
.
result
=
"
getATR
结果为空
"
this
.
result
=
"
getATR
result is null
"
;
}
}
}
catch
(
e
)
{
}
catch
(
e
)
{
this
.
result
=
"
getATR
异常:
"
+
e
.
message
;
this
.
result
=
"
getATR
exception:
"
+
e
.
message
;
}
}
```
```
...
@@ -521,17 +461,8 @@ close(): void
...
@@ -521,17 +461,8 @@ close(): void
关闭与SE的连接。这将关闭此应用程序与此SE打开的所有channel。
关闭与SE的连接。这将关闭此应用程序与此SE打开的所有channel。
> **说明:**
> 从 API version 10 开始支持。
**系统能力:**
SystemCapability.Communication.SecureElement
**系统能力:**
SystemCapability.Communication.SecureElement
**返回值:**
|
**类型**
|
**说明**
|
| -------- | ------------ |
| void | 失败抛出异常 |
**错误码:**
**错误码:**
错误码的详细介绍请参见
[
SE错误码
](
../errorcodes/errorcode-se.md
)
。
错误码的详细介绍请参见
[
SE错误码
](
../errorcodes/errorcode-se.md
)
。
...
@@ -545,15 +476,15 @@ close(): void
...
@@ -545,15 +476,15 @@ close(): void
```
js
```
js
import
secureElement
from
'
@ohos.secureElement
'
;
import
secureElement
from
'
@ohos.secureElement
'
;
@
State
result
:
string
=
''
@
State
result
:
string
=
''
;
@
State
nfcOmaSession
:
secureElement
.
Session
=
null
;
@
State
nfcOmaSession
:
secureElement
.
Session
=
null
;
try
{
try
{
//
this.nfcOmaSession:有效的Session,获取方式参考Reader.open
Session
//
refer to Reader.openSession for this.nfcOma
Session
this
.
nfcOmaSession
.
close
();
this
.
nfcOmaSession
.
close
();
this
.
result
=
"
session close
成功
"
;
this
.
result
=
"
session close
successfully
"
;
}
catch
(
e
)
{
}
catch
(
e
)
{
this
.
result
=
"
session close
异常
:
"
+
e
.
message
;
this
.
result
=
"
session close
exception
:
"
+
e
.
message
;
}
}
```
```
...
@@ -561,18 +492,15 @@ try {
...
@@ -561,18 +492,15 @@ try {
isClosed(): boolean
isClosed(): boolean
检查session是否关闭.
检查session是否关闭。
> **说明:**
> 从 API version 10 开始支持。
**系统能力:**
SystemCapability.Communication.SecureElement
**系统能力:**
SystemCapability.Communication.SecureElement
**返回值:**
**返回值:**
|
**类型**
|
**说明**
|
|
**类型**
|
**说明**
|
| -------- | ---------------------------------- |
| -------- | ----------------------------------
--
|
| boolean | true:session状态已关闭,否则false |
| boolean | true:session状态已关闭,否则false
。
|
**错误码:**
**错误码:**
...
@@ -583,19 +511,19 @@ isClosed(): boolean
...
@@ -583,19 +511,19 @@ isClosed(): boolean
```
Js
```
Js
import secureElement from '@ohos.secureElement';
import secureElement from '@ohos.secureElement';
@State result: string = ''
@State result: string = ''
;
@State nfcOmaSession: secureElement.Session = null;
@State nfcOmaSession: secureElement.Session = null;
try {
try {
//
this.nfcOmaSession:有效的Session,获取方式参考Reader.open
Session
//
refer to Reader.openSession for this.nfcOma
Session
let ret = this.nfcOmaSession.isClosed();
let ret = this.nfcOmaSession.isClosed();
if (ret) {
if (ret) {
this.result = "session
状态:
closed";
this.result = "session
state is
closed";
} else {
} else {
this.result = "session
状态:
not closed";
this.result = "session
state is
not closed";
}
}
} catch (e) {
} catch (e) {
this.result = "isClosed
异常:
" + e.message;
this.result = "isClosed
exception:
" + e.message;
}
}
```
```
...
@@ -605,17 +533,8 @@ closeChannels(): void
...
@@ -605,17 +533,8 @@ closeChannels(): void
关闭此session上打开的所有channel。
关闭此session上打开的所有channel。
> **说明:**
> 从 API version 10 开始支持。
**系统能力:**
SystemCapability.Communication.SecureElement
**系统能力:**
SystemCapability.Communication.SecureElement
**返回值:**
|
**类型**
|
**说明**
|
| -------- | ------------ |
| void | 失败抛出异常 |
**错误码:**
**错误码:**
错误码的详细介绍请参见
[
SE错误码
](
../errorcodes/errorcode-se.md
)
。
错误码的详细介绍请参见
[
SE错误码
](
../errorcodes/errorcode-se.md
)
。
...
@@ -629,26 +548,23 @@ closeChannels(): void
...
@@ -629,26 +548,23 @@ closeChannels(): void
```
js
```
js
import
secureElement
from
'
@ohos.secureElement
'
;
import
secureElement
from
'
@ohos.secureElement
'
;
@
State
result
:
string
=
''
@
State
result
:
string
=
''
;
@
State
nfcOmaSession
:
secureElement
.
Session
=
null
;
@
State
nfcOmaSession
:
secureElement
.
Session
=
null
;
try
{
try
{
//
this.nfcOmaSession:有效的Session,获取方式参考Reader.open
Session
//
refer to Reader.openSession for this.nfcOma
Session
this
.
nfcOmaSession
.
closeChannels
();
this
.
nfcOmaSession
.
closeChannels
();
this
.
result
=
"
关闭Channels成功
"
;
this
.
result
=
"
close Channels successfully
"
;
}
catch
(
e
)
{
}
catch
(
e
)
{
this
.
result
=
"
closeChannels
出现异常:
"
+
e
.
message
;
this
.
result
=
"
closeChannels
exception:
"
+
e
.
message
;
}
}
```
```
## Session.openBasicChannel
## Session.openBasicChannel
openBasicChannel(aid: number
[
]): Promise<
[Channel
](
#Channel
)
>
openBasicChannel(aid: number[]): Promise
<
Channel
>
获取基本channel,参考
[
ISO 7816-4
](
https://www.iso.org/standard/77180.html
)
协议,返回
[
Channel
](
#Channel
)
实例对象
获取基本channel,参考[ISO 7816-4]协议,返回Channel实例对象,SE不能提供新逻辑Channel或因缺乏可用逻辑Channel对象而无法获取访问控制规则,返回null。
> **说明:**
> 从 API version 10 开始支持。
**系统能力:**
SystemCapability.Communication.SecureElement
**系统能力:**
SystemCapability.Communication.SecureElement
...
@@ -656,13 +572,13 @@ openBasicChannel(aid: number[]): Promise<[Channel](#Channel)>
...
@@ -656,13 +572,13 @@ openBasicChannel(aid: number[]): Promise<[Channel](#Channel)>
|
**参数名**
|
**类型**
|
**说明**
|
|
**参数名**
|
**类型**
|
**说明**
|
| ---------- | -------- | ------------------------------------------------------------ |
| ---------- | -------- | ------------------------------------------------------------ |
| aid | number[] | 在此channel上选择的applet的AID数组或
null 如果没有applet被选择
|
| aid | number[] | 在此channel上选择的applet的AID数组或
如果没有applet被选择时空的数组null。
|
**返回值:**
**返回值:**
|
**类型**
|
**说明**
|
|
**类型**
|
**说明**
|
| --------
----------- | ---------------------------------------
--------------------- |
| --------
|
--------------------- |
|
[
Channel
](
#Channel
)
| 返回可用
[
Channel
](
#Channel
)
对象实例,SE不能提供新逻辑
[
Channel
](
#Channel
)
或因缺乏可用逻辑
[
Channel
](
#Channel
)
对象而无法获取访问控制规则,返回null
|
|
Channel | 可用Channel对象实例。
|
**错误码:**
**错误码:**
...
@@ -680,47 +596,38 @@ openBasicChannel(aid: number[]): Promise<[Channel](#Channel)>
...
@@ -680,47 +596,38 @@ openBasicChannel(aid: number[]): Promise<[Channel](#Channel)>
```
js
```
js
import
secureElement
from
'
@ohos.secureElement
'
;
import
secureElement
from
'
@ohos.secureElement
'
;
@
State
result
:
string
=
''
@
State
result
:
string
=
''
;
@
State
nfcOmaSession
:
secureElement
.
Session
=
null
;
@
State
nfcOmaSession
:
secureElement
.
Session
=
null
;
@
State
nfcOmaChannel
:
secureElement
.
Channel
=
null
;
@
State
nfcOmaChannel
:
secureElement
.
Channel
=
null
;
try
{
try
{
//
this.nfcOmaSession:有效的Session,获取方式参考Reader.open
Session
//
refer to Reader.openSession for this.nfcOma
Session
let
getPromise
=
this
.
nfcOmaSession
.
openBasicChannel
(
this
.
aidArray
);
let
getPromise
=
this
.
nfcOmaSession
.
openBasicChannel
(
this
.
aidArray
);
getPromise
.
then
((
channel
)
=>
{
getPromise
.
then
((
channel
)
=>
{
this
.
nfcOmaChannel
=
channel
;
this
.
nfcOmaChannel
=
channel
;
this
.
result
=
"
openBasicChannel1
获取channel成功
"
;
this
.
result
=
"
openBasicChannel1
get channel successfully
"
;
}).
catch
((
err
)
=>
{
}).
catch
((
err
)
=>
{
this
.
result
=
"
openBasicChannel1
出现异常:
"
+
err
.
mee
sage
;
this
.
result
=
"
openBasicChannel1
exception:
"
+
err
.
mes
sage
;
});
});
}
catch
(
e
)
{
}
catch
(
e
)
{
this
.
result
=
"
OpenBasicChannel1
出现异常
:
"
+
e
.
message
;
this
.
result
=
"
OpenBasicChannel1
exception
:
"
+
e
.
message
;
}
}
```
```
## Session.openBasicChannel
## Session.openBasicChannel
openBasicChannel(aid: number
[
], callback: AsyncCallback<
[Channel
](
#Channel
)
>): void
openBasicChannel(aid: number[], callback: AsyncCallback
<
Channel
>
): void
获取基本channel,参考
[
ISO 7816-4
](
https://www.iso.org/standard/77180.html
)
协议,返回channel实例对象
获取基本channel,参考[ISO 7816-4]协议,返回channel实例对象,SE不能提供新逻辑Channel或因缺乏可用逻辑Channel对象而无法获取访问控制规则,返回null。
> **说明:**
> 从 API version 10 开始支持。
**系统能力:**
SystemCapability.Communication.SecureElement
**系统能力:**
SystemCapability.Communication.SecureElement
**参数:**
**参数:**
|
**参数名**
|
**类型**
|
**说明**
|
|
**参数名**
|
**类型**
|
**说明**
|
| ---------- | ---------------------------------- | ------------------------------------------------------------ |
| ---------- | ---------------------- | ------------------------------------------------------------ |
| aid | number[] | 在此channel上选择的applet的AID数组或null 如果没有applet被选择 |
| aid | number[] | 在此channel上选择的applet的AID数组或null 如果没有applet被选择。 |
| callback | AsyncCallback
<
[
Channel
](
#Channel
)
>
| callback返回可用
[
Channel
](
#Channel
)
对象实例,SE不能提供新逻辑
[
Channel
](
#Channel
)
或因缺乏可用逻辑
[
Channel
](
#Channel
)
对象而无法获取访问控制规则,返回null |
| callback | AsyncCallback
<Channel>
| callback返回可用Channel对象实例。 |
**返回值:**
|
**类型**
|
**说明**
|
| -------- | ------------ |
| void | 失败抛出异常 |
**错误码:**
**错误码:**
...
@@ -738,34 +645,31 @@ try {
...
@@ -738,34 +645,31 @@ try {
```
js
```
js
import
secureElement
from
'
@ohos.secureElement
'
;
import
secureElement
from
'
@ohos.secureElement
'
;
@
State
result
:
string
=
''
@
State
result
:
string
=
''
;
@
State
nfcOmaSession
:
secureElement
.
Session
=
null
;
@
State
nfcOmaSession
:
secureElement
.
Session
=
null
;
@
State
nfcOmaChannel
:
secureElement
.
Channel
=
null
;
@
State
nfcOmaChannel
:
secureElement
.
Channel
=
null
;
aidArray
:
number
[]
=
[
720
,
1080
]
aidArray
:
number
[]
=
[
720
,
1080
]
;
try
{
try
{
//
this.nfcOmaSession:有效的Session,获取方式参考Reader.open
Session
//
refer to Reader.openSession for this.nfcOma
Session
this
.
nfcOmaSession
.
openBasicChannel
(
this
.
aidArray
,
(
error
,
data
)
=>
{
this
.
nfcOmaSession
.
openBasicChannel
(
this
.
aidArray
,
(
error
,
data
)
=>
{
if
(
error
)
{
if
(
error
)
{
this
.
result
=
"
openBasicChannel2
失败:
"
+
JSON
.
stringify
(
error
);
this
.
result
=
"
openBasicChannel2
failed:
"
+
JSON
.
stringify
(
error
);
return
;
return
;
}
}
this
.
nfcOmaChannel
=
data
;
this
.
nfcOmaChannel
=
data
;
this
.
result
=
"
openBasicChannel2
获取channel成功
"
;
this
.
result
=
"
openBasicChannel2
get channel successfully
"
;
});
});
}
catch
(
e
)
{
}
catch
(
e
)
{
this
.
result
=
"
openBasicChannel2
出现异常
:
"
+
e
.
message
;
this
.
result
=
"
openBasicChannel2
exception
:
"
+
e
.
message
;
}
}
```
```
## Session.openBasicChannel
## Session.openBasicChannel
openBasicChannel(aid: number
[
], p2: number): Promise<[Channel
](
#Channel
)
>
openBasicChannel(aid: number[], p2: number): Promise
<Channel>
获取基本channel,参考
[
ISO 7816-4
](
https://www.iso.org/standard/77180.html
)
协议,返回
[
Channel
](
#Channel
)
实例对象
> **说明:**
获取基本channel,参考[ISO 7816-4]协议,返回Channel实例对象,SE不能提供新逻辑Channel对象或因缺乏可用逻辑Channel对象而无法获取访问控制规则,返回null。
> 从 API version 10 开始支持。
**系统能力:**
SystemCapability.Communication.SecureElement
**系统能力:**
SystemCapability.Communication.SecureElement
...
@@ -773,14 +677,14 @@ openBasicChannel(aid: number[], p2: number): Promise<[Channel](#Channel)>
...
@@ -773,14 +677,14 @@ openBasicChannel(aid: number[], p2: number): Promise<[Channel](#Channel)>
|
**参数名**
|
**类型**
|
**说明**
|
|
**参数名**
|
**类型**
|
**说明**
|
| ---------- | -------- | ------------------------------------------------------------ |
| ---------- | -------- | ------------------------------------------------------------ |
| aid | number[] | 在此channel上选择的applet的AID数组或null 如果没有applet被选择 |
| aid | number[] | 在此channel上选择的applet的AID数组或null 如果没有applet被选择
。
|
| p2 | number | 在该channel上执行的SELECT APDU的P2参数
|
| p2 | number | 在该channel上执行的SELECT APDU的P2参数
。
|
**返回值:**
**返回值:**
|
**类型**
|
**说明**
|
|
**类型**
|
**说明**
|
| --------
----------- | ---------------------------------------
--------------------- |
| --------
|
--------------------- |
|
[
Channel
](
#Channel
)
| 返回可用
[
Channel
](
#Channel
)
对象实例,SE不能提供新逻辑
[
Channel
](
#Channel
)
对象或因缺乏可用逻辑
[
Channel
](
#Channel
)
对象而无法获取访问控制规则,返回null
|
|
Channel | 可用Channel对象实例。
|
**错误码:**
**错误码:**
...
@@ -798,50 +702,41 @@ openBasicChannel(aid: number[], p2: number): Promise<[Channel](#Channel)>
...
@@ -798,50 +702,41 @@ openBasicChannel(aid: number[], p2: number): Promise<[Channel](#Channel)>
```
js
```
js
import
secureElement
from
'
@ohos.secureElement
'
;
import
secureElement
from
'
@ohos.secureElement
'
;
@
State
result
:
string
=
''
@
State
result
:
string
=
''
;
@
State
nfcOmaSession
:
secureElement
.
Session
=
null
;
@
State
nfcOmaSession
:
secureElement
.
Session
=
null
;
@
State
nfcOmaChannel
:
secureElement
.
Channel
=
null
;
@
State
nfcOmaChannel
:
secureElement
.
Channel
=
null
;
aidArray
:
number
[]
=
[
720
,
1080
]
aidArray
:
number
[]
=
[
720
,
1080
]
;
p2
:
number
=
0x00
p2
:
number
=
0x00
;
try
{
try
{
//
this.nfcOmaSession:有效的Session,获取方式参考Reader.open
Session
//
refer to Reader.openSession for this.nfcOma
Session
let
getPromise
=
this
.
nfcOmaSession
.
openBasicChannel
(
this
.
aidArray
,
this
.
p2
)
let
getPromise
=
this
.
nfcOmaSession
.
openBasicChannel
(
this
.
aidArray
,
this
.
p2
)
;
getPromise
.
then
((
channel
)
=>
{
getPromise
.
then
((
channel
)
=>
{
this
.
nfcOmaChannel
=
channel
;
this
.
nfcOmaChannel
=
channel
;
this
.
result
=
"
openBasicChannel3
获取channel成功
"
;
this
.
result
=
"
openBasicChannel3
get channel successfully
"
;
}).
catch
((
err
)
=>
{
}).
catch
((
err
)
=>
{
this
.
result
=
"
openBasicChannel3
出现异常
"
;
this
.
result
=
"
openBasicChannel3
exception
"
;
});
});
}
catch
(
e
)
{
}
catch
(
e
)
{
this
.
result
=
"
openBasicChannel3
出现异常
:
"
+
e
.
message
;
this
.
result
=
"
openBasicChannel3
exception
:
"
+
e
.
message
;
}
}
```
```
## Session.openBasicChannel
## Session.openBasicChannel
openBasicChannel(aid: number
[
], p2:number, callback: AsyncCallback<
[Channel
](
#Channel
)
>): void
openBasicChannel(aid: number[], p2:number, callback: AsyncCallback
<
Channel
>
): void
获取基本channel,参考
[
ISO 7816-4
](
https://www.iso.org/standard/77180.html
)
协议,返回channel实例对象
获取基本channel,参考[ISO 7816-4]协议,返回channel实例对象,SE不能提供新逻辑Channel对象或因缺乏可用逻辑Channel对象而无法获取访问控制规则,返回null。
> **说明:**
> 从 API version 10 开始支持。
**系统能力:**
SystemCapability.Communication.SecureElement
**系统能力:**
SystemCapability.Communication.SecureElement
**参数:**
**参数:**
|
**参数名**
|
**类型**
|
**说明**
|
|
**参数名**
|
**类型**
|
**说明**
|
| ---------- | ----------------------
------------
| ------------------------------------------------------------ |
| ---------- | ---------------------- | ------------------------------------------------------------ |
| aid | number[]
| 在此channel上选择的applet的AID数组或null 如果没有applet被选择
|
| aid | number[]
| 在此channel上选择的applet的AID数组或null 如果没有applet被选择。
|
| p2 | number | 此channel上执行SELECT APDU命令的P2参数。 |
| p2 | number | 此channel上执行SELECT APDU命令的P2参数。 |
| callback | AsyncCallback
<
[
Channel
](
#Channel
)
>
| callback返回可用
[
Channel
](
#Channel
)
对象实例,SE不能提供新逻辑
[
Channel
](
#Channel
)
对象或因缺乏可用逻辑
[
Channel
](
#Channel
)
对象而无法获取访问控制规则,返回null |
| callback | AsyncCallback
<Channel>
| callback返回可用Channel对象实例。 |
**返回值:**
|
**类型**
|
**说明**
|
| -------- | ------------ |
| void | 失败抛出异常 |
**错误码:**
**错误码:**
...
@@ -859,24 +754,24 @@ openBasicChannel(aid: number[], p2:number, callback: AsyncCallback<[Channel](#Ch
...
@@ -859,24 +754,24 @@ openBasicChannel(aid: number[], p2:number, callback: AsyncCallback<[Channel](#Ch
```
js
```
js
import
secureElement
from
'
@ohos.secureElement
'
;
import
secureElement
from
'
@ohos.secureElement
'
;
@
State
result
:
string
=
''
@
State
result
:
string
=
''
;
@
State
nfcOmaSession
:
secureElement
.
Session
=
null
;
@
State
nfcOmaSession
:
secureElement
.
Session
=
null
;
@
State
nfcOmaChannel
:
secureElement
.
Channel
=
null
;
@
State
nfcOmaChannel
:
secureElement
.
Channel
=
null
;
aidArray
:
number
[]
=
[
720
,
1080
]
aidArray
:
number
[]
=
[
720
,
1080
]
;
p2
:
number
=
0x00
p2
:
number
=
0x00
;
try
{
try
{
//
this.nfcOmaSession:有效的Session,获取方式参考Reader.open
Session
//
refer to Reader.openSession for this.nfcOma
Session
this
.
nfcOmaSession
.
openBasicChannel
(
this
.
aidArray
,
this
.
p2
,
(
error
,
data
)
=>
{
this
.
nfcOmaSession
.
openBasicChannel
(
this
.
aidArray
,
this
.
p2
,
(
error
,
data
)
=>
{
if
(
error
)
{
if
(
error
)
{
this
.
result
=
"
openBasicChannel4
失败:
"
+
JSON
.
stringify
(
error
);
this
.
result
=
"
openBasicChannel4
failed:
"
+
JSON
.
stringify
(
error
);
return
;
return
;
}
}
this
.
nfcOmaChannel
=
data
;
this
.
nfcOmaChannel
=
data
;
this
.
result
=
"
openBasicChannel4
获取channel成功
"
;
this
.
result
=
"
openBasicChannel4
get channel successfully
"
;
});
});
}
catch
(
e
)
{
}
catch
(
e
)
{
this
.
result
=
"
openBasicChannel4
异常
:
"
+
e
.
message
;
this
.
result
=
"
openBasicChannel4
exception
:
"
+
e
.
message
;
}
}
```
```
...
@@ -884,24 +779,21 @@ try {
...
@@ -884,24 +779,21 @@ try {
openLogicalChannel(aid: number
[
]): Promise<[Channel
](
#Channel
)
>
openLogicalChannel(aid: number
[
]): Promise<[Channel
](
#Channel
)
>
打开指定SE的逻辑
[
Channel
](
#Channel
)
对象
打开指定SE的逻辑Channel对象。
> **说明:**
> 从 API version 10 开始支持。
**系统能力:**
SystemCapability.Communication.SecureElement
**系统能力:**
SystemCapability.Communication.SecureElement
**参数:**
**参数:**
|
**参数名**
|
**类型**
|
**说明**
|
|
**参数名**
|
**类型**
|
**说明**
|
| ---------- | -------- | ---------------------------------------
------------
|
| ---------- | -------- | --------------------------------------- |
| aid | number
[
] | 在该
[Channel
](
#Channel
)
对象上选择的applet AID数组。 |
| aid | number[] | 在该
Channel
对象上选择的applet AID数组。 |
**返回值:**
**返回值:**
|
**类型**
|
**说明**
|
|
**类型**
|
**说明**
|
| --------
-----------
| ------------------------------------------------------------ |
| -------- | ------------------------------------------------------------ |
|
[
Channel
](
#Channel
)
| 返回可用
[
Channel
](
#Channel
)
对象实例,SE不能提供新的
[
Channel
](
#Channel
)
对象或因缺乏可用逻辑
[
Channel
](
#Channel
)
对象无法获取访问控制规则返回null
|
|
Channel | 返回可用Channel对象实例,SE不能提供新的Channel对象或因缺乏可用逻辑Channel对象无法获取访问控制规则返回null。
|
**错误码:**
**错误码:**
...
@@ -919,22 +811,22 @@ openLogicalChannel(aid: number[]): Promise<[Channel](#Channel)>
...
@@ -919,22 +811,22 @@ openLogicalChannel(aid: number[]): Promise<[Channel](#Channel)>
```
js
```
js
import
secureElement
from
'
@ohos.secureElement
'
;
import
secureElement
from
'
@ohos.secureElement
'
;
@
State
result
:
string
=
''
@
State
result
:
string
=
''
;
@
State
nfcOmaSession
:
secureElement
.
Session
=
null
;
@
State
nfcOmaSession
:
secureElement
.
Session
=
null
;
@
State
nfcOmaChannel
:
secureElement
.
Channel
=
null
;
@
State
nfcOmaChannel
:
secureElement
.
Channel
=
null
;
aidArray
:
number
[]
=
[
720
,
1080
]
aidArray
:
number
[]
=
[
720
,
1080
]
;
try
{
try
{
//
this.nfcOmaSession:有效的Session,获取方式参考Reader.open
Session
//
refer to Reader.openSession for this.nfcOma
Session
let
getPromise
=
this
.
nfcOmaSession
.
openLogicalChannel
(
this
.
aidArray
)
let
getPromise
=
this
.
nfcOmaSession
.
openLogicalChannel
(
this
.
aidArray
)
getPromise
.
then
((
channel
)
=>
{
getPromise
.
then
((
channel
)
=>
{
this
.
nfcOmaChannel
=
channel
;
this
.
nfcOmaChannel
=
channel
;
this
.
result
=
"
openLogicChannel1
获取channel成功
"
;
this
.
result
=
"
openLogicChannel1
get channel successfully
"
;
}).
catch
((
err
)
=>
{
}).
catch
((
err
)
=>
{
this
.
result
=
"
openLogicChannel1
出现异常:
"
+
err
.
cod
e
;
this
.
result
=
"
openLogicChannel1
exception:
"
+
err
.
messag
e
;
});
});
}
catch
(
e
)
{
}
catch
(
e
)
{
this
.
result
=
"
openLogicChannel1
出现异常
:
"
+
e
.
message
;
this
.
result
=
"
openLogicChannel1
exception
:
"
+
e
.
message
;
}
}
```
```
...
@@ -942,25 +834,16 @@ try {
...
@@ -942,25 +834,16 @@ try {
openLogicalChannel(aid:number
[
], callback: AsyncCallback<[Channel
](
#Channel
)
>): void
openLogicalChannel(aid:number
[
], callback: AsyncCallback<[Channel
](
#Channel
)
>): void
打开指定SE的逻辑
[
Channel
](
#Channel
)
对象
打开指定SE的逻辑Channel对象。
> **说明:**
> 从 API version 10 开始支持。
**系统能力:**
SystemCapability.Communication.SecureElement
**系统能力:**
SystemCapability.Communication.SecureElement
**参数:**
**参数:**
|
**参数名**
|
**类型**
|
**说明**
|
|
**参数名**
|
**类型**
|
**说明**
|
| ---------- | ---------------------------------- | ------------------------------------------------------------ |
| ---------- | ---------------------- | ------------------------------------------------------------ |
| aid | number
[
] | 在该[Channel
](
#Channel
)
对象上被选择的applet AID数组。 |
| aid | number[] | 在该Channel对象上被选择的applet AID数组。 |
| callback | AsyncCallback
<
[
Channel
](
#Channel
)
>
| callback返回可用
[
Channel
](
#Channel
)
对象实例,SE不能提供新的channel或因缺乏可用逻辑
[
Channel
](
#Channel
)
对象无法获取访问控制规则返回null |
| callback | AsyncCallback
<Channel>
| callback返回可用Channel对象实例,SE不能提供新的channel或因缺乏可用逻辑Channel对象无法获取访问控制规则返回null。 |
**返回值:**
|
**类型**
|
**说明**
|
| -------- | ------------ |
| void | 失败抛出异常 |
**错误码:**
**错误码:**
...
@@ -978,29 +861,29 @@ try {
...
@@ -978,29 +861,29 @@ try {
```
js
```
js
import
secureElement
from
'
@ohos.secureElement
'
;
import
secureElement
from
'
@ohos.secureElement
'
;
@
State
result
:
string
=
''
@
State
result
:
string
=
''
;
@
State
nfcOmaSession
:
secureElement
.
Session
=
null
;
@
State
nfcOmaSession
:
secureElement
.
Session
=
null
;
@
State
nfcOmaChannel
:
secureElement
.
Channel
=
null
;
@
State
nfcOmaChannel
:
secureElement
.
Channel
=
null
;
aidArray
:
number
[]
=
[
720
,
1080
];
aidArray
:
number
[]
=
[
720
,
1080
];
try
{
try
{
//
this.nfcOmaSession:有效的Session,获取方式参考Reader.open
Session
//
refer to Reader.openSession for this.nfcOma
Session
this
.
nfcOmaSession
.
openLogicalChannel
(
this
.
aidArray
,
(
error
,
data
)
=>
{
this
.
nfcOmaSession
.
openLogicalChannel
(
this
.
aidArray
,
(
error
,
data
)
=>
{
if
(
error
)
{
if
(
error
)
{
this
.
result
=
"
openLogicChannel2
失败:
"
+
JSON
.
stringify
(
error
);
this
.
result
=
"
openLogicChannel2
failed:
"
+
JSON
.
stringify
(
error
);
return
;
return
;
}
}
this
.
nfcOmaChannel
=
data
;
this
.
nfcOmaChannel
=
data
;
this
.
result
=
"
openLogicChannel2
获取channel成功
"
;
this
.
result
=
"
openLogicChannel2
get channel successfully
"
;
});
});
}
catch
(
e
)
{
}
catch
(
e
)
{
this
.
result
=
"
openLogicChannel2
异常
:
"
+
e
.
message
;
this
.
result
=
"
openLogicChannel2
exception
:
"
+
e
.
message
;
}
}
```
```
## Session.openLogicalChannel
## Session.openLogicalChannel
openLogicalChannel(aid: number
[
], p2: number): Promise<
[Channel
](
#Channel
)
>
openLogicalChannel(aid: number[], p2: number): Promise
<
Channel
>
使用SE打开逻辑通道,选择由给定AID数组(AID非null且长度不为0)表示的applet.
使用SE打开逻辑通道,选择由给定AID数组(AID非null且长度不为0)表示的applet.
...
@@ -1010,24 +893,15 @@ openLogicalChannel(aid: number[], p2: number): Promise<[Channel](#Channel)>
...
@@ -1010,24 +893,15 @@ openLogicalChannel(aid: number[], p2: number): Promise<[Channel](#Channel)>
P2通常为0x00。设备应允许P2的任何值,并且应允许以下值: 0x00, 0x04, 0x08, 0x0C (如
[
ISO 7816-4
](
https://www.iso.org/standard/77180.html
)
中所定义).
P2通常为0x00。设备应允许P2的任何值,并且应允许以下值: 0x00, 0x04, 0x08, 0x0C (如
[
ISO 7816-4
](
https://www.iso.org/standard/77180.html
)
中所定义).
> **说明:**
> 从 API version 10 开始支持。
**系统能力:**
SystemCapability.Communication.SecureElement
**系统能力:**
SystemCapability.Communication.SecureElement
**参数:**
**参数:**
|
**参数名**
|
**类型**
|
**说明**
|
|
**参数名**
|
**类型**
|
**说明**
|
| ---------- | -------- | -----------------------------------------
------------
|
| ---------- | -------- | ----------------------------------------- |
| aid | number
[
] | 在该
[Channel
](
#Channel
)
对象上被选择的applet AID数组。 |
| aid | number[] | 在该
Channel
对象上被选择的applet AID数组。 |
| p2 | number | 此channel上执行SELECT APDU命令的P2参数。 |
| p2 | number | 此channel上执行SELECT APDU命令的P2参数。 |
**返回值:**
|
**类型**
|
**说明**
|
| -------- | ------------ |
| void | 失败抛出异常 |
**错误码:**
**错误码:**
错误码的详细介绍请参见
[
SE错误码
](
../errorcodes/errorcode-se.md
)
。
错误码的详细介绍请参见
[
SE错误码
](
../errorcodes/errorcode-se.md
)
。
...
@@ -1044,30 +918,30 @@ P2通常为0x00。设备应允许P2的任何值,并且应允许以下值: 0x
...
@@ -1044,30 +918,30 @@ P2通常为0x00。设备应允许P2的任何值,并且应允许以下值: 0x
```
js
```
js
import
secureElement
from
'
@ohos.secureElement
'
;
import
secureElement
from
'
@ohos.secureElement
'
;
@
State
result
:
string
=
''
@
State
result
:
string
=
''
;
@
State
nfcOmaSession
:
secureElement
.
Session
=
null
;
@
State
nfcOmaSession
:
secureElement
.
Session
=
null
;
@
State
nfcOmaChannel
:
secureElement
.
Channel
=
null
;
@
State
nfcOmaChannel
:
secureElement
.
Channel
=
null
;
aidArray
:
number
[]
=
[
720
,
1080
]
aidArray
:
number
[]
=
[
720
,
1080
]
;
p2
:
number
=
0x00
p2
:
number
=
0x00
;
if
(
this
.
nfcOmaSession
)
{
if
(
this
.
nfcOmaSession
)
{
try
{
try
{
// this.nfcOmaSession:有效的Session,获取方式参考Reader.open
Session
// refer to Reader.openSession for this.nfcOma
Session
let
getPromise
=
this
.
nfcOmaSession
.
openLogicalChannel
(
this
.
aidArray
,
this
.
p2
)
let
getPromise
=
this
.
nfcOmaSession
.
openLogicalChannel
(
this
.
aidArray
,
this
.
p2
)
;
getPromise
.
then
((
channel
)
=>
{
getPromise
.
then
((
channel
)
=>
{
this
.
nfcOmaChannel
=
channel
;
this
.
nfcOmaChannel
=
channel
;
this
.
result
=
"
openLogicChannel3
获取channel成功
"
;
this
.
result
=
"
openLogicChannel3
get channel successfully
"
;
}).
catch
((
err
)
=>
{
}).
catch
((
err
)
=>
{
this
.
result
=
"
openLogicChannel3
出现异常
"
;
this
.
result
=
"
openLogicChannel3
exception
"
;
})
;
})
}
catch
(
e
)
{
}
catch
(
e
)
{
this
.
result
=
"
openLogicChannel3
出现异常
:
"
+
e
.
message
;
this
.
result
=
"
openLogicChannel3
exception
:
"
+
e
.
message
;
}
}
```
```
## Session.openLogicalChannel
## Session.openLogicalChannel
openLogicalChannel(aid: number
[
], p2: number, callback: AsyncCallback<
[Channel
](
#Channel
)
>):void
openLogicalChannel(aid: number[], p2: number, callback: AsyncCallback
<
Channel
>
):void
使用SE打开逻辑通道,选择由给定AID数组(AID非null且长度不为0)表示的applet.
使用SE打开逻辑通道,选择由给定AID数组(AID非null且长度不为0)表示的applet.
...
@@ -1077,24 +951,15 @@ openLogicalChannel(aid: number[], p2: number, callback: AsyncCallback<[Channel](
...
@@ -1077,24 +951,15 @@ openLogicalChannel(aid: number[], p2: number, callback: AsyncCallback<[Channel](
P2通常为0x00。设备应允许P2的任何值,并且应允许以下值: 0x00, 0x04, 0x08, 0x0C (如
[
ISO 7816-4
](
https://www.iso.org/standard/77180.html
)
中所定义).
P2通常为0x00。设备应允许P2的任何值,并且应允许以下值: 0x00, 0x04, 0x08, 0x0C (如
[
ISO 7816-4
](
https://www.iso.org/standard/77180.html
)
中所定义).
> **说明:**
> 从 API version 10 开始支持。
**系统能力:**
SystemCapability.Communication.SecureElement
**系统能力:**
SystemCapability.Communication.SecureElement
**参数:**
**参数:**
|
**参数名**
|
**类型**
|
**说明**
|
|
**参数名**
|
**类型**
|
**说明**
|
| ---------- | ----------------------
------------
| ------------------------------------------------------------ |
| ---------- | ---------------------- | ------------------------------------------------------------ |
| aid | number
[
]
| 在该[Channel
](
#Channel
)
对象上被选择的applet AID数组。
|
| aid | number[]
| 在该Channel对象上被选择的applet AID数组。
|
| p2 | number | 此channel上执行SELECT APDU命令的P2参数。 |
| p2 | number | 此channel上执行SELECT APDU命令的P2参数。 |
| callback | AsyncCallback
<
[
Channel
](
#Channel
)
>
| callback返回可用
[
Channel
](
#Channel
)
对象实例,SE不能提供新的
[
Channel
](
#Channel
)
对象或因缺乏可用逻辑
[
Channel
](
#Channel
)
对象无法获取访问控制规则返回null |
| callback | AsyncCallback
<Channel>
| callback返回可用Channel对象实例,SE不能提供新的Channel对象或因缺乏可用逻辑Channel对象无法获取访问控制规则返回null。 |
**返回值:**
|
**类型**
|
**说明**
|
| -------- | ------------ |
| void | 失败抛出异常 |
**错误码:**
**错误码:**
...
@@ -1112,67 +977,60 @@ P2通常为0x00。设备应允许P2的任何值,并且应允许以下值: 0x
...
@@ -1112,67 +977,60 @@ P2通常为0x00。设备应允许P2的任何值,并且应允许以下值: 0x
```
js
```
js
import
secureElement
from
'
@ohos.secureElement
'
;
import
secureElement
from
'
@ohos.secureElement
'
;
@
State
result
:
string
=
''
@
State
result
:
string
=
''
;
@
State
nfcOmaSession
:
secureElement
.
Session
=
null
;
@
State
nfcOmaSession
:
secureElement
.
Session
=
null
;
@
State
nfcOmaChannel
:
secureElement
.
Channel
=
null
;
@
State
nfcOmaChannel
:
secureElement
.
Channel
=
null
;
aidArray
:
number
[]
=
[
720
,
1080
]
aidArray
:
number
[]
=
[
720
,
1080
]
;
p2
:
number
=
0x00
p2
:
number
=
0x00
;
try
{
try
{
//
this.nfcOmaSession:有效的Session,获取方式参考Reader.open
Session
//
refer to Reader.openSession for this.nfcOma
Session
this
.
nfcOmaSession
.
openLogicalChannel
(
this
.
aidArray
,
this
.
p2
,
(
error
,
data
)
=>
{
this
.
nfcOmaSession
.
openLogicalChannel
(
this
.
aidArray
,
this
.
p2
,
(
error
,
data
)
=>
{
if
(
error
)
{
if
(
error
)
{
this
.
result
=
"
openLogicChannel4
失败:
"
+
JSON
.
stringify
(
error
);
this
.
result
=
"
openLogicChannel4
failed:
"
+
JSON
.
stringify
(
error
);
return
;
return
;
}
}
this
.
nfcOmaChannel
=
data
;
this
.
nfcOmaChannel
=
data
;
this
.
result
=
"
openLogicChannel4
获取channel成功
"
;
this
.
result
=
"
openLogicChannel4
get channel successfully
"
;
})
})
}
catch
(
e
)
{
}
catch
(
e
)
{
this
.
result
=
"
openLogicChannel4
异常
:
"
+
e
.
message
;
this
.
result
=
"
openLogicChannel4
exception
:
"
+
e
.
message
;
}
}
```
```
## Channel. getSession
## Channel. getSession
getSession():
[
Session
](
#Session
)
getSession(): Session
获取打开该channel的
[
Session
](
#Session
)
对象。
> **说明:**
获取打开该channel的Session对象。
> 从 API version 10 开始支持。
**系统能力:**
SystemCapability.Communication.SecureElement
**系统能力:**
SystemCapability.Communication.SecureElement
**返回值:**
**返回值:**
|
**类型**
|
**说明**
|
|
**类型**
|
**说明**
|
| ------------------- | --------------------------------------- |
| ------------------- | ----------------------------- |
|
[
Session
](
#Session
)
| 该channel绑定的
[
Session
](
#Session
)
对象 |
|
[
Session
](
#Session
)
| 该channel绑定的Session 对象。 |
**错误码:**
错误码的详细介绍请参见
[
SE错误码
](
../errorcodes/errorcode-se.md
)
。
**示例:**
**示例:**
```
js
```
js
import
secureElement
from
'
@ohos.secureElement
'
;
import
secureElement
from
'
@ohos.secureElement
'
;
@
State
result
:
string
=
''
@
State
result
:
string
=
''
;
@
State
nfcOmaSession
:
secureElement
.
Session
=
null
;
@
State
nfcOmaSession
:
secureElement
.
Session
=
null
;
@
State
nfcOmaChannel
:
secureElement
.
Channel
=
null
;
@
State
nfcOmaChannel
:
secureElement
.
Channel
=
null
;
try
{
try
{
//
this.nfcOmaSession:有效的Session,获取方式参考Reader.openSession
//
refer to Session.openBasicChannel for this.nfcOmaChannel
let
ret
=
this
.
nfcOmaChannel
.
getSession
();
let
ret
=
this
.
nfcOmaChannel
.
getSession
();
if
(
ret
)
{
if
(
ret
)
{
this
.
result
=
"
获取到session对象
"
;
this
.
result
=
"
get session successfully
"
;
}
else
{
}
else
{
this
.
result
=
"
无法获取到session对象
"
;
this
.
result
=
"
get session failed
"
;
}
}
}
catch
(
e
)
{
}
catch
(
e
)
{
this
.
result
=
"
getSession
异常
:
"
+
e
.
message
;
this
.
result
=
"
getSession
exception
:
"
+
e
.
message
;
}
}
```
```
...
@@ -1180,38 +1038,25 @@ try {
...
@@ -1180,38 +1038,25 @@ try {
close(): void
close(): void
关闭与SE的此channel
关闭与SE的此channel。
> **说明:**
> 从 API version 10 开始支持。
**系统能力:**
SystemCapability.Communication.SecureElement
**系统能力:**
SystemCapability.Communication.SecureElement
**返回值:**
|
**类型**
|
**说明**
|
| ------------ | -------- |
| 失败抛出异常 |
**错误码:**
错误码的详细介绍请参见
[
SE错误码
](
../errorcodes/errorcode-se.md
)
。
**示例:**
**示例:**
```
js
```
js
import
secureElement
from
'
@ohos.secureElement
'
;
import
secureElement
from
'
@ohos.secureElement
'
;
@
State
result
:
string
=
''
@
State
result
:
string
=
''
;
@
State
nfcOmaSession
:
secureElement
.
Session
=
null
;
@
State
nfcOmaSession
:
secureElement
.
Session
=
null
;
@
State
nfcOmaChannel
:
secureElement
.
Channel
=
null
;
@
State
nfcOmaChannel
:
secureElement
.
Channel
=
null
;
try
{
try
{
//
this.nfcOmaChannel:获取方式参考Session.openBasic
Channel
//
refer to Session.openBasicChannel for this.nfcOma
Channel
this
.
nfcOmaChannel
.
close
();
this
.
nfcOmaChannel
.
close
();
this
.
result
=
"
channel close
成功
"
;
this
.
result
=
"
channel close
successfully
"
;
}
catch
(
e
)
{
}
catch
(
e
)
{
this
.
result
=
"
channel close
异常
:
"
+
e
.
message
;
this
.
result
=
"
channel close
exception
:
"
+
e
.
message
;
}
}
```
```
...
@@ -1219,33 +1064,26 @@ try {
...
@@ -1219,33 +1064,26 @@ try {
isBasicChannel(): boolean
isBasicChannel(): boolean
检查该channel是否为基本channel
检查该channel是否为基本channel。
> **说明:**
> 从 API version 10 开始支持。
**系统能力:**
SystemCapability.Communication.SecureElement
**系统能力:**
SystemCapability.Communication.SecureElement
**返回值:**
**返回值:**
|
**类型**
|
**说明**
|
|
**类型**
|
**说明**
|
| -------- | ---------------------------------------------- |
| -------- | ------------------------------------------------------------ |
| boolean | true:如果该channel是基本channel,否则返回false |
| boolean | true: 该channel是基本channel false:该channel不是基本channel 。 |
**错误码:**
错误码的详细介绍请参见
[
SE错误码
](
../errorcodes/errorcode-se.md
)
。
**示例:**
**示例:**
```
js
```
js
import
secureElement
from
'
@ohos.secureElement
'
;
import
secureElement
from
'
@ohos.secureElement
'
;
@
State
result
:
string
=
''
@
State
result
:
string
=
''
;
@
State
nfcOmaChannel
:
secureElement
.
Channel
=
null
;
@
State
nfcOmaChannel
:
secureElement
.
Channel
=
null
;
try
{
try
{
//
this.nfcOmaChannel:获取方式参考Session.openBasic
Channel
//
refer to Session.openBasicChannel for this.nfcOma
Channel
let
ret
=
this
.
nfcOmaChannel
.
isBasicChannel
();
let
ret
=
this
.
nfcOmaChannel
.
isBasicChannel
();
if
(
ret
)
{
if
(
ret
)
{
this
.
result
=
"
isBasicChannel TRUE
"
;
this
.
result
=
"
isBasicChannel TRUE
"
;
...
@@ -1263,31 +1101,24 @@ isClosed(): boolean
...
@@ -1263,31 +1101,24 @@ isClosed(): boolean
检查该channel是否为closed。
检查该channel是否为closed。
> **说明:**
> 从 API version 10 开始支持。
**系统能力:**
SystemCapability.Communication.SecureElement
**系统能力:**
SystemCapability.Communication.SecureElement
**返回值:**
**返回值:**
|
**类型**
|
**说明**
|
|
**类型**
|
**说明**
|
| -------- | ----------------------------------------- |
| -------- | --------------------------------------------- |
| boolean | true:如果该channel是closed,否则返回false |
| boolean | true:channel是closed false: 不是closed状态。 |
**错误码:**
错误码的详细介绍请参见
[
SE错误码
](
../errorcodes/errorcode-se.md
)
。
**示例:**
**示例:**
```
js
```
js
import
secureElement
from
'
@ohos.secureElement
'
;
import
secureElement
from
'
@ohos.secureElement
'
;
@
State
result
:
string
=
''
@
State
result
:
string
=
''
;
@
State
nfcOmaChannel
:
secureElement
.
Channel
=
null
;
@
State
nfcOmaChannel
:
secureElement
.
Channel
=
null
;
try
{
try
{
//
this.nfcOmaChannel:获取方式参考Session.openBasic
Channel
//
refer to Session.openBasicChannel for this.nfcOma
Channel
let
ret
=
this
.
nfcOmaChannel
.
isClosed
();
let
ret
=
this
.
nfcOmaChannel
.
isClosed
();
if
(
ret
)
{
if
(
ret
)
{
this
.
result
=
"
channel isClosed TRUE
"
;
this
.
result
=
"
channel isClosed TRUE
"
;
...
@@ -1295,7 +1126,7 @@ try {
...
@@ -1295,7 +1126,7 @@ try {
this
.
result
=
"
channel isClosed False
"
;
this
.
result
=
"
channel isClosed False
"
;
}
}
}
catch
(
e
)
{
}
catch
(
e
)
{
this
.
result
=
"
Channel isClosed
异常:
"
+
e
.
message
;
this
.
result
=
"
Channel isClosed
exception:
"
+
e
.
message
;
}
}
```
```
...
@@ -1305,9 +1136,6 @@ getSelectResponse():number[]
...
@@ -1305,9 +1136,6 @@ getSelectResponse():number[]
返回从应用程序选择命令接收的数据,包括在applet选择时接收的状态字。
返回从应用程序选择命令接收的数据,包括在applet选择时接收的状态字。
> **说明:**
> 从 API version 10 开始支持。
**系统能力:**
SystemCapability.Communication.SecureElement
**系统能力:**
SystemCapability.Communication.SecureElement
**返回值:**
**返回值:**
...
@@ -1325,24 +1153,24 @@ getSelectResponse():number[]
...
@@ -1325,24 +1153,24 @@ getSelectResponse():number[]
```
js
```
js
import
secureElement
from
'
@ohos.secureElement
'
;
import
secureElement
from
'
@ohos.secureElement
'
;
@
State
result
:
string
=
''
@
State
result
:
string
=
''
;
@
State
nfcOmaChannel
:
secureElement
.
Channel
=
null
;
@
State
nfcOmaChannel
:
secureElement
.
Channel
=
null
;
try
{
try
{
//
this.nfcOmaChannel:获取方式参考Session.openBasic
Channel
//
refer to Session.openBasicChannel for this.nfcOma
Channel
let
ret
=
this
.
nfcOmaChannel
.
getSelectResponse
();
let
ret
=
this
.
nfcOmaChannel
.
getSelectResponse
();
if
(
ret
)
{
if
(
ret
)
{
this
.
result
=
"
getSelectResponse
结果
:[
"
;
this
.
result
=
"
getSelectResponse
result
:[
"
;
for
(
let
i
=
0
;
i
<
ret
.
length
;
++
i
)
{
for
(
let
i
=
0
;
i
<
ret
.
length
;
++
i
)
{
this
.
result
+=
ret
[
i
];
this
.
result
+=
ret
[
i
];
this
.
result
+=
'
'
;
this
.
result
+=
'
'
;
}
}
this
.
result
+=
'
]
'
this
.
result
+=
'
]
'
;
}
else
{
}
else
{
this
.
result
=
"
getSelectResponse
结果为空
"
this
.
result
=
"
getSelectResponse
result is null
"
;
}
}
}
catch
(
e
)
{
}
catch
(
e
)
{
this
.
result
=
"
getSelectResponse
异常:
"
+
e
.
message
;
this
.
result
=
"
getSelectResponse
exception:
"
+
e
.
message
;
}
}
```
```
...
@@ -1350,10 +1178,7 @@ try {
...
@@ -1350,10 +1178,7 @@ try {
transmit(command: number[]): Promise
<number
[]
>
transmit(command: number[]): Promise
<number
[]
>
向SE发送APDU命令(根据ISO/IEC 7816)
向SE发送APDU命令(根据ISO/IEC 7816)。
> **说明:**
> 从 API version 10 开始支持。
**系统能力:**
SystemCapability.Communication.SecureElement
**系统能力:**
SystemCapability.Communication.SecureElement
...
@@ -1366,8 +1191,8 @@ transmit(command: number[]): Promise<number[]>
...
@@ -1366,8 +1191,8 @@ transmit(command: number[]): Promise<number[]>
**返回值:**
**返回值:**
|
**类型**
|
**说明**
|
|
**类型**
|
**说明**
|
| -------- | ------------ |
| -------- | ------------
--
|
| number[] | 响应结果数组 |
| number[] | 响应结果数组
。
|
**错误码:**
**错误码:**
...
@@ -1384,25 +1209,25 @@ transmit(command: number[]): Promise<number[]>
...
@@ -1384,25 +1209,25 @@ transmit(command: number[]): Promise<number[]>
```
js
```
js
import
secureElement
from
'
@ohos.secureElement
'
;
import
secureElement
from
'
@ohos.secureElement
'
;
@
State
result
:
string
=
''
@
State
result
:
string
=
''
;
@
State
nfcOmaChannel
:
secureElement
.
Channel
=
null
;
@
State
nfcOmaChannel
:
secureElement
.
Channel
=
null
;
try
{
try
{
let
command
:
number
[]
=
[
100
,
200
]
let
command
:
number
[]
=
[
100
,
200
]
;
//
this.nfcOmaChannel:获取方式参考Session.openBasic
Channel
//
refer to Session.openBasicChannel for this.nfcOma
Channel
let
getPromise
=
this
.
nfcOmaChannel
.
transmit
(
command
);
let
getPromise
=
this
.
nfcOmaChannel
.
transmit
(
command
);
getPromise
.
then
((
data
)
=>
{
getPromise
.
then
((
data
)
=>
{
this
.
result
=
"
transmit1
结果
:[
"
;
this
.
result
=
"
transmit1
result
:[
"
;
for
(
let
i
=
0
;
i
<
data
.
length
;
++
i
)
{
for
(
let
i
=
0
;
i
<
data
.
length
;
++
i
)
{
this
.
result
+=
data
[
i
];
this
.
result
+=
data
[
i
];
this
.
result
+=
"
"
;
this
.
result
+=
"
"
;
}
}
this
.
result
+=
"
]
"
;
this
.
result
+=
"
]
"
;
}).
catch
((
err
)
=>
{
}).
catch
((
err
)
=>
{
this
.
result
=
"
transmit1
出现异常
:
"
+
err
.
code
;
this
.
result
=
"
transmit1
exception
:
"
+
err
.
code
;
})
})
}
catch
(
e
)
{
}
catch
(
e
)
{
this
.
result
=
"
transit1
调用异常:
"
+
e
.
message
;
this
.
result
=
"
transit1
exception:
"
+
e
.
message
;
}
}
```
```
...
@@ -1410,10 +1235,7 @@ try {
...
@@ -1410,10 +1235,7 @@ try {
transmit(command: number[], callback: AsyncCallback
<number
[]
>
): void
transmit(command: number[], callback: AsyncCallback
<number
[]
>
): void
向SE发送APDU命令(根据ISO/IEC 7816)
向SE发送APDU命令(根据ISO/IEC 7816)。
> **说明:**
> 从 API version 10 开始支持。
**系统能力:**
SystemCapability.Communication.SecureElement
**系统能力:**
SystemCapability.Communication.SecureElement
...
@@ -1422,13 +1244,7 @@ transmit(command: number[], callback: AsyncCallback<number[]>): void
...
@@ -1422,13 +1244,7 @@ transmit(command: number[], callback: AsyncCallback<number[]>): void
|
**参数名**
|
**类型**
|
**说明**
|
|
**参数名**
|
**类型**
|
**说明**
|
| ---------- | ----------------------- | ------------------------------------- |
| ---------- | ----------------------- | ------------------------------------- |
| command | number[] | 在该Channel上被选择的applet AID数组。 |
| command | number[] | 在该Channel上被选择的applet AID数组。 |
| callback | AsyncCallback
<number
[]
>
| 返回接收到的响应的回调,number数组 |
| callback | AsyncCallback
<number
[]
>
| 返回接收到的响应的回调,number数组。 |
**返回值:**
|
**类型**
|
**说明**
|
| -------- | ------------ |
| void | 出错抛出异常 |
**错误码:**
**错误码:**
...
@@ -1445,18 +1261,18 @@ transmit(command: number[], callback: AsyncCallback<number[]>): void
...
@@ -1445,18 +1261,18 @@ transmit(command: number[], callback: AsyncCallback<number[]>): void
```
js
```
js
import
secureElement
from
'
@ohos.secureElement
'
;
import
secureElement
from
'
@ohos.secureElement
'
;
@
State
result
:
string
=
''
@
State
result
:
string
=
''
;
@
State
nfcOmaChannel
:
secureElement
.
Channel
=
null
;
@
State
nfcOmaChannel
:
secureElement
.
Channel
=
null
;
try
{
try
{
let
command
:
number
[]
=
[
100
,
200
];
let
command
:
number
[]
=
[
100
,
200
];
//
this.nfcOmaChannel:获取方式参考Session.openBasic
Channel
//
refer to Session.openBasicChannel for this.nfcOma
Channel
this
.
nfcOmaChannel
.
transmit
(
command
,
(
error
,
data
)
=>
{
this
.
nfcOmaChannel
.
transmit
(
command
,
(
error
,
data
)
=>
{
if
(
error
)
{
if
(
error
)
{
this
.
result
=
"
transmit2
异常:
"
+
JSON
.
stringify
(
error
);
this
.
result
=
"
transmit2
exception:
"
+
JSON
.
stringify
(
error
);
return
;
return
;
}
}
this
.
result
=
"
transmit2
结果:
[
"
;
this
.
result
=
"
transmit2
result:
[
"
;
for
(
let
i
=
0
;
i
<
data
.
length
;
++
i
)
{
for
(
let
i
=
0
;
i
<
data
.
length
;
++
i
)
{
this
.
result
+=
data
[
i
];
this
.
result
+=
data
[
i
];
this
.
result
+=
"
"
;
this
.
result
+=
"
"
;
...
@@ -1464,24 +1280,6 @@ try {
...
@@ -1464,24 +1280,6 @@ try {
this
.
result
+=
"
]
"
;
this
.
result
+=
"
]
"
;
});
});
}
catch
(
e
)
{
}
catch
(
e
)
{
this
.
result
=
"
transit2
调用异常:
"
+
e
.
message
;
this
.
result
=
"
transit2
exception:
"
+
e
.
message
;
}
}
```
```
# SE Tech [ISO/IEC 7816-4]
## SEService
SEService实现与设备上可用的SE的通信。
## Reader
此类的实例表示该设备支持的SE Reader。
## Session
此类的实例表示与设备上可用的某个SE的连接会话。
## Channel
此类的实例表示向SE打开的ISO/IEC 7816-4通道。
zh-cn/application-dev/reference/errorcodes/errorcode-se.md
浏览文件 @
2d0f8b70
...
@@ -4,7 +4,7 @@
...
@@ -4,7 +4,7 @@
>
>
> 以下仅介绍本模块特有错误码,通用错误码请参考[通用错误码说明文档](errorcode-universal.md)。
> 以下仅介绍本模块特有错误码,通用错误码请参考[通用错误码说明文档](errorcode-universal.md)。
## 3
1
00101
## 3
3
00101
**错误信息**
**错误信息**
...
@@ -12,17 +12,17 @@ Illegal service state exception.
...
@@ -12,17 +12,17 @@ Illegal service state exception.
**错误描述**
**错误描述**
SE
Service服务状态异常
SE
服务状态异常。
**可能原因**
**可能原因**
1.
SE
Service状态已断开
1.
SE
服务状态已断开。
**处理步骤**
**处理步骤**
1.
重新执行打开或关闭SE服务。
1.
关闭SE服务。
2.
重新和SE服务建立连接。
## 3300102
## 3300102
...
@@ -32,7 +32,7 @@ No such element exception.
...
@@ -32,7 +32,7 @@ No such element exception.
**错误描述**
**错误描述**
没有这样的SE异常
没有这样的SE异常
。
**可能原因**
**可能原因**
...
@@ -41,7 +41,7 @@ No such element exception.
...
@@ -41,7 +41,7 @@ No such element exception.
**处理步骤**
**处理步骤**
1.
重新执行打开或关闭SE
。
1.
关闭SE服务后重新建立连接
。
2.
重启设备尝试。
2.
重启设备尝试。
## 3300103
## 3300103
...
@@ -56,12 +56,12 @@ Illegal access rule exception.
...
@@ -56,12 +56,12 @@ Illegal access rule exception.
**可能原因**
**可能原因**
1.
无可用的channel
。
1.
安全单元上没有应用所依赖的访问规则
。
**处理步骤**
**处理步骤**
1.
释放已经连接的Channel
。
1.
写入正确的访问规则到安全单元上
。
2.
重启设备尝试
。
2.
关闭SE服务后重新建立连接
。
## 3300104
## 3300104
...
@@ -71,7 +71,7 @@ Secure element IO exception.
...
@@ -71,7 +71,7 @@ Secure element IO exception.
**错误描述**
**错误描述**
SE芯片IO异常
SE芯片IO异常
。
**可能原因**
**可能原因**
...
@@ -80,8 +80,6 @@ SE芯片IO异常
...
@@ -80,8 +80,6 @@ SE芯片IO异常
**处理步骤**
**处理步骤**
1.
重启设备尝试。
1.
关闭SE服务后重新建立连接。
2.
重新执行打开或关闭SE。
2.
重启设备尝试。
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录