• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# @ohos.secureElement (SE Management)
2
3The **secureElement** module provides APIs for managing secure elements (SEs). SEs include the Embedded SE (eSE) and SIM on a device. The SE service mentioned in this topic is an **SEService** instance. For details, see [newSEService](#omapinewseservice).
4
5The instances of the following types are mentioned in this topic:
6
7| Type   | Description                                          |
8| ------- | ---------------------------------------------- |
9| Reader  | SE supported by the device. If eSE and SIM are supported, two instances will be returned.|
10| Session | Session created on an SE **Reader** instance.|
11| Channel | Channel set up by a **Session** instance. The channel can be a basic channel or a logical channel.  |
12
13> **NOTE**
14>
15> The initial APIs of this module are supported since API version 10. Newly added APIs will be marked with a superscript to indicate their earliest API version.
16
17## **Modules to Import**
18
19```js
20import { omapi } from '@kit.ConnectivityKit';
21```
22
23## ServiceState
24
25Enumerates the SE service states.
26
27**System capability**: SystemCapability.Communication.SecureElement
28
29| Name        | Value  | Description              |
30| ------------ | ---- | ------------------ |
31| DISCONNECTED | 0    | The SE service is disconnected.|
32| CONNECTED    | 1    | The SE service is connected.|
33
34## omapi.newSEService
35
36newSEService(type: 'serviceState', callback: Callback\<ServiceState>): SEService
37
38Creates an **SEService** instance for connecting to all available SEs in the system. The connection is time-consuming. Therefore, this API supports only the asynchronous mode. This API uses an asynchronous callback to return the result.
39
40The returned **SEService** instance is available only when **true** is returned by the specified callback or [isConnected](#seserviceisconnected).
41
42> **NOTE**
43> This API is supported since API version 10 and deprecated since API version 12. Use [createService](#omapicreateservice12) instead.
44
45**System capability**: SystemCapability.Communication.SecureElement
46
47**Parameters**
48
49| **Name**| **Type**                                            | **Mandatory**| **Description**            |
50| ---------- | ---------------------------------------------------- | ------ | -------------------- |
51| type       | string                                               | Yes     | Type of the SE service to create. It has a fixed value of **'serviceState'**.     |
52| callback   | Callback<[ServiceState](#servicestate)> | Yes     | Callback used to return the SE service state.|
53
54**Return value**
55
56| **Type** | **Description**  |
57| -------- | --------- |
58| SEService | **SEService** instance created.|
59
60**Error codes**
61
62For details about error codes, see [SE Error Codes](errorcode-se.md).
63
64| ID| Error Message|
65| ------- | -------|
66| 401  | The parameter check failed. Possible causes: <br>1. Mandatory parameters are left unspecified.<br>2. Incorrect parameters types.<br>3. Parameter verification failed. |
67| 801  | Capability not supported. |
68
69**Example**
70
71```js
72import { omapi } from '@kit.ConnectivityKit';
73import { hilog } from '@kit.PerformanceAnalysisKit';
74
75let seService : omapi.SEService;
76
77function secureElementDemo() {
78    // Obtain the service.
79    try {
80        seService = omapi.newSEService("serviceState", (state) => {
81        hilog.info(0x0000, 'testTag', 'se service state = %{public}s', JSON.stringify(state));
82        });
83    } catch (error) {
84        hilog.error(0x0000, 'testTag', 'newSEService error %{public}s', JSON.stringify(error));
85    }
86    if (seService == undefined || !seService.isConnected()) {
87        hilog.error(0x0000, 'testTag', 'secure element service disconnected.');
88        return;
89    }
90}
91```
92
93## omapi.createService<sup>12+</sup>
94
95createService(): Promise\<SEService>;
96
97Creates an **SEService** instance for connecting to all available SEs in the system. The connection is time-consuming. Therefore, only asynchronous APIs are provided. This API uses a promise to return the result.
98
99The **SEService** object is available only when [isConnected](#seserviceisconnected) returns **true**.
100
101**System capability**: SystemCapability.Communication.SecureElement
102
103**Return value**
104
105| **Type** | **Description**  |
106| :-------- | :--------- |
107| Promise\<[SEService](#seservice)> | Promise used to return the **SEService** instance created.|
108
109**Error codes**
110
111For details about error codes, see [SE Error Codes](errorcode-se.md).
112
113| ID| Error Message                                 |
114| -------- | ----------------------------------------- |
115| 801  | Capability not supported. |
116
117**Example**
118
119```js
120import { omapi } from '@kit.ConnectivityKit';
121import { BusinessError } from '@kit.BasicServicesKit';
122import { hilog } from '@kit.PerformanceAnalysisKit';
123
124let seService : omapi.SEService;
125
126function secureElementDemo() {
127    omapi.createService().then((data) => {
128        seService = data;
129        if (seService == undefined || !seService.isConnected()) {
130            hilog.error(0x0000, 'testTag', 'seservice state disconnected');
131            return;
132        }
133        hilog.info(0x0000, 'testTag', 'seservice state connected');
134    }).catch((error : BusinessError)=> {
135        hilog.error(0x0000, 'testTag', 'createService error %{public}s', JSON.stringify(error));
136    });
137}
138```
139
140## omapi.on<sup>18+</sup>
141
142on(type: 'stateChanged', callback: Callback\<ServiceState>): void;
143
144Enables listening for service status change events.
145
146Call this API to register a callback after you use [omapi.newSEService](#omapinewseservice) or [omapi.createService](#omapicreateservice12) to create a service.
147
148**System capability**: SystemCapability.Communication.SecureElement
149
150**Parameters**
151
152| **Name**| **Type**                                            | **Mandatory**| **Description**            |
153| ---------- | ---------------------------------------------------- | ------ | -------------------- |
154| type       | string                                               | Yes     | Event type. It has a fixed value of **serviceState**.     |
155| callback   | Callback<[ServiceState](#servicestate)> | Yes     | Callback used to return the SE service state.|
156
157**Error codes**
158
159For details about error codes, see [SE Error Codes](errorcode-se.md).
160
161| ID| Error Message                                 |
162| -------- | ----------------------------------------- |
163| 401  | Invalid parameter.        |
164| 801  | Capability not supported. |
165
166**Example**
167
168See the sample code in [off](#omapioff18).
169
170## omapi.off<sup>18+</sup>
171
172off(type: 'stateChanged', callback?: Callback\<ServiceState>): void;
173
174Disables listening for service status change events.
175
176**System capability**: SystemCapability.Communication.SecureElement
177
178**Parameters**
179
180| **Name**| **Type**                                            | **Mandatory**| **Description**            |
181| ---------- | ---------------------------------------------------- | ------ | -------------------- |
182| type       | string                                               | Yes     | Event type. It has a fixed value of **serviceState**.     |
183| callback   | Callback<[ServiceState](#servicestate)> | No     | Callback used to return the SE service state.|
184
185**Error codes**
186
187For details about error codes, see [SE Error Codes](errorcode-se.md).
188
189| ID| Error Message                                 |
190| -------- | ----------------------------------------- |
191| 401  | Invalid parameter.        |
192| 801  | Capability not supported. |
193
194**Example**
195
196```js
197import { omapi } from '@kit.ConnectivityKit';
198import { BusinessError } from '@kit.BasicServicesKit';
199import { hilog } from '@kit.PerformanceAnalysisKit';
200
201let seService: omapi.SEService;
202function seStateOnCb(data: omapi.ServiceState) {
203    console.log("omapi.on ServiceState: ", data);
204}
205
206function seStateOffCb(data: omapi.ServiceState) {
207    console.log("omapi.off ServiceState: ", data);
208}
209
210function secureElementDemo() {
211    try{
212        omapi.createService().then((data) => {
213            seService = data;
214            if (seService == undefined || !seService.isConnected()) {
215                hilog.error(0x0000, 'testTag', 'seservice state disconnected');
216                return;
217            }
218            hilog.info(0x0000, 'testTag', 'seservice state connected');
219        }).catch((error : BusinessError)=> {
220            hilog.error(0x0000, 'testTag', 'createService error %{public}s', JSON.stringify(error));
221        });
222        omapi.on('stateChanged', seStateOnCb);
223    } catch (error) {
224        if (error as BusinessError) {
225            console.error(`omapi on error catch Code: ${(error as BusinessError).code}, ` + `message: ${(error as BusinessError).message}`);
226        }
227    }
228    try{
229        omapi.off('stateChanged', seStateOffCb);
230    } catch (error) {
231        if (error as BusinessError) {
232            console.error(`omapi off error catch Code: ${(error as BusinessError).code}, ` + `message: ${(error as BusinessError).message}`);
233        }
234    }
235}
236```
237
238## SEService
239
240**SEService** indicates the connection service used to connect to all available SEs in the system. You can use [createService](#omapicreateservice12) to create an **SEService** instance.
241
242### SEService.getReaders
243
244getReaders(): Reader[]
245
246Obtains available SE readers, which include all the SEs on the device.
247
248**System capability**: SystemCapability.Communication.SecureElement
249
250**Return value**
251
252| **Type**| **Description**              |
253| :------- | :--------------------- |
254| [Reader](#reader)[] | Available readers obtained.|
255
256**Error codes**
257
258For details about error codes, see [SE Error Codes](errorcode-se.md).
259
260| ID| Error Message                                 |
261| -------- | ----------------------------------------- |
262| 801  | Capability not supported. |
263
264**Example**
265
266<!--code_no_check-->
267```js
268import { omapi } from '@kit.ConnectivityKit';
269import { hilog } from '@kit.PerformanceAnalysisKit';
270
271let seService : omapi.SEService;
272let seReaders : omapi.Reader[];
273
274// Initialize seService before using it.
275function secureElementDemo() {
276    // Obtain readers.
277    try {
278        seReaders = seService.getReaders();
279    } catch (error) {
280        hilog.error(0x0000, 'testTag', 'getReaders error %{public}s', JSON.stringify(error));
281    }
282    if (seReaders == undefined || seReaders.length == 0) {
283        hilog.error(0x0000, 'testTag', 'no valid reader found.');
284        return;
285    }
286}
287```
288
289### SEService.isConnected
290
291isConnected(): boolean
292
293Checks whether this SE service is connected.
294
295**System capability**: SystemCapability.Communication.SecureElement
296
297**Return value**
298
299| **Type**| **Description**                                      |
300| :------- | :--------------------------------------------- |
301| boolean  | **true** if the SE service is connected; **false** otherwise.|
302
303**Error codes**
304
305For details about error codes, see [SE Error Codes](errorcode-se.md).
306
307| ID| Error Message                                 |
308| -------- | ----------------------------------------- |
309| 801  | Capability not supported. |
310
311**Example**
312
313
314```JS
315import { omapi } from '@kit.ConnectivityKit';
316import { BusinessError } from '@kit.BasicServicesKit';
317import { hilog } from '@kit.PerformanceAnalysisKit';
318
319let seService : omapi.SEService;
320
321function secureElementDemo() {
322    // Obtain the service.
323    try {
324        seService = omapi.newSEService("serviceState", (state) => {
325        hilog.info(0x0000, 'testTag', 'se service state = %{public}s', JSON.stringify(state));
326        });
327    } catch (error) {
328        hilog.error(0x0000, 'testTag', 'newSEService error %{public}s', JSON.stringify(error));
329    }
330    if (seService == undefined || !seService.isConnected()) {
331        hilog.error(0x0000, 'testTag', 'secure element service disconnected.');
332        return;
333    }
334}
335```
336
337### SEService.shutdown
338
339shutdown(): void
340
341Releases all SE resources allocated to this SE service. After that, [isConnected](#seserviceisconnected) returns **false**.
342
343**System capability**: SystemCapability.Communication.SecureElement
344
345**Error codes**
346
347For details about error codes, see [SE Error Codes](errorcode-se.md).
348
349| ID| Error Message                                 |
350| -------- | ----------------------------------------- |
351| 801  | Capability not supported. |
352
353**Example**
354
355<!--code_no_check-->
356```js
357import { omapi } from '@kit.ConnectivityKit';
358import { BusinessError } from '@kit.BasicServicesKit';
359import { hilog } from '@kit.PerformanceAnalysisKit';
360
361let seService : omapi.SEService;
362
363// Initialize seService before using it.
364
365try {
366    seService.shutdown();
367} catch (error) {
368    hilog.error(0x0000, 'testTag', 'shutdown error %{public}s', JSON.stringify(error));
369}
370```
371
372### SEService.getVersion
373
374getVersion(): string
375
376Obtains the version of the Open Mobile API (OMAPI) specification used.
377
378**System capability**: SystemCapability.Communication.SecureElement
379
380**Return value**
381
382| **Type**| **Description**                                          |
383| -------- | -------------------------------------------------- |
384| string   | OMAPI version obtained. For example, **3.3** indicates Open Mobile API Specification v3.3.|
385
386**Error codes**
387
388For details about error codes, see [SE Error Codes](errorcode-se.md).
389
390| ID| Error Message                                 |
391| -------- | ----------------------------------------- |
392| 801  | Capability not supported. |
393
394**Example**
395
396<!--code_no_check-->
397```JS
398import { omapi } from '@kit.ConnectivityKit';
399import { BusinessError } from '@kit.BasicServicesKit';
400import { hilog } from '@kit.PerformanceAnalysisKit';
401
402let seService : omapi.SEService;
403
404// Initialize seService before using it.
405
406try {
407    let version = seService.getVersion();
408    hilog.error(0x0000, 'testTag', 'version %{public}s', JSON.stringify(version));
409} catch (error) {
410    hilog.error(0x0000, 'testTag', 'getVersion error %{public}s', JSON.stringify(error));
411}
412```
413## Reader
414
415A **Reader** instance indicates the SEs supported by a device. If eSE and SIM are supported, two instances will be returned. You can use [SEService.getReaders](#seservicegetreaders) to obtain a **Reader** instance.
416
417### Reader.getName
418
419getName(): string
420
421Obtains the name of this reader. The name is **SIM** for a SIM reader and **eSE** for an eSE.
422
423**System capability**: SystemCapability.Communication.SecureElement
424
425**Return value**
426
427| **Type**| **Description**  |
428| -------- | ---------- |
429| string   | [Reader](#reader) name obtained.|
430
431**Error codes**
432
433For details about the error codes, see [NFC Error Codes](errorcode-nfc.md).
434
435| ID| Error Message                                 |
436| -------- | ----------------------------------------- |
437| 801  | Capability not supported. |
438
439**Example**
440
441<!--code_no_check-->
442```js
443import { hilog } from '@kit.PerformanceAnalysisKit';
444import { omapi } from '@kit.ConnectivityKit';
445
446let seReaders : omapi.Reader[];
447
448// Initialize seReaders before using it.
449
450try {
451    let reader = seReaders[0]; // Set the expected reader (ese or sim).
452    let name = reader.getName();
453    hilog.info(0x0000, 'testTag', 'name %{public}s', JSON.stringify(name));
454} catch (error) {
455    hilog.error(0x0000, 'testTag', 'getName error %{public}s', JSON.stringify(error));
456}
457```
458
459### Reader.isSecureElementPresent
460
461isSecureElementPresent(): boolean
462
463Checks whether the SE corresponding to this reader is available.
464
465**System capability**: SystemCapability.Communication.SecureElement
466
467**Return value**
468
469| **Type**| **Description**                                    |
470| -------- | -------------------------------------------- |
471| boolean  | **true** if the SE is available; **false** otherwise.|
472
473**Error codes**
474
475For details about error codes, see [SE Error Codes](errorcode-se.md).
476
477| ID| Error Message                        |
478| -------- | -------------------------------- |
479| 801  | Capability not supported. |
480| 3300101  | IllegalStateError, service state exception. |
481
482**Example**
483
484<!--code_no_check-->
485```js
486import { hilog } from '@kit.PerformanceAnalysisKit';
487import { omapi } from '@kit.ConnectivityKit';
488
489let seReaders : omapi.Reader[];
490
491// Initialize seReaders before using it.
492
493try {
494    let reader = seReaders[0]; // Set the expected reader (ese or sim).
495    let isPresent = reader.isSecureElementPresent();
496    hilog.info(0x0000, 'testTag', 'isPresent %{public}s', JSON.stringify(isPresent));
497} catch (error) {
498    hilog.error(0x0000, 'testTag', 'isSecureElementPresent error %{public}s', JSON.stringify(error));
499}
500```
501
502### Reader.openSession
503
504 openSession(): Session
505
506Opens a session to connect to an SE in this reader. Multiple sessions can be opened on a reader at the same time.
507
508**System capability**: SystemCapability.Communication.SecureElement
509
510**Return value**
511
512| **Type**| **Description**                      |
513| -------- | ------------------------------ |
514| [Session](#session)  | Session instance opened.|
515
516**Error codes**
517
518For details about error codes, see [SE Error Codes](errorcode-se.md).
519
520| ID| Error Message                        |
521| -------- | -------------------------------- |
522| 801  | Capability not supported. |
523| 3300101  | IllegalStateError, service state exception. |
524| 3300104  | IOError, there is a communication problem to the reader or the SE.     |
525
526**Example**
527
528<!--code_no_check-->
529```js
530import { hilog } from '@kit.PerformanceAnalysisKit';
531import { omapi } from '@kit.ConnectivityKit';
532
533let seReaders : omapi.Reader[];
534let seSession : omapi.Session;
535
536// Initialize seReaders before using it.
537function secureElementDemo() {
538    try {
539        let reader = seReaders[0]; // Set the expected reader (ese or sim).
540        seSession = reader.openSession();
541    } catch (error) {
542        hilog.error(0x0000, 'testTag', 'openSession error %{public}s', JSON.stringify(error));
543    }
544    if (seSession == undefined) {
545        hilog.error(0x0000, 'testTag', 'seSession invalid.');
546        return;
547    }
548}
549```
550
551### Reader.closeSessions
552
553 closeSessions(): void
554
555Closes all sessions opened on this reader. All channels opened by these sessions will be closed.
556
557**System capability**: SystemCapability.Communication.SecureElement
558
559**Error codes**
560
561For details about error codes, see [SE Error Codes](errorcode-se.md).
562
563| ID| Error Message                        |
564| -------- | -------------------------------- |
565| 801  | Capability not supported. |
566| 3300101  | IllegalStateError, service state exception. |
567
568**Example**
569
570<!--code_no_check-->
571```js
572import { hilog } from '@kit.PerformanceAnalysisKit';
573import { omapi } from '@kit.ConnectivityKit';
574
575let seReaders : omapi.Reader[];
576let seSession : omapi.Session;
577let reader : omapi.Reader;
578
579// Initialize seReaders before using it.
580function secureElementDemo() {
581    try {
582        reader = seReaders[0]; // Set the expected reader (ese or sim).
583        seSession = reader.openSession();
584    } catch (error) {
585        hilog.error(0x0000, 'testTag', 'openSession error %{public}s', JSON.stringify(error));
586    }
587    if (seSession == undefined) {
588        hilog.error(0x0000, 'testTag', 'seSession invalid.');
589        return;
590    }
591    try {
592        reader.closeSessions();
593    } catch (error) {
594        hilog.error(0x0000, 'testTag', 'closeSessions error %{public}s', JSON.stringify(error));
595    }
596}
597```
598
599## Session
600
601A **Session** instance indicates a session created on an SE **Reader** instance. You can use [Reader.openSession](#readeropensession) to obtain a **Session** instance.
602
603### Session.getReader
604
605getReader(): Reader
606
607Obtains the reader that provides this session.
608
609**System capability**: SystemCapability.Communication.SecureElement
610
611**Return value**
612
613| **Type**| **Description**                   |
614| -------- | --------------------------- |
615| [Reader](#reader)   | Reader instance obtained.|
616
617**Error codes**
618
619For details about error codes, see [SE Error Codes](errorcode-se.md).
620
621| ID| Error Message                                 |
622| -------- | ----------------------------------------- |
623| 801  | Capability not supported. |
624
625**Example**
626
627<!--code_no_check-->
628```js
629import { hilog } from '@kit.PerformanceAnalysisKit';
630import { omapi } from '@kit.ConnectivityKit';
631
632let seReaders : omapi.Reader[];
633let seSession : omapi.Session;
634let reader : omapi.Reader;
635
636// Initialize seReaders before using it.
637function secureElementDemo() {
638    try {
639        reader = seReaders[0]; // Set the expected reader (ese or sim).
640        seSession = reader.openSession();
641    } catch (error) {
642        hilog.error(0x0000, 'testTag', 'openSession error %{public}s', JSON.stringify(error));
643    }
644    if (seSession == undefined) {
645        hilog.error(0x0000, 'testTag', 'seSession invalid.');
646        return;
647    }
648    try {
649        let sessionReader = seSession.getReader();
650    } catch (error) {
651        hilog.error(0x0000, 'testTag', 'getReader error %{public}s', JSON.stringify(error));
652    }
653}
654```
655
656### Session.getATR
657
658getATR(): number[]
659
660Obtains the Answer to Reset (ATR) of this SE. If the ATR of this SE is not available, an empty array will be returned.
661
662**System capability**: SystemCapability.Communication.SecureElement
663
664**Return value**
665
666| **Type**| **Description**                                    |
667| -------- | -------------------------------------------- |
668| number[] | ATR if the SE has an available ATR; an empty array otherwise.|
669
670**Error codes**
671
672For details about error codes, see [SE Error Codes](errorcode-se.md).
673
674| ID| Error Message                        |
675| -------- | -------------------------------- |
676| 801  | Capability not supported. |
677| 3300101  | IllegalStateError, service state exception. |
678
679**Example**
680
681<!--code_no_check-->
682```js
683import { hilog } from '@kit.PerformanceAnalysisKit';
684import { omapi } from '@kit.ConnectivityKit';
685
686let seSession : omapi.Session;
687
688// Initialize seSession before using it.
689
690try {
691    let atr = seSession.getATR();
692    hilog.info(0x0000, 'testTag', 'atr %{public}s', JSON.stringify(atr));
693} catch (error) {
694    hilog.error(0x0000, 'testTag', 'getATR error %{public}s', JSON.stringify(error));
695}
696```
697
698### Session.close
699
700close(): void
701
702Closes the session with the SE. All channels opened by this session will be closed.
703
704**System capability**: SystemCapability.Communication.SecureElement
705
706**Error codes**
707
708For details about error codes, see [SE Error Codes](errorcode-se.md).
709
710| ID| Error Message                        |
711| -------- | -------------------------------- |
712| 801  | Capability not supported. |
713| 3300101  | IllegalStateError, service state exception. |
714
715**Example**
716
717<!--code_no_check-->
718```js
719import { hilog } from '@kit.PerformanceAnalysisKit';
720import { omapi } from '@kit.ConnectivityKit';
721
722let seSession : omapi.Session;
723
724// Initialize seSession before using it.
725
726try {
727    seSession.close();
728} catch (error) {
729    hilog.error(0x0000, 'testTag', 'close error %{public}s', JSON.stringify(error));
730}
731```
732
733### Session. isClosed
734
735isClosed(): boolean
736
737Checks whether this session is closed.
738
739**System capability**: SystemCapability.Communication.SecureElement
740
741**Return value**
742
743| **Type**| **Description**                            |
744| -------- | ------------------------------------ |
745| boolean  | **true** if the session is closed; **false** otherwise.|
746
747**Error codes**
748
749For details about error codes, see [SE Error Codes](errorcode-se.md).
750
751| ID| Error Message                                 |
752| -------- | ----------------------------------------- |
753| 801  | Capability not supported. |
754
755**Example**
756
757<!--code_no_check-->
758```Js
759import { hilog } from '@kit.PerformanceAnalysisKit';
760import { omapi } from '@kit.ConnectivityKit';
761
762let seSession : omapi.Session;
763
764// Initialize seSession before using it.
765
766try {
767    let isClosed = seSession.isClosed();
768    hilog.info(0x0000, 'testTag', 'isClosed %{public}s', JSON.stringify(isClosed));
769} catch (error) {
770    hilog.error(0x0000, 'testTag', 'isClosed error %{public}s', JSON.stringify(error));
771}
772```
773
774### Session.closeChannels
775
776closeChannels(): void
777
778Closes all channels opened on this session.
779
780**System capability**: SystemCapability.Communication.SecureElement
781
782**Error codes**
783
784For details about error codes, see [SE Error Codes](errorcode-se.md).
785
786| ID| Error Message                        |
787| -------- | -------------------------------- |
788|801 | Capability not supported.          |
789| 3300101  | IllegalStateError, service state exception. |
790
791**Example**
792
793<!--code_no_check-->
794```js
795import { hilog } from '@kit.PerformanceAnalysisKit';
796import { omapi } from '@kit.ConnectivityKit';
797
798let seSession : omapi.Session;
799
800// Initialize seSession before using it.
801
802try {
803    seSession.closeChannels();
804} catch (error) {
805    hilog.error(0x0000, 'testTag', 'closeChannels error %{public}s', JSON.stringify(error));
806}
807```
808
809### Session.openBasicChannel
810
811openBasicChannel(aid: number[]): Promise\<Channel>
812
813Opens a basic channel, as defined in ISO/IEC 7816-4. If the SE cannot provide the basic channel or the application does not have the permission to access the SE, null is returned. This API uses a promise to return the result.
814
815**System capability**: SystemCapability.Communication.SecureElement
816
817**Parameters**
818
819| **Name**| **Type**| **Mandatory**| **Description**                                                    |
820| ---------- | -------- | ------ | ------------------------------------------------------------ |
821| aid        | number[] | Yes     |AID of the Applet to be selected on this channel as a byte array, or an empty array if no Applet is to be selected.|
822
823**Return value**
824
825| **Type**| **Description**             |
826| -------- | --------------------- |
827| Promise\<[Channel](#channel)>  | Promise used to return the basic channel instance obtained.|
828
829**Error codes**
830
831For details about error codes, see [SE Error Codes](errorcode-se.md).
832
833| ID| Error Message                        |
834| -------- | -------------------------------- |
835|401 | The parameter check failed. Possible causes: <br>1. Mandatory parameters are left unspecified.<br>2. Incorrect parameters types.<br>3. Parameter verification failed. |
836|801 | Capability not supported.          |
837| 3300101  | IllegalStateError, an attempt is made to use an SE session that has been closed. |
838| 3300102  | NoSuchElementError, the AID on the SE is not available or cannot be selected.       |
839| 3300103  | SecurityError, the calling application cannot be granted access to this AID or the default applet on this session.   |
840| 3300104  | IOError, there is a communication problem to the reader or the SE.     |
841
842**Example**
843
844<!--code_no_check-->
845```js
846import { hilog } from '@kit.PerformanceAnalysisKit';
847import { omapi } from '@kit.ConnectivityKit';
848
849let seSession : omapi.Session;
850let seChannel : omapi.Channel;
851let aidArray : number[] = [0xA0, 0x00, 0x00, 0x00, 0x03, 0x10, 0x10];
852
853// Initialize seSession before using it.
854function secureElementDemo() {
855    try {
856        // Set the AID of the application selected on the channel.
857        seSession.openBasicChannel(aidArray).then((data) => {
858            seChannel = data;
859        }).catch((error : BusinessError)=> {
860            hilog.error(0x0000, 'testTag', 'openBasicChannel error %{public}s', JSON.stringify(error));
861        });
862    } catch (exception) {
863        hilog.error(0x0000, 'testTag', 'openBasicChannel exception %{public}s', JSON.stringify(exception));
864    }
865    if (seChannel == undefined) {
866        hilog.error(0x0000, 'testTag', 'seChannel invalid.');
867        return;
868    }
869}
870```
871
872### Session.openBasicChannel
873
874 openBasicChannel(aid: number[], callback: AsyncCallback\<Channel>): void
875
876Opens a basic channel, as defined in ISO/IEC 7816-4. If the SE cannot provide the basic channel or the application does not have the permission to access the SE, null is returned. This API uses an asynchronous callback to return the result.
877
878**System capability**: SystemCapability.Communication.SecureElement
879
880**Parameters**
881
882| **Name**| **Type**              | **Mandatory**| **Description**                                                    |
883| ---------- | ---------------------- | ------ | ------------------------------------------------------------ |
884| aid        | number[]               | Yes     | AID of the Applet to be selected on this channel as a byte array, or an empty array if no Applet is to be selected.|
885| callback   | AsyncCallback\<[Channel](#channel)> | Yes     | Callback used to return the basic channel instance obtained.                           |
886
887**Error codes**
888
889For details about error codes, see [SE Error Codes](errorcode-se.md).
890
891| ID| Error Message                        |
892| -------- | -------------------------------- |
893|401 | The parameter check failed. Possible causes: <br>1. Mandatory parameters are left unspecified.<br>2. Incorrect parameters types.<br>3. Parameter verification failed. |
894|801 | Capability not supported.          |
895| 3300101  | IllegalStateError, an attempt is made to use an SE session that has been closed. |
896| 3300102  | NoSuchElementError, the AID on the SE is not available or cannot be selected.       |
897| 3300103  | SecurityError, the calling application cannot be granted access to this AID or the default applet on this session.   |
898| 3300104  | IOError, there is a communication problem to the reader or the SE.     |
899
900**Example**
901
902<!--code_no_check-->
903```js
904import { hilog } from '@kit.PerformanceAnalysisKit';
905import { omapi } from '@kit.ConnectivityKit';
906
907let seSession : omapi.Session;
908let seChannel : omapi.Channel;
909let aidArray : number[] = [0xA0, 0x00, 0x00, 0x00, 0x03, 0x10, 0x10];
910
911// Initialize seSession before using it.
912function secureElementDemo() {
913    try {
914        // Set the AID of the application selected on the channel.
915        seSession.openBasicChannel(aidArray, (error, data) => {
916            if (error) {
917                hilog.error(0x0000, 'testTag', 'openBasicChannel error %{public}s', JSON.stringify(error));
918            } else {
919                seChannel = data;
920            }
921        });
922    } catch (exception) {
923        hilog.error(0x0000, 'testTag', 'openBasicChannel exception %{public}s', JSON.stringify(exception));
924    }
925    if (seChannel == undefined) {
926        hilog.error(0x0000, 'testTag', 'seChannel invalid.');
927        return;
928    }
929}
930```
931
932### Session.openBasicChannel
933
934openBasicChannel(aid: number[], p2: number): Promise\<Channel>
935
936Opens a basic channel, as defined in ISO/IEC 7816-4. If the SE cannot provide the basic channel or the application does not have the permission to access the SE, null is returned. This API uses a promise to return the result.
937
938**System capability**: SystemCapability.Communication.SecureElement
939
940**Parameters**
941
942| **Name**| **Type**| **Mandatory**| **Description**                                                    |
943| ---------- | -------- | ------ | ------------------------------------------------------------ |
944| aid        | number[] | Yes      | AID of the Applet to be selected on this channel as a byte array, or an empty array if no Applet is to be selected.|
945| p2         | number   | Yes      |P2 parameter of the **SELECT APDU** command executed on this channel.                    |
946
947**Return value**
948
949| **Type**| **Description**             |
950| -------- | --------------------- |
951| Promise\<[Channel](#channel)>  | Promise used to return the basic channel instance obtained.|
952
953**Error codes**
954
955For details about error codes, see [SE Error Codes](errorcode-se.md).
956
957| ID| Error Message                        |
958| -------- | -------------------------------- |
959|401 | The parameter check failed. Possible causes: <br>1. Mandatory parameters are left unspecified.<br>2. Incorrect parameters types.<br>3. Parameter verification failed. |
960|801 | Capability not supported.          |
961| 3300101  | IllegalStateError, an attempt is made to use an SE session that has been closed. |
962| 3300102  | NoSuchElementError, the AID on the SE is not available or cannot be selected.       |
963| 3300103  | SecurityError, the calling application cannot be granted access to this AID or the default applet on this session.   |
964| 3300104  | IOError, there is a communication problem to the reader or the SE.     |
965
966**Example**
967
968<!--code_no_check-->
969```js
970import { hilog } from '@kit.PerformanceAnalysisKit';
971import { omapi } from '@kit.ConnectivityKit';
972
973let seSession : omapi.Session;
974let seChannel : omapi.Channel;
975let aidArray : number[] = [0xA0, 0x00, 0x00, 0x00, 0x03, 0x10, 0x10];
976let p2 : number = 0x00;
977
978// Initialize seSession before using it.
979function secureElementDemo() {
980    try {
981        // Set the AID of the application selected on the channel.
982        seSession.openBasicChannel(aidArray, p2).then((data) => {
983            seChannel = data;
984        }).catch((error : BusinessError)=> {
985            hilog.error(0x0000, 'testTag', 'openBasicChannel error %{public}s', JSON.stringify(error));
986        });
987    } catch (exception) {
988        hilog.error(0x0000, 'testTag', 'openBasicChannel exception %{public}s', JSON.stringify(exception));
989    }
990    if (seChannel == undefined) {
991        hilog.error(0x0000, 'testTag', 'seChannel invalid.');
992        return;
993    }
994}
995```
996
997### Session.openBasicChannel
998
999openBasicChannel(aid: number[], p2:number, callback: AsyncCallback\<Channel>): void
1000
1001Opens a basic channel, as defined in ISO/IEC 7816-4. If the SE cannot provide the basic channel or the application does not have the permission to access the SE, null is returned. This API uses an asynchronous callback to return the result.
1002
1003**System capability**: SystemCapability.Communication.SecureElement
1004
1005**Parameters**
1006
1007| **Name**| **Type**              | **Mandatory**| **Description**                                                    |
1008| ---------- | ---------------------- | ------ | ------------------------------------------------------------ |
1009| aid        | number[]               | Yes     | AID of the Applet to be selected on this channel as a byte array, or an empty array if no Applet is to be selected.|
1010| p2         | number                 | Yes     | P2 parameter of the **SELECT APDU** command executed on this channel.                    |
1011| callback   | AsyncCallback\<[Channel](#channel)> | Yes     | Callback used to return the basic channel instance obtained.                           |
1012
1013**Error codes**
1014
1015For details about error codes, see [SE Error Codes](errorcode-se.md).
1016
1017| ID| Error Message                        |
1018| -------- | -------------------------------- |
1019|401 | The parameter check failed. Possible causes: <br>1. Mandatory parameters are left unspecified.<br>2. Incorrect parameters types.<br>3. Parameter verification failed. |
1020|801 | Capability not supported.          |
1021| 3300101  | IllegalStateError, an attempt is made to use an SE session that has been closed. |
1022| 3300102  | NoSuchElementError, the AID on the SE is not available or cannot be selected.      |
1023| 3300103  | SecurityError, the calling application cannot be granted access to this AID or the default applet on this session.   |
1024| 3300104  | IOError, there is a communication problem to the reader or the SE.     |
1025
1026**Example**
1027
1028<!--code_no_check-->
1029```js
1030import { hilog } from '@kit.PerformanceAnalysisKit';
1031import { omapi } from '@kit.ConnectivityKit';
1032
1033let seSession : omapi.Session;
1034let seChannel : omapi.Channel;
1035let aidArray : number[] = [0xA0, 0x00, 0x00, 0x00, 0x03, 0x10, 0x10];
1036let p2 : number = 0x00;
1037
1038// Initialize seSession before using it.
1039function secureElementDemo() {
1040    try {
1041        // Set the AID of the application selected on the channel.
1042        seSession.openBasicChannel(aidArray, p2, (error, data) => {
1043            if (error) {
1044                hilog.error(0x0000, 'testTag', 'openBasicChannel error %{public}s', JSON.stringify(error));
1045            } else {
1046                seChannel = data;
1047            }
1048        });
1049    } catch (exception) {
1050        hilog.error(0x0000, 'testTag', 'openBasicChannel exception %{public}s', JSON.stringify(exception));
1051    }
1052    if (seChannel == undefined) {
1053        hilog.error(0x0000, 'testTag', 'seChannel invalid.');
1054        return;
1055    }
1056}
1057```
1058
1059### Session.openLogicalChannel
1060
1061openLogicalChannel(aid: number[]): Promise\<Channel>
1062
1063Opens a logical channel, as defined in ISO/IEC 7816-4. If the SE cannot provide the logical channel or the application does not have the permission to access the SE, null is returned. This API uses a promise to return the result.
1064
1065**System capability**: SystemCapability.Communication.SecureElement
1066
1067**Parameters**
1068
1069| **Name**| **Type**| **Mandatory**| **Description**                               |
1070| ---------- | -------- | ------ | --------------------------------------- |
1071| aid        | number[] | Yes     | AID of the Applet to be selected on this channel as a byte array, or an empty array if no Applet is to be selected.|
1072
1073**Return value**
1074
1075| **Type**| **Description**                                                    |
1076| -------- | ------------------------------------------------------------ |
1077| Promise\<[Channel](#channel)>  | Promise used to return the logical channel instance obtained.|
1078
1079**Error codes**
1080
1081For details about error codes, see [SE Error Codes](errorcode-se.md).
1082
1083| ID| Error Message                        |
1084| -------- | -------------------------------- |
1085|401 | The parameter check failed. Possible causes: <br>1. Mandatory parameters are left unspecified.<br>2. Incorrect parameters types.<br>3. Parameter verification failed. |
1086|801 | Capability not supported.          |
1087| 3300101  | IllegalStateError, an attempt is made to use an SE session that has been closed. |
1088| 3300102  | NoSuchElementError, the AID on the SE is not available or cannot be selected or a logical channel is already open to a non-multi-selectable applet.      |
1089| 3300103  | SecurityError, the calling application cannot be granted access to this AID or the default applet on this session.   |
1090| 3300104  | IOError, there is a communication problem to the reader or the SE.     |
1091
1092**Example**
1093
1094<!--code_no_check-->
1095```js
1096import { hilog } from '@kit.PerformanceAnalysisKit';
1097import { omapi } from '@kit.ConnectivityKit';
1098
1099let seSession : omapi.Session;
1100let seChannel : omapi.Channel;
1101let aidArray : number[] = [0xA0, 0x00, 0x00, 0x00, 0x03, 0x10, 0x10];
1102
1103// Initialize seSession before using it.
1104function secureElementDemo() {
1105    try {
1106        // Set the AID of the application selected on the channel.
1107        seSession.openLogicalChannel(aidArray).then((data) => {
1108            seChannel = data;
1109        }).catch((error : BusinessError)=> {
1110            hilog.error(0x0000, 'testTag', 'openLogicalChannel error %{public}s', JSON.stringify(error));
1111        });
1112    } catch (exception) {
1113        hilog.error(0x0000, 'testTag', 'openLogicalChannel exception %{public}s', JSON.stringify(exception));
1114    }
1115    if (seChannel == undefined) {
1116        hilog.error(0x0000, 'testTag', 'seChannel invalid.');
1117        return;
1118    }
1119}
1120```
1121
1122### Session.openLogicalChannel
1123
1124 openLogicalChannel(aid: number[], callback: AsyncCallback\<Channel>): void
1125
1126Opens a logical channel, as defined in ISO/IEC 7816-4. If the SE cannot provide the logical channel or the application does not have the permission to access the SE, null is returned. This API uses an asynchronous callback to return the result.
1127
1128**System capability**: SystemCapability.Communication.SecureElement
1129
1130**Parameters**
1131
1132| **Name**| **Type**              | **Mandatory**| **Description**                                                    |
1133| ---------- | ---------------------- | ------ | ------------------------------------------------------------ |
1134| aid        | number[]               | Yes     | AID of the Applet to be selected on this channel as a byte array, or an empty array if no Applet is to be selected.|
1135| callback   | AsyncCallback\<[Channel](#channel)> | Yes     | Callback used to return the logical channel instance obtained.|
1136
1137**Error codes**
1138
1139For details about error codes, see [SE Error Codes](errorcode-se.md).
1140
1141| ID| Error Message                        |
1142| -------- | -------------------------------- |
1143|401 | The parameter check failed. Possible causes: <br>1. Mandatory parameters are left unspecified.<br>2. Incorrect parameters types.<br>3. Parameter verification failed. |
1144|801 | Capability not supported.          |
1145| 3300101  | IllegalStateError, an attempt is made to use an SE session that has been closed. |
1146| 3300102  | NoSuchElementError, the AID on the SE is not available or cannot be selected or a logical channel is already open to a non-multi-selectable applet.      |
1147| 3300103  | SecurityError, the calling application cannot be granted access to this AID or the default applet on this session.   |
1148| 3300104  | IOError, there is a communication problem to the reader or the SE.    |
1149
1150**Example**
1151
1152<!--code_no_check-->
1153```js
1154import { hilog } from '@kit.PerformanceAnalysisKit';
1155import { omapi } from '@kit.ConnectivityKit';
1156
1157let seSession : omapi.Session;
1158let seChannel : omapi.Channel;
1159let aidArray : number[] = [0xA0, 0x00, 0x00, 0x00, 0x03, 0x10, 0x10];
1160
1161// Initialize seSession before using it.
1162function secureElementDemo() {
1163    try {
1164        // Set the AID of the application selected on the channel.
1165        seSession.openLogicalChannel(aidArray, (error, data) => {
1166            if (error) {
1167                hilog.error(0x0000, 'testTag', 'openLogicalChannel error %{public}s', JSON.stringify(error));
1168            } else {
1169                seChannel = data;
1170            }
1171        });
1172    } catch (exception) {
1173        hilog.error(0x0000, 'testTag', 'openLogicalChannel exception %{public}s', JSON.stringify(exception));
1174    }
1175    if (seChannel == undefined) {
1176        hilog.error(0x0000, 'testTag', 'seChannel invalid.');
1177        return;
1178    }
1179}
1180```
1181
1182### Session.openLogicalChannel
1183
1184openLogicalChannel(aid: number[], p2: number): Promise\<Channel>
1185
1186Opens a logical channel, as defined in ISO/IEC 7816-4. If the SE cannot provide the logical channel or the application does not have the permission to access the SE, null is returned. This API uses a promise to return the result.
1187
1188**System capability**: SystemCapability.Communication.SecureElement
1189
1190**Parameters**
1191
1192| **Name**| **Type**| **Mandatory**| **Description**                                 |
1193| ---------- | -------- | ------ | ----------------------------------------- |
1194| aid        | number[] | Yes     | AID of the Applet to be selected on this channel as a byte array, or an empty array if no Applet is to be selected.|
1195| p2         | number   | Yes     | P2 parameter of the **SELECT APDU** command executed on this channel. |
1196
1197**Return value**
1198
1199| **Type**| **Description**      |
1200| -------- | -------------- |
1201| Promise\<[Channel](#channel)> | Promise used to return the logical channel instance obtained.|
1202
1203**Error codes**
1204
1205For details about error codes, see [SE Error Codes](errorcode-se.md).
1206
1207| ID| Error Message                        |
1208| -------- | -------------------------------- |
1209|401 | The parameter check failed. Possible causes: <br>1. Mandatory parameters are left unspecified.<br>2. Incorrect parameters types.<br>3. Parameter verification failed. |
1210|801 | Capability not supported.          |
1211| 3300101  | IllegalStateError, an attempt is made to use an SE session that has been closed. |
1212| 3300102  | NoSuchElementError, the AID on the SE is not available or cannot be selected or a logical channel is already open to a non-multi-selectable applet.      |
1213| 3300103  | SecurityError, the calling application cannot be granted access to this AID or the default applet on this session.   |
1214| 3300104  | IOError, there is a communication problem to the reader or the SE.     |
1215
1216**Example**
1217
1218<!--code_no_check-->
1219```js
1220import { hilog } from '@kit.PerformanceAnalysisKit';
1221import { omapi } from '@kit.ConnectivityKit';
1222
1223let seSession : omapi.Session;
1224let seChannel : omapi.Channel;
1225let aidArray : number[] = [0xA0, 0x00, 0x00, 0x00, 0x03, 0x10, 0x10];
1226let p2 : number = 0x00;
1227
1228// Initialize seSession before using it.
1229function secureElementDemo() {
1230    try {
1231        // Set the AID of the application selected on the channel.
1232        seSession.openLogicalChannel(aidArray, p2).then((data) => {
1233            seChannel = data;
1234        }).catch((error : BusinessError)=> {
1235            hilog.error(0x0000, 'testTag', 'openLogicalChannel error %{public}s', JSON.stringify(error));
1236        });
1237    } catch (exception) {
1238        hilog.error(0x0000, 'testTag', 'openLogicalChannel exception %{public}s', JSON.stringify(exception));
1239    }
1240    if (seChannel == undefined) {
1241        hilog.error(0x0000, 'testTag', 'seChannel invalid.');
1242        return;
1243    }
1244}
1245```
1246
1247### Session.openLogicalChannel
1248
1249openLogicalChannel(aid: number[], p2: number, callback: AsyncCallback\<Channel>):void
1250
1251Opens a logical channel, as defined in ISO/IEC 7816-4. If the SE cannot provide the logical channel or the application does not have the permission to access the SE, null is returned. This API uses an asynchronous callback to return the result.
1252
1253**System capability**: SystemCapability.Communication.SecureElement
1254
1255**Parameters**
1256
1257| **Name**| **Type**              | **Mandatory**| **Description**                                                    |
1258| ---------- | ---------------------- | ------ | ------------------------------------------------------------ |
1259| aid        | number[]               | Yes     | AID of the Applet to be selected on this channel as a byte array, or an empty array if no Applet is to be selected.|
1260| p2         | number                 | Yes     | P2 parameter of the **SELECT APDU** command executed on this channel.|
1261| callback   | AsyncCallback\<[Channel](#channel)> | Yes     | Callback used to return the logical channel instance obtained.|
1262
1263**Error codes**
1264
1265For details about error codes, see [SE Error Codes](errorcode-se.md).
1266
1267| ID| Error Message                        |
1268| -------- | -------------------------------- |
1269|401 | The parameter check failed. Possible causes: <br>1. Mandatory parameters are left unspecified.<br>2. Incorrect parameters types.<br>3. Parameter verification failed. |
1270|801 | Capability not supported.          |
1271| 3300101  | IllegalStateError, an attempt is made to use an SE session that has been closed. |
1272| 3300102  | NoSuchElementError, the AID on the SE is not available or cannot be selected or a logical channel is already open to a non-multi-selectable applet.       |
1273| 3300103  | SecurityError, the calling application cannot be granted access to this AID or the default applet on this session.   |
1274| 3300104  | IOError, there is a communication problem to the reader or the SE.     |
1275
1276**Example**
1277
1278<!--code_no_check-->
1279```js
1280import { hilog } from '@kit.PerformanceAnalysisKit';
1281import { omapi } from '@kit.ConnectivityKit';
1282
1283let seSession : omapi.Session;
1284let seChannel : omapi.Channel;
1285let aidArray : number[] = [0xA0, 0x00, 0x00, 0x00, 0x03, 0x10, 0x10];
1286let p2 : number = 0x00;
1287
1288// Initialize seSession before using it.
1289function secureElementDemo() {
1290    try {
1291    // Set the AID of the application selected on the channel.
1292        seSession.openLogicalChannel(aidArray, p2, (error, data) => {
1293            if (error) {
1294                hilog.error(0x0000, 'testTag', 'openLogicalChannel error %{public}s', JSON.stringify(error));
1295            } else {
1296                seChannel = data;
1297            }
1298        });
1299    } catch (exception) {
1300        hilog.error(0x0000, 'testTag', 'openLogicalChannel exception %{public}s', JSON.stringify(exception));
1301    }
1302    if (seChannel == undefined) {
1303        hilog.error(0x0000, 'testTag', 'seChannel invalid.');
1304        return;
1305    }
1306}
1307```
1308## Channel
1309
1310A **Channel** instance indicates a channel set up by a **Session** instance. The channel can be a basic channel or a logical channel. You can use [Session.openBasicChannel](#sessionopenbasicchannel) or [Session.openLogicalChannel](#sessionopenlogicalchannel) to obtain a channel instance.
1311
1312### Channel.getSession
1313
1314 getSession(): Session
1315
1316Obtains the session used to open this channel.
1317
1318**System capability**: SystemCapability.Communication.SecureElement
1319
1320**Return value**
1321
1322| **Type**| **Description**                     |
1323| -------- | ----------------------------- |
1324| [Session](#session)  | Session instance obtained.|
1325
1326**Error codes**
1327
1328For details about error codes, see [SE Error Codes](errorcode-se.md).
1329
1330| ID| Error Message                                 |
1331| -------- | ----------------------------------------- |
1332| 801  | Capability not supported. |
1333
1334**Example**
1335
1336<!--code_no_check-->
1337```js
1338import { hilog } from '@kit.PerformanceAnalysisKit';
1339import { omapi } from '@kit.ConnectivityKit';
1340
1341let seSession : omapi.Session;
1342let seChannel : omapi.Channel;
1343
1344// Initialize seChannel before using it.
1345
1346try {
1347    seSession = seChannel.getSession();
1348} catch (exception) {
1349    hilog.error(0x0000, 'testTag', 'getSession exception %{public}s', JSON.stringify(exception));
1350}
1351```
1352
1353### Channel.close
1354
1355close(): void
1356
1357Closes this channel.
1358
1359**System capability**: SystemCapability.Communication.SecureElement
1360
1361**Error codes**
1362
1363For details about error codes, see [SE Error Codes](errorcode-se.md).
1364
1365| ID| Error Message                                 |
1366| -------- | ----------------------------------------- |
1367| 801  | Capability not supported. |
1368
1369**Example**
1370
1371<!--code_no_check-->
1372```js
1373import { hilog } from '@kit.PerformanceAnalysisKit';
1374import { omapi } from '@kit.ConnectivityKit';
1375
1376let seChannel : omapi.Channel;
1377
1378// Initialize seChannel before using it.
1379try {
1380    seChannel.close();
1381} catch (exception) {
1382    hilog.error(0x0000, 'testTag', 'close exception %{public}s', JSON.stringify(exception));
1383}
1384```
1385
1386### Channel.isBasicChannel
1387
1388isBasicChannel(): boolean
1389
1390Checks whether this channel is a basic channel.
1391
1392**System capability**: SystemCapability.Communication.SecureElement
1393
1394**Return value**
1395
1396| **Type**| **Description**                                                    |
1397| -------- | ------------------------------------------------------------ |
1398| boolean  | **true** if the channel is a basic channel; **false** otherwise.|
1399
1400**Error codes**
1401
1402For details about error codes, see [SE Error Codes](errorcode-se.md).
1403
1404| ID| Error Message                                 |
1405| -------- | ----------------------------------------- |
1406| 801  | Capability not supported. |
1407
1408**Example**
1409
1410<!--code_no_check-->
1411```js
1412import { hilog } from '@kit.PerformanceAnalysisKit';
1413import { omapi } from '@kit.ConnectivityKit';
1414
1415let seChannel : omapi.Channel;
1416
1417// Initialize seChannel before using it.
1418try {
1419    let isBasic = seChannel.isBasicChannel();
1420    hilog.info(0x0000, 'testTag', 'isBasic = %{public}s', JSON.stringify(isBasic));
1421} catch (exception) {
1422    hilog.error(0x0000, 'testTag', 'isBasicChannel exception %{public}s', JSON.stringify(exception));
1423}
1424```
1425
1426### Channel.isClosed
1427
1428isClosed(): boolean
1429
1430Checks whether this channel is closed.
1431
1432**System capability**: SystemCapability.Communication.SecureElement
1433
1434**Return value**
1435
1436| **Type**| **Description**                                     |
1437| -------- | --------------------------------------------- |
1438| boolean  | **true** if the channel is closed; **false** otherwise.|
1439
1440**Error codes**
1441
1442For details about error codes, see [SE Error Codes](errorcode-se.md).
1443
1444| ID| Error Message                                 |
1445| -------- | ----------------------------------------- |
1446| 801  | Capability not supported. |
1447
1448**Example**
1449
1450<!--code_no_check-->
1451```js
1452import { hilog } from '@kit.PerformanceAnalysisKit';
1453import { omapi } from '@kit.ConnectivityKit';
1454
1455let seChannel : omapi.Channel;
1456
1457// Initialize seChannel before using it.
1458try {
1459    let isClosed = seChannel.isClosed();
1460    hilog.info(0x0000, 'testTag', 'isClosed = %{public}s', JSON.stringify(isClosed));
1461} catch (exception) {
1462    hilog.error(0x0000, 'testTag', 'isClosed exception %{public}s', JSON.stringify(exception));
1463}
1464```
1465
1466### Channel.getSelectResponse
1467
1468getSelectResponse(): number[]
1469
1470Obtains the response data including the status word of **SELECT Applet**.
1471
1472**System capability**: SystemCapability.Communication.SecureElement
1473
1474**Return value**
1475
1476| **Type**| **Description**                                                    |
1477| -------- | ------------------------------------------------------------ |
1478| number[] | Response data including the status word obtained.|
1479
1480**Error codes**
1481
1482For details about error codes, see [SE Error Codes](errorcode-se.md).
1483
1484| ID| Error Message                                 |
1485| -------- | ----------------------------------------- |
1486| 801  | Capability not supported. |
1487
1488**Example**
1489
1490<!--code_no_check-->
1491```js
1492import { hilog } from '@kit.PerformanceAnalysisKit';
1493import { omapi } from '@kit.ConnectivityKit';
1494
1495let seChannel : omapi.Channel;
1496
1497// Initialize seChannel before using it.
1498try {
1499    let response = seChannel.getSelectResponse();
1500    hilog.info(0x0000, 'testTag', 'response = %{public}s', JSON.stringify(response));
1501} catch (exception) {
1502    hilog.error(0x0000, 'testTag', 'getSelectResponse exception %{public}s', JSON.stringify(exception));
1503}
1504```
1505
1506### Channel.transmit
1507
1508transmit(command: number[]): Promise\<number[]>
1509
1510Transmits APDU data (as per ISO/IEC 7816) to the SE. This API uses a promise to return the result.
1511
1512**System capability**: SystemCapability.Communication.SecureElement
1513
1514**Parameters**
1515
1516| **Name**| **Type**| **Mandatory**| **Description**                             |
1517| ---------- | -------- | ------ | ------------------------------------- |
1518| command    | number[] | Yes     | APDU data to send.|
1519
1520**Return value**
1521
1522| **Type**| **Description**      |
1523| -------- | -------------- |
1524| Promise\<number[]> | Promise used to return the response received, in a number array.|
1525
1526**Error codes**
1527
1528For details about error codes, see [SE Error Codes](errorcode-se.md).
1529
1530| ID| Error Message                        |
1531| -------- | -------------------------------- |
1532|401 | The parameter check failed. Possible causes: <br>1. Mandatory parameters are left unspecified.<br>2. Incorrect parameters types.<br>3. Parameter verification failed. |
1533|801 | Capability not supported.          |
1534| 3300101  | IllegalStateError, an attempt is made to use an SE session or channel that has been closed. |
1535| 3300103  | SecurityError, the command is filtered by the security policy. |
1536| 3300104  | IOError, there is a communication problem to the reader or the SE.     |
1537
1538**Example**
1539
1540<!--code_no_check-->
1541```js
1542import { hilog } from '@kit.PerformanceAnalysisKit';
1543import { omapi } from '@kit.ConnectivityKit';
1544
1545let seChannel : omapi.Channel;
1546
1547// Initialize seChannel before using it.
1548let cmdData = [0x01, 0x02, 0x03, 0x04]; // Set command data correctly.
1549try {
1550    seChannel.transmit(cmdData).then((response) => {
1551        hilog.info(0x0000, 'testTag', 'transmit response = %{public}s.', JSON.stringify(response));
1552    }).catch((error : BusinessError) => {
1553        hilog.error(0x0000, 'testTag', 'transmit error = %{public}s.', JSON.stringify(error));
1554    });
1555} catch (exception) {
1556    hilog.error(0x0000, 'testTag', 'transmit exception = %{public}s.', JSON.stringify(exception));
1557}
1558```
1559
1560### Channel.transmit
1561
1562transmit(command: number[], callback: AsyncCallback\<number[]>): void
1563
1564Transmits APDU data (as per ISO/IEC 7816) to the SE. This API uses an asynchronous callback to return the result.
1565
1566**System capability**: SystemCapability.Communication.SecureElement
1567
1568**Parameters**
1569
1570| **Name**| **Type**               | **Mandatory**| **Description**                             |
1571| ---------- | ----------------------- | ------ | ------------------------------------- |
1572| command    | number[]                | Yes     | APDU data to send.|
1573| callback   | AsyncCallback\<number[]> | Yes     | Callback used to return the response received, in a number array. |
1574
1575**Error codes**
1576
1577For details about error codes, see [SE Error Codes](errorcode-se.md).
1578
1579| ID| Error Message                        |
1580| -------- | -------------------------------- |
1581|401 | The parameter check failed. Possible causes: <br>1. Mandatory parameters are left unspecified.<br>2. Incorrect parameters types.<br>3. Parameter verification failed. |
1582|801 | Capability not supported.          |
1583| 3300101  | IllegalStateError, an attempt is made to use an SE session or channel that has been closed. |
1584| 3300103  | SecurityError, the command is filtered by the security policy. |
1585| 3300104  | IOError, there is a communication problem to the reader or the SE.     |
1586
1587**Example**
1588
1589<!--code_no_check-->
1590```js
1591import { hilog } from '@kit.PerformanceAnalysisKit';
1592import { omapi } from '@kit.ConnectivityKit';
1593
1594let seChannel : omapi.Channel;
1595
1596// Initialize seChannel before using it.
1597let cmdData = [0x01, 0x02, 0x03, 0x04]; // Set command data correctly.
1598try {
1599    seChannel.transmit(cmdData, (error, response) => {
1600    if (error) {
1601        hilog.error(0x0000, 'testTag', 'transmit error %{public}s', JSON.stringify(error));
1602    } else {
1603        hilog.info(0x0000, 'testTag', 'transmit response = %{public}s.', JSON.stringify(response));
1604    }
1605    });
1606} catch (exception) {
1607    hilog.error(0x0000, 'testTag', 'transmit exception %{public}s', JSON.stringify(exception));
1608}
1609```
1610