mirror of
https://gitee.com/openharmony/interface_sdk-js
synced 2024-12-17 20:50:42 +00:00
df09a070ae
Signed-off-by: liujiawei <liujiawei11@huawei.com>
117 lines
3.0 KiB
TypeScript
Executable File
117 lines
3.0 KiB
TypeScript
Executable File
/*
|
|
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
* you may not use this file except in compliance with the License.
|
|
* You may obtain a copy of the License at
|
|
*
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
*
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
* See the License for the specific language governing permissions and
|
|
* limitations under the License.
|
|
*/
|
|
|
|
import { Callback } from './basic';
|
|
|
|
/**
|
|
* Provides methods to operate or manage NFC.
|
|
*
|
|
* @import import controller from '@ohos.nfc.controller';
|
|
*
|
|
* @since 7
|
|
* @syscap SystemCapability.Communication.NFC.Core
|
|
*/
|
|
declare namespace nfcController {
|
|
enum NfcState {
|
|
/** Indicates that NFC is disabled. */
|
|
STATE_OFF = 1,
|
|
|
|
/** Indicates that NFC is being enabled. */
|
|
STATE_TURNING_ON = 2,
|
|
|
|
/** Indicates that NFC is enabled. */
|
|
STATE_ON = 3,
|
|
|
|
/** Indicates that NFC is being disabled. */
|
|
STATE_TURNING_OFF = 4,
|
|
}
|
|
|
|
/**
|
|
* Checks whether a device supports NFC.
|
|
*
|
|
* @return Returns {@code true} if the device supports NFC; returns {@code false} otherwise.
|
|
*
|
|
* @since 7
|
|
*/
|
|
function isNfcAvailable(): boolean
|
|
|
|
/**
|
|
* register nfc state changed event.
|
|
*
|
|
* @param type the type to register.
|
|
* @param callback Callback used to listen for the nfc state changed event.
|
|
*
|
|
* @since 7
|
|
*/
|
|
|
|
function on(type: "nfcStateChange", callback: Callback<NfcState>): void
|
|
|
|
/**
|
|
* unregister nfc state changed event.
|
|
*
|
|
* @param type the type to unregister.
|
|
* @param callback Callback used to listen for the nfc state changed event.
|
|
*
|
|
* @since 7
|
|
*/
|
|
|
|
function off(type: "nfcStateChange", callback?: Callback<NfcState>): void
|
|
|
|
/**
|
|
* Enables NFC.
|
|
*
|
|
* @return Returns {@code true} if NFC is enabled or has been enabled; returns {@code false} otherwise.
|
|
* @permission ohos.permission.MANAGE_SECURE_SETTINGS
|
|
*
|
|
* @since 7
|
|
*/
|
|
function openNfc(): boolean
|
|
|
|
/**
|
|
* Disables NFC.
|
|
*
|
|
* @return Returns {@code true} if NFC is disabled or has been disabled; returns {@code false} otherwise.
|
|
* @permission ohos.permission.MANAGE_SECURE_SETTINGS
|
|
*
|
|
* @since 7
|
|
*/
|
|
function closeNfc(): boolean
|
|
|
|
/**
|
|
* Checks whether NFC is enabled.
|
|
*
|
|
* @return Returns {@code true} if NFC is enabled; returns {@code false} otherwise.
|
|
*
|
|
* @since 7
|
|
*/
|
|
function isNfcOpen(): boolean
|
|
|
|
/**
|
|
* Obtains the NFC status.
|
|
*
|
|
* <p>The NFC status can be any of the following: <ul><li>{@link #STATE_OFF}: Indicates that NFC
|
|
* is disabled. <li>{@link #STATE_TURNING_ON}: Indicates that NFC is being enabled.
|
|
* <li>{@link #STATE_ON}: Indicates that NFC is enabled. <li>{@link #STATE_TURNING_OFF}: Indicates
|
|
* that NFC is being disabled.</ul>
|
|
*
|
|
* @return Returns the NFC status.
|
|
*
|
|
* @since 7
|
|
*/
|
|
function getNfcState(): NfcState
|
|
}
|
|
|
|
export default nfcController;
|