提交 008ed8b8 编写于 作者: Z zhaoyuan17

Update xts service 1201

Signed-off-by: Nzhaoyuan17 <zhaoyuan17@huawei.com>
上级 bb3554f2
......@@ -26,6 +26,7 @@ group("ams_standard") {
"serviceability/sceneProject/particletestserver:ParticleTestServer",
"serviceability/stserviceabilityclient:amsStServiceAbilityClient",
"serviceability/stserviceabilityserver:amsStServiceAilityServer",
"serviceability/stserviceabilityserversecond:stserviceabilityserversecond",
]
}
}
......@@ -22,26 +22,18 @@
"distro": {
"deliveryWithInstall": true,
"moduleName": "entry",
"moduleType": "entry"
"moduleType": "entry",
"installationFree": true
},
"abilities": [
{
"skills": [
{
"entities": [
"entity.system.home"
],
"actions": [
"action.system.home"
]
}
],
"name": "com.amsst.stserviceabilityserver.MainAbility",
"icon": "$media:icon",
"description": "$string:mainability_description",
"label": "$string:app_name",
"type": "service",
"visible": true,
"uri": "serviceability://com.amsst.stserviceabilityserver",
"launchType": "standard"
}
],
......
......@@ -12,12 +12,14 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import rpc from "@ohos.rpc";
let mMyStub;
let mMyProxy;
import particleAbility from '@ohos.ability.particleability'
import featureAbility from '@ohos.ability.featureAbility'
import commonEvent from '@ohos.commonevent'
var serversecond_bundleName = "com.amsst.stserviceabilityserversecond";
var serversecond_abilityName = "com.amsst.stserviceabilityserversecond.MainAbility";
var mConnIdJs;
export default {
data: {
title: ""
......@@ -25,75 +27,150 @@ export default {
onInit() {
this.title = this.$t('strings.world');
},
onStart(want) {
console.log('SerivceAbilityServer onStart');
class MyStub extends rpc.RemoteObject{
constructor(des) {
if (typeof des === 'string') {
super(des, des.length);
onShow() {
console.debug('ACTS_SerivceAbilityServer ====<onShow')
},
onReady() {
console.debug('ACTS_SerivceAbilityServer ====<onReady');
},
onReconnect(want) {
console.debug('ACTS_SerivceAbilityServer ====>onReconnect='
+ want + " , JSON." + JSON.stringify(want));
commonEvent.publish("ACTS_SerivceAbilityServer_onReconnect" + "_" + want.action, (err) => { });
},
onActive() {
console.debug('ACTS_SerivceAbilityServer ====<onActive');
commonEvent.publish("ACTS_SerivceAbilityServer_onActive", (err) => { });
},
onCommand(want, restart, startId) {
console.debug('ACTS_SerivceAbilityServer ====>onCommand='
+ "JSON(want)=" + JSON.stringify(want)
+ " ,restart=" + restart + " ,startId=" + startId);
if (want.action == 'ServiceStartService_0900') {
particleAbility.startAbility(
{
want:
{
bundleName: serversecond_bundleName,
abilityName: serversecond_abilityName,
action: "ServiceStartService_0900",
},
}
return null;
}
onRemoteRequest(code, message, reply, option) {
console.log("RPCTestServer onRemoteRequest code:" + code);
if (code === 1) {
console.log("RPCTestServer: 调用到方法");
let getContextObject = rpc.IPCSkeleton.getContextObject();
console.log("RPCTestServer: getContextObject 方法调用的结果为: " + getContextObject);
let getCallingPid = rpc.IPCSkeleton.getCallingPid();
console.log("RPCTestServer: getCallingPid 方法调用的结果为: " + getCallingPid);
let getCallingUid = rpc.IPCSkeleton.getCallingUid();
console.log("RPCTestServer: getCallingUid 方法调用的结果为: " + getCallingUid);
let getCallingDeviceID = rpc.IPCSkeleton.getCallingDeviceID();
console.log("RPCTestServer: getCallingDeviceID 方法调用的结果为: " + getCallingDeviceID);
let getLocalDeviceID = rpc.IPCSkeleton.getLocalDeviceID();
console.log("RPCTestServer: getLocalDeviceID 方法调用的结果为: " + getLocalDeviceID);
let isLocalCalling = rpc.IPCSkeleton.isLocalCalling();
console.log("RPCTestServer: isLocalCalling 方法调用的结果为: " + isLocalCalling);
let remoteObject = new rpc.RemoteObject("aaa",3);
let flushCommands = rpc.IPCSkeleton.flushCommands(remoteObject);
console.log("RPCTestServer: flushCommands 方法调用的结果为: " + flushCommands);
let resetCallingIdentity = rpc.IPCSkeleton.resetCallingIdentity();
console.log("RPCTestServer: resetCallingIdentity 方法调用的结果为: " + resetCallingIdentity);
let setCallingIdentity = rpc.IPCSkeleton.setCallingIdentity("aaa", 3);
console.log("RPCTestServer: setCallingIdentity 方法调用的结果为: " + setCallingIdentity);
let num = message.readInt();
let msg = message.readString();
console.log("num is " + num + "msg is " + msg);
reply.writeString("Success");
return true;
);
featureAbility.terminateSelf();
} else if (want.action == 'ServiceStartService_1000') {
particleAbility.startAbility(
{
want:
{
bundleName: serversecond_bundleName,
abilityName: serversecond_abilityName,
action: "ServiceStartService_1000",
},
}, (err, data) => {
console.debug('ACTS_SerivceAbilityServer start Ability 1000 callback====='
+ err + ', data= ' + data + " , JSON." + JSON.stringify(data));
featureAbility.terminateSelf();
}
}
);
} else {
commonEvent.publish("ACTS_SerivceAbilityServer_onCommand" + "_" + want.action, (err) => {
if (!err.code) {
if (want.action == 'PageStartService_0100' || want.action == 'PageStartService_0200'
|| want.action == 'PageStartService_0301' || want.action == 'PageStartService_0401') {
console.debug('ACTS_SerivceAbilityServer_onCommand 100 200 301 401.terminateSelf()=====>'
+ want.action);
featureAbility.terminateSelf();
}
} else {
console.debug('ACTS_SerivceAbilityServer_onCommand publish err=====>' + err);
}
});
}
console.log("RPCTestServer: 判断其是否可以创建对象")
mMyStub = new MyStub("ServiceAbility-test");
console.log("xxx RPCTestServer: 创建的对象为:" + mMyStub)
// console.log("RPCTestServer: 向saMgr中注册stub");
// let result = rpc.IPCSkeleton.addLocalAbility(mMyStub);
// console.log("RPCTestServer: 注册的结果为:" + result);
// mMyProxy = rpc.IPCSkeleton.getLocalAbility();
// console.log("RPCTestProxy: 判断当前获取的对象是不是proxy:" + (mMyProxy instanceof rpc.RemoteProxy));
},
onReady() {
console.info('SerivceAbilityServer onReady');
onStart(want) {
console.debug('ACTS_SerivceAbilityServer ====>onStart='
+ want + " , JSON." + JSON.stringify(want));
commonEvent.publish("ACTS_SerivceAbilityServer_onStart", (err) => { });
class MyStub extends rpc.RemoteObject {
constructor(des) { super(des); }
}
console.debug("ACTS_SerivceAbilityServer ====< RPCTestServer");
mMyStub = new MyStub("ServiceAbility-test");
console.debug("ACTS_SerivceAbilityServer RPCTestServer: mMyStub:" + mMyStub
+ " , " + JSON.stringify(mMyStub))
},
onStop() {
console.info('SerivceAbilityServer onStop');
console.debug('ACTS_SerivceAbilityServer ====<onStop');
commonEvent.publish("ACTS_SerivceAbilityServer_onStop", (err) => { });
featureAbility.terminateSelf();
},
onConnect(want) {
console.info('stub SerivceAbilityServer OnConnect');
console.debug('ACTS_SerivceAbilityServer ====>onConnect='
+ want + " , JSON." + JSON.stringify(want));
function onConnectCallback(element, remote) {
console.debug('ACTS_SerivceAbilityServer_onConnectCallback ====> mConnIdJs='
+ JSON.stringify(mConnIdJs) + " , " + mConnIdJs);
console.debug('ACTS_SerivceAbilityServer_onConnectCallback ====> element='
+ JSON.stringify(element) + " , " + element);
console.debug('ACTS_SerivceAbilityServer_onConnectCallback ====> remote='
+ JSON.stringify(remote) + " , " + remote);
}
function onDisconnectCallback(element) {
console.debug('ACTS_SerivceAbilityServer_onDisconnectCallback ====> element='
+ JSON.stringify(element) + " , " + element);
}
function onFailedCallback(code) {
console.debug('ACTS_SerivceAbilityServer_onFailedCallback ====> code='
+ JSON.stringify(code) + " , " + code)
}
if (want.action == 'ServiceConnectService_1300' || want.action == 'ServiceConnectService_1400'
|| want.action == 'ServiceConnectService_1500' || want.action == 'ServiceConnectService_1600') {
mConnIdJs = particleAbility.connectAbility(
{
bundleName: serversecond_bundleName,
abilityName: serversecond_abilityName,
action: want.action,
},
{
onConnect: onConnectCallback,
onDisconnect: onDisconnectCallback,
onFailed: onFailedCallback,
},
)
} else {
commonEvent.publish("ACTS_SerivceAbilityServer_onConnect" + "_" + want.action, (err) => { });
}
return mMyStub;
},
onReconnect(want) {
console.info('SerivceAbilityServer onReconnect');
},
onDisconnect() {
console.info('SerivceAbilityServer OnDisConnect');
OnAbilityConnectDone(element, remoteObject, resultCode) {
console.debug('ACTS_SerivceAbilityServer ====>OnAbilityConnectDone='
+ element + " , JSON." + JSON.stringify(element)
+ remoteObject + " , JSON." + JSON.stringify(remoteObject)
+ resultCode + " , JSON." + JSON.stringify(resultCode)
);
commonEvent.publish("ACTS_SerivceAbilityServer_OnAbilityConnectDone", (err) => { });
},
onCommand(want, restart, startId) {
console.info('SerivceAbilityServer onCommand');
onDisconnect(want) {
console.debug('ACTS_SerivceAbilityServer ====>onDisConnect='
+ want + " , JSON." + JSON.stringify(want));
commonEvent.publish("ACTS_SerivceAbilityServer_onDisConnect", (err) => {
if (err.code) {
console.debug('ACTS_SerivceAbilityServer_onDisConnect publish err=====>' + err);
} else {
console.debug('ACTS_SerivceAbilityServer_onDisConnect featureAbility.terminateSelf()=====<'
+ want.action);
if (want.action == 'ServiceConnectService_1300' || want.action == 'ServiceConnectService_1400'
|| want.action == 'ServiceConnectService_1500' || want.action == 'ServiceConnectService_1501'
|| want.action == 'ServiceConnectService_1600' || want.action == 'ServiceConnectService_1601'
) {
particleAbility.disconnectAbility(mConnIdJs, (err) => {
console.debug("=ACTS_SerivceAbilityServer_onDisConnect 13 14 15 16 err====>"
+ ("json err=") + JSON.stringify(err) + " , " + want.action);
})
}
featureAbility.terminateSelf();
}
});
},
}
\ No newline at end of file
# Copyright (c) 2021 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("//test/xts/tools/build/suite.gni")
ohos_js_hap_suite("amsStServiceAilityServerSecond") {
hap_profile = "./entry/src/main/config.json"
deps = [
":hjs_demo_js_assets",
":hjs_demo_resources",
]
certificate_profile = "./signature/openharmony_sx.p7b"
hap_name = "amsStServiceAilityServerSecond"
}
ohos_js_assets("hjs_demo_js_assets") {
source_dir = "./entry/src/main/js/default"
}
ohos_resources("hjs_demo_resources") {
sources = [ "./entry/src/main/js/resources" ]
hap_profile = "./entry/src/main/config.json"
}
{
"description": "Configuration for hjunit demo Tests"
}
{
"app": {
"bundleName": "com.amsst.stserviceabilityserversecond",
"vendor": "amsst",
"version": {
"code": 1,
"name": "1.0"
},
"apiVersion": {
"compatible": 4,
"target": 5,
"releaseType": "Beta1"
}
},
"deviceConfig": {},
"module": {
"package": "com.amsst.stserviceabilityserversecond",
"name": ".MyApplication",
"deviceType": [
"phone"
],
"distro": {
"deliveryWithInstall": true,
"moduleName": "entry",
"moduleType": "entry",
"installationFree": true
},
"abilities": [
{
"name": "com.amsst.stserviceabilityserversecond.MainAbility",
"icon": "$media:icon",
"description": "$string:mainability_description",
"label": "$string:app_name",
"type": "service",
"visible": true,
"uri": "serviceability://com.amsst.stserviceabilityserversecond",
"launchType": "standard"
}
],
"js": [
{
"pages": [
"pages/index/index"
],
"name": "default",
"window": {
"designWidth": 720,
"autoDesignWidth": false
}
}
]
}
}
\ No newline at end of file
/*
* Copyright (c) 2021 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 {
onCreate() {
console.info('TestApplication onCreate');
},
onDestroy() {
console.info('TestApplication onDestroy');
}
};
{
"strings": {
"hello": "Hello",
"world": "World"
}
}
\ No newline at end of file
{
"strings": {
"hello": "您好",
"world": "世界"
}
}
\ No newline at end of file
.container {
flex-direction: column;
justify-content: center;
align-items: center;
}
.title {
font-size: 100px;
}
.titleST {
font-size: 32px;
}
<div class="container">
<text class="title">
{{ $t('strings.hello') }} {{ title }}
</text>
<text class="titleST">
StServiceAbilityServer
</text>
</div>
/*
* Copyright (c) 2021 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 rpc from "@ohos.rpc";
let mMyStub;
import particleAbility from '@ohos.ability.particleability'
import featureAbility from '@ohos.ability.featureAbility'
import commonEvent from '@ohos.commonevent'
var server_bundleName = "com.amsst.stserviceabilityserver";
var server_abilityName = "com.amsst.stserviceabilityserver.MainAbility";
var mConnIdJs;
export default {
data: {
title: ""
},
onInit() {
this.title = this.$t('strings.world');
},
onShow() {
console.debug('ACTS_SerivceAbilityServer ====<onShow')
},
onReady() {
console.debug('ACTS_SerivceAbilityServerSecond ====<onReady');
},
onReconnect(want) {
console.debug('ACTS_SerivceAbilityServerSecond ====>onReconnect='
+ want + " , JSON." + JSON.stringify(want));
},
onActive() {
console.debug('ACTS_SerivceAbilityServerSecond ====<onActive');
commonEvent.publish("ACTS_SerivceAbilityServerSecond_onActive", (err) => { });
},
onCommand(want, restart, startId) {
console.debug('ACTS_SerivceAbilityServerSecond ====>onCommand='
+ "JSON(want)=" + JSON.stringify(want)
+ " ,restart=" + restart + " ,startId=" + startId);
commonEvent.publish("ACTS_SerivceAbilityServerSecond_onCommand" + "_" + want.action, (err) => { });
featureAbility.terminateSelf();
},
onStart(want) {
console.debug('ACTS_SerivceAbilityServerSecond ====>onStart='
+ want + " , JSON." + JSON.stringify(want));
commonEvent.publish("ACTS_SerivceAbilityServerSecond_onStart", (err) => { });
class MyStub extends rpc.RemoteObject {
constructor(des) { super(des); }
}
console.debug("ACTS_SerivceAbilityServerSecond ====< RPCTestServer");
mMyStub = new MyStub("ServiceAbility-test");
console.debug("ACTS_SerivceAbilityServerSecond RPCTestServer: mMyStub:" + mMyStub
+ " ,JSON. " + JSON.stringify(mMyStub))
},
onStop() {
console.debug('ACTS_SerivceAbilityServerSecond ====<onStop');
commonEvent.publish("ACTS_SerivceAbilityServerSecond_onStop", (err) => { });
featureAbility.terminateSelf();
},
onConnect(want) {
console.debug('ACTS_SerivceAbilityServerSecond ====>onConnect='
+ want + " , JSON." + JSON.stringify(want));
function onConnectCallback(element, remote) {
console.debug('ACTS_SerivceAbilityServerSecond_onConnectCallback ====> want.action='
+ JSON.stringify(want.action) + " , " + want.action);
console.debug('ACTS_SerivceAbilityServerSecond_onConnectCallback ====> element='
+ JSON.stringify(element) + " , " + element);
console.debug('ACTS_SerivceAbilityServerSecond_onConnectCallback ====> remote='
+ JSON.stringify(remote) + " , " + remote);
if(want.action == 'ServiceConnectService_1500' || want.action == 'ServiceConnectService_1600'){
commonEvent.publish("ACTS_SerivceAbilityServerSecond_onConnect" + "_" + want.action, (err) => {
console.debug("publish = ACTS_SerivceAbilityServerSecond_onConnect" + "_" + want.action);
});
}
}
function onDisconnectCallback(element) {
console.debug('ACTS_SerivceAbilityServerSecond_onDisconnectCallback ====> element='
+ JSON.stringify(element) + " , " + element);
}
function onFailedCallback(code) {
console.debug('ACTS_SerivceAbilityServerSecond_onFailedCallback ====> code='
+ JSON.stringify(code) + " , " + code)
}
if (want.action == 'ServiceConnectService_1500') {
mConnIdJs = particleAbility.connectAbility(
{
bundleName: server_bundleName,
abilityName: server_abilityName,
action: "ServiceConnectService_1501",
},
{
onConnect: onConnectCallback,
onDisconnect: onDisconnectCallback,
onFailed: onFailedCallback,
},
)
} else if (want.action == 'ServiceConnectService_1600') {
mConnIdJs = particleAbility.connectAbility(
{
bundleName: server_bundleName,
abilityName: server_abilityName,
action: "ServiceConnectService_1601",
},
{
onConnect: onConnectCallback,
onDisconnect: onDisconnectCallback,
onFailed: onFailedCallback,
},
)
} else if (want.action == 'ServiceConnectService_1590') {
mConnIdJs = particleAbility.connectAbility(
{
bundleName: server_bundleName,
abilityName: server_abilityName,
action: "ServiceConnectService_1591",
},
{
onConnect: onConnectCallback,
onDisconnect: onDisconnectCallback,
onFailed: onFailedCallback,
},
)
} else {
commonEvent.publish("ACTS_SerivceAbilityServerSecond_onConnect" + "_" + want.action, (err) => { });
}
return mMyStub;
},
OnAbilityConnectDone(element, remoteObject, resultCode) {
console.debug('ACTS_SerivceAbilityServerSecond ====>OnAbilityConnectDone='
+ element + " , JSON." + JSON.stringify(element)
+ remoteObject + " , JSON." + JSON.stringify(remoteObject)
+ resultCode + " , JSON." + JSON.stringify(resultCode)
);
commonEvent.publish("ACTS_SerivceAbilityServerSecond_OnAbilityConnectDone", (err) => { });
},
onDisconnect(want) {
console.debug('ACTS_SerivceAbilityServerSecond ====>onDisConnect='
+ want + " , JSON." + JSON.stringify(want));
commonEvent.publish("ACTS_SerivceAbilityServerSecond_onDisConnect", (err) => {
if (err.code) {
console.debug('ACTS_SerivceAbilityServerSecond_onDisConnect publish err=====>' + err);
} else {
console.debug('ACTS_SerivceAbilityServerSecond_onDisConnect featureAbility.terminateSelf()=====<'
+ want.action);
if (want.action == 'ServiceConnectService_1500' || want.action == 'ServiceConnectService_1501'
|| want.action == 'ServiceConnectService_1600' || want.action == 'ServiceConnectService_1601'
|| want.action == 'ServiceConnectService_1590') {
particleAbility.disconnectAbility(mConnIdJs, (err) => {
console.debug("=ACTS_SerivceAbilityServerSecond_onDisConnect err====>"
+ ("json err=") + JSON.stringify(err) + " , " + want.action);
})
}
featureAbility.terminateSelf();
}
});
},
}
\ No newline at end of file
{
"string": [
{
"name": "app_name",
"value": "StServiceAbilityServer"
},
{
"name": "mainability_description",
"value": "hap sample empty page"
}
]
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册