1 Star 0 Fork 1

Taps-OH/applications_device_manager_tv

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
@ohos.distributedHardware.deviceManager.d.ts 17.52 KB
一键复制 编辑 原始数据 按行查看 历史
雷琦玮 提交于 2023-07-04 15:01 +08:00 . 适配TV形态
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620
/*
* Copyright (c) 2020-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 { AsyncCallback, Callback } from './basic';
/**
* Providers interfaces to create a {@link deviceManager} instances.
*
* @since 7
* @Syscap SystemCapability.DISTRIBUTEDHARDWARE.deviceManager
*
*/
declare namespace deviceManager {
/**
* DeviceInfo
*
* @systemapi this method can be used only by system applications.
*/
interface DeviceInfo {
/**
* DeviceId ID.
*/
deviceId: string;
/**
* Device name of the device.
*/
deviceName: string;
/**
* Device type of the device.
*/
deviceType: DeviceType;
/**
* NetworkId of the device.
*
* @since 8
*/
networkId: string;
/**
* @since 9
* The distance of dicovered device, in centimeters(cm).
*/
range: number;
}
/**
* Device Type definitions
*/
enum DeviceType {
/**
* Indicates an unknown device type.
*/
UNKNOWN_TYPE = 0,
/**
* Indicates a speaker.
*/
SPEAKER = 0x0A,
/**
* Indicates a smartphone.
*/
PHONE = 0x0E,
/**
* Indicates a tablet.
*/
TABLET = 0x11,
/**
* Indicates a smart watch.
*/
WEARABLE = 0x6D,
/**
* Indicates a car.
*/
CAR = 0x83,
/**
* Indicates a smart TV.
*/
TV = 0x9C
}
/**
* Device state change event definition
*
* @systemapi this method can be used only by system applications.
*/
enum DeviceStateChangeAction {
/**
* device online action
*/
ONLINE = 0,
/**
* device ready action, the device information synchronization was completed.
*/
READY = 1,
/**
* device offline action
*/
OFFLINE = 2,
/**
* device change action
*/
CHANGE = 3
}
/**
* Service subscribe info for device discover
*
* @systemapi this method can be used only by system applications.
*/
interface SubscribeInfo {
/**
* Service subscribe ID, the value is in scope [0, 65535], should be unique for each discover process
*/
subscribeId: number;
/**
* Discovery mode for service subscription.
*/
mode: DiscoverMode;
/**
* Service subscription medium.
*/
medium: ExchangeMedium;
/**
* Service subscription frequency.
*/
freq: ExchangeFreq;
/**
* only find the device with the same account.
*/
isSameAccount: boolean;
/**
* find the sleeping devices.
*/
isWakeRemote: boolean;
/**
* Subscribe capability.
*/
capability: SubscribeCap;
}
/**
* Service publish info for device discover
* @since 9
* @systemapi this method can be used only by system applications.
*/
interface PublishInfo {
/**
* Service publish ID, the value is in scope [0, 65535], should be unique for each publish process
*/
publishId: number;
/**
* Discovery mode for service subscription.
*/
mode: DiscoverMode;
/**
* Service subscription frequency.
*/
freq: ExchangeFreq;
/**
* Whether the device should be ranged by discoverers.
*/
ranging : boolean;
}
/**
* device discover mode
*
* @systemapi this method can be used only by system applications.
*/
enum DiscoverMode {
/**
* when using this key at client side, it means discovering for available nearby devices by
* calling @startDeviceDiscovery function, while using this key at server side indicating that
* a device publication or advertisement by calling @publishDeviceDiscovery.
*/
DISCOVER_MODE_PASSIVE = 0x55,
/**
* when using this key at server side, it means discovering for available nearby devices by
* calling @startDeviceDiscovery function, while using this key at client side indicating that
* a device publication or advertisement by calling @publishDeviceDiscovery.
*/
DISCOVER_MODE_ACTIVE = 0xAA
}
/**
* device discover medium
*
* @systemapi this method can be used only by system applications.
*/
enum ExchangeMedium {
/**
* Automatic medium selection
*/
AUTO = 0,
/**
* Bluetooth
*/
BLE = 1,
/**
* Wi-Fi
*/
COAP = 2,
/**
* USB
*/
USB = 3
}
/**
* device discover freq
*
* @systemapi this method can be used only by system applications.
*/
enum ExchangeFreq {
/**
* Low
*/
LOW = 0,
/**
* Medium
*/
MID = 1,
/**
* High
*/
HIGH = 2,
/**
* Super-high
*/
SUPER_HIGH = 3
}
/**
* device discover capability
*
* @systemapi this method can be used only by system applications.
*/
enum SubscribeCap {
/**
* ddmpCapability, will be discarded later. Currently, it will be converted to OSD capability inner.
*/
SUBSCRIBE_CAPABILITY_DDMP = 0,
/**
* One Super Device Capability
*/
SUBSCRIBE_CAPABILITY_OSD = 1
}
/**
* Device Authentication param
*
* @systemapi this method can be used only by system applications
*/
interface AuthParam {
/**
* Authentication type, 1 for pin code.
*/
authType: number;
/**
* Authentication extra infos.
*/
extraInfo: {[key:string] : any};
}
/**
* Device auth info.
*
* @systemapi this method can be used only by system applications
*/
interface AuthInfo {
/**
* Authentication type, 1 for pin code.
*/
authType: number;
/**
* the token used for this authentication.
*/
token: number;
/**
* Authentication extra infos.
*/
extraInfo: {[key:string] : any};
}
/**
* Creates a {@code DeviceManager} instance.
*
* <p>To manage devices, you must first call this method to obtain a {@code DeviceManager} instance and then
* use this instance to call other device management methods.
*
* @param bundleName Indicates the bundle name of the application.
* @param callback Indicates the callback to be invoked upon {@code DeviceManager} instance creation.
* @systemapi this method can be used only by system applications.
*/
function createDeviceManager(bundleName: string, callback: AsyncCallback<DeviceManager>): void;
/**
* Provides methods for managing devices.
*/
interface DeviceManager {
/**
* Releases the {@code DeviceManager} instance after the methods for device management are no longer used.
*
* @systemapi this method can be used only by system applications.
*/
release(): void;
/**
* Obtains a list of trusted devices.
*
* @return Returns a list of trusted devices.
* @systemapi this method can be used only by system applications.
*/
getTrustedDeviceListSync(): Array<DeviceInfo>;
/**
* Obtains a list of trusted devices.
*
* @since 8
* @param callback Indicates the callback to be invoked upon getTrustedDeviceList
* @return Returns a list of trusted devices.
* @systemapi this method can be used only by system applications.
*/
getTrustedDeviceList(callback:AsyncCallback<Array<DeviceInfo>>): void;
/**
* Obtains a list of trusted devices.
*
* @since 8
* @return Returns a list of trusted devices.
* @systemapi this method can be used only by system applications.
*/
getTrustedDeviceList(): Promise<Array<DeviceInfo>>;
/**
* Obtains local device info
*
* @since 8
* @return Returns local device info.
* @systemapi this method can be used only by system applications.
*/
getLocalDeviceInfoSync(): DeviceInfo;
/**
* Obtains local device info
*
* @since 8
* @param callback Indicates the callback to be invoked upon getLocalDeviceInfo
* @return Returns local device info.
* @systemapi this method can be used only by system applications.
*/
getLocalDeviceInfo(callback:AsyncCallback<DeviceInfo>): void;
/**
* Obtains local device info
*
* @since 8
* @return Returns local device info.
* @systemapi this method can be used only by system applications.
*/
getLocalDeviceInfo(): Promise<DeviceInfo>;
/**
* Start to discover device.
*
* @since 8
* @param subscribeInfo subscribe info to discovery device
* @systemapi this method can be used only by system applications.
*/
startDeviceDiscovery(subscribeInfo: SubscribeInfo): void;
/**
* Start to discover device.
*
* @since 9
* @param subscribeInfo subscribe info to discovery device
* @param filterOptions filterOptions to filter discovery device
* @systemapi this method can be used only by system applications.
*/
startDeviceDiscovery(subscribeInfo: SubscribeInfo, filterOptions?: string): void;
/**
* Stop to discover device.
*
* @param subscribeId Service subscribe ID
* @systemapi this method can be used only by system applications.
*/
stopDeviceDiscovery(subscribeId: number): void;
/**
* Publish discover device.
* @since 9
* @param publishInfo publish info to Publish discovery device
* @systemapi this method can be used only by system applications.
*/
publishDeviceDiscovery(publishInfo: PublishInfo): void;
/**
* UnPublish discover device.
* @since 9
* @param publishId Service publish ID, identify a publish operation, should be a unique id in package range
* @systemapi this method can be used only by system applications.
*/
unPublishDeviceDiscovery(publishId: number): void;
/**
* Authenticate the specified device.
*
* @param deviceInfo deviceInfo of device to authenticate
* @param authParam authParam of device to authenticate
* @param callback Indicates the callback to be invoked upon authenticateDevice
* @systemapi this method can be used only by system applications.
*/
authenticateDevice(deviceInfo: DeviceInfo, authParam: AuthParam, callback: AsyncCallback<{deviceId: string, pinTone ?: number}>): void;
/**
* unAuthenticate the specified device.
*
* @since 8
* @param deviceInfo deviceInfo of device to unAuthenticate
* @systemapi this method can be used only by system applications.
*/
unAuthenticateDevice(deviceInfo: DeviceInfo): void
/**
* verify auth info, such as pin code.
*
* @param authInfo device auth info o verify
* @param callback Indicates the callback to be invoked upon verifyAuthInfo
* @systemapi this method can be used only by system applications.
*/
verifyAuthInfo(authInfo: AuthInfo, callback: AsyncCallback<{deviceId: string, level: number}>): void;
/**
* Set user Operation from devicemanager ui, this interface can only be used by devicemanager ui.
*
* @since 9
* @param operateAction User Operation Actions.
* operateAction = 0 - allow authentication
* operateAction = 1 - cancel authentication
* operateAction = 2 - user operation timeout for authentication confirm
* operateAction = 3 - cancel pincode display
* operateAction = 4 - cancel pincode input
* operateAction = 5 - confirm pincode input
* @param params Indicates the input param of the user.
* @throws {BusinessError} 401 - Input parameter error.
* @systemapi this method can be used only by system applications.
*/
setUserOperation(operateAction: number, params: string): void;
/**
* Register a callback from deviceManager service so that the devicemanager ui can be notified when ui statue
* changes.
*
* @since 9
* @param callback Indicates the devicemanager ui state to register.
* @throws {BusinessError} 401 - Input parameter error.
* @systemapi this method can be used only by system applications.
*/
on(type: 'uiStateChange', callback: Callback<{ param: string}>): void;
/**
* Unregister uiStatueChange, this interface can only be used by devicemanager ui.
*
* @since 9
* @param callback Indicates the devicemanager ui state to unregister.
* @throws {BusinessError} 401 - Input parameter error.
* @systemapi this method can be used only by system applications.
*/
off(type: 'uiStateChange', callback?: Callback<{ param: string}>): void;
/**
* Register a device state callback so that the application can be notified upon device state changes based on
* the application bundle name.
*
* @param bundleName Indicates the bundle name of the application.
* @param callback Indicates the device state callback to register.
* @systemapi this method can be used only by system applications.
*/
on(type: 'deviceStateChange', callback: Callback<{ action: DeviceStateChangeAction, device: DeviceInfo }>): void;
/**
* UnRegister device state callback based on the application bundle name.
*
* @param bundleName Indicates the bundle name of the application.
* @param callback Indicates the device state callback to register.
* @systemapi this method can be used only by system applications.
*/
off(type: 'deviceStateChange', callback?: Callback<{ action: DeviceStateChangeAction, device: DeviceInfo }>): void;
/**
* Register a device found callback so that the application can be notified when the device was found
*
* @param callback Indicates the device found callback to register.
* @systemapi this method can be used only by system applications.
*/
on(type: 'deviceFound', callback: Callback<{ subscribeId: number, device: DeviceInfo }>): void;
/**
* UnRegister a device found callback so that the application can be notified when the device was found
*
* @param callback Indicates the device found callback to register.
* @systemapi this method can be used only by system applications.
*/
off(type: 'deviceFound', callback?: Callback<{ subscribeId: number, device: DeviceInfo }>): void;
/**
* Register a device found result callback so that the application can be notified when the device discover was failed
*
* @param callback Indicates the device found result callback to register.
* @systemapi this method can be used only by system applications.
*/
on(type: 'discoverFail', callback: Callback<{ subscribeId: number, reason: number }>): void;
/**
* UnRegister a device found result callback so that the application can be notified when the device discover was failed
*
* @param callback Indicates the device found result callback to register.
* @systemapi this method can be used only by system applications.
*/
off(type: 'discoverFail', callback?: Callback<{ subscribeId: number, reason: number }>): void;
/**
* Register a device publish result callback so that the application can be notified when the device publish success
*
* @since 9
* @param callback Indicates the device publish result callback to register.
* @systemapi this method can be used only by system applications.
*/
on(type: 'publishSuccess', callback: Callback<{ publishId: number }>): void;
/**
* UnRegister a device publish result callback so that the application can be notified when the device publish was failed
*
* @since 9
* @param callback Indicates the device publish result callback to register.
* @systemapi this method can be used only by system applications.
*/
off(type: 'publishSuccess', callback?: Callback<{ publishId: number }>): void;
/**
* Register a device publish result callback so that the application can be notified when the device publish was failed
*
* @since 9
* @param callback Indicates the device publish result callback to register.
* @systemapi this method can be used only by system applications.
*/
on(type: 'publishFail', callback: Callback<{ publishId: number, reason: number }>): void;
/**
* UnRegister a device publish result callback so that the application can be notified when the device publish was failed
*
* @since 9
* @param callback Indicates the device publish result callback to register.
* @systemapi this method can be used only by system applications.
*/
off(type: 'publishFail', callback?: Callback<{ publishId: number, reason: number }>): void;
/**
* Register a serviceError callback so that the application can be notified when devicemanager service died
*
* @param callback Indicates the service error callback to register.
* @systemapi this method can be used only by system applications.
*/
on(type: 'serviceDie', callback: () => void): void;
/**
* UnRegister a serviceError callback so that the application can be notified when devicemanager service died
*
* @param callback Indicates the service error callback to register.
* @systemapi this method can be used only by system applications.
*/
off(type: 'serviceDie', callback?: () => void): void;
}
}
export default deviceManager;
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/taps-oh/applications_device_manager.git
git@gitee.com:taps-oh/applications_device_manager.git
taps-oh
applications_device_manager
applications_device_manager_tv
master

搜索帮助