mirror of
https://gitee.com/openharmony/ability_dmsfwk
synced 2024-11-27 00:20:44 +00:00
commit
f314b25b8c
@ -1,14 +1,31 @@
|
||||
{
|
||||
"name": "entry",
|
||||
"version": "1.0.0",
|
||||
"ohos": {
|
||||
"org": "ohos",
|
||||
"buildTool": "hvigor",
|
||||
"directoryLevel": "module"
|
||||
},
|
||||
"description": "example description",
|
||||
"repository": {},
|
||||
"license": "ISC",
|
||||
"dependencies": {}
|
||||
}
|
||||
|
||||
"license":"ISC",
|
||||
"devDependencies":{},
|
||||
"name":"entry",
|
||||
"ohos":{
|
||||
"org":"ohos",
|
||||
"directoryLevel":"module",
|
||||
"buildTool":"hvigor"
|
||||
},
|
||||
"description":"example description",
|
||||
"repository":{},
|
||||
"version":"1.0.0",
|
||||
"reqPermissions":[
|
||||
{
|
||||
"reason":"need use ohos.permission.GET_BUNDLE_INFO_PRIVILEGED",
|
||||
"name":"ohos.permission.GET_BUNDLE_INFO_PRIVILEGED"
|
||||
},
|
||||
{
|
||||
"reason":"need use ohos.permission.GET_BUNDLE_INFO",
|
||||
"name":"ohos.permission.GET_BUNDLE_INFO"
|
||||
},
|
||||
{
|
||||
"reason":"need use ohos.permission.CHANGE_ABILITY_ENABLED_STATE",
|
||||
"name":"ohos.permission.CHANGE_ABILITY_ENABLED_STATE"
|
||||
},
|
||||
{
|
||||
"name":"ohos.permission.DISTRIBUTED_DATASYNC"
|
||||
}
|
||||
],
|
||||
"dependencies":{}
|
||||
}
|
@ -0,0 +1,49 @@
|
||||
/**
|
||||
* Copyright (c) 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 Ability from '@ohos.application.Ability'
|
||||
|
||||
export default class MainAbility1 extends Ability {
|
||||
onCreate(want, launchParam) {
|
||||
console.log("[Demo] MainAbility onCreate")
|
||||
globalThis.abilityWant = want;
|
||||
}
|
||||
|
||||
onDestroy() {
|
||||
console.log("[Demo] MainAbility onDestroy")
|
||||
}
|
||||
|
||||
onWindowStageCreate(windowStage) {
|
||||
// Main window is created, set main page for this ability
|
||||
console.log("[Demo] MainAbility onWindowStageCreate")
|
||||
|
||||
windowStage.setUIContent(this.context, "pages/MainAbility", null)
|
||||
}
|
||||
|
||||
onWindowStageDestroy() {
|
||||
// Main window is destroyed, release UI related resources
|
||||
console.log("[Demo] MainAbility onWindowStageDestroy")
|
||||
}
|
||||
|
||||
onForeground() {
|
||||
// Ability has brought to foreground
|
||||
console.log("[Demo] MainAbility onForeground")
|
||||
}
|
||||
|
||||
onBackground() {
|
||||
// Ability has back to background
|
||||
console.log("[Demo] MainAbility onBackground")
|
||||
}
|
||||
};
|
@ -0,0 +1,26 @@
|
||||
/**
|
||||
* Copyright (c) 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.
|
||||
*/
|
||||
|
||||
export default class Utils {
|
||||
static sleep(time) {
|
||||
return new Promise((resolve, reject) => {
|
||||
setTimeout(() => {
|
||||
resolve()
|
||||
}, time)
|
||||
}).then(() => {
|
||||
console.info(`sleep ${time} over...`)
|
||||
})
|
||||
}
|
||||
}
|
@ -0,0 +1,67 @@
|
||||
/**
|
||||
* Copyright (c) 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 deviceManager from '@ohos.distributedHardware.deviceManager';
|
||||
|
||||
var SUBSCRIBE_ID = 100;
|
||||
|
||||
export default class RemoteDeviceModel {
|
||||
deviceList = [];
|
||||
deviceManager;
|
||||
|
||||
constructor() {
|
||||
}
|
||||
|
||||
registerDeviceListCallback() {
|
||||
if (typeof (this.deviceManager) === 'undefined') {
|
||||
console.log('[dmsDemo] deviceManager.createDeviceManager begin');
|
||||
let self = this;
|
||||
deviceManager.createDeviceManager('com.ohos.distributedmusicplayer', (error, value) => {
|
||||
if (error) {
|
||||
console.error('createDeviceManager failed.');
|
||||
return;
|
||||
}
|
||||
self.deviceManager = value;
|
||||
self.registerDeviceListCallback_();
|
||||
console.log('[dmsDemo] createDeviceManager callback returned, error=' + error + ' value=' + JSON.stringify(value));
|
||||
});
|
||||
console.log('[dmsDemo] deviceManager.createDeviceManager end');
|
||||
} else {
|
||||
this.registerDeviceListCallback_();
|
||||
}
|
||||
}
|
||||
|
||||
registerDeviceListCallback_(){
|
||||
console.info('[dmsDemo] registerDeviceListCallback');
|
||||
if (this.deviceManager == undefined) {
|
||||
console.error('[dmsDemo] deviceManager has not initialized');
|
||||
return;
|
||||
}
|
||||
|
||||
console.info('[dmsDemo] getTrustedDeviceListSync begin');
|
||||
var list = this.deviceManager.getTrustedDeviceListSync();
|
||||
console.info('[dmsDemo] getTrustedDeviceListSync end, deviceList=' + JSON.stringify(list));
|
||||
if (typeof (list) != 'undefined' && typeof (list.length) != 'undefined') {
|
||||
this.deviceList = list;
|
||||
}
|
||||
console.info('[dmsDemo] callback finished');
|
||||
}
|
||||
|
||||
unregisterDeviceListCallback() {
|
||||
console.info('[dmsDemo] stopDeviceDiscovery ' + SUBSCRIBE_ID);
|
||||
this.deviceManager.stopDeviceDiscovery(SUBSCRIBE_ID);
|
||||
this.deviceList = [];
|
||||
}
|
||||
}
|
@ -0,0 +1,53 @@
|
||||
/**
|
||||
* Copyright (c) 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.
|
||||
*/
|
||||
// @ts-nocheck
|
||||
|
||||
import ServiceExtensionAbility from '@ohos.application.ServiceExtensionAbility';
|
||||
import wantConstant from '@ohos.ability.wantConstant'
|
||||
|
||||
export default class ServiceAbility extends ServiceExtensionAbility {
|
||||
onCreate() {
|
||||
console.info('ServiceAbility onCreate');
|
||||
}
|
||||
|
||||
onRequest(want, startId) {
|
||||
console.info('ServiceAbility onRequest, want: ' + want.abilityName);
|
||||
console.info('ServiceAbility onRequest, startId: ' + startId);
|
||||
console.info('ServiceAbility onRequest');
|
||||
let str = {
|
||||
'deviceId': 'xxx', // remote deviceId
|
||||
'bundleName': 'com.example.continue.hmservice',
|
||||
'abilityName': 'com.example.continue.ServiceAbility',
|
||||
'flags': wantConstant.Flags.FLAG_INSTALL_ON_DEMAND,
|
||||
}
|
||||
console.info('ServiceAbility onRequest START, str is : ' + JSON.stringify(str));
|
||||
|
||||
let options ={
|
||||
windowMode: 0,
|
||||
displayId:2
|
||||
}
|
||||
console.info('ServiceAbility onRequest START, options is : ' + JSON.stringify(options));
|
||||
|
||||
this.context.startAbility(str, options).then((data) => {
|
||||
console.log("ServiceAbility onRequest data: " + JSON.stringify(data))
|
||||
}).catch((error) => {
|
||||
console.log("ServiceAbility onRequest error: " + JSON.stringify(error))
|
||||
})
|
||||
}
|
||||
|
||||
onDestroy() {
|
||||
console.info('ServiceAbility onDestroy');
|
||||
}
|
||||
};
|
@ -0,0 +1,53 @@
|
||||
/**
|
||||
* Copyright (c) 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.
|
||||
*/
|
||||
// @ts-nocheck
|
||||
|
||||
import ServiceExtensionAbility from '@ohos.application.ServiceExtensionAbility';
|
||||
import wantConstant from '@ohos.ability.wantConstant'
|
||||
|
||||
export default class ServiceAbility2 extends ServiceExtensionAbility {
|
||||
onCreate() {
|
||||
console.info('ServiceAbility2 onCreate');
|
||||
}
|
||||
|
||||
onRequest(want, startId) {
|
||||
console.info('ServiceAbility2 onRequest, want: ' + want.abilityName);
|
||||
console.info('ServiceAbility2 onRequest, startId: ' + startId);
|
||||
console.info('ServiceAbility2 onRequest');
|
||||
let str = {
|
||||
'deviceId': '',
|
||||
'bundleName': 'com.example.continue.hmservice',
|
||||
'abilityName': 'com.example.continue.ServiceAbility',
|
||||
'flags': wantConstant.Flags.FLAG_INSTALL_ON_DEMAND,
|
||||
}
|
||||
console.info('ServiceAbility2 onRequest START, str is : ' + JSON.stringify(str));
|
||||
|
||||
let options ={
|
||||
windowMode: 0,
|
||||
displayId:2
|
||||
}
|
||||
console.info('ServiceAbility2 onRequest START, options is : ' + JSON.stringify(options));
|
||||
|
||||
this.context.startAbility(str, options).then((data) => {
|
||||
console.log("ServiceAbility2 onRequest data: " + JSON.stringify(data))
|
||||
}).catch((error) => {
|
||||
console.log("ServiceAbility2 onRequest error: " + JSON.stringify(error))
|
||||
})
|
||||
}
|
||||
|
||||
onDestroy() {
|
||||
console.info('ServiceAbility2 onDestroy');
|
||||
}
|
||||
};
|
@ -12,7 +12,9 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
// @ts-nocheck
|
||||
|
||||
import router from '@system.router'
|
||||
|
||||
var printLog = '[ServiceExtensionDemo]'
|
||||
AppStorage.Link("message")
|
||||
AppStorage.Link("receiveMessage")
|
||||
@ -38,6 +40,13 @@ struct Index {
|
||||
|
||||
Row() {
|
||||
Column() {
|
||||
Button('back')
|
||||
.width(100)
|
||||
.height(50)
|
||||
.onClick(() => {
|
||||
router.back();
|
||||
})
|
||||
|
||||
Button('connect')
|
||||
.width(100)
|
||||
.height(50)
|
||||
@ -65,7 +74,7 @@ struct Index {
|
||||
})
|
||||
}.editable(this.editFlag)
|
||||
}, (item : string) => item.toString())
|
||||
}.height('100%').width('100%').borderWidth(1).align(ItemAlign.Start)
|
||||
}.height('75%').width('100%').borderWidth(1).align(ItemAlign.Start)
|
||||
}.width('30%').height('100%').padding(5)
|
||||
|
||||
Column() {
|
||||
|
@ -12,7 +12,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
// @ts-nocheck
|
||||
|
||||
import router from '@system.router'
|
||||
|
||||
@Entry
|
||||
@ -33,10 +33,11 @@ struct Index {
|
||||
router.push({uri : 'pages/ConnectServiceExtensionAbility'})
|
||||
})
|
||||
|
||||
Button('other')
|
||||
Button('StartAbility+StartAbilityForResult')
|
||||
.width("90%")
|
||||
.height(50)
|
||||
.onClick(() => {
|
||||
router.push({uri : 'pages/StartAbility'})
|
||||
})
|
||||
}.width('100%').height('100%')
|
||||
}
|
||||
|
@ -11,6 +11,30 @@
|
||||
{
|
||||
"name": "MainAbility_label",
|
||||
"value": "StageManualTestSuite"
|
||||
},
|
||||
{
|
||||
"name": "MainAbility1_desc",
|
||||
"value": "description"
|
||||
},
|
||||
{
|
||||
"name": "MainAbility1_label",
|
||||
"value": "label"
|
||||
},
|
||||
{
|
||||
"name": "form_FormAbility_desc",
|
||||
"value": "form_description"
|
||||
},
|
||||
{
|
||||
"name": "form_FormAbility_label",
|
||||
"value": "form_label"
|
||||
},
|
||||
{
|
||||
"name": "form_ServiceAbility_desc",
|
||||
"value": "form_description"
|
||||
},
|
||||
{
|
||||
"name": "form_ServiceAbility_label",
|
||||
"value": "form_label"
|
||||
}
|
||||
]
|
||||
}
|
@ -1,6 +1,10 @@
|
||||
{
|
||||
"src": [
|
||||
"pages/ConnectServiceExtensionAbility",
|
||||
"pages/MainPage"
|
||||
"pages/MainPage",
|
||||
"pages/StartAbility",
|
||||
"pages/startAbilityAndStartAbilityForResultBsb",
|
||||
"pages/startAbilityKsb",
|
||||
"pages/targetBundleList"
|
||||
]
|
||||
}
|
@ -1,17 +1,18 @@
|
||||
{
|
||||
"name": "stagemanualtestsuite",
|
||||
"version": "1.0.0",
|
||||
"ohos": {
|
||||
"org": "ohos",
|
||||
"buildTool": "hvigor",
|
||||
"directoryLevel": "project"
|
||||
},
|
||||
"description": "example description",
|
||||
"repository": {},
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"@ohos/hypium": "1.0.1",
|
||||
"@ohos/hvigor": "1.1.6",
|
||||
"@ohos/hvigor-ohos-plugin": "1.1.6"
|
||||
}
|
||||
}
|
||||
"license": "ISC",
|
||||
"devDependencies": {},
|
||||
"name": "stagemanualtestsuite",
|
||||
"ohos": {
|
||||
"org": "ohos",
|
||||
"directoryLevel": "project",
|
||||
"buildTool": "hvigor"
|
||||
},
|
||||
"description": "example description",
|
||||
"repository": {},
|
||||
"version": "1.0.0",
|
||||
"dependencies": {
|
||||
"@ohos/hypium": "1.0.1",
|
||||
"@ohos/hvigor-ohos-plugin": "1.1.6",
|
||||
"@ohos/hvigor": "1.1.6"
|
||||
}
|
||||
}
|
||||
|
@ -1,14 +1,14 @@
|
||||
{
|
||||
"license": "ISC",
|
||||
"devDependencies": {},
|
||||
"name": "entry",
|
||||
"ohos": {
|
||||
"org": "ohos",
|
||||
"directoryLevel": "module",
|
||||
"buildTool": "hvigor"
|
||||
},
|
||||
"description": "example description",
|
||||
"repository": {},
|
||||
"version": "1.0.0",
|
||||
"dependencies": {}
|
||||
"license": "ISC",
|
||||
"devDependencies": {},
|
||||
"name": "entry",
|
||||
"ohos": {
|
||||
"org": "ohos",
|
||||
"directoryLevel": "module",
|
||||
"buildTool": "hvigor"
|
||||
},
|
||||
"description": "example description",
|
||||
"repository": {},
|
||||
"version": "1.0.0",
|
||||
"dependencies": {}
|
||||
}
|
||||
|
@ -1,18 +1,18 @@
|
||||
{
|
||||
"license":"ISC",
|
||||
"devDependencies":{},
|
||||
"name":"continuationmanager",
|
||||
"ohos":{
|
||||
"org":"ohos",
|
||||
"directoryLevel":"project",
|
||||
"buildTool":"hvigor"
|
||||
},
|
||||
"description":"example description",
|
||||
"repository":{},
|
||||
"version":"1.0.0",
|
||||
"dependencies":{
|
||||
"@ohos/hvigor-ohos-plugin":"1.0.6",
|
||||
"hypium":"^1.0.0",
|
||||
"@ohos/hvigor":"1.0.6"
|
||||
}
|
||||
"license":"ISC",
|
||||
"devDependencies":{},
|
||||
"name":"continuationmanager",
|
||||
"ohos":{
|
||||
"org":"ohos",
|
||||
"directoryLevel":"project",
|
||||
"buildTool":"hvigor"
|
||||
},
|
||||
"description":"example description",
|
||||
"repository":{},
|
||||
"version":"1.0.0",
|
||||
"dependencies":{
|
||||
"@ohos/hvigor-ohos-plugin":"1.0.6",
|
||||
"hypium":"^1.0.0",
|
||||
"@ohos/hvigor":"1.0.6"
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user