source
stringlengths
14
113
code
stringlengths
10
21.3k
application-dev\basic-services\account\manage-os-account-credential.md
let challenge: Uint8Array = await userIDM.openSession();
application-dev\basic-services\account\manage-os-account-credential.md
let credentialInfo: osAccount.CredentialInfo = { credType: osAccount.AuthType.PIN, credSubType: osAccount.AuthSubType.PIN_SIX, token: new Uint8Array([0]) };
application-dev\basic-services\account\manage-os-account-credential.md
userIDM.addCredential(credentialInfo, { onResult: (code: number, result: osAccount.RequestResult) => { console.log('addCredential code = ' + code); console.log('addCredential result = ' + result); } });
application-dev\basic-services\account\manage-os-account-credential.md
let challenge: Uint8Array = new Uint8Array([1, 2, 3, 4, 5]); let authType: osAccount.AuthType = osAccount.AuthType.PIN; let authTrustLevel: osAccount.AuthTrustLevel = osAccount.AuthTrustLevel.ATL1;
application-dev\basic-services\account\manage-os-account-credential.md
let userAuth: osAccount.UserAuth = new osAccount.UserAuth(); userAuth.auth(challenge, authType, authTrustLevel, { onResult: (result: number, extraInfo: osAccount.AuthResult) => { console.log('pin auth result = ' + result); console.log('pin auth extraInfo = ' + JSON.stringify(extraInfo)); le...
application-dev\basic-services\account\manage-os-account-credential.md
let faceCredInfo: osAccount.CredentialInfo = { credType: osAccount.AuthType.FACE, credSubType: osAccount.AuthSubType.FACE_2D, token: new Uint8Array([1, 2, 3, 4, 5]) }
application-dev\basic-services\account\manage-os-account-credential.md
userIDM.addCredential(faceCredInfo, { onResult: (code: number, result: osAccount.RequestResult) => { console.log('add face credential, resultCode: ' + code); console.log('add face credential, request result: ' + result); } });
application-dev\basic-services\account\manage-os-account-credential.md
let fingerprintCredInfo: osAccount.CredentialInfo = { credType: osAccount.AuthType.FINGERPRINT, credSubType: osAccount.AuthSubType.FINGERPRINT_CAPACITIVE, token: new Uint8Array([1, 2, 3, 4, 5]) }
application-dev\basic-services\account\manage-os-account-credential.md
userIDM.addCredential(fingerprintCredInfo, { onResult: (code: number, result: osAccount.RequestResult) => { console.log('add fingerprint credential, resultCode: ' + code); console.log('add fingerprint credential, request result: ' + result); } });
application-dev\basic-services\account\manage-os-account-credential.md
let challenge: Uint8Array = new Uint8Array([1, 2, 3, 4, 5]); let authType: osAccount.AuthType = osAccount.AuthType.FACE; let authTrustLevel: osAccount.AuthTrustLevel = osAccount.AuthTrustLevel.ATL1;
application-dev\basic-services\account\manage-os-account-credential.md
let userAuth: osAccount.UserAuth = new osAccount.UserAuth(); userAuth.auth(challenge, authType, authTrustLevel, { onResult: (result: number, extraInfo: osAccount.AuthResult) => { console.log('face auth result = ' + result); console.log('face auth extraInfo = ' + JSON.stringify(extraInfo)); } ...
application-dev\basic-services\account\manage-os-account-credential.md
let credentialInfo: osAccount.CredentialInfo = { credType: osAccount.AuthType.PIN, credSubType: osAccount.AuthSubType.PIN_SIX, token: new Uint8Array([1, 2, 3, 4, 5]) };
application-dev\basic-services\account\manage-os-account-credential.md
userIDM.updateCredential(credentialInfo, { onResult: (result: number, extraInfo: osAccount.RequestResult) => { console.log('updateCredential result = ' + result); console.log('updateCredential extraInfo = ' + extraInfo); } });
application-dev\basic-services\account\manage-os-account-credential.md
let enrolledCredInfoList: osAccount.EnrolledCredInfo[] = await userIDM.getAuthInfo();
application-dev\basic-services\account\manage-os-account-credential.md
let enrolledFingerCredInfoList: osAccount.EnrolledCredInfo[] = await userIDM.getAuthInfo(osAccount.AuthType.FINGERPRINT);
application-dev\basic-services\account\manage-os-account-credential.md
let credentialId: Uint8Array = new Uint8Array([1, 2, 3, 4, 5]); let token: Uint8Array = new Uint8Array([1, 2, 3, 4, 5]) let credInfoList: osAccount.EnrolledCredInfo[] = await userIDM.getAuthInfo(osAccount.AuthType.FINGERPRINT); if (credInfoList.length != 0) { credentialId = credInfoList[0].credentialId; ...
application-dev\basic-services\account\manage-os-account-credential.md
userIDM.delCred(credentialId, token, { onResult: (result: number, extraInfo: osAccount.RequestResult) => { console.log('delCred result = ' + result); console.log('delCred extraInfo = ' + JSON.stringify(extraInfo)); } });
application-dev\basic-services\account\manage-os-account-credential.md
pinAuth.unregisterInputer();
application-dev\basic-services\account\manage-os-account-credential.md
userIDM.closeSession();
application-dev\basic-services\account\manage-os-account.md
import { osAccount, BusinessError } from '@kit.BasicServicesKit';
application-dev\basic-services\account\manage-os-account.md
let accountManager = osAccount.getAccountManager();
application-dev\basic-services\account\manage-os-account.md
let name: string = 'Bob'; let type: osAccount.OsAccountType = osAccount.OsAccountType.NORMAL; accountManager.createOsAccount(name, type, (err: BusinessError, osAccountInfo: osAccount.OsAccountInfo)=>{ console.log('createOsAccount err:' + JSON.stringify(err)); console.log('createOsAccount osAccountInfo:' + JSON.str...
application-dev\basic-services\account\manage-os-account.md
accountManager.queryAllCreatedOsAccounts((err: BusinessError, accountArr: osAccount.OsAccountInfo[])=>{ console.log('queryAllCreatedOsAccounts err:' + JSON.stringify(err)); console.log('queryAllCreatedOsAccounts accountArr:' + JSON.stringify(accountArr)); });
application-dev\basic-services\account\manage-os-account.md
let localId: number = 100; accountManager.queryOsAccountById(localId, (err: BusinessError, accountInfo: osAccount.OsAccountInfo)=>{ console.log('queryOsAccountById err:' + JSON.stringify(err)); console.log('queryOsAccountById accountInfo:' + JSON.stringify(accountInfo)); });
application-dev\basic-services\account\manage-os-account.md
let localId: number = 100; let newPhoto: string = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA0AAAAPCAYAAAA/I0V3AAAAAXNSR0IArs4c6QAAAARnQU1BAA'+ 'Cxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAACwSURBVDhPvZLBDYMwDEV/ugsXRjAT0EHCOuFIBwkbdIRewi6unbiAyoGgSn1SFH85+Y'+ 'q/4ljARW62X+LHS8uIzjm4dXUYF+utzBikB52Jo5e5iEPKqp...
application-dev\basic-services\account\manage-os-account.md
let localId: number = 100; let newName: string = 'Tom'; accountManager.setOsAccountName(localId, newName, (err: BusinessError) => { if (err) { console.error('setOsAccountName failed, error: ' + JSON.stringify(err)); } else { console.log('setOsAccountName successfully'); } });
application-dev\basic-services\account\manage-os-account.md
let localId: number = 101; accountManager.activateOsAccount(localId, (err: BusinessError)=>{ if (err) { console.error(`activateOsAccount failed, code is ${err.code}, message is ${err.message}`); } else { console.log('activateOsAccount successfully'); } });
application-dev\basic-services\account\manage-os-account.md
let localId: number = 101; accountManager.removeOsAccount(localId, (err: BusinessError)=>{ if (err) { console.error('removeOsAccount failed, error: ' + JSON.stringify(err)); } else { console.log('removeOsAccount successfully'); } });
application-dev\basic-services\common-event\common-event-publish.md
import { BusinessError, commonEventManager } from '@kit.BasicServicesKit'; import { hilog } from '@kit.PerformanceAnalysisKit'; const TAG: string = 'ProcessModel'; const DOMAIN_NUMBER: number = 0xFF00;
application-dev\basic-services\common-event\common-event-publish.md
// Publish the common event. Replace the event field with the actual event name. commonEventManager.publish('event', (err: BusinessError) => { if (err) { hilog.error(DOMAIN_NUMBER, TAG, `Publish failed, code is ${JSON.stringify(err.code)}, message is ${JSON.stringify(err.message)}`); } else { ...
application-dev\basic-services\common-event\common-event-publish.md
import { BusinessError, commonEventManager } from '@kit.BasicServicesKit'; import { hilog } from '@kit.PerformanceAnalysisKit'; const TAG: string = 'ProcessModel'; const DOMAIN_NUMBER: number = 0xFF00;
application-dev\basic-services\common-event\common-event-publish.md
// Attributes of a common event. let options: commonEventManager.CommonEventPublishData = { code: 1, // Result code of the common event. data: 'initial data', // Initial data of the common event. };
application-dev\basic-services\common-event\common-event-publish.md
// Publish the common event. Replace the event field with the actual event name. commonEventManager.publish('event', options, (err: BusinessError) => { if (err) { hilog.error(DOMAIN_NUMBER, TAG, `Failed to publish common event. Code is ${err.code}, message is ${err.message}`); } else { //... ...
application-dev\basic-services\common-event\common-event-remove-sticky.md
import { BusinessError, commonEventManager } from '@kit.BasicServicesKit'; import { hilog } from '@kit.PerformanceAnalysisKit'; const TAG: string = 'ProcessModel'; const DOMAIN_NUMBER: number = 0xFF00;
application-dev\basic-services\common-event\common-event-remove-sticky.md
// Remove the sticky common event. Replace the event field with the actual event name. commonEventManager.removeStickyCommonEvent('event', (err: BusinessError) => { // sticky_event indicates the name of the target sticky common event. if (err) { hilog.error(DOMAIN_NUMBER, TAG, `Failed to remove stic...
application-dev\basic-services\common-event\common-event-static-subscription.md
import { commonEventManager, StaticSubscriberExtensionAbility } from '@kit.BasicServicesKit'; import { hilog } from '@kit.PerformanceAnalysisKit'; const TAG: string = 'StaticSubscriber'; const DOMAIN_NUMBER: number = 0xFF00; export default class StaticSubscriber extends StaticSubscriberExtensionAbility...
application-dev\basic-services\common-event\common-event-subscription.md
import { BusinessError, commonEventManager } from '@kit.BasicServicesKit'; import { hilog } from '@kit.PerformanceAnalysisKit'; const TAG: string = 'ProcessModel'; const DOMAIN_NUMBER: number = 0xFF00;
application-dev\basic-services\common-event\common-event-subscription.md
// Used to save the created subscriber object for subsequent subscription and unsubscription. let subscriber: commonEventManager.CommonEventSubscriber | null = null; //Subscriber information. Replace the event field with the actual event name. let subscribeInfo: commonEventManager.CommonEventSubscribeInfo = { ...
application-dev\basic-services\common-event\common-event-subscription.md
// Callback for subscriber creation. commonEventManager.createSubscriber(subscribeInfo, (err: BusinessError, data: commonEventManager.CommonEventSubscriber) => { if (err) { hilog.error(DOMAIN_NUMBER, TAG, `Failed to create subscriber. Code is ${err.code}, message is ${err.message}`); return; ...
application-dev\basic-services\common-event\common-event-subscription.md
// Callback for common event subscription. if (subscriber !== null) { commonEventManager.subscribe(subscriber, (err: BusinessError, data: commonEventManager.CommonEventData) => { if (err) { hilog.error(DOMAIN_NUMBER, TAG, `Failed to subscribe common event. Code is ${err.code}, message is ${err.m...
application-dev\basic-services\common-event\common-event-unsubscription.md
import { BusinessError, commonEventManager } from '@kit.BasicServicesKit'; import { hilog } from '@kit.PerformanceAnalysisKit'; const TAG: string = 'ProcessModel'; const DOMAIN_NUMBER: number = 0xFF00;
application-dev\basic-services\common-event\common-event-unsubscription.md
// The subscriber object is created during event subscription. if (subscriber !== null) { commonEventManager.unsubscribe(subscriber, (err: BusinessError) => { if (err) { hilog.error(DOMAIN_NUMBER, TAG, `UnsubscribeCallBack err = ${JSON.stringify(err)}`); } else { hilog.info(DOMAI...
application-dev\basic-services\common-event\itc-with-emitter.md
import { emitter, Callback } from '@kit.BasicServicesKit';
application-dev\basic-services\common-event\itc-with-emitter.md
// Define an event with eventId 1. let event: emitter.InnerEvent = { eventId: 1 }; // Define a callback for an event. let callback: Callback<emitter.EventData> = (eventData: emitter.EventData) => { console.info(`eventData: ${JSON.stringify(eventData)}`); } // Execute the callback af...
application-dev\basic-services\common-event\itc-with-emitter.md
// Execute the callback after receiving the event whose eventId is 1. // Note that the event is received only once using once(), while the event is received until the subscription is canceled using on(). emitter.once(innerEvent, callback);
application-dev\basic-services\common-event\itc-with-emitter.md
// Define an event with eventId 1 and priority Low. let event: emitter.InnerEvent = { eventId: 1, priority: emitter.EventPriority.LOW }; let callback: Callback<emitter.EventData> = (eventData: emitter.EventData) => { console.info(`eventData: ${JSON.stringify(eventData)}`); } // Subscribes...
application-dev\basic-services\common-event\itc-with-emitter.md
// Unsubscribe from the event with eventId 1. emitter.off(1);
application-dev\basic-services\compress\deflate-and-inflate.md
import { fileIo as fs} from '@kit.CoreFileKit'; import { BusinessError, zlib } from '@kit.BasicServicesKit'; @Entry @Component struct Index { @State dataSize: number = 0; build() { Row() { Column() { // Create the data.txt file and write test data. Button('C...
application-dev\basic-services\compress\deflate-and-inflate.md
import { fileIo as fs} from '@kit.CoreFileKit'; import { BusinessError, zlib } from '@kit.BasicServicesKit'; @Entry @Component struct Index { build() { Row() { // Example 1: Compress the data.txt file into the data.zip file. Button('compressFile').onClick(() => { le...
application-dev\basic-services\compress\deflate-and-inflate.md
import { fileIo as fs} from '@kit.CoreFileKit'; import { BusinessError, zlib } from '@kit.BasicServicesKit'; @Entry @Component struct Index { @State dataSize: number = 0; // Size of the original data. build() { Row() { // Example 1: Read the data.txt file and save it to a buffer....
application-dev\basic-services\compress\deflate-and-inflate.md
import { fileIo as fs} from '@kit.CoreFileKit'; import { BusinessError, zlib } from '@kit.BasicServicesKit'; @Entry @Component struct Index { build() { Row() { // Example 1: Continuously read data from a file for compression. Button('deflateFile').onClick(() => { le...
application-dev\basic-services\compress\deflate-and-inflate.md
import { fileIo as fs} from '@kit.CoreFileKit'; import { BusinessError, zlib } from '@kit.BasicServicesKit'; @Entry @Component struct Index { build() { Row() { // Example 1: Continuously read data from a file for compression. Button('deflateGzipFile').onClick(() => { ...
application-dev\basic-services\pasteboard\pasteboard-time-lapse-copy-and-paste.md
\ import {unifiedDataChannel, uniformTypeDescriptor} from '@kit.ArkData'; import {BusinessError, pasteboard} from '@kit.BasicServicesKit'
application-dev\basic-services\pasteboard\pasteboard-time-lapse-copy-and-paste.md
let plainTextData = new unifiedDataChannel.UnifiedData(); let GetDelayPlainText = ((dataType:string) => { let plainText = new unifiedDataChannel.PlainText(); plainText.details = { Key: 'delayPlaintext', Value: 'delayPlaintext', }; plainText.textContent = 'delayTextContent'; pla...
application-dev\basic-services\pasteboard\pasteboard-time-lapse-copy-and-paste.md
let SetDelayPlainText = (() => { plainTextData.properties.shareOptions = unifiedDataChannel.ShareOptions.CROSS_APP; // For cross-application use, set this parameter to CROSS_APP. For intra-application use, set this parameter to IN_APP. plainTextData.properties.getDelayData = GetDelayPlainText; paste...
application-dev\basic-services\pasteboard\pasteboard-time-lapse-copy-and-paste.md
let GetPlainTextUnifiedData = (() => { pasteboard.getSystemPasteboard().getUnifiedData().then((data) => { let outputData = data; let records = outputData.getRecords(); if (records[0].getType() == uniformTypeDescriptor.UniformDataType.PLAIN_TEXT) { let record = records[0] as unifiedDat...
application-dev\basic-services\pasteboard\use_pasteboard_to_copy_and_paste.md
import {unifiedDataChannel, uniformTypeDescriptor} from '@kit.ArkData'; import {BusinessError, pasteboard} from '@kit.BasicServicesKit'; // Construct a piece of PlainText data and write the function for obtaining the delay data. let plainTextData = new unifiedDataChannel.UnifiedData(); let GetDelayPlainText = ((dataTy...
application-dev\basic-services\pasteboard\use_pasteboard_to_copy_and_paste.md
import {BusinessError, pasteboard} from '@kit.BasicServicesKit'; // Obtain the system pasteboard object. let text = "test"; // Create a pasteboard content object of the plain text type. let pasteData = pasteboard.createData(pasteboard.MIMETYPE_TEXT_PLAIN, text); // Write data to the system pasteboard. let systemPastebo...
application-dev\basic-services\request\app-file-upload-download.md
// Approach 1: Use request.uploadFile. // pages/xxx.ets import { common } from '@kit.AbilityKit'; import fs from '@ohos.file.fs'; import { BusinessError, request } from '@kit.BasicServicesKit'; @Entry @Component struct Index { build() { Row() { Column() { Button("Upload").onClick(() => { ...
application-dev\basic-services\request\app-file-upload-download.md
// Approach 2: Use request.agent. // pages/xxx.ets import { common } from '@kit.AbilityKit'; import fs from '@ohos.file.fs'; import { BusinessError, request } from '@kit.BasicServicesKit'; @Entry @Component struct Index { build() { Row() { Column() { Button("Upload").onClick(() => { // Ob...
application-dev\basic-services\request\app-file-upload-download.md
// Approach 1: Use request.downloadFile. // pages/xxx.ets // Download the network resource file to the local application file directory, and read data from the file. import { common } from '@kit.AbilityKit'; import fs from '@ohos.file.fs'; import { BusinessError, request } from '@kit.BasicServicesKit'; import { buffer ...
application-dev\basic-services\request\app-file-upload-download.md
// Approach 2: Use request.agent. // pages/xxx.ets // Download the network resource file to the local application file directory, and read data from the file. import { common } from '@kit.AbilityKit'; import fs from '@ohos.file.fs'; import { BusinessError, request } from '@kit.BasicServicesKit'; import { buffer } from ...
application-dev\basic-services\request\app-file-upload-download.md
import { BusinessError, request } from '@kit.BasicServicesKit'; import { picker } from '@kit.CoreFileKit'; import { common } from '@kit.AbilityKit'; @Entry @Component struct Index { build() { Row() { Column() { Button("Download Document").width("50%").margin({ top: 20 }).height(40).onClick(async ()...
application-dev\basic-services\request\app-file-upload-download.md
import { BusinessError, request } from '@kit.BasicServicesKit'; import { picker } from '@kit.CoreFileKit'; import { common } from '@kit.AbilityKit'; @Entry @Component struct Index { build() { Row() { Column() { Button("Download Audio").width("50%").margin({ top: 20 }).height(40).onClick(async () =>...
application-dev\basic-services\request\app-file-upload-download.md
import { BusinessError, request } from '@kit.BasicServicesKit'; import { photoAccessHelper } from '@kit.MediaLibraryKit'; import { bundleManager } from '@kit.AbilityKit'; import { abilityAccessCtrl, Context, PermissionRequestResult, common } from '@kit.AbilityKit'; @Entry @Component struct Index { build() { Row...
application-dev\basic-services\request\app-file-upload-download.md
{ "network-security-config": { "base-config": { "cleartextTrafficPermitted": true, "trust-anchors": [ { "certificates": "/etc/security/certificates" } ] }, "domain-config": [ { "cleartextTrafficPermitted": true, "domains": [ { ...
application-dev\basic-services\usb\usb-guidelines.md
// Import the USB API package. import { usbManager } from '@kit.BasicServicesKit'; // Obtain the USB device list. let deviceList : Array<usbManager.USBDevice> = usbManager.getDevices(); /* Example deviceList structure: [ { name: "1-1", serial: "", manufacturerName: "", ...
application-dev\basic-services\usb\usb-guidelines.md
import { usbManager } from '@kit.BasicServicesKit'; import { BusinessError } from '@kit.BasicServicesKit'; let deviceName : string = deviceList[0].name; // Request the permissions to operate a specified device. usbManager.requestRight(deviceName).then((hasRight : boolean) => { console.info(`usb device...
application-dev\basic-services\usb\usb-guidelines.md
// Open the device, and obtain the USB device pipe for data transfer. let pipe : usbManager.USBDevicePipe = usbManager.connectDevice(deviceList[0]); let interface1 : usbManager.USBInterface = deviceList[0].configs[0].interfaces[0]; /* Claim the corresponding interface from **deviceList**. interface1 mus...
application-dev\basic-services\usb\usb-guidelines.md
import { usbManager } from '@kit.BasicServicesKit'; import { BusinessError } from '@kit.BasicServicesKit'; /* Read data. Select the corresponding RX endpoint from deviceList for data transfer. (endpoint.direction == 0x80); dataUint8Array indicates the data to read. The data type is Uint8Array. */ ...
application-dev\basic-services\usb\usb-guidelines.md
import { usbManager } from '@kit.BasicServicesKit'; import { BusinessError } from '@kit.BasicServicesKit'; /* Construct control transfer parameters. */ let param: usbManager.USBDeviceRequestParams = { bmRequestType: 0x80, // 0x80 indicates a standard request for data transfer from the de...
application-dev\basic-services\usb\usb-guidelines.md
usbManager.releaseInterface(pipe, interface1); usbManager.closePipe(pipe);
application-dev\basic-services\usb\usbManager\usbHost\bulkTransfer.md
// Import the usbManager module. import { usbManager } from '@kit.BasicServicesKit'; import { BusinessError } from '@kit.BasicServicesKit';
application-dev\basic-services\usb\usbManager\usbHost\bulkTransfer.md
// Obtain the USB device list. let deviceList : Array<usbManager.USBDevice> = usbManager.getDevices(); /* Example deviceList structure: [ { name: "1-1", serial: "", manufacturerName: "", productName: "", version: "", vendorId: 7531, productId: 2, ...
application-dev\basic-services\usb\usbManager\usbHost\bulkTransfer.md
let deviceName : string = deviceList[0].name; // Request the permissions to operate a specified device. usbManager.requestRight(deviceName).then((hasRight : boolean) => { console.info(`usb device request right result: ${hasRight}`); }).catch((error : BusinessError)=> { console.error(`usb device reque...
application-dev\basic-services\usb\usbManager\usbHost\bulkTransfer.md
// Open the device, and obtain the USB device pipe for data transfer. let pipe : usbManager.USBDevicePipe = usbManager.connectDevice(deviceList[0]); let interface1 : usbManager.USBInterface = deviceList[0].configs[0].interfaces[0]; /* Claim the corresponding interface from deviceList. interface1 must be...
application-dev\basic-services\usb\usbManager\usbHost\bulkTransfer.md
/* Read data. Select the corresponding RX endpoint from deviceList for data transfer. (endpoint.direction == 0x80); dataUint8Array indicates the data to read. The data type is Uint8Array. */ let inEndpoint : usbManager.USBEndpoint = interface1.endpoints[2]; let outEndpoint : usbManager.USBEndpoint...
application-dev\basic-services\usb\usbManager\usbHost\bulkTransfer.md
usbManager.releaseInterface(pipe, interface1); usbManager.closePipe(pipe);
application-dev\basic-services\usb\usbManager\usbHost\controlTransfer.md
// Import the usbManager module. import { usbManager } from '@kit.BasicServicesKit'; import { BusinessError } from '@kit.BasicServicesKit';
application-dev\basic-services\usb\usbManager\usbHost\controlTransfer.md
// Obtain the USB device list. let deviceList : Array<usbManager.USBDevice> = usbManager.getDevices(); /* Example deviceList structure: [ { name: "1-1", serial: "", manufacturerName: "", productName: "", version: "", vendorId: 7531, productId: 2, ...
application-dev\basic-services\usb\usbManager\usbHost\controlTransfer.md
let deviceName : string = deviceList[0].name; // Request the permissions to operate a specified device. usbManager.requestRight(deviceName).then((hasRight : boolean) => { console.info("usb device request right result: " + hasRight); }).catch((error : BusinessError)=> { console.error(`usb device reque...
application-dev\basic-services\usb\usbManager\usbHost\controlTransfer.md
// Open the device, and obtain the USB device pipe for data transfer. let pipe : usbManager.USBDevicePipe = usbManager.connectDevice(deviceList[0]); let interface1 : usbManager.USBInterface = deviceList[0].configs[0].interfaces[0]; /* Claim the corresponding interface from deviceList. interface1 mus...
application-dev\basic-services\usb\usbManager\usbHost\controlTransfer.md
/* Construct control transfer parameters. */ let param: usbManager.USBDeviceRequestParams = { bmRequestType: 0x80, // 0x80 indicates a standard request for data transfer from the device to the host. bRequest: 0x06, // 0x06 indicates a request for the descriptor. wValue:0x01 << 8 | ...
application-dev\basic-services\usb\usbManager\usbHost\controlTransfer.md
usbManager.releaseInterface(pipe, interface1); usbManager.closePipe(pipe);
application-dev\basic-services\usb\usbManager\usbHost\deviceManager.md
// Import the usbManager module. import { usbManager } from '@kit.BasicServicesKit'; import { BusinessError } from '@kit.BasicServicesKit';
application-dev\basic-services\usb\usbManager\usbHost\deviceManager.md
// Obtain the USB device list. let deviceList : Array<usbManager.USBDevice> = usbManager.getDevices(); /* Example deviceList structure: [ { name: "1-1", serial: "", manufacturerName: "", productName: "", version: "", vendorId: 7531, productId: 2, ...
application-dev\basic-services\usb\usbManager\usbHost\deviceManager.md
let deviceName : string = deviceList[0].name; // Request the permissions to operate a specified device. usbManager.requestRight(deviceName).then((hasRight : boolean) => { console.info("usb device request right result: " + hasRight); }).catch((error : BusinessError)=> { console.error(`usb device reque...
application-dev\basic-services\usb\usbManager\usbHost\deviceManager.md
// Open the device, and obtain the USB device pipe for data transfer. let pipe : usbManager.USBDevicePipe = usbManager.connectDevice(deviceList[0]); let interface1 : usbManager.USBInterface = deviceList[0].configs[0].interfaces[0]; /* Claim the corresponding interface from **deviceList**. interface1 mus...
application-dev\basic-services\usb\usbManager\usbHost\deviceManager.md
usbManager.releaseInterface(pipe, interface1); usbManager.closePipe(pipe);
application-dev\basic-services\usb\usbManager\usbHost\interruptTransfer.md
// Import the usbManager module. import { usbManager } from '@kit.BasicServicesKit';
application-dev\basic-services\usb\usbManager\usbHost\interruptTransfer.md
// Obtain the list of USB devices connected to the host. let usbDevices: Array<usbManager.USBDevice> = usbManager.getDevices(); console.info(`usbDevices: ${usbDevices}`); if(usbDevices.length === 0) { console.error('usbDevices is empty'); return; }
application-dev\basic-services\usb\usbManager\usbHost\interruptTransfer.md
// Check whether the first USB device in the list has the access permission. let usbDevice: usbManager.USBDevice = usbDevices[0]; if(!usbManager.hasRight(usbDevice.name)) { await usbManager.requestRight(usbDevice.name).then(result => { if(!result) { // If the USB device does not have the...
application-dev\basic-services\usb\usbManager\usbHost\interruptTransfer.md
let devicePipe: usbManager.USBDevicePipe = usbManager.connectDevice(usbDevice); let usbConfigs: usbManager.USBConfiguration[] = usbDevice.configs; let usbInterfaces: usbManager.USBInterface[] = []; let usbInterface: usbManager.USBInterface | undefined = undefined let usbEndpoints: usbManager.USBEndpoint[] =...
application-dev\basic-services\usb\usbManager\usbHost\interruptTransfer.md
// Register a communication interface. If the registration is successful, 0 is returned; otherwise, other error codes are returned. let claimInterfaceResult: number = usbManager.claimInterface(devicePipe, usbInterface, true); if (claimInterfaceResult !== 0) { console.error(`claimInterface error = ${claimI...
application-dev\basic-services\usb\usbManager\usbHost\interruptTransfer.md
try { // The communication interface is successfully registered and performs data transfer. let transferParams: usbManager.UsbDataTransferParams = { devPipe: devicePipe, flags: usbManager.UsbTransferFlags.USB_TRANSFER_SHORT_NOT_OK, endpoint: usbEndprint.address, type: usbManager.Us...
application-dev\basic-services\usb\usbManager\usbHost\interruptTransfer.md
usbManager.usbCancelTransfer(transferParams); usbManager.releaseInterface(devicePipe, usbInterface); usbManager.closePipe(devicePipe);
application-dev\basic-services\usb\usbManager\usbHost\isochronousTransfer.md
// Import the usbManager module. import { usbManager } from '@kit.BasicServicesKit';
application-dev\basic-services\usb\usbManager\usbHost\isochronousTransfer.md
// Obtain the list of USB devices connected to the host. let usbDevices: Array<usbManager.USBDevice> = usbManager.getDevices(); console.info(`usbDevices: ${usbDevices}`); if(usbDevices.length === 0) { console.error('usbDevices is empty'); return; }
application-dev\basic-services\usb\usbManager\usbHost\isochronousTransfer.md
// Check whether the first USB device in the list has the access permission. let usbDevice: usbManager.USBDevice = usbDevices[0]; if(!usbManager.hasRight(usbDevice.name)) { await usbManager.requestRight(usbDevice.name).then(result => { if(!result) { // If the USB device does not have the...
application-dev\basic-services\usb\usbManager\usbHost\isochronousTransfer.md
let devicePipe: usbManager.USBDevicePipe = usbManager.connectDevice(usbDevice); let usbConfigs: usbManager.USBConfiguration[] = usbDevice.configs; let usbInterfaces: usbManager.USBInterface[] = []; let usbInterface: usbManager.USBInterface | undefined = undefined let usbEndpoints: usbManager.USBEndpoint[] =...