mirror of
https://gitee.com/openharmony/xts_dcts
synced 2024-11-23 15:50:20 +00:00
DM新接口适配
Signed-off-by: yueye <yueye2@huawei.com>
This commit is contained in:
parent
20636f01c7
commit
5c0a0c45ed
@ -13,10 +13,9 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import deviceManager from '@ohos.distributedHardware.deviceManager';
|
import deviceManager from '@ohos.distributedDeviceManager';
|
||||||
import featureAbility from '@ohos.ability.featureAbility';
|
import featureAbility from '@ohos.ability.featureAbility';
|
||||||
|
|
||||||
var results;
|
|
||||||
var bundleName = "com.ohos.fileiotest";
|
var bundleName = "com.ohos.fileiotest";
|
||||||
var abilityName = "com.ohos.fileiotest.ServiceAbility";
|
var abilityName = "com.ohos.fileiotest.ServiceAbility";
|
||||||
var deviceList;
|
var deviceList;
|
||||||
@ -26,8 +25,8 @@ export default class TestService {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
getDeviceList(deviceManager) {
|
getDeviceList(dmInstance) {
|
||||||
deviceList = deviceManager.getTrustedDeviceListSync();
|
deviceList = dmInstance.getAvailableDeviceListSync();
|
||||||
console.info("getDeviceList success, deviceList id: " + JSON.stringify(deviceList))
|
console.info("getDeviceList success, deviceList id: " + JSON.stringify(deviceList))
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -35,34 +34,32 @@ export default class TestService {
|
|||||||
console.info("fileioClient: toConnectAbility")
|
console.info("fileioClient: toConnectAbility")
|
||||||
return new Promise(resolve=>{
|
return new Promise(resolve=>{
|
||||||
let self = this;
|
let self = this;
|
||||||
deviceManager.createDeviceManager('com.ohos.fileiotest', (error, deviceManager) => {
|
let dmInstance = deviceManager.createDeviceManager('com.ohos.fileiotest');
|
||||||
self.getDeviceList(deviceManager);
|
self.getDeviceList(dmInstance);
|
||||||
console.info("fileioClient: got deviceManager: " + deviceManager)
|
console.info("fileioClient: got deviceManager: " + dmInstance)
|
||||||
let networkId = deviceList[0].networkId
|
let networkId = deviceList[0].networkId
|
||||||
console.info("fileioClient: deviceid : " + networkId)
|
console.info("fileioClient: deviceid : " + networkId)
|
||||||
console.info("fileioClient: online deviceList id: " + JSON.stringify(deviceList))
|
console.info("fileioClient: online deviceList id: " + JSON.stringify(deviceList))
|
||||||
let want = {
|
let want = {
|
||||||
"bundleName": bundleName,
|
"bundleName": bundleName,
|
||||||
"abilityName": abilityName,
|
"abilityName": abilityName,
|
||||||
"deviceId": networkId,
|
"deviceId": networkId,
|
||||||
"flags": 256
|
"flags": 256
|
||||||
|
}
|
||||||
|
let connect = {
|
||||||
|
onConnect: function (elementName, remoteProxy) {
|
||||||
|
console.log('fileioClient: onConnect called, remoteProxy: ' + remoteProxy);
|
||||||
|
resolve(remoteProxy)
|
||||||
|
},
|
||||||
|
onDisconnect: function (elementName) {
|
||||||
|
console.log("fileioClient: onDisconnect")
|
||||||
|
},
|
||||||
|
onFailed: function () {
|
||||||
|
console.log("fileioClient: onFailed")
|
||||||
}
|
}
|
||||||
let connect = {
|
}
|
||||||
onConnect: function (elementName, remoteProxy) {
|
let connectId = featureAbility.connectAbility(want, connect)
|
||||||
console.log('fileioClient: onConnect called, remoteProxy: ' + remoteProxy);
|
console.info("fileioClient: connect ability got id: " + connectId)
|
||||||
resolve(remoteProxy)
|
|
||||||
},
|
|
||||||
onDisconnect: function (elementName) {
|
|
||||||
console.log("fileioClient: onDisconnect")
|
|
||||||
},
|
|
||||||
onFailed: function () {
|
|
||||||
console.log("fileioClient: onFailed")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
let connectId = featureAbility.connectAbility(want, connect)
|
|
||||||
console.info("fileioClient: connect ability got id: " + connectId)
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user