未验证 提交 7fda93b3 编写于 作者: O openharmony_ci 提交者: Gitee

!3320 添加卡片的xts测试

Merge pull request !3320 from chengxingzhen/master
......@@ -17,10 +17,23 @@ group("formmanager") {
testonly = true
if (is_standard_system) {
deps = [
"formhostst_ets/formsystemhostc:FormSystemHostC",
"formhostst_ets/formsystemhostf:FormSystemHostF",
"formhostst_ets/formsystemhostg:FormSystemHostG",
"formhostst_ets/formsystemhostk:FormSystemHostK",
"formhostst_ets/formsystemhostl:FormSystemHostL",
"formhostst_ets/formsystemhostn:FormSystemHostN",
"formhostst_ets/formsystemhostnoperm:FormSystemHostNoPerm",
"formhostst_ets/formsystemhosto:FormSystemHostO",
"formhostst_ets/formsystemhostp:FormSystemHostP",
"formproviderst_ets/formsupplyapplicationA:FormSupplyAppA",
"formproviderst_ets/formsupplyapplicationB:FormSupplyAppB",
"formproviderst_ets/formsupplyapplicationD:FormSupplyAppD",
"formproviderst_ets/formsupplyapplicationE:FormSupplyAppE",
"formproviderst_ets/formsupplyapplicationF:FormSupplyAppF",
"formproviderst_ets/formsupplyapplicationG:FormSupplyAppG",
"formproviderst_ets/formsupplyapplicationH:FormSupplyAppH",
"formproviderst_ets/formsupplyapplicationNotSysApp:FormSupplyAppNS",
"formproviderst_ets/formsystemprovidera:FormSystemProviderA",
"formproviderst_ets/formsystemproviderb:FormSystemProviderB",
"formproviderst_ets/formsystemproviderc:FormSystemProviderC",
......@@ -33,6 +46,11 @@ group("formmanager") {
"formsystemtest_ets/formgetformsinfotest/formszerotest:FormsZeroTest",
"formsystemtest_ets/formhostdeathrecipienttest:FormHostDeathRecipientTest",
"formsystemtest_ets/formperformancetest:FormPerformanceTest",
"formsystemtest_ets/formstatetest_disable:FormStateDisableTest",
"formsystemtest_ets/formstatetest_enable:FormStateEnableTest",
"formsystemtest_ets/formstatetest_notifyinvisible:FormStateNotifyInvisibleTest",
"formsystemtest_ets/formstatetest_notifyinvisible2:FormStateNotifyInvisibleTest2",
"formsystemtest_ets/formstatetest_notifyvisible:FormStateNotifyVisibleTest",
"formsystemtest_ets/formstresstest:FormStressTest",
]
}
......
# 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("FormSystemHostC") {
hap_profile = "./entry/src/main/config.json"
deps = [
":hjs_demo_js_assets",
":hjs_demo_resources",
]
ets2abc = true
certificate_profile = "./signature/openharmony_sx.p7b"
hap_name = "FormSystemHostC"
}
ohos_js_assets("hjs_demo_js_assets") {
source_dir = "./entry/src/main/ets/MainAbility"
}
ohos_resources("hjs_demo_resources") {
sources = [ "./entry/src/main/resources" ]
hap_profile = "./entry/src/main/config.json"
}
{
"description": "Configuration for hjunit demo Tests"
}
{
"app": {
"bundleName": "com.ohos.st.formsystemhostc",
"vendor": "ohos",
"version": {
"code": 1000000,
"name": "1.0.0"
},
"apiVersion": {
"compatible": 7,
"releaseType": "Release",
"target": 7
}
},
"deviceConfig": {},
"module": {
"package": "com.ohos.st.formsystemhostc",
"name": ".FormStHostAppC",
"mainAbility": ".MainAbility",
"deviceType": [
"phone"
],
"distro": {
"deliveryWithInstall": true,
"moduleName": "entry",
"moduleType": "entry",
"installationFree": false
},
"abilities": [
{
"skills": [
{
"entities": [
"entity.system.home"
],
"actions": [
"action.system.home"
]
}
],
"visible": true,
"name": ".MainAbility",
"srcLanguage": "ets",
"icon": "$media:icon",
"description": "$string:description_mainability",
"label": "$string:entry_MainAbility",
"type": "page",
"launchType": "standard"
}
],
"js": [
{
"mode": {
"syntax": "ets",
"type": "pageAbility"
},
"pages": [
"pages/index"
],
"name": ".MainAbility",
"window": {
"designWidth": 720,
"autoDesignWidth": false
}
}
],
"defPermissions": [
{
"availableScope": [],
"grantMode": "system_grant",
"name": "FMS_FormDelete_commonEvent"
},
{
"availableScope": [],
"grantMode": "system_grant",
"name": "FMS_FormOnAcquired_commonEvent"
},
{
"availableScope": [],
"grantMode": "system_grant",
"name": "FMS_FormOnError_commonEvent"
},
{
"availableScope": [],
"grantMode": "system_grant",
"name": "FMS_FormCast_commonEvent"
},
{
"availableScope": [],
"grantMode": "system_grant",
"name": "FMS_FormOnDeleted_commonEvent"
},
{
"availableScope": [],
"grantMode": "system_grant",
"name": "FMS_FormOnReleased_commonEvent"
},
{
"availableScope": [],
"grantMode": "system_grant",
"name": "FMS_TimeChange_commonEvent"
}
],
"reqPermissions": [
{
"name": "FMS_FormOnAcquired_commonEvent"
},
{
"name": "FMS_FormDelete_commonEvent"
},
{
"name": "FMS_FormOnError_commonEvent"
},
{
"name": "FMS_FormCast_commonEvent"
},
{
"name": "FMS_FormOnDeleted_commonEvent"
},
{
"name": "FMS_FormOnReleased_commonEvent"
},
{
"name": "FMS_TimeChange_commonEvent"
},
{
"name": "ohos.permission.GET_BUNDLE_INFO_PRIVILEGED"
},
{
"name": "ohos.permission.INSTALL_BUNDLE"
},
{
"name": "ohos.permission.LISTEN_BUNDLE_CHANGE"
},
{
"name": "ohos.permission.REQUIRE_FORM"
}
]
}
}
\ 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('[FormComponent.host] Application onCreate')
},
onDestroy() {
console.info('[FormComponent.host] Application onDestroy')
},
}
\ 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 formManager from '@ohos.ability.formmanager';
import bundleManager from '@ohos.bundle';
import abilityManager from '@ohos.app.abilityManager';
export default class FormViewModel {
private static sFormViewModel: FormViewModel = null;
public static getInstance(): FormViewModel {
if (FormViewModel.sFormViewModel == null) {
FormViewModel.sFormViewModel = new FormViewModel();
}
return FormViewModel.sFormViewModel;
}
public async castTempFormToNormal(formId: string) {
formManager.castTempForm(formId)
.then((data) => {
console.info('[FormComponent] castTempForm result:' + data);
});
}
public async requestForm(formId: string) {
formManager.requestForm(formId)
.then((data) => {
console.info('[FormComponent] requestForm result:' + data);
});
}
public async deleteCard(formId: string) {
formManager.deleteForm(formId)
.then((data) => {
console.info('[FormComponent] deleteForm result:' + data);
});
}
public async releaseCard(formId: string) {
formManager.releaseForm(formId)
.then((data) => {
console.info('[FormComponent] releaseForm result:' + data);
});
}
public async enableCard(formId: string) {
formManager.enableFormsUpdate([formId])
.then((data) => {
console.info('[FormComponent] enableFormsUpdate result:' + data);
});
}
public async disableCard(formId: string) {
formManager.disableFormsUpdate([formId])
.then((data) => {
console.info('[FormComponent] disableCard result:' + data);
});
}
public async changeCardVisible(formId: string, isVisible: boolean) {
if (isVisible) {
formManager.notifyVisibleForms([formId])
.then((data) => {
console.info('[FormComponent] changeCardVisible result:' + data + ', isVisible:' + isVisible);
});
} else {
formManager.notifyInvisibleForms([formId])
.then((data) => {
console.info('[FormComponent] changeCardVisible result:' + data + ', isVisible:' + isVisible);
});
}
}
public async isFmsReady() {
formManager.isSystemReady()
.then((data) => {
console.info('[FormComponent] isFmsReady result:' + data);
});
}
public async getAllFormsInfo() {
formManager.getAllFormsInfo()
.then((data) => {
console.info('[FormComponent] getAllFormsInfo result:' + JSON.stringify(data));
});
}
public async getFormsInfoByApp(bundle: string) {
formManager.getFormsInfo(bundle)
.then((data) => {
console.info('[FormComponent] getFormsInfoByApp result:' + JSON.stringify(data));
});
}
public async getFormsInfoByModule(bundle: string, moduleName: string) {
formManager.getFormsInfo(bundle, moduleName)
.then((data) => {
console.info('[FormComponent] getFormsInfoByModule result:' + JSON.stringify(data));
});
}
public async clearFormUserCache() {
abilityManager.clearUpApplicationData('com.ohos.myapplicationform')
.then((data) => {
console.info('[FormComponent] cleanBundleCacheFiles result:' + JSON.stringify(data));
});
}
public async clearFormProviderCache(bundle: string) {
abilityManager.clearUpApplicationData(bundle)
.then((data) => {
console.info('[FormComponent] cleanBundleCacheFiles result:' + JSON.stringify(data));
});
}
}
\ 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 FormViewModel from './FormViewModel.ets';
import router from '@system.router';
import featureAbility from "@ohos.ability.featureAbility";
import formManager from '@ohos.application.formHost'
import commonEvent from '@ohos.commonEvent';
import systemTime from '@ohos.systemTime';
@Entry
@Component
struct Index {
@State formId: number = 0;
@State bundle: string = "com.form.formsystemtestservicea.hmservice";
@State ability: string = "com.form.formsystemtestservicea.hmservice.MainAbility";
@State moduleName: string = "entry";
@State name: string = "Form_Js001";
@State width: number = 300;
@State height: number = 200;
@State allowUpate: boolean = true;
@State onAcquireResult: string = "";
@State isShowing: boolean = true;
@State canCreateForm: boolean = false;
private dimension: FormDimension = FormDimension.Dimension_1_2;
private releaseForm = false;
private releaseId = "-1";
private deleteForm = false;
private deleteId = "-1";
private temporaryId="-1";
private temporary = false;
private mFormViewModel: FormViewModel;
private isVisible = false;
private mMargin = 15;
private BTN_BG_COLOR: string = '#0D9FFB';
private castForm = false;
private tempFormId: number = 0;
private sendCastForm = false;
private sendCastFormMsg;
private formOnAcquiredEvent = "FMS_FormOnAcquired_commonEvent";
private formCastEvent = "FMS_FormCast_commonEvent";
private formOnErrorEvent = "FMS_FormOnError_commonEvent";
private formOnDeletedEvent = "FMS_FormOnDeleted_commonEvent";
private formOnReleasedEvent = "FMS_FormOnReleased_commonEvent";
private subscriberDel;
private subscriberFormDeleteEvent = {
events: ["FMS_FormDelete_commonEvent"],
};
private subscriberTimeChange;
private subscriberTimeChangeEvent = {
events: ["FMS_TimeChange_commonEvent"],
};
private publishOnErrorCallBack() {
this.canCreateForm = false;
console.debug("====>formsystemhostc formOnErrorEventCallBack ====>");
}
private publishOnDeletedCallBack() {
this.canCreateForm = false;
console.debug("====>formsystemhostc publishOnDeletedCallBack ====>");
}
private publishOnReleasedCallBack() {
this.canCreateForm = false;
console.debug("====>formsystemhostc publishOnReleasedCallBackk ====>");
}
private publishOnAcquiredCallBack() {
console.debug("====>formsystemhostc formOnAcquiredEventCallBack ====>");
}
private publishCastCallBack() {
console.debug("====>formsystemhostc formCastEventCallBack ====>");
}
private deleteCallBack(err, data) {
console.info("!!!====>[FormComponent] deleteCallBack start:====>" + JSON.stringify(data));
if(data.bundleName && data.bundleName != "com.ohos.st.formsystemhostc") {
return;
}
formManager.deleteForm(data.data)
.then((data2) => {
console.info('[FormComponent] deleteForm result:' + data2);
});
this.canCreateForm = false;
console.info("!!!====>[FormComponent] deleteCallBack end ====>");
}
private unSubscribeDeleteCallback() {
console.debug("====>[FormComponent] unSubscribeDeleteCallback_1100 CallBack====>");
}
private timeChangeCallBack(err, data) {
console.info("!!!====>[FormComponent] timeChangeCallBack start:====>" + JSON.stringify(data));
if(data.bundleName && data.bundleName != "com.ohos.st.formsystemhostc") {
return;
}
this.changeTime(data.parameters.hour, data.parameters.min, data.parameters.second);
console.info("!!!====>[FormComponent] timeChangeCallBack end ====>");
}
private unSubscribeTimeChangeCallback() {
console.debug("====>[FormComponent] unSubscribeTimeChangeCallback CallBack====>");
}
/**
*
* @param hour hour of 24H clock
* @param min minute
* @param second second
*/
private changeTime(hour: number, min: number, second: number): void {
let datetime = new Date();
let year = datetime.getFullYear();
let month = datetime.getMonth() + 1;
let day = datetime.getDate();
let formatTime = year + '-' + this.fill(month) + '-' + this.fill(day)
+ 'T' + this.fill(hour) + ':' + this.fill(min) + ':' + this.fill(second);
let s = (new Date(formatTime)).getTime();
systemTime.setTime(s).then(data => {
console.log(`set time success: ${formatTime}, result:${data}`);
}).catch(error => {
console.log(`set time failure: ${error}`);
})
}
private fill(value: number): string {
return (value > 9 ? "" : "0") + value;
}
private aboutToAppear() {
const TAG = "[FormComponent.host]"
this.mFormViewModel = FormViewModel.getInstance();
commonEvent.createSubscriber(this.subscriberFormDeleteEvent).then(async (data) => {
console.info("====>[FormComponent] Subscriber FormDelete data:====>", JSON.stringify(data));
this.subscriberDel = data;
await commonEvent.subscribe(this.subscriberDel, this.deleteCallBack);
})
commonEvent.createSubscriber(this.subscriberTimeChangeEvent).then(async (data) => {
console.info("====>[FormComponent] Subscriber TimeChange data:====>", JSON.stringify(data));
this.subscriberTimeChange = data;
await commonEvent.subscribe(this.subscriberTimeChange, this.timeChangeCallBack);
})
console.error('[FormComponent] getWant');
featureAbility.getWant()
.then((want: any) => {
this.formId = parseInt(want.parameters.formId);
this.name = want.parameters.name;
this.bundle = want.parameters.bundle;
this.ability = want.parameters.ability;
if(want.parameters.moduleName) {
this.moduleName = want.parameters.moduleName;
}
if(want.parameters.temporary) {
this.temporary = want.parameters.temporary;
}
if(want.parameters.dimension) {
this.dimension = want.parameters.dimension;
}
if(!this.dimension) {
this.dimension = FormDimension.Dimension_1_2;
}
if(want.parameters.castForm) {
this.castForm = want.parameters.castForm;
}
if(want.parameters.temporaryId) {
this.temporaryId = want.parameters.temporaryId;
}
if(want.parameters.deleteForm) {
this.deleteForm = want.parameters.deleteForm;
}
if(want.parameters.deleteId) {
this.deleteId = want.parameters.deleteId;
}
if(want.parameters.releaseForm) {
this.releaseForm = want.parameters.releaseForm;
}
if(want.parameters.releaseId) {
this.releaseId = want.parameters.releaseId;
}
if(want.parameters.sendCastForm) {
this.sendCastForm = want.parameters.sendCastForm;
}
if(want.parameters.sendCastFormMsg) {
this.sendCastFormMsg = want.parameters.sendCastFormMsg;
}
setTimeout(() => {
this.canCreateForm = want.parameters.isCreate ? true : false;
console.error('[FormComponent] getWant canCreateForm:'+ this.canCreateForm);
}, 10);
console.error('[FormComponent] getWant end'+ JSON.stringify(want));
if(!want.parameters.isCreate && this.sendCastForm) {
console.log("[FormComponent.host] sendCastForm start");
setTimeout(() => {
let commonEventPublishData = {
data: sendCastFormMsg,
parameters: {
"formId" : ""
}
};
commonEvent.publish(this.formCastEvent, commonEventPublishData, this.publishCastCallBack);
}, 5);
console.log("[FormComponent.host] sendCastForm end");
}
if(!want.parameters.isCreate && this.deleteForm) {
console.log("[FormComponent] deleteForm start");
formManager.deleteForm(this.deleteId)
.then((data) => {
console.info('[FormComponent] deleteForm result:' + data);
let commonEventPublishData = {
data: data.toString(),
parameters: {
"formId" : this.deleteId
}
};
commonEvent.publish(this.formOnDeletedEvent, commonEventPublishData, this.publishOnDeletedCallBack);
})
.catch((error) => {
console.info('[FormComponent] deleteForm error:' + error);
let commonEventPublishData = {
data: error.code.toString(),
parameters: {
"formId" : this.deleteId.toString()
}
};
commonEvent.publish(this.formOnDeletedEvent, commonEventPublishData, this.publishOnDeletedCallBack);
});
console.log("[FormComponent] deleteForm end");
}
if(!want.parameters.isCreate && this.releaseForm) {
console.log("[FormComponent] releaseForm start");
formManager.releaseForm(this.releaseId, true)
.then((data) => {
console.info('[FormComponent] releaseForm result:' + data);
let commonEventPublishData = {
data: data.toString(),
parameters: {
"formId" : this.releaseId
}
};
commonEvent.publish(this.formOnReleasedEvent, commonEventPublishData, this.publishOnReleasedCallBack);
})
.catch((error) => {
console.info('[FormComponent] releaseForm error:' + error);
let commonEventPublishData = {
data: error.code.toString(),
parameters: {
"formId" : this.releaseId
}
};
commonEvent.publish(this.formOnReleasedEvent, commonEventPublishData, this.publishOnReleasedCallBack);
});
console.log("[FormComponent] releaseForm end");
}
})
.catch((error: any) => {
console.error('[FormComponent] Operation failed. Cause: ' + JSON.stringify(error));
})
console.log(`[FormComponent.host] aboutToAppear end`);
}
build() {
Column() {
Text('form component test begin')
Column() {
if (this.canCreateForm) {
FormComponent({
id: this.formId,
name: this.name,
bundle: this.bundle,
ability: this.ability,
module: this.moduleName,
dimension: this.dimension,
temporary: this.temporary,
})
.allowUpdate(this.allowUpate)
.visibility(this.isShowing ? Visibility.Visible : Visibility.Hidden)
.onAcquired((form) => {
console.log("[FormComponent.host] get form, form id:" + form.id);
this.formId = form.id;
if(this.castForm) {
console.log("[FormComponent.host] castTempForm start");
formManager.castTempForm(this.temporaryId)
.then((data) => {
console.info('[FormComponent] castTempForm result:' + data);
setTimeout(() => {
let commonEventPublishData = {
data: data.toString(),
parameters: {
"formId" : this.formId.toString()
}
};
commonEvent.publish(this.formCastEvent, commonEventPublishData, this.publishCastCallBack);
}, 5);
})
.catch((error) => {
console.info('[FormComponent] castTempForm error:' + error);
setTimeout(() => {
let commonEventPublishData = {
data: error.code.toString(),
parameters: {
"formId" : this.formId.toString()
}
};
commonEvent.publish(this.formCastEvent, commonEventPublishData, this.publishCastCallBack);
}, 5);
});
console.log("[FormComponent.host] castTempForm end");
} else if(this.deleteForm) {
console.log("[FormComponent.host] deleteForm start");
if(this.deleteId == "self") {
this.deleteId = this.formId.toString();
}
setTimeout(() => {
formManager.deleteForm(this.deleteId)
.then((data) => {
console.info('[FormComponent] deleteForm result:' + data);
var commonEventPublishData = {
data: data.toString(),
parameters: {
"formId" : this.deleteId
}
};
commonEvent.publish(this.formOnDeletedEvent, commonEventPublishData, this.publishOnDeletedCallBack);
})
.catch((error) => {
console.info('[FormComponent] deleteForm error:' + error);
var commonEventPublishData = {
data: error.code.toString(),
parameters: {
"formId" : this.deleteId
}
};
commonEvent.publish(this.formOnDeletedEvent, commonEventPublishData, this.publishOnDeletedCallBack);
});
console.log("[FormComponent.host] deleteForm end");
}, 1000);
} else if(this.releaseForm) {
console.log("[FormComponent.host] releaseForm start");
if(this.releaseId == "self") {
this.releaseId = this.formId.toString();
}
setTimeout(() => {
formManager.releaseForm(this.releaseId, true)
.then((data) => {
console.info('[FormComponent] releaseForm result:' + data);
var commonEventPublishData = {
data: data.toString(),
parameters: {
"formId" : this.releaseId
}
};
commonEvent.publish(this.formOnReleasedEvent, commonEventPublishData, this.publishOnReleasedCallBack);
})
.catch((error) => {
console.info('[FormComponent] releaseForm error:' + error);
let commonEventPublishData = {
data: error.code.toString(),
parameters: {
"formId" : this.releaseId
}
};
commonEvent.publish(this.formOnReleasedEvent, commonEventPublishData, this.publishOnReleasedCallBack);
});
console.log("[FormComponent.host] releaseForm end");
}, 1000);
} else {
var commonEventPublishData = {
data: this.formId.toString()
};
commonEvent.publish(this.formOnAcquiredEvent, commonEventPublishData, this.publishOnAcquiredCallBack);
}
})
// .onUninstall((info) => {
// console.log("[FormComponent] onUninstall:" + JSON.stringify(info));
// })
.onError((error) => {
console.log("[FormComponent.host] error code:" + error.errcode);
console.log("[FormComponent.host] error msg:" + error.msg);
this.onAcquireResult += error.errcode;
this.onAcquireResult += " ";
this.onAcquireResult += error.msg;
if(this.deleteForm && this.deleteId) {
let commonEventPublishData = {
data: error.msg,
parameters: {
"formId" : this.formId.toString()
}
};
commonEvent.publish(this.formOnDeletedEvent, commonEventPublishData, this.publishOnDeletedCallBack);
} else {
let commonEventPublishData = {
data: error.msg
};
commonEvent.publish(this.formOnErrorEvent, commonEventPublishData, this.publishOnErrorCallBack);
}
})
}
}
.backgroundColor(Color.White)
Text('form component test end')
}
.backgroundColor(Color.White)
}
}
\ No newline at end of file
{
"string": [
{
"name": "entry_MainAbility",
"value": "formhostC"
},
{
"name": "description_mainability",
"value": "ETS_Empty Ability"
}
]
}
\ 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("FormSystemHostF") {
hap_profile = "./entry/src/main/config.json"
deps = [
":hjs_demo_js_assets",
":hjs_demo_resources",
]
ets2abc = true
certificate_profile = "./signature/openharmony_sx.p7b"
hap_name = "FormSystemHostF"
}
ohos_js_assets("hjs_demo_js_assets") {
source_dir = "./entry/src/main/ets/MainAbility"
}
ohos_resources("hjs_demo_resources") {
sources = [ "./entry/src/main/resources" ]
hap_profile = "./entry/src/main/config.json"
}
{
"description": "Configuration for hjunit demo Tests"
}
{
"app": {
"bundleName": "com.ohos.st.formsystemhostf",
"vendor": "ohos",
"version": {
"code": 1000000,
"name": "1.0.0"
},
"apiVersion": {
"compatible": 7,
"releaseType": "Release",
"target": 7
}
},
"deviceConfig": {},
"module": {
"package": "com.ohos.st.formsystemhostf",
"name": ".FormStHostAppF",
"mainAbility": ".MainAbility",
"deviceType": [
"phone"
],
"distro": {
"deliveryWithInstall": true,
"moduleName": "entry",
"moduleType": "entry",
"installationFree": false
},
"abilities": [
{
"skills": [
{
"entities": [
"entity.system.home"
],
"actions": [
"action.system.home"
]
}
],
"visible": true,
"name": ".MainAbility",
"srcLanguage": "ets",
"icon": "$media:icon",
"description": "$string:description_mainability",
"label": "$string:entry_MainAbility",
"type": "page",
"launchType": "standard"
}
],
"js": [
{
"mode": {
"syntax": "ets",
"type": "pageAbility"
},
"pages": [
"pages/index"
],
"name": ".MainAbility",
"window": {
"designWidth": 720,
"autoDesignWidth": false
}
}
],
"defPermissions": [
{
"availableScope": [],
"grantMode": "system_grant",
"name": "FMS_FormDelete_commonEvent"
},
{
"availableScope": [],
"grantMode": "system_grant",
"name": "FMS_FormOnAcquired_commonEvent"
},
{
"availableScope": [],
"grantMode": "system_grant",
"name": "FMS_FormOnError_commonEvent"
},
{
"availableScope": [],
"grantMode": "system_grant",
"name": "FMS_FormOnDeleted_commonEvent"
},
{
"availableScope": [],
"grantMode": "system_grant",
"name": "FMS_FormOnReleased_commonEvent"
},
{
"availableScope": [],
"grantMode": "system_grant",
"name": "FMS_FormUpdateRefresh_commonEvent"
}
],
"reqPermissions": [
{
"name": "FMS_FormOnAcquired_commonEvent"
},
{
"name": "FMS_FormDelete_commonEvent"
},
{
"name": "FMS_FormOnError_commonEvent"
},
{
"name": "FMS_FormOnDeleted_commonEvent"
},
{
"name": "FMS_FormOnReleased_commonEvent"
},
{
"name": "FMS_FormUpdateRefresh_commonEvent"
},
{
"name": "ohos.permission.GET_BUNDLE_INFO_PRIVILEGED"
},
{
"name": "ohos.permission.INSTALL_BUNDLE"
},
{
"name": "ohos.permission.LISTEN_BUNDLE_CHANGE"
},
{
"name": "ohos.permission.REQUIRE_FORM"
}
]
}
}
\ 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('[FormComponent.host] Application onCreate')
},
onDestroy() {
console.info('[FormComponent.host] Application onDestroy')
},
}
\ 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 formManager from '@ohos.ability.formmanager';
import bundleManager from '@ohos.bundle';
import abilityManager from '@ohos.app.abilityManager';
export default class FormViewModel {
private static sFormViewModel: FormViewModel = null;
public static getInstance(): FormViewModel {
if (FormViewModel.sFormViewModel == null) {
FormViewModel.sFormViewModel = new FormViewModel();
}
return FormViewModel.sFormViewModel;
}
public async castTempFormToNormal(formId: string) {
formManager.castTempForm(formId)
.then((data) => {
console.info('[FormComponent] castTempForm result:' + data);
});
}
public async requestForm(formId: string) {
formManager.requestForm(formId)
.then((data) => {
console.info('[FormComponent] requestForm result:' + data);
});
}
public async deleteCard(formId: string) {
formManager.deleteForm(formId)
.then((data) => {
console.info('[FormComponent] deleteForm result:' + data);
});
}
public async releaseCard(formId: string) {
formManager.releaseForm(formId)
.then((data) => {
console.info('[FormComponent] releaseForm result:' + data);
});
}
public async enableCard(formId: string) {
formManager.enableFormsUpdate([formId])
.then((data) => {
console.info('[FormComponent] enableFormsUpdate result:' + data);
});
}
public async disableCard(formId: string) {
formManager.disableFormsUpdate([formId])
.then((data) => {
console.info('[FormComponent] disableCard result:' + data);
});
}
public async changeCardVisible(formId: string, isVisible: boolean) {
if (isVisible) {
formManager.notifyVisibleForms([formId])
.then((data) => {
console.info('[FormComponent] changeCardVisible result:' + data + ', isVisible:' + isVisible);
});
} else {
formManager.notifyInvisibleForms([formId])
.then((data) => {
console.info('[FormComponent] changeCardVisible result:' + data + ', isVisible:' + isVisible);
});
}
}
public async isFmsReady() {
formManager.isSystemReady()
.then((data) => {
console.info('[FormComponent] isFmsReady result:' + data);
});
}
public async getAllFormsInfo() {
formManager.getAllFormsInfo()
.then((data) => {
console.info('[FormComponent] getAllFormsInfo result:' + JSON.stringify(data));
});
}
public async getFormsInfoByApp(bundle: string) {
formManager.getFormsInfo(bundle)
.then((data) => {
console.info('[FormComponent] getFormsInfoByApp result:' + JSON.stringify(data));
});
}
public async getFormsInfoByModule(bundle: string, moduleName: string) {
formManager.getFormsInfo(bundle, moduleName)
.then((data) => {
console.info('[FormComponent] getFormsInfoByModule result:' + JSON.stringify(data));
});
}
public async clearFormUserCache() {
abilityManager.clearUpApplicationData('com.ohos.myapplicationform')
.then((data) => {
console.info('[FormComponent] cleanBundleCacheFiles result:' + JSON.stringify(data));
});
}
public async clearFormProviderCache(bundle: string) {
abilityManager.clearUpApplicationData(bundle)
.then((data) => {
console.info('[FormComponent] cleanBundleCacheFiles result:' + JSON.stringify(data));
});
}
}
\ 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 FormViewModel from './FormViewModel.ets';
import router from '@system.router';
import featureAbility from '@ohos.ability.featureAbility';
import formManager from '@ohos.application.formHost';
import formProvider from '@ohos.application.formProvider';
import commonEvent from '@ohos.commonEvent';
import formBindingData from '@ohos.application.formBindingData';
@Entry
@Component
struct Index {
@State formId: number = 0;
@State bundle: string = "com.form.formsystemtestservicea.hmservice";
@State ability: string = "com.form.formsystemtestservicea.hmservice.MainAbility";
@State moduleName: string = "entry";
@State name: string = "Form_Js001";
@State width: number = 300;
@State height: number = 200;
@State allowUpate: boolean = true;
@State onAcquireResult: string = "";
@State isShowing: boolean = true;
@State canCreateForm: boolean = false;
private dimension: FormDimension = FormDimension.Dimension_1_2;
private updateForm = false;
private updateId = "-1";
private jsonEmpty = false;
private releaseForm = false;
private releaseId = "-1";
private deleteForm = false;
private deleteId = "-1";
private temporaryId="-1";
private temporary = false;
private mFormViewModel: FormViewModel;
private isVisible = false;
private mMargin = 15;
private BTN_BG_COLOR: string = '#0D9FFB';
private tempFormId: number = 0;
private isStartOtherApp = false;
private otherAppState = "visible";
private formOnAcquiredEvent = "FMS_FormOnAcquired_commonEvent";
private formOnErrorEvent = "FMS_FormOnError_commonEvent";
private formOnDeletedEvent = "FMS_FormOnDeleted_commonEvent";
private formOnReleasedEvent = "FMS_FormOnReleased_commonEvent";
private formOnUpdatedEvent = "FMS_FormUpdateRefresh_commonEvent";
private subscriberDel;
private subscriberFormDeleteEvent = {
events: ["FMS_FormDelete_commonEvent"],
};
private publishOnErrorCallBack() {
this.canCreateForm = false;
console.debug("====>formsystemhostc formOnErrorEventCallBack ====>");
}
private publishOnDeletedCallBack() {
this.canCreateForm = false;
console.debug("====>formsystemhostc publishOnDeletedCallBack ====>");
}
private publishOnReleasedCallBack() {
this.canCreateForm = false;
console.debug("====>formsystemhostc publishOnReleasedCallBackk ====>");
}
private publishOnAcquiredCallBack() {
console.debug("====>formsystemhostc formOnAcquiredEventCallBack ====>");
}
private publishOnUpdatedCallBack() {
this.canCreateForm = false;
console.debug("====>formsystemhostc publishOnUpdatedCallBack ====>");
}
private deleteCallBack(err, data) {
console.info("!!!====>formsystemhost deleteCallBack start:====>" + JSON.stringify(data));
if(data.bundleName && data.bundleName != "com.ohos.st.formsystemhostf") {
return;
}
formManager.deleteForm(data.data)
.then((data2) => {
console.info('[FormComponent] deleteForm result:' + data2);
});
this.canCreateForm = false;
console.info("!!!====>formsystemhost deleteCallBack end ====>");
}
private unSubscribeDeleteCallback() {
console.debug("====>formsystemhost unSubscribeDeleteCallback_1100 CallBack====>");
}
private aboutToAppear() {
const TAG = "[FormComponent.host]"
this.mFormViewModel = FormViewModel.getInstance();
commonEvent.createSubscriber(this.subscriberFormDeleteEvent).then(async (data) => {
console.info("====>formsystemhost Subscriber FormDelete data:====>", JSON.stringify(data));
this.subscriberDel = data;
await commonEvent.subscribe(this.subscriberDel, this.deleteCallBack);
})
console.error('[FormComponent] getWant');
featureAbility.getWant()
.then((want: any) => {
this.formId = parseInt(want.parameters.formId);
this.name = want.parameters.name;
this.bundle = want.parameters.bundle;
this.ability = want.parameters.ability;
if(want.parameters.moduleName) {
this.moduleName = want.parameters.moduleName;
}
if(want.parameters.temporary) {
this.temporary = want.parameters.temporary;
}
if(want.parameters.dimension) {
this.dimension = want.parameters.dimension;
}
if(!this.dimension) {
this.dimension = FormDimension.Dimension_1_2;
}
if(want.parameters.temporaryId) {
this.temporaryId = want.parameters.temporaryId;
}
if(want.parameters.deleteForm) {
this.deleteForm = want.parameters.deleteForm;
}
if(want.parameters.deleteId) {
this.deleteId = want.parameters.deleteId;
}
if(want.parameters.releaseForm) {
this.releaseForm = want.parameters.releaseForm;
}
if(want.parameters.releaseId) {
this.releaseId = want.parameters.releaseId;
}
if(want.parameters.updateForm) {
this.updateForm = want.parameters.updateForm;
}
if(want.parameters.updateId) {
this.updateId = want.parameters.updateId;
}
if(want.parameters.jsonEmpty) {
this.jsonEmpty = want.parameters.jsonEmpty;
}
if(want.parameters.isStartOtherApp) {
this.isStartOtherApp = true;
if(want.parameters.otherAppState) {
this.otherAppState = want.parameters.otherAppState;
}
}
setTimeout(() => {
this.canCreateForm = want.parameters.isCreate ? true : false;
console.error('[FormComponent] getWant canCreateForm:'+ this.canCreateForm);
}, 10);
console.error('[FormComponent] getWant end'+ JSON.stringify(want));
if(!want.parameters.isCreate && this.deleteForm) {
console.log("formsystemhost deleteForm start");
formManager.deleteForm(this.deleteId)
.then((data) => {
console.info('formsystemhost deleteForm result:' + data);
let commonEventPublishData = {
data: "0",
parameters: {
"formId" : this.deleteId.toString()
}
};
commonEvent.publish(this.formOnDeletedEvent, commonEventPublishData, this.publishOnDeletedCallBack);
})
.catch((error) => {
console.info('formsystemhost deleteForm error:' + error);
let commonEventPublishData = {
data: error.code.toString(),
parameters: {
"formId" : this.deleteId.toString()
}
};
commonEvent.publish(this.formOnDeletedEvent, commonEventPublishData, this.publishOnDeletedCallBack);
});
console.log("formsystemhost deleteForm end");
}
if(!want.parameters.isCreate && this.releaseForm) {
console.log("formsystemhost releaseForm start");
formManager.releaseForm(this.releaseId)
.then((data) => {
console.info('formsystemhost releaseForm result:' + data);
let commonEventPublishData = {
data: "0",
parameters: {
"formId" : this.releaseId.toString()
}
};
commonEvent.publish(this.formOnReleasedEvent, commonEventPublishData, this.publishOnReleasedCallBack);
})
.catch((error) => {
console.info('formsystemhost releaseForm error:' + error);
let commonEventPublishData = {
data: error.code.toString(),
parameters: {
"formId" : this.releaseId.toString()
}
};
commonEvent.publish(this.formOnReleasedEvent, commonEventPublishData, this.publishOnReleasedCallBack);
});
console.log("formsystemhost releaseForm end");
}
if(!want.parameters.isCreate && this.updateForm) {
console.log("formsystemhost updateForm start");
let formData = {
temperature: "11°",
time: "11:00",
area: "Shenyang",
epidemic: true,
count: 10
};
if(this.jsonEmpty) {
formData = {};
}
let bindingData = formBindingData.createFormBindingData(formData);
formProvider.updateForm(this.updateId, bindingData)
.then((data) => {
console.info('formsystemhost updateForm result:' + data);
let commonEventPublishData = {
data: "0",
parameters: {
"formId" : this.updateId
}
};
commonEvent.publish(this.formOnUpdatedEvent, commonEventPublishData, this.publishOnUpdatedCallBack);
})
.catch((error) => {
console.info('formsystemhost updateForm error:' + error);
let commonEventPublishData = {
data: error.code.toString(),
parameters: {
"formId" : this.updateId
}
};
commonEvent.publish(this.formOnUpdatedEvent, commonEventPublishData, this.publishOnUpdatedCallBack);
});
console.log("formsystemhost releaseForm end");
}
})
.catch((error: any) => {
console.error('[FormComponent] Operation failed. Cause: ' + JSON.stringify(error));
})
console.log(`[FormComponent.host] aboutToAppear end`);
}
build() {
Column() {
Text('form component test begin')
Column() {
if (this.canCreateForm) {
FormComponent({
id: this.formId,
name: this.name,
bundle: this.bundle,
ability: this.ability,
module: this.moduleName,
dimension: this.dimension,
temporary: this.temporary,
})
.allowUpdate(this.allowUpate)
.visibility(this.isShowing ? Visibility.Visible : Visibility.Hidden)
.onAcquired((form) => {
console.log("[FormComponent.host] get form, form id:" + form.id);
this.formId = form.id;
if(this.deleteForm) {
console.log("[FormComponent.host] deleteForm start");
if(this.deleteId == "self") {
this.deleteId = this.formId.toString();
}
setTimeout(() => {
formManager.deleteForm(this.deleteId)
.then((data) => {
console.info('[FormComponent] deleteForm result:' + data);
var commonEventPublishData = {
data: "0",
parameters: {
"formId" : this.deleteId.toString()
}
};
commonEvent.publish(this.formOnDeletedEvent, commonEventPublishData, this.publishOnDeletedCallBack);
})
.catch((error) => {
console.info('formsystemhost deleteForm error:' + error);
let commonEventPublishData = {
data: error.code.toString(),
parameters: {
"formId" : this.deleteId.toString()
}
};
commonEvent.publish(this.formOnDeletedEvent, commonEventPublishData, this.publishOnDeletedCallBack);
});
console.log("[FormComponent.host] deleteForm end");
}, 500);
} else if(this.releaseForm) {
console.log("[FormComponent.host] releaseForm start");
if(this.releaseId == "self") {
this.releaseId = this.formId.toString();
}
setTimeout(() => {
formManager.releaseForm(this.releaseId)
.then((data) => {
console.info('[FormComponent] releaseForm result:' + data);
var commonEventPublishData = {
data: "0",
parameters: {
"formId" : this.releaseId.toString()
}
};
commonEvent.publish(this.formOnReleasedEvent, commonEventPublishData, this.publishOnReleasedCallBack);
})
.catch((error) => {
console.info('formsystemhost releaseForm error:' + error);
let commonEventPublishData = {
data: error.code.toString(),
parameters: {
"formId" : this.releaseId.toString()
}
};
commonEvent.publish(this.formOnReleasedEvent, commonEventPublishData, this.publishOnReleasedCallBack);
});
console.log("[FormComponent.host] releaseForm end");
}, 500);
} else if (this.updateForm) {
console.log("formsystemhost updateForm start");
let formData = {
temperature: "11°",
time: "11:00",
area: "Shenyang",
epidemic: true,
count: 10
};
if(this.jsonEmpty) {
formData = {};
}
let bindingData = formBindingData.createFormBindingData(formData);
formProvider.updateForm(this.updateId, bindingData)
.then((data) => {
console.info('formsystemhost updateForm result:' + data);
let commonEventPublishData = {
data: "0",
parameters: {
"formId" : this.updateId
}
};
commonEvent.publish(this.formOnUpdatedEvent, commonEventPublishData, this.publishOnUpdatedCallBack);
})
.catch((error) => {
console.info('formsystemhost updateForm error:' + error);
let commonEventPublishData = {
data: error.code.toString(),
parameters: {
"formId" : this.updateId
}
};
commonEvent.publish(this.formOnUpdatedEvent, commonEventPublishData, this.publishOnUpdatedCallBack);
});
console.log("formsystemhost releaseForm end");
} else if (this.isStartOtherApp) {
console.log("formsystemhost app G start");
featureAbility.startAbility({
want: {
bundleName: "com.ohos.st.formsystemhostg",
abilityName: "com.ohos.st.formsystemhostg.MainAbility",
parameters: {
"formId" : "0",
"name" : "name",
"bundle" : "bundle",
"ability" : "ability",
"moduleName" : "entry",
"temporary" : false,
"stateForm" : this.otherAppState,
"stateIds" : [this.formId.toString()],
"isCreate" : false
}
}
}).then((res: any) => {
console.log(`formsystemhost featureAbility.startAbilityhost res: ${JSON.stringify(res)}`);
}).catch((err: any) => {
console.log(`formsystemhost featureAbility.startAbilityhost error: ${JSON.stringify(err)}`);
});
} else {
var commonEventPublishData = {
data: this.formId.toString()
};
commonEvent.publish(this.formOnAcquiredEvent, commonEventPublishData, this.publishOnAcquiredCallBack);
}
})
// .onUninstall((info) => {
// console.log("[FormComponent] onUninstall:" + JSON.stringify(info));
// })
.onError((error) => {
console.log("[FormComponent.host] error code:" + error.errcode);
console.log("[FormComponent.host] error msg:" + error.msg);
this.onAcquireResult += error.errcode;
this.onAcquireResult += " ";
this.onAcquireResult += error.msg;
if(this.deleteForm && this.deleteId) {
let commonEventPublishData = {
data: error.msg,
parameters: {
"formId" : this.formId.toString()
}
};
commonEvent.publish(this.formOnDeletedEvent, commonEventPublishData, this.publishOnDeletedCallBack);
} else {
let commonEventPublishData = {
data: error.msg
};
commonEvent.publish(this.formOnErrorEvent, commonEventPublishData, this.publishOnErrorCallBack);
}
})
}
}
.backgroundColor(Color.White)
Text('form component test end')
}
.backgroundColor(Color.White)
}
}
\ No newline at end of file
{
"string": [
{
"name": "entry_MainAbility",
"value": "formhostF"
},
{
"name": "description_mainability",
"value": "ETS_Empty Ability"
}
]
}
\ 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("FormSystemHostG") {
hap_profile = "./entry/src/main/config.json"
deps = [
":hjs_demo_js_assets",
":hjs_demo_resources",
]
ets2abc = true
certificate_profile = "./signature/openharmony_sx.p7b"
hap_name = "FormSystemHostG"
}
ohos_js_assets("hjs_demo_js_assets") {
source_dir = "./entry/src/main/ets/MainAbility"
}
ohos_resources("hjs_demo_resources") {
sources = [ "./entry/src/main/resources" ]
hap_profile = "./entry/src/main/config.json"
}
{
"description": "Configuration for hjunit demo Tests"
}
{
"app": {
"bundleName": "com.ohos.st.formsystemhostg",
"vendor": "ohos",
"version": {
"code": 1000000,
"name": "1.0.0"
},
"apiVersion": {
"compatible": 7,
"releaseType": "Release",
"target": 7
}
},
"deviceConfig": {},
"module": {
"package": "com.ohos.st.formsystemhostg",
"name": ".FormStHostAppG",
"mainAbility": ".MainAbility",
"deviceType": [
"phone"
],
"distro": {
"deliveryWithInstall": true,
"moduleName": "entry",
"moduleType": "entry",
"installationFree": false
},
"abilities": [
{
"skills": [
{
"entities": [
"entity.system.home"
],
"actions": [
"action.system.home"
]
}
],
"visible": true,
"name": ".MainAbility",
"srcLanguage": "ets",
"icon": "$media:icon",
"description": "$string:description_mainability",
"label": "$string:entry_MainAbility",
"type": "page",
"launchType": "standard"
}
],
"js": [
{
"mode": {
"syntax": "ets",
"type": "pageAbility"
},
"pages": [
"pages/index"
],
"name": ".MainAbility",
"window": {
"designWidth": 720,
"autoDesignWidth": false
}
}
],
"defPermissions": [
{
"availableScope": [],
"grantMode": "system_grant",
"name": "FMS_FormDelete_commonEvent"
},
{
"availableScope": [],
"grantMode": "system_grant",
"name": "FMS_FormOnAcquired_commonEvent"
},
{
"availableScope": [],
"grantMode": "system_grant",
"name": "FMS_FormOnError_commonEvent"
},
{
"availableScope": [],
"grantMode": "system_grant",
"name": "FMS_FormOnDeleted_commonEvent"
},
{
"availableScope": [],
"grantMode": "system_grant",
"name": "FMS_FormOnState_commonEvent"
}
],
"reqPermissions": [
{
"name": "FMS_FormOnAcquired_commonEvent"
},
{
"name": "FMS_FormDelete_commonEvent"
},
{
"name": "FMS_FormOnError_commonEvent"
},
{
"name": "FMS_FormOnDeleted_commonEvent"
},
{
"name": "FMS_FormOnState_commonEvent"
},
{
"name": "ohos.permission.GET_BUNDLE_INFO_PRIVILEGED"
},
{
"name": "ohos.permission.INSTALL_BUNDLE"
},
{
"name": "ohos.permission.LISTEN_BUNDLE_CHANGE"
},
{
"name": "ohos.permission.REQUIRE_FORM"
}
]
}
}
\ 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('[FormComponent.host] Application onCreate')
},
onDestroy() {
console.info('[FormComponent.host] Application onDestroy')
},
}
\ 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 formManager from '@ohos.ability.formmanager';
import bundleManager from '@ohos.bundle';
import abilityManager from '@ohos.app.abilityManager';
export default class FormViewModel {
private static sFormViewModel: FormViewModel = null;
public static getInstance(): FormViewModel {
if (FormViewModel.sFormViewModel == null) {
FormViewModel.sFormViewModel = new FormViewModel();
}
return FormViewModel.sFormViewModel;
}
public async castTempFormToNormal(formId: string) {
formManager.castTempForm(formId)
.then((data) => {
console.info('[FormComponent] castTempForm result:' + data);
});
}
public async requestForm(formId: string) {
formManager.requestForm(formId)
.then((data) => {
console.info('[FormComponent] requestForm result:' + data);
});
}
public async deleteCard(formId: string) {
formManager.deleteForm(formId)
.then((data) => {
console.info('[FormComponent] deleteForm result:' + data);
});
}
public async releaseCard(formId: string) {
formManager.releaseForm(formId)
.then((data) => {
console.info('[FormComponent] releaseForm result:' + data);
});
}
public async enableCard(formId: string) {
formManager.enableFormsUpdate([formId])
.then((data) => {
console.info('[FormComponent] enableFormsUpdate result:' + data);
});
}
public async disableCard(formId: string) {
formManager.disableFormsUpdate([formId])
.then((data) => {
console.info('[FormComponent] disableCard result:' + data);
});
}
public async changeCardVisible(formId: string, isVisible: boolean) {
if (isVisible) {
formManager.notifyVisibleForms([formId])
.then((data) => {
console.info('[FormComponent] changeCardVisible result:' + data + ', isVisible:' + isVisible);
});
} else {
formManager.notifyInvisibleForms([formId])
.then((data) => {
console.info('[FormComponent] changeCardVisible result:' + data + ', isVisible:' + isVisible);
});
}
}
public async isFmsReady() {
formManager.isSystemReady()
.then((data) => {
console.info('[FormComponent] isFmsReady result:' + data);
});
}
public async getAllFormsInfo() {
formManager.getAllFormsInfo()
.then((data) => {
console.info('[FormComponent] getAllFormsInfo result:' + JSON.stringify(data));
});
}
public async getFormsInfoByApp(bundle: string) {
formManager.getFormsInfo(bundle)
.then((data) => {
console.info('[FormComponent] getFormsInfoByApp result:' + JSON.stringify(data));
});
}
public async getFormsInfoByModule(bundle: string, moduleName: string) {
formManager.getFormsInfo(bundle, moduleName)
.then((data) => {
console.info('[FormComponent] getFormsInfoByModule result:' + JSON.stringify(data));
});
}
public async clearFormUserCache() {
abilityManager.clearUpApplicationData('com.ohos.myapplicationform')
.then((data) => {
console.info('[FormComponent] cleanBundleCacheFiles result:' + JSON.stringify(data));
});
}
public async clearFormProviderCache(bundle: string) {
abilityManager.clearUpApplicationData(bundle)
.then((data) => {
console.info('[FormComponent] cleanBundleCacheFiles result:' + JSON.stringify(data));
});
}
}
\ No newline at end of file
{
"string": [
{
"name": "entry_MainAbility",
"value": "formhostG"
},
{
"name": "description_mainability",
"value": "ETS_Empty Ability"
}
]
}
\ 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("FormSystemHostN") {
hap_profile = "./entry/src/main/config.json"
deps = [
":hjs_demo_js_assets",
":hjs_demo_resources",
]
ets2abc = true
certificate_profile = "./signature/openharmony_sx.p7b"
hap_name = "FormSystemHostN"
}
ohos_js_assets("hjs_demo_js_assets") {
source_dir = "./entry/src/main/ets/MainAbility"
}
ohos_resources("hjs_demo_resources") {
sources = [ "./entry/src/main/resources" ]
hap_profile = "./entry/src/main/config.json"
}
{
"description": "Configuration for hjunit demo Tests"
}
{
"app": {
"bundleName": "com.ohos.st.formsystemhostn",
"vendor": "ohos",
"version": {
"code": 1000000,
"name": "1.0.0"
},
"apiVersion": {
"compatible": 7,
"releaseType": "Release",
"target": 7
}
},
"deviceConfig": {},
"module": {
"package": "com.ohos.st.formsystemhostn",
"name": ".FormStHostAppN",
"mainAbility": ".MainAbility",
"deviceType": [
"phone"
],
"distro": {
"deliveryWithInstall": true,
"moduleName": "entry",
"moduleType": "entry",
"installationFree": false
},
"abilities": [
{
"skills": [
{
"entities": [
"entity.system.home"
],
"actions": [
"action.system.home"
]
}
],
"visible": true,
"name": ".MainAbility",
"srcLanguage": "ets",
"icon": "$media:icon",
"description": "$string:description_mainability",
"label": "$string:entry_MainAbility",
"type": "page",
"launchType": "standard"
}
],
"js": [
{
"mode": {
"syntax": "ets",
"type": "pageAbility"
},
"pages": [
"pages/index"
],
"name": ".MainAbility",
"window": {
"designWidth": 720,
"autoDesignWidth": false
}
}
],
"defPermissions": [
{
"availableScope": [],
"grantMode": "system_grant",
"name": "FMS_FormDelete_commonEvent"
},
{
"availableScope": [],
"grantMode": "system_grant",
"name": "FMS_FormOnAcquired_commonEvent"
},
{
"availableScope": [],
"grantMode": "system_grant",
"name": "FMS_FormOnError_commonEvent"
},
{
"availableScope": [],
"grantMode": "system_grant",
"name": "FMS_FormCast_commonEvent"
},
{
"availableScope": [],
"grantMode": "system_grant",
"name": "FMS_SendCastForm_commonEvent"
}
],
"reqPermissions": [
{
"name": "FMS_FormOnAcquired_commonEvent"
},
{
"name": "FMS_FormDelete_commonEvent"
},
{
"name": "FMS_FormOnError_commonEvent"
},
{
"name": "FMS_FormCast_commonEvent"
},
{
"name": "FMS_SendCastForm_commonEvent"
},
{
"name": "ohos.permission.GET_BUNDLE_INFO_PRIVILEGED"
},
{
"name": "ohos.permission.INSTALL_BUNDLE"
},
{
"name": "ohos.permission.LISTEN_BUNDLE_CHANGE"
},
{
"name": "ohos.permission.REQUIRE_FORM"
}
]
}
}
\ 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('[FormComponent.host] Application onCreate')
},
onDestroy() {
console.info('[FormComponent.host] Application onDestroy')
},
}
\ No newline at end of file
{
"string": [
{
"name": "entry_MainAbility",
"value": "formhostN"
},
{
"name": "description_mainability",
"value": "ETS_Empty Ability"
}
]
}
# 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("FormSystemHostNoPerm") {
hap_profile = "./entry/src/main/config.json"
deps = [
":hjs_demo_js_assets",
":hjs_demo_resources",
]
ets2abc = true
certificate_profile = "./signature/openharmony_sx.p7b"
hap_name = "FormSystemHostNoPerm"
}
ohos_js_assets("hjs_demo_js_assets") {
source_dir = "./entry/src/main/ets/MainAbility"
}
ohos_resources("hjs_demo_resources") {
sources = [ "./entry/src/main/resources" ]
hap_profile = "./entry/src/main/config.json"
}
{
"description": "Configuration for hjunit demo Tests"
}
{
"app": {
"bundleName": "com.ohos.st.formsystemhostnoperm",
"vendor": "ohos",
"version": {
"code": 1000000,
"name": "1.0.0"
},
"apiVersion": {
"compatible": 7,
"releaseType": "Release",
"target": 7
}
},
"deviceConfig": {},
"module": {
"package": "com.ohos.st.formsystemhostnoperm",
"name": ".FormStHostAppNoPerm",
"mainAbility": ".MainAbility",
"deviceType": [
"phone"
],
"distro": {
"deliveryWithInstall": true,
"moduleName": "entry",
"moduleType": "entry",
"installationFree": false
},
"abilities": [
{
"skills": [
{
"entities": [
"entity.system.home"
],
"actions": [
"action.system.home"
]
}
],
"visible": true,
"name": ".MainAbility",
"srcLanguage": "ets",
"icon": "$media:icon",
"description": "$string:description_mainability",
"label": "$string:entry_MainAbility",
"type": "page",
"launchType": "standard"
}
],
"js": [
{
"mode": {
"syntax": "ets",
"type": "pageAbility"
},
"pages": [
"pages/index"
],
"name": ".MainAbility",
"window": {
"designWidth": 720,
"autoDesignWidth": false
}
}
],
"defPermissions": [
{
"availableScope": [],
"grantMode": "system_grant",
"name": "FMS_FormDelete_commonEvent"
},
{
"availableScope": [],
"grantMode": "system_grant",
"name": "FMS_FormOnAcquired_commonEvent"
},
{
"availableScope": [],
"grantMode": "system_grant",
"name": "FMS_FormOnError_commonEvent"
},
{
"availableScope": [],
"grantMode": "system_grant",
"name": "FMS_FormOnDeleted_commonEvent"
},
{
"availableScope": [],
"grantMode": "system_grant",
"name": "FMS_FormOnReleased_commonEvent"
},
{
"availableScope": [],
"grantMode": "system_grant",
"name": "FMS_FormOnRequest_commonEvent"
},
{
"availableScope": [],
"grantMode": "system_grant",
"name": "FMS_FormOnState_commonEvent"
}
],
"reqPermissions": [
{
"name": "FMS_FormOnAcquired_commonEvent"
},
{
"name": "FMS_FormDelete_commonEvent"
},
{
"name": "FMS_FormOnError_commonEvent"
},
{
"name": "FMS_FormOnDeleted_commonEvent"
},
{
"name": "FMS_FormOnReleased_commonEvent"
},
{
"name": "FMS_FormOnRequest_commonEvent"
},
{
"name": "FMS_FormOnState_commonEvent"
},
{
"name": "ohos.permission.GET_BUNDLE_INFO_PRIVILEGED"
},
{
"name": "ohos.permission.INSTALL_BUNDLE"
},
{
"name": "ohos.permission.LISTEN_BUNDLE_CHANGE"
}
]
}
}
\ 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('[FormComponent.host] Application onCreate')
},
onDestroy() {
console.info('[FormComponent.host] Application onDestroy')
},
}
\ 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 formManager from '@ohos.ability.formmanager';
import bundleManager from '@ohos.bundle';
import abilityManager from '@ohos.app.abilityManager';
export default class FormViewModel {
private static sFormViewModel: FormViewModel = null;
public static getInstance(): FormViewModel {
if (FormViewModel.sFormViewModel == null) {
FormViewModel.sFormViewModel = new FormViewModel();
}
return FormViewModel.sFormViewModel;
}
public async castTempFormToNormal(formId: string) {
formManager.castTempForm(formId)
.then((data) => {
console.info('[FormComponent] castTempForm result:' + data);
});
}
public async requestForm(formId: string) {
formManager.requestForm(formId)
.then((data) => {
console.info('[FormComponent] requestForm result:' + data);
});
}
public async deleteCard(formId: string) {
formManager.deleteForm(formId)
.then((data) => {
console.info('[FormComponent] deleteForm result:' + data);
});
}
public async releaseCard(formId: string) {
formManager.releaseForm(formId)
.then((data) => {
console.info('[FormComponent] releaseForm result:' + data);
});
}
public async enableCard(formId: string) {
formManager.enableFormsUpdate([formId])
.then((data) => {
console.info('[FormComponent] enableFormsUpdate result:' + data);
});
}
public async disableCard(formId: string) {
formManager.disableFormsUpdate([formId])
.then((data) => {
console.info('[FormComponent] disableCard result:' + data);
});
}
public async changeCardVisible(formId: string, isVisible: boolean) {
if (isVisible) {
formManager.notifyVisibleForms([formId])
.then((data) => {
console.info('[FormComponent] changeCardVisible result:' + data + ', isVisible:' + isVisible);
});
} else {
formManager.notifyInvisibleForms([formId])
.then((data) => {
console.info('[FormComponent] changeCardVisible result:' + data + ', isVisible:' + isVisible);
});
}
}
public async isFmsReady() {
formManager.isSystemReady()
.then((data) => {
console.info('[FormComponent] isFmsReady result:' + data);
});
}
public async getAllFormsInfo() {
formManager.getAllFormsInfo()
.then((data) => {
console.info('[FormComponent] getAllFormsInfo result:' + JSON.stringify(data));
});
}
public async getFormsInfoByApp(bundle: string) {
formManager.getFormsInfo(bundle)
.then((data) => {
console.info('[FormComponent] getFormsInfoByApp result:' + JSON.stringify(data));
});
}
public async getFormsInfoByModule(bundle: string, moduleName: string) {
formManager.getFormsInfo(bundle, moduleName)
.then((data) => {
console.info('[FormComponent] getFormsInfoByModule result:' + JSON.stringify(data));
});
}
public async clearFormUserCache() {
abilityManager.clearUpApplicationData('com.ohos.myapplicationform')
.then((data) => {
console.info('[FormComponent] cleanBundleCacheFiles result:' + JSON.stringify(data));
});
}
public async clearFormProviderCache(bundle: string) {
abilityManager.clearUpApplicationData(bundle)
.then((data) => {
console.info('[FormComponent] cleanBundleCacheFiles result:' + JSON.stringify(data));
});
}
}
\ 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 FormViewModel from './FormViewModel.ets';
import router from '@system.router';
import featureAbility from "@ohos.ability.featureAbility";
import formManager from '@ohos.application.formHost'
import commonEvent from '@ohos.commonEvent';
@Entry
@Component
struct Index {
@State formId: number = 0;
@State bundle: string = "com.form.formsystemtestservicea.hmservice";
@State ability: string = "com.form.formsystemtestservicea.hmservice.MainAbility";
@State moduleName: string = "entry";
@State name: string = "Form_Js001";
@State width: number = 300;
@State height: number = 200;
@State allowUpate: boolean = true;
@State onAcquireResult: string = "";
@State isShowing: boolean = true;
@State canCreateForm: boolean = false;
private dimension: FormDimension = FormDimension.Dimension_1_2;
private stateForm = "visible";
private stateIds = [];
private requestForm = false;
private requestId = "-1";
private releaseForm = false;
private releaseId = "-1";
private deleteForm = false;
private deleteId = "-1";
private temporary = false;
private mFormViewModel: FormViewModel;
private isVisible = false;
private mMargin = 15;
private BTN_BG_COLOR: string = '#0D9FFB';
private castForm = false;
private tempFormId: number = 0;
private formOnErrorEvent = "FMS_FormOnError_commonEvent";
private formOnDeletedEvent = "FMS_FormOnDeleted_commonEvent";
private formOnReleasedEvent = "FMS_FormOnReleased_commonEvent";
private formOnRequestEvent = "FMS_FormOnRequest_commonEvent";
private formOnStateEvent = "FMS_FormOnState_commonEvent";
private publishCallBack() {
console.debug("====>formOnErrorEvent Publish CallBack ====>");
}
private aboutToAppear() {
const TAG = "[FormComponent.host]"
this.mFormViewModel = FormViewModel.getInstance();
console.error('[FormComponent] getWant');
featureAbility.getWant()
.then((want: any) => {
this.formId = parseInt(want.parameters.formId);
this.name = want.parameters.name;
this.bundle = want.parameters.bundle;
this.ability = want.parameters.ability;
if(want.parameters.moduleName) {
this.moduleName = want.parameters.moduleName;
}
if(want.parameters.temporary) {
this.temporary = want.parameters.temporary;
}
if(want.parameters.dimension) {
this.dimension = want.parameters.dimension;
}
if(want.parameters.castForm) {
this.castForm = want.parameters.castForm;
}
if(want.parameters.deleteForm) {
this.deleteForm = want.parameters.deleteForm;
}
if(want.parameters.deleteId) {
this.deleteId = want.parameters.deleteId;
}
if(want.parameters.releaseForm) {
this.releaseForm = want.parameters.releaseForm;
}
if(want.parameters.releaseId) {
this.releaseId = want.parameters.releaseId;
}
if(want.parameters.requestForm) {
this.requestForm = want.parameters.requestForm;
}
if(want.parameters.requestId) {
this.requestId = want.parameters.requestId;
}
if(want.parameters.stateForm) {
this.stateForm = want.parameters.stateForm;
}
if(want.parameters.stateIds) {
this.stateIds = want.parameters.stateIds;
}
setTimeout(() => {
this.canCreateForm = want.parameters.isCreate ? true : false;
console.error('[FormComponent] getWant canCreateForm:'+ this.canCreateForm);
}, 10);
console.error('[FormComponent] getWant end'+ JSON.stringify(want));
if(!want.parameters.isCreate && this.deleteForm) {
console.log("formsystemhostnoperm deleteForm start");
formManager.deleteForm(this.deleteId)
.then((data) => {
console.info('formsystemhostnoperm deleteForm result:' + data);
let commonEventPublishData = {
data: data.toString(),
parameters: {
"formId" : this.deleteId.toString()
}
};
commonEvent.publish(this.formOnDeletedEvent, commonEventPublishData, this.publishCallBack);
})
.catch((error) => {
console.info('formsystemhostnoperm deleteForm error:' + error);
let commonEventPublishData = {
data: error.code.toString(),
parameters: {
"formId" : this.deleteId.toString()
}
};
commonEvent.publish(this.formOnDeletedEvent, commonEventPublishData, this.publishCallBack);
});
console.log("formsystemhostnoperm deleteForm end");
}
if(!want.parameters.isCreate && this.releaseForm) {
console.log("formsystemhost releaseForm start");
formManager.releaseForm(this.releaseId)
.then((data) => {
console.info('formsystemhost releaseForm result:' + data);
let commonEventPublishData = {
data: data.toString(),
parameters: {
"formId" : this.releaseId.toString()
}
};
commonEvent.publish(this.formOnReleasedEvent, commonEventPublishData, this.publishCallBack);
})
.catch((error) => {
console.info('formsystemhost releaseForm error:' + error);
let commonEventPublishData = {
data: error.code.toString(),
parameters: {
"formId" : this.releaseId.toString()
}
};
commonEvent.publish(this.formOnReleasedEvent, commonEventPublishData, this.publishCallBack);
});
console.log("formsystemhost releaseForm end");
}
if(!want.parameters.isCreate && this.requestForm) {
console.log("[FormComponent.host] requestForm start");
formManager.requestForm(this.requestId)
.then((data) => {
console.info('[FormComponent] requestForm result:' + data);
let commonEventPublishData = {
data: data.toString(),
parameters: {
"formId" : this.requestId
}
};
commonEvent.publish(this.formOnRequestEvent, commonEventPublishData, this.publishCallBack);
})
.catch((error) => {
console.info('[FormComponent] requestForm error:' + error);
let commonEventPublishData = {
data: error.code.toString(),
parameters: {
"formId" : this.requestId
}
};
commonEvent.publish(this.formOnRequestEvent, commonEventPublishData, this.publishCallBack);
});
console.log("[FormComponent.host] requestForm end");
}
if(!want.parameters.isCreate && this.stateForm) {
if(this.stateForm == "visible") {
console.log("formsystemhost notifyVisibleForm start");
formManager.notifyVisibleForms(this.stateIds)
.then((data) => {
console.info('formsystemhost notifyVisibleForm result:' + data);
let retData = "0";
if(data == 0) {
retData = data.toString();
} else {
retData = data.code.toString();
}
let commonEventPublishData = {
data: retData,
parameters: {
"formId" : this.stateIds.toString()
}
};
commonEvent.publish(this.formOnStateEvent, commonEventPublishData, this.publishCallBack);
})
.catch((error) => {
console.info('formsystemhost notifyVisibleForm error:' + error);
let commonEventPublishData = {
data: error.code.toString(),
parameters: {
"formId" : this.stateIds.toString()
}
};
commonEvent.publish(this.formOnStateEvent, commonEventPublishData, this.publishCallBack);
});
console.log("formsystemhost notifyVisibleForm end");
} else if(this.stateForm == "invisible") {
console.log("formsystemhost notifyInvisibleForm start");
formManager.notifyInvisibleForms(this.stateIds)
.then((data) => {
console.info('formsystemhost notifyInvisibleForm result:' + data);
let commonEventPublishData = {
data: data.toString(),
parameters: {
"formId" : this.stateIds.toString()
}
};
commonEvent.publish(this.formOnStateEvent, commonEventPublishData, this.publishCallBack);
})
.catch((error) => {
console.info('formsystemhost notifyInvisibleForm error:' + error);
let commonEventPublishData = {
data: error.code.toString(),
parameters: {
"formId" : this.stateIds.toString()
}
};
commonEvent.publish(this.formOnStateEvent, commonEventPublishData, this.publishCallBack);
});
console.log("formsystemhost notifyInvisibleForm end");
} else if(this.stateForm == "enable") {
console.log("formsystemhost enableFormsUpdate start");
formManager.enableFormsUpdate(this.stateIds)
.then((data) => {
console.info('formsystemhost enableFormsUpdate result:' + data);
let commonEventPublishData = {
data: data.toString(),
parameters: {
"formId" : this.stateIds.toString()
}
};
commonEvent.publish(this.formOnStateEvent, commonEventPublishData, this.publishCallBack);
})
.catch((error) => {
console.info('formsystemhost enableFormsUpdate error:' + error);
let commonEventPublishData = {
data: error.code.toString(),
parameters: {
"formId" : this.stateIds.toString()
}
};
commonEvent.publish(this.formOnStateEvent, commonEventPublishData, this.publishCallBack);
});
console.log("formsystemhost enableFormsUpdate end");
} else {
console.log("formsystemhost disableFormsUpdate start");
formManager.disableFormsUpdate(this.stateIds)
.then((data) => {
console.info('formsystemhost disableFormsUpdate result:' + data);
let commonEventPublishData = {
data: data.toString(),
parameters: {
"formId" : this.stateIds.toString()
}
};
commonEvent.publish(this.formOnStateEvent, commonEventPublishData, this.publishCallBack);
})
.catch((error) => {
console.info('formsystemhost disableFormsUpdate error:' + error);
let commonEventPublishData = {
data: error.code.toString(),
parameters: {
"formId" : this.stateIds.toString()
}
};
commonEvent.publish(this.formOnStateEvent, commonEventPublishData, this.publishCallBack);
});
console.log("formsystemhost disableFormsUpdate end");
}
}
})
.catch((error: any) => {
console.error('[FormComponent] Operation failed. Cause: ' + JSON.stringify(error));
})
console.log(`[FormComponent.host] aboutToAppear end`);
}
build() {
Column() {
Text('form component test begin')
Column() {
if (this.canCreateForm) {
FormComponent({
id: this.formId,
name: this.name,
bundle: this.bundle,
ability: this.ability,
module: this.moduleName,
dimension: this.dimension,
temporary: this.temporary,
})
.allowUpdate(this.allowUpate)
.visibility(this.isShowing ? Visibility.Visible : Visibility.Hidden)
.onAcquired((form) => {
this.formId = form.id;
console.log("[FormComponent.host] get form, form id:" + form.id);
})
.onError((error) => {
console.log("[FormComponent.host] error code:" + error.errcode);
console.log("[FormComponent.host] error msg:" + error.msg);
this.onAcquireResult += error.errcode;
this.onAcquireResult += " ";
this.onAcquireResult += error.msg;
let commonEventPublishData = {
data: error.msg
};
commonEvent.publish(this.formOnErrorEvent, commonEventPublishData, this.publishCallBack);
})
}
}
.backgroundColor(Color.White)
Text('form component test end')
}
.backgroundColor(Color.White)
}
}
\ No newline at end of file
{
"string": [
{
"name": "entry_MainAbility",
"value": "formhostB"
},
{
"name": "description_mainability",
"value": "ETS_Empty Ability"
}
]
}
\ 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("FormSystemHostO") {
hap_profile = "./entry/src/main/config.json"
deps = [
":hjs_demo_js_assets",
":hjs_demo_resources",
]
ets2abc = true
certificate_profile = "./signature/openharmony_sx.p7b"
hap_name = "FormSystemHostO"
}
ohos_js_assets("hjs_demo_js_assets") {
source_dir = "./entry/src/main/ets/MainAbility"
}
ohos_resources("hjs_demo_resources") {
sources = [ "./entry/src/main/resources" ]
hap_profile = "./entry/src/main/config.json"
}
{
"description": "Configuration for hjunit demo Tests"
}
{
"app": {
"bundleName": "com.ohos.st.formsystemhosto",
"vendor": "ohos",
"version": {
"code": 1000000,
"name": "1.0.0"
},
"apiVersion": {
"compatible": 7,
"releaseType": "Release",
"target": 7
}
},
"deviceConfig": {},
"module": {
"package": "com.ohos.st.formsystemhosto",
"name": ".FormStHostAppO",
"mainAbility": ".MainAbility",
"deviceType": [
"phone"
],
"distro": {
"deliveryWithInstall": true,
"moduleName": "entry",
"moduleType": "entry",
"installationFree": false
},
"abilities": [
{
"skills": [
{
"entities": [
"entity.system.home"
],
"actions": [
"action.system.home"
]
}
],
"visible": true,
"name": ".MainAbility",
"srcLanguage": "ets",
"icon": "$media:icon",
"description": "$string:description_mainability",
"label": "$string:entry_MainAbility",
"type": "page",
"launchType": "standard"
}
],
"js": [
{
"mode": {
"syntax": "ets",
"type": "pageAbility"
},
"pages": [
"pages/index"
],
"name": ".MainAbility",
"window": {
"designWidth": 720,
"autoDesignWidth": false
}
}
],
"defPermissions": [
{
"availableScope": [],
"grantMode": "system_grant",
"name": "FMS_FormDelete_commonEvent"
},
{
"availableScope": [],
"grantMode": "system_grant",
"name": "FMS_FormOnAcquired_commonEvent"
},
{
"availableScope": [],
"grantMode": "system_grant",
"name": "FMS_FormOnError_commonEvent"
},
{
"availableScope": [],
"grantMode": "system_grant",
"name": "FMS_FormCast_commonEvent"
},
{
"availableScope": [],
"grantMode": "system_grant",
"name": "FMS_SendCastForm_commonEvent"
}
],
"reqPermissions": [
{
"name": "FMS_FormOnAcquired_commonEvent"
},
{
"name": "FMS_FormDelete_commonEvent"
},
{
"name": "FMS_FormOnError_commonEvent"
},
{
"name": "FMS_FormCast_commonEvent"
},
{
"name": "FMS_SendCastForm_commonEvent"
},
{
"name": "ohos.permission.GET_BUNDLE_INFO_PRIVILEGED"
},
{
"name": "ohos.permission.INSTALL_BUNDLE"
},
{
"name": "ohos.permission.LISTEN_BUNDLE_CHANGE"
},
{
"name": "ohos.permission.REQUIRE_FORM"
}
]
}
}
\ 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('[FormComponent.host] Application onCreate')
},
onDestroy() {
console.info('[FormComponent.host] Application onDestroy')
},
}
\ 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 featureAbility from "@ohos.ability.featureAbility";
import formManager from '@ohos.application.formHost';
import commonEvent from '@ohos.commonEvent';
@Entry
@Component
struct Index {
@State bundle: string = "com.form.formsystemtestservicea.hmservice";
@State ability: string = "com.form.formsystemtestservicea.hmservice.FormAbility";
@State moduleName: string = "entry";
@State name: string = "Form_Js001";
@State width: number = 300;
@State height: number = 200;
@State allowUpate: boolean = true;
@State onAcquireResult: string = "";
@State isShowing: boolean = true;
@State optType: number = 0;
private dimension: FormDimension = FormDimension.Dimension_1_2;
private isTemporary = false;
private isVisible = false;
private mMargin = 15;
private BTN_BG_COLOR: string = '#0D9FFB';
private normal = 0;
private temporary = 0;
private normaldel = 0;
private temporarydel = 0;
private normalFormIds = [];
private tempFormIds = [];
private deleteIds = [];
private delCount = 0;
private normalFormCounts = [];
private tempFormCounts = [];
private castFormId = "-1";
private formOnAcquiredEvent = "FMS_FormOnAcquired_commonEvent";
private formOnErrorEvent = "FMS_FormOnError_commonEvent";
private formCastEvent = "FMS_FormCast_commonEvent";
private subscriberDel;
private subscriberFormDeleteEvent = {
events: ["FMS_FormDelete_commonEvent"],
};
private subscriberSendCastForm;
private subscriberSendCastFormEvent = {
events: ["FMS_SendCastForm_commonEvent"],
};
private publishOnErrorCallBack() {
console.debug("====> [FormComponent] formsystemhosto formOnErrorEvent Publish CallBack ====>");
}
private publishOnAcquiredCallBack() {
console.debug("====> [FormComponent] formsystemhosto formOnAcquiredEvent Publish CallBack ====>");
}
private publishDeleteCallBack() {
console.debug("====> [FormComponent] formsystemhosto publishDeleteCallBack Publish CallBack ====>");
}
private publishCastCallBack() {
console.debug("====>formCastEvent Publish CallBack ====>");
}
private startAbility(bundleName, abilityName, sendMsg) {
featureAbility.startAbility({
want: {
bundleName: bundleName,
abilityName: abilityName,
parameters: {
"formId": "0",
"name": "Form_Js001",
"bundle": "com.form.formsystemtestservicea.hmservice",
"ability": "com.form.formsystemtestservicea.hmservice.FormAbility",
"moduleName": "entry",
"temporary": false,
"sendCastForm": true,
"sendCastFormMsg": sendMsg,
"isCreate": false
}
}
}).then((res: any) => {
console.info(`[FormComponent] formsystemhosto featureAbility.startAbility res: ${JSON.stringify(res)}`);
}).catch((err: any) => {
console.info(`[FormComponent] formsystemhosto featureAbility.startAbility error: ${JSON.stringify(err)}`);
});
}
private publishOnSendCastForm(err, data) {
console.info("!!!====>[FormComponent] formsystemhosto OnSendCastForm start:====>" + JSON.stringify(data));
if (data.bundleName && data.bundleName != "com.ohos.st.formsystemhosto") {
return;
}
let formId = data.parameters.castFormId;
setTimeout(function () {
console.info("[FormComponent.host] castTempForm start, formId: " + formId);
formManager.castTempForm(formId)
.then((data) => {
console.info('[FormComponent] castTempForm result:' + data);
this.startAbility("com.ohos.st.formsystemhostc", "com.ohos.st.formsystemhostc.MainAbility", data.toString());
})
.catch((error) => {
console.info('[FormComponent] castTempForm error:' + JSON.stringify(error));
this.startAbility("com.ohos.st.formsystemhostc", "com.ohos.st.formsystemhostc.MainAbility", error.code.toString());
});
console.info("[FormComponent.host] castTempForm end");
}, 5000);
console.info("!!!====>[FormComponent] formsystemhosto OnSendCastForm end");
}
private deleteCallBack(err, data) {
console.info("!!!====>[FormComponent] formsystemhosto deleteCallBack start:====>" + JSON.stringify(data));
const delFormIds = data.parameters.formIds;
console.info(`[FormComponent] data size ${delFormIds.length}`);
console.info(`[FormComponent] data.subscriber ${JSON.stringify(this.subscriberDel)}`);
commonEvent.unsubscribe(this.subscriberDel, () => {
console.info("====> [FormComponent] formsystemhosto optType unSubscribeDeleteCallback CallBack====>");
});
commonEvent.unsubscribe(this.subscriberSendCastForm, () => {
console.info("====> [FormComponent] formsystemhosto optType unSubscribeCastFormCallback CallBack====>");
});
console.info(`[FormComponent] data.bundleName ${JSON.stringify(data.bundleName)}`);
console.info(`[FormComponent] tof ${"com.ohos.st.formsystemhosto" != data.bundleName}`);
if ("com.ohos.st.formsystemhosto" != data.bundleName) {
return;
}
delFormIds.forEach(async (formId, index) => {
console.info(`[FormComponent] formsystemhosto deleteForm ${index}`);
try {
const res = await formManager.deleteForm(formId);
console.info(`[FormComponent] formsystemhosto deleteForm ${index} ${formId} result: ${JSON.stringify(res)}`);
} catch (error) {
console.info(`[FormComponent] formsystemhosto deleteForm ${index} ${formId} error: ${JSON.stringify(error)}`);
}
});
console.info("!!!====> [FormComponent] formsystemhosto optType deleteCallBack end ====>");
}
private unSubscribeDeleteCallback() {
console.debug("====> [FormComponent] formsystemhosto optType unSubscribeDeleteCallback CallBack====>");
}
private unSubscribeCastFormCallback() {
console.debug("====> [FormComponent] formsystemhosto optType unSubscribeCastFormCallback CallBack====>");
}
private aboutToAppear() {
const TAG = "[FormComponent.hosto]";
commonEvent.createSubscriber(this.subscriberFormDeleteEvent).then(async (data) => {
console.info("====>[FormComponent] formsystemhosto Subscriber FormDelete data:====>", JSON.stringify(data));
this.subscriberDel = data;
commonEvent.subscribe(this.subscriberDel, (err, data) => {
if ("com.ohos.st.formsystemhosto" != data.bundleName) {
return;
} else {
console.info("!!!====>[FormComponent.hosto] formsystemhosto deleteCallBack start:====>" + JSON.stringify(data));
const delFormIds = data.parameters.formIds;
console.info(`[FormComponent] data size ${delFormIds.length}`);
commonEvent.unsubscribe(this.subscriberDel, () => {
console.info("====> [FormComponent] formsystemhosto optType unSubscribeDeleteCallback CallBack====>");
});
commonEvent.unsubscribe(this.subscriberSendCastForm, () => {
console.info("====> [FormComponent] formsystemhosto optType unSubscribeCastFormCallback CallBack====>");
});
let delCounter = 0;
delFormIds.forEach((formId) => {
formManager.deleteForm(formId, (error, data) => {
console.info(`[FormComponent] formsystemhosto deleteForm ${++delCounter} ${formId} data: ${JSON.stringify(data)} err: ${JSON.stringify(error)}`);
});
});
}
});
});
commonEvent.createSubscriber(this.subscriberSendCastFormEvent).then(async (data) => {
console.info("====>[FormComponent] formsystemhosto Subscriber SendCastForm data:====>", JSON.stringify(data));
this.subscriberSendCastForm = data;
await commonEvent.subscribe(this.subscriberSendCastForm, this.publishOnSendCastForm);
});
featureAbility.getWant()
.then((want: any) => {
console.info(" [FormComponent] formsystemhosto getWant:" + JSON.stringify(want));
this.name = want.parameters.name;
this.bundle = want.parameters.bundle;
this.ability = want.parameters.ability;
if (want.parameters.moduleName) {
this.moduleName = want.parameters.moduleName;
}
if (want.parameters.dimension) {
this.dimension = want.parameters.dimension;
}
if (want.parameters.normal) {
this.normal = want.parameters.normal;
}
if (want.parameters.temporary) {
this.temporary = want.parameters.temporary;
}
if (want.parameters.normaldel) {
this.normaldel = want.parameters.normaldel;
}
if (want.parameters.temporarydel) {
this.temporarydel = want.parameters.temporarydel;
}
if (want.parameters.deleteIds) {
this.deleteIds = want.parameters.deleteIds;
}
if (want.parameters.castFormId) {
this.castFormId = want.parameters.castFormId;
}
this.makeCount();
setTimeout(() => {
this.optType = want.parameters.optType;
console.info(' [FormComponent] formsystemhosto getWant optType:' + this.optType);
}, 10);
if (this.castFormId != "-1" && want.parameters.optType == 3) {
console.info("[FormComponent.host] castTempForm start");
commonEvent.unsubscribe(this.subscriberDel, () => {
console.info("====> [FormComponent] formsystemhosto optType unSubscribeDeleteCallback CallBack====>");
});
commonEvent.unsubscribe(this.subscriberSendCastForm, () => {
console.info("====> [FormComponent] formsystemhosto optType unSubscribeCastFormCallback CallBack====>");
});
formManager.castTempForm(this.castFormId)
.then((data) => {
console.info('[FormComponent] castTempForm result:' + data);
let commonEventPublishData = {
data: data || `0`,
bundleName: "com.ohos.st.formsystemhosto",
parameters: {
formId: this.castFormId.toString()
}
};
commonEvent.publish(this.formCastEvent, commonEventPublishData, this.publishCastCallBack);
})
.catch((error) => {
console.info('[FormComponent] castTempForm error:' + JSON.stringify(error));
let commonEventPublishData = {
data: error.code.toString(),
bundleName: "com.ohos.st.formsystemhosto",
parameters: {
errMsg: error.message,
formId: this.castFormId.toString()
}
};
commonEvent.publish(this.formCastEvent, commonEventPublishData, this.publishCastCallBack);
});
console.info("[FormComponent.host] castTempForm end");
}
if (want.parameters.optType == 2 && this.deleteIds.length > 0) {
for (let iIndex = 0; iIndex < this.deleteIds.length; ++iIndex) {
console.info("[FormComponent] formsystemhosto deleteForm start");
formManager.deleteForm(this.deleteIds[iIndex])
.then((data) => {
console.info('[FormComponent] formsystemhosto deleteForm result:' + data);
this.delCount++;
if (this.delCount == this.deleteIds.length) {
let commonEventPublishData = {
data: data.toString(),
bundleName: "com.ohos.st.formsystemhosto",
parameters: {
"formIds": this.deleteIds
}
};
commonEvent.publish(this.formOnErrorEvent, commonEventPublishData, this.publishDeleteCallBack);
}
})
.catch((error) => {
console.info(' [FormComponent] formsystemhosto deleteForm error:' + error);
let commonEventPublishData = {
data: error.code.toString(),
bundleName: "com.ohos.st.formsystemhosto",
parameters: {
"formIds": [this.deleteIds[iIndex]]
}
};
commonEvent.publish(this.formOnErrorEvent, commonEventPublishData, this.publishOnErrorCallBack);
});
console.info("[FormComponent] formsystemhosto deleteForm end");
}
}
})
.catch((error: any) => {
console.error(' [FormComponent] formsystemhosto Operation failed. Cause: ' + JSON.stringify(error));
})
console.info(`[FormComponent.host] aboutToAppear end`);
}
private makeCount() {
console.info(' [FormComponent] formsystemhosto makeCount start.');
for (let nNormal = 0; nNormal < this.normal; nNormal++) {
this.normalFormCounts.push(nNormal);
}
console.info(' [FormComponent] formsystemhosto this.normalFormCounts.length:' + this.normalFormCounts.length);
for (let nTemp = 0; nTemp < this.temporary; nTemp++) {
this.tempFormCounts.push(nTemp);
}
console.info(' [FormComponent] formsystemhosto this.tempFormCounts.length:' + this.tempFormCounts.length);
}
build() {
Scroll(new Scroller()) {
Column() {
if (this.optType == 1) {
Text(' [FormComponent] formsystemhosto normal form component test begin')
Grid() {
ForEach(this.normalFormCounts, (item) => {
GridItem() {
FormComponent({
id: 0,
name: this.name,
bundle: this.bundle,
ability: this.ability,
module: this.moduleName,
dimension: this.dimension,
temporary: false
})
.allowUpdate(this.allowUpate)
.visibility(this.isShowing ? Visibility.Visible : Visibility.Hidden)
.onAcquired((form) => {
console.info(" [FormComponent] formsystemhosto get normal form, form id:" + form.id);
this.normalFormIds.push(form.id.toString());
if (this.normalFormIds.length == this.normal - this.normaldel) {
let commonEventPublishData = {
data: "normalForm",
bundleName: "com.ohos.st.formsystemhosto",
parameters: {
"formIds": this.normalFormIds
}
};
commonEvent.publish(this.formOnAcquiredEvent, commonEventPublishData, this.publishOnAcquiredCallBack);
}
})
.onError((error) => {
console.info(" [FormComponent] formsystemhosto normal form error code:" + error.errcode);
console.info(" [FormComponent] formsystemhosto normal form error msg:" + error.msg);
let commonEventPublishData = {
data: error.msg,
bundleName: "com.ohos.st.formsystemhosto"
};
commonEvent.publish(this.formOnErrorEvent, commonEventPublishData, this.publishOnErrorCallBack);
})
.size({ width: 40, height: 40 })
}
}, (item) => JSON.stringify(item))
}
.columnsTemplate('1fr 1fr 1fr 1fr 1fr 1fr 1fr 1fr 1fr 1fr ')
.columnsGap(2)
.rowsGap(2)
.width('100%')
Text(' [FormComponent] formsystemhosto normal form component test end')
Text(' [FormComponent] formsystemhosto temp form component test start')
Grid() {
ForEach(this.tempFormCounts, (item) => {
GridItem() {
FormComponent({
id: 0,
name: this.name,
bundle: this.bundle,
ability: this.ability,
module: this.moduleName,
dimension: this.dimension,
temporary: true
})
.allowUpdate(this.allowUpate)
.visibility(this.isShowing ? Visibility.Visible : Visibility.Hidden)
.onAcquired((form) => {
console.info(" [FormComponent] formsystemhosto get temp form, form id:" + form.id);
this.tempFormIds.push(form.id.toString());
if (this.tempFormIds.length == this.temporary - this.temporarydel) {
let commonEventPublishData = {
data: "tempForm",
bundleName: "com.ohos.st.formsystemhosto",
parameters: {
"formIds": this.tempFormIds
}
};
commonEvent.publish(this.formOnAcquiredEvent, commonEventPublishData, this.publishOnAcquiredCallBack);
}
})
.onError((error) => {
console.info(" [FormComponent] formsystemhosto temp form error code:" + error.errcode);
console.info(" [FormComponent] formsystemhosto temp form error msg:" + error.msg);
let commonEventPublishData = {
data: error.msg,
bundleName: "com.ohos.st.formsystemhosto"
};
commonEvent.publish(this.formOnErrorEvent, commonEventPublishData, this.publishOnErrorCallBack);
})
.size({ width: 40, height: 40 })
}
}, (item) => JSON.stringify(item))
}
.columnsTemplate('1fr 1fr 1fr 1fr 1fr 1fr 1fr 1fr 1fr 1fr ')
.columnsGap(2)
.rowsGap(2)
.width('100%')
Text(' [FormComponent] formsystemhosto temp form component test end')
}
}
.backgroundColor(Color.White)
}
.scrollable(ScrollDirection.Vertical)
.width('100%')
.height('100%')
}
}
\ No newline at end of file
{
"string": [
{
"name": "entry_MainAbility",
"value": "formhostO"
},
{
"name": "description_mainability",
"value": "ETS_Empty Ability"
}
]
}
\ 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("FormSystemHostP") {
hap_profile = "./entry/src/main/config.json"
deps = [
":hjs_demo_js_assets",
":hjs_demo_resources",
]
ets2abc = true
certificate_profile = "./signature/openharmony_sx.p7b"
hap_name = "FormSystemHostP"
}
ohos_js_assets("hjs_demo_js_assets") {
source_dir = "./entry/src/main/ets/MainAbility"
}
ohos_resources("hjs_demo_resources") {
sources = [ "./entry/src/main/resources" ]
hap_profile = "./entry/src/main/config.json"
}
{
"description": "Configuration for hjunit demo Tests"
}
{
"app": {
"bundleName": "com.ohos.st.formsystemhostp",
"vendor": "ohos",
"version": {
"code": 1000000,
"name": "1.0.0"
},
"apiVersion": {
"compatible": 7,
"releaseType": "Release",
"target": 7
}
},
"deviceConfig": {},
"module": {
"package": "com.ohos.st.formsystemhostp",
"name": ".FormStHostAppP",
"mainAbility": ".MainAbility",
"deviceType": [
"phone"
],
"distro": {
"deliveryWithInstall": true,
"moduleName": "entry",
"moduleType": "entry",
"installationFree": false
},
"abilities": [
{
"skills": [
{
"entities": [
"entity.system.home"
],
"actions": [
"action.system.home"
]
}
],
"visible": true,
"name": ".MainAbility",
"srcLanguage": "ets",
"icon": "$media:icon",
"description": "$string:description_mainability",
"label": "$string:entry_MainAbility",
"type": "page",
"launchType": "standard"
}
],
"js": [
{
"mode": {
"syntax": "ets",
"type": "pageAbility"
},
"pages": [
"pages/index"
],
"name": ".MainAbility",
"window": {
"designWidth": 720,
"autoDesignWidth": false
}
}
],
"defPermissions": [
{
"availableScope": [],
"grantMode": "system_grant",
"name": "FMS_FormDelete_commonEvent"
},
{
"availableScope": [],
"grantMode": "system_grant",
"name": "FMS_FormOnAcquired_commonEvent"
},
{
"availableScope": [],
"grantMode": "system_grant",
"name": "FMS_FormOnError_commonEvent"
},
{
"availableScope": [],
"grantMode": "system_grant",
"name": "FMS_FormCast_commonEvent"
},
{
"availableScope": [],
"grantMode": "system_grant",
"name": "FMS_SendCastForm_commonEvent"
}
],
"reqPermissions": [
{
"name": "FMS_FormOnAcquired_commonEvent"
},
{
"name": "FMS_FormDelete_commonEvent"
},
{
"name": "FMS_FormOnError_commonEvent"
},
{
"name": "FMS_FormCast_commonEvent"
},
{
"name": "FMS_SendCastForm_commonEvent"
},
{
"name": "ohos.permission.GET_BUNDLE_INFO_PRIVILEGED"
},
{
"name": "ohos.permission.INSTALL_BUNDLE"
},
{
"name": "ohos.permission.LISTEN_BUNDLE_CHANGE"
},
{
"name": "ohos.permission.REQUIRE_FORM"
}
]
}
}
\ 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('[FormComponent.host] Application onCreate')
},
onDestroy() {
console.info('[FormComponent.host] Application onDestroy')
},
}
\ No newline at end of file
{
"string": [
{
"name": "entry_MainAbility",
"value": "formhostP"
},
{
"name": "description_mainability",
"value": "ETS_Empty Ability"
}
]
}
\ 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("FormSupplyAppA") {
hap_profile = "entry/src/main/config.json"
deps = [
":FormOfFaEts_form_js_assets",
":FormOfFaEts_js_assets",
":FormOfFaEts_resources",
]
certificate_profile = "signature/openharmony_sx.p7b"
hap_name = "FormSupplyAppA"
part_name = "prebuilt_hap"
subsystem_name = "applications"
}
ohos_js_assets("FormOfFaEts_js_assets") {
hap_profile = "entry/src/main/config.json"
ets2abc = true
source_dir = "entry/src/main/ets"
}
ohos_js_assets("FormOfFaEts_form_js_assets") {
hap_profile = "entry/src/main/config.json"
js2abc = true
source_dir = "entry/src/main/js"
}
ohos_resources("FormOfFaEts_resources") {
sources = [ "entry/src/main/resources" ]
hap_profile = "entry/src/main/config.json"
}
{
"app": {
"bundleName": "com.form.formsystemtestservicea.hmservice",
"vendor": "ohos",
"version": {
"code": 1000000,
"name": "1.0.0"
},
"apiVersion": {
"compatible": 9,
"releaseType": "Release",
"target": 9
}
},
"deviceConfig": {},
"module": {
"package": "com.form.formsystemtestservicea.hmservice",
"name": ".FormSupplyAppA",
"mainAbility": ".MainAbility",
"srcPath": "",
"deviceType": [
"phone"
],
"distro": {
"deliveryWithInstall": true,
"moduleName": "entry",
"moduleType": "entry",
"installationFree": false
},
"abilities": [
{
"skills": [
{
"entities": [
"entity.system.home"
],
"actions": [
"action.system.home"
]
}
],
"orientation": "unspecified",
"visible": true,
"srcPath": "MainAbility",
"name": ".MainAbility",
"srcLanguage": "ets",
"icon": "$media:icon",
"description": "$string:description_mainability",
"label": "$string:entry_MainAbility",
"type": "page",
"launchType": "standard"
},
{
"name": ".FormAbility",
"srcPath": "FormAbility",
"icon": "$media:icon",
"description": "$string:description_mainability",
"label": "$string:entry_MainAbility",
"type": "service",
"formsEnabled": true,
"forms": [
{
"jsComponentName": "Form_Js001",
"isDefault": true,
"scheduledUpdateTime": "10:30",
"formVisibleNotify": true,
"defaultDimension": "1*2",
"name": "Form_Js001",
"description": "This is a form 001",
"colorMode": "auto",
"type": "JS",
"supportDimensions": [
"1*2",
"2*2"
],
"updateEnabled": true,
"updateDuration": 1
},
{
"jsComponentName":"Form_Js002",
"isDefault":false,
"defaultDimension":"2*2",
"formVisibleNotify":true,
"name":"Form_Js002",
"colorMode":"auto",
"description":"This is a form 002",
"supportDimensions":[
"1*2",
"2*2"
],
"type":"JS",
"updateEnabled":true,
"updateDuration":1
}
],
"srcLanguage": "ets"
}
],
"js": [
{
"mode": {
"syntax": "ets",
"type": "pageAbility"
},
"pages": [
"pages/index",
"pages/second"
],
"name": ".MainAbility",
"window": {
"designWidth": 720,
"autoDesignWidth": false
}
},
{
"pages": [
"pages/index/index"
],
"name": "Form_Js001",
"window": {
"designWidth": 720,
"autoDesignWidth": true
},
"type": "form"
}
],
"defPermissions": [
{
"availableScope": [],
"grantMode": "system_grant",
"name": "FMS_FormSupply_commonEvent"
}
],
"reqPermissions": [
{
"reason": "need use FormSupply commonEvent",
"name": "FMS_FormSupply_commonEvent"
}
]
}
}
\ No newline at end of file
import formBindingData from '@ohos.application.formBindingData'
import commonEvent from '@ohos.commonEvent'
let supplyForm_Event = "FMS_FormSupply_commonEvent";
function publishCallBack() {
console.info("!!!====>FormAbility publishCallBack====>");
}
export default {
onCreate(want) {
console.info('FormAbility onCreate, want:' + JSON.stringify(want));
let formData = {
temperature: "11°",
time: "11:00",
area: "Shenyang",
epidemic: true,
count: 10
};
let bindingData = formBindingData.createFormBindingData(formData);
var commonEventPublishData = {
parameters: {
"kind" : "onCreate",
"parameters" : JSON.stringify(want),
"data" : JSON.stringify(formData)
}
};
commonEvent.publish(supplyForm_Event, commonEventPublishData, publishCallBack);
return bindingData;
},
onUpdate(formId) {
console.info('FormAbility onUpdate, formId: ' + formId);
var commonEventPublishData = {
parameters: {
"kind" : "onUpdate",
"parameters" : formId,
"data" : ""
}
};
commonEvent.publish(supplyForm_Event, commonEventPublishData, publishCallBack);
},
onCastToNormal(formId) {
console.info('FormAbility onCastTemp, formId: ' + formId);
var commonEventPublishData = {
parameters: {
"kind" : "onCastToNormal",
"parameters" : formId,
"data" : ""
}
};
commonEvent.publish(supplyForm_Event, commonEventPublishData, publishCallBack);
},
onEvent(formId, message) {
console.info('FormAbility onTriggerEvent, formId: ' + formId + 'message: ' + message);
var commonEventPublishData = {
parameters: {
"kind" : "onEvent",
"parameters" : formId,
"data" : message
}
};
commonEvent.publish(supplyForm_Event, commonEventPublishData, publishCallBack);
},
onVisibilityChange(formEvents) {
console.info('FormAbility onVisibilityChanged, ' + JSON.stringify(formEvents));
var commonEventPublishData = {
parameters: {
"kind" : "onVisibilityChange",
"parameters" : JSON.stringify(formEvents),
"data" : ""
}
};
commonEvent.publish(supplyForm_Event, commonEventPublishData, publishCallBack);
},
onDestroy(formId) {
console.info('FormAbility onDestroy, formId: ' + formId);
var commonEventPublishData = {
parameters: {
"kind" : "onDestroy",
"parameters" : formId,
"data" : ""
}
};
commonEvent.publish(supplyForm_Event, commonEventPublishData, publishCallBack);
}
};
\ 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('Application onCreate')
},
onDestroy() {
console.info('Application onDestroy')
},
}
\ 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 router from '@system.router';
async function routePage() {
let options = {
uri: 'pages/second'
}
try {
await router.push(options)
} catch (err) {
console.error(`fail callback, code: ${err.code}, msg: ${err.msg}`)
}
}
@Entry
@Component
struct Index {
build() {
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
Text('Hello World')
.fontSize(50)
.fontWeight(FontWeight.Bold)
Button() {
Text('next page')
.fontSize(25)
.fontWeight(FontWeight.Bold)
}.type(ButtonType.Capsule)
.margin({
top: 20
})
.backgroundColor('#0D9FFB')
.onClick(() => {
routePage()
})
}
.width('100%')
.height('100%')
}
}
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册