提交 c275cd86 编写于 作者: X xuchenghua09

update

Signed-off-by: Nxuchenghua09 <xuchenghua09@huawei.com>
上级 4fefdaaf
...@@ -16,31 +16,44 @@ import commonEvent from '@ohos.commonEvent' ...@@ -16,31 +16,44 @@ import commonEvent from '@ohos.commonEvent'
import ServiceExtension from '@ohos.application.ServiceExtensionAbility' import ServiceExtension from '@ohos.application.ServiceExtensionAbility'
import rpc from '@ohos.rpc'; import rpc from '@ohos.rpc';
var conn = -1; var conn = -1;
function publishCallBackOne () { function publishCallBackOne() {
console.log("========Publish CallBack AMS_ConnectAbility_0100_commonEvent========"); console.log("========Publish CallBack AMS_ConnectAbility_0100_commonEvent========");
} }
function publishCallBackTwo () { function publishCallBackTwo() {
console.log("========Publish CallBack AMS_ConnectAbility_0200_commonEvent========"); console.log("========Publish CallBack AMS_ConnectAbility_0200_commonEvent========");
} }
function publishCallBackThree () { function publishCallBackThree() {
console.log("========Publish CallBack AMS_ConnectAbility_0300_commonEvent========"); console.log("========Publish CallBack AMS_ConnectAbility_0300_commonEvent========");
} }
function publishCallBackFour () { function publishCallBackFour() {
console.log("========Publish CallBack AMS_ConnectAbility_0400_commonEvent========"); console.log("========Publish CallBack AMS_ConnectAbility_0400_commonEvent========");
} }
function publishCallBackFive () { function publishCallBackFive() {
console.log("========Publish CallBack AMS_ConnectAbility_0500_commonEvent========"); console.log("========Publish CallBack AMS_ConnectAbility_0500_commonEvent========");
} }
function publishCallBackSix () { function publishCallBackSix() {
console.log("========Publish CallBack AMS_ConnectAbility_0600_commonEvent========"); console.log("========Publish CallBack AMS_ConnectAbility_0600_commonEvent========");
} }
function publishCallBackzero () { function publishCallBackzero() {
console.log("========Publish CallBack AMSc_disonnectAbility_0100_commonEvent========"); console.log("========Publish CallBack AMSc_disonnectAbility_0100_commonEvent========");
} }
function publishCallBackttwo () { function publishCallBackttwo() {
console.log("========Publish CallBack AMSc_disonnectAbility_0200_commonEvent========"); console.log("========Publish CallBack AMSc_disonnectAbility_0200_commonEvent========");
} }
function onConnectCallback(element, remote) {
console.log('onConnectCallback====> element=' + JSON.stringify(element));
console.log('onConnectCallback====> remote=' + JSON.stringify(remote));
}
function onDisconnectCallback(element) {
console.log('onDisconnectCallback====> element=' + JSON.stringify(element));
}
function onFailedCallback(code) {
console.log('onFailedCallback====> code=' + JSON.stringify(code))
}
export default class ServiceAbility extends ServiceExtension { export default class ServiceAbility extends ServiceExtension {
onCreate(want) { onCreate(want) {
console.log('ServiceAbility onCreate, want: ' + want.abilityName); console.log('ServiceAbility onCreate, want: ' + want.abilityName);
...@@ -85,7 +98,11 @@ export default class ServiceAbility extends ServiceExtension { ...@@ -85,7 +98,11 @@ export default class ServiceAbility extends ServiceExtension {
{ {
bundleName: "com.example.actsconnectabilitysystemabilitytest", bundleName: "com.example.actsconnectabilitysystemabilitytest",
abilityName: "com.example.actsconnectabilitysystemabilitytest.ServiceAbility2", abilityName: "com.example.actsconnectabilitysystemabilitytest.ServiceAbility2",
} }, {
onConnect: onConnectCallback,
onDisconnect: onDisconnectCallback,
onFailed: onFailedCallback
}
); );
}; };
if (want.action == "Eight") { if (want.action == "Eight") {
...@@ -93,7 +110,11 @@ export default class ServiceAbility extends ServiceExtension { ...@@ -93,7 +110,11 @@ export default class ServiceAbility extends ServiceExtension {
{ {
bundleName: "com.example.actsconnectabilitysystemabilitytest", bundleName: "com.example.actsconnectabilitysystemabilitytest",
abilityName: "com.example.actsconnectabilitysystemabilitytest.ServiceAbility3", abilityName: "com.example.actsconnectabilitysystemabilitytest.ServiceAbility3",
} }, {
onConnect: onConnectCallback,
onDisconnect: onDisconnectCallback,
onFailed: onFailedCallback
}
); );
}; };
if (want.action == "Nine") { if (want.action == "Nine") {
...@@ -102,12 +123,16 @@ export default class ServiceAbility extends ServiceExtension { ...@@ -102,12 +123,16 @@ export default class ServiceAbility extends ServiceExtension {
{ {
bundleName: 'com.example.actsconnectabilitysystemabilitytest', bundleName: 'com.example.actsconnectabilitysystemabilitytest',
abilityName: 'com.example.actsconnectabilitysystemabilitytest.ServiceAbility2' abilityName: 'com.example.actsconnectabilitysystemabilitytest.ServiceAbility2'
}) }, {
setTimeout(()=>{ onConnect: onConnectCallback,
extensionContext.disconnectAbility(num).then(()=>{ onDisconnect: onDisconnectCallback,
onFailed: onFailedCallback
})
setTimeout(() => {
extensionContext.disconnectAbility(num).then(() => {
console.log('in disconnectAbility'); console.log('in disconnectAbility');
}) })
},1000) }, 1000)
}; };
if (want.action == "Ten") { if (want.action == "Ten") {
...@@ -116,12 +141,16 @@ export default class ServiceAbility extends ServiceExtension { ...@@ -116,12 +141,16 @@ export default class ServiceAbility extends ServiceExtension {
{ {
bundleName: 'com.example.actsconnectabilitysystemabilitytest', bundleName: 'com.example.actsconnectabilitysystemabilitytest',
abilityName: 'com.example.actsconnectabilitysystemabilitytest.ServiceAbility2' abilityName: 'com.example.actsconnectabilitysystemabilitytest.ServiceAbility2'
}) }, {
setTimeout(()=>{ onConnect: onConnectCallback,
extensionContext.disconnectAbility(num).then(()=>{ onDisconnect: onDisconnectCallback,
onFailed: onFailedCallback
})
setTimeout(() => {
extensionContext.disconnectAbility(num).then(() => {
console.log('in disconnectAbility2'); console.log('in disconnectAbility2');
}) })
},1000) }, 1000)
}; };
if (want.action == "Ten one") { if (want.action == "Ten one") {
...@@ -130,12 +159,16 @@ export default class ServiceAbility extends ServiceExtension { ...@@ -130,12 +159,16 @@ export default class ServiceAbility extends ServiceExtension {
{ {
bundleName: 'com.example.actsconnectabilitysystemabilitytest', bundleName: 'com.example.actsconnectabilitysystemabilitytest',
abilityName: 'com.example.actsconnectabilitysystemabilitytest.ServiceAbility2' abilityName: 'com.example.actsconnectabilitysystemabilitytest.ServiceAbility2'
}) }, {
setTimeout(()=>{ onConnect: onConnectCallback,
extensionContext.disconnectAbility(2222).then(()=>{ onDisconnect: onDisconnectCallback,
onFailed: onFailedCallback
})
setTimeout(() => {
extensionContext.disconnectAbility(2222).then(() => {
console.log('in disconnectAbility3'); console.log('in disconnectAbility3');
}) })
},1000) }, 1000)
}; };
if (want.action == "Ten two") { if (want.action == "Ten two") {
...@@ -144,12 +177,16 @@ export default class ServiceAbility extends ServiceExtension { ...@@ -144,12 +177,16 @@ export default class ServiceAbility extends ServiceExtension {
{ {
bundleName: 'com.example.actsconnectabilitysystemabilitytest', bundleName: 'com.example.actsconnectabilitysystemabilitytest',
abilityName: 'com.example.actsconnectabilitysystemabilitytest.ServiceAbility2' abilityName: 'com.example.actsconnectabilitysystemabilitytest.ServiceAbility2'
}) }, {
setTimeout(()=>{ onConnect: onConnectCallback,
extensionContext.disconnectAbility(2222).then(()=>{ onDisconnect: onDisconnectCallback,
onFailed: onFailedCallback
})
setTimeout(() => {
extensionContext.disconnectAbility(2222).then(() => {
console.log('in disconnectAbility4'); console.log('in disconnectAbility4');
}) })
},1000) }, 1000)
}; };
return new rpc.RemoteObject('connect'); return new rpc.RemoteObject('connect');
...@@ -157,8 +194,8 @@ export default class ServiceAbility extends ServiceExtension { ...@@ -157,8 +194,8 @@ export default class ServiceAbility extends ServiceExtension {
onDisconnect(want) { onDisconnect(want) {
console.log('ServiceAbility onDisconnect, want:' + want.abilityName); console.log('ServiceAbility onDisconnect, want:' + want.abilityName);
commonEvent.publish("AMSc_disonnectAbility_0100_commonEvent",publishCallBackzero); commonEvent.publish("AMSc_disonnectAbility_0100_commonEvent", publishCallBackzero);
commonEvent.publish("AMSc_disonnectAbility_0200_commonEvent",publishCallBackttwo); commonEvent.publish("AMSc_disonnectAbility_0200_commonEvent", publishCallBackttwo);
} }
onDestroy() { onDestroy() {
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
* limitations under the License. * limitations under the License.
*/ */
import file from '@system.file'; import file from '@system.file';
import {Core, ExpectExtend, InstrumentLog, ReportExtend} from "deccjsunit/index.ets" import {Core, ExpectExtend, InstrumentLog, ReportExtend} from "deccjsunit/index"
import testsuite from "../../test/List.test.ets" import testsuite from "../../test/List.test.ets"
@Entry @Entry
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册