提交 b85ba5ac 编写于 作者: Z zhoujun62

add XTS of DataAbility access DataShare

Signed-off-by: Nzhoujun62 <zhoujun62@huawei.com>
Change-Id: Ieadb354fcb2b52954a1b094d3889bd55f17c0026
上级 b086ff93
# 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")
group("dataability") {
testonly = true
if (is_standard_system) {
deps = [
"actsdataabilityaccessdatasharetest:ActsDataAbilityAccessDataShareTest",
"datashareserverhap:DataShareServerHap",
]
}
}
# 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("ActsDataAbilityAccessDataShareTest") {
hap_profile = "./src/main/config.json"
hap_name = "ActsDataAbilityAccessDataShareTest"
deps = [
":hjs_demo_js_assets",
":hjs_demo_resources",
]
certificate_profile = "./signature/openharmony_sx.p7b"
subsystem_name = "ability"
part_name = "ability_runtime"
}
ohos_js_assets("hjs_demo_js_assets") {
js2abc = true
hap_profile = "./src/main/config.json"
source_dir = "./src/main/js"
}
ohos_resources("hjs_demo_resources") {
sources = [ "./src/main/resources" ]
hap_profile = "./src/main/config.json"
}
{
"description": "Configuration for hjunit demo Tests",
"driver": {
"type": "OHJSUnitTest",
"test-timeout": "180000",
"shell-timeout": "180000",
"bundle-name": "com.amsst.dataabilityaccessdatashare",
"package-name": "com.amsst.dataabilityaccessdatashare"
},
"kits": [
{
"test-file-name": [
"ActsDataAbilityAccessDataShareTest.hap",
"DataShareServerHap.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
}
]
}
\ No newline at end of file
{
"app": {
"bundleName": "com.amsst.dataabilityaccessdatashare",
"vendor": "amsst",
"version": {
"code": 1,
"name": "1.0"
},
"apiVersion": {
"compatible": 9,
"target": 5,
"releaseType": "Beta1"
}
},
"deviceConfig": {},
"module": {
"package": "com.amsst.dataabilityaccessdatashare",
"name": ".entry",
"deviceType": [
"phone"
],
"distro": {
"deliveryWithInstall": true,
"moduleName": "entry",
"moduleType": "entry"
},
"abilities": [
{
"skills": [
{
"entities": [
"entity.system.home"
],
"actions": [
"action.system.home"
]
}
],
"orientation": "unspecified",
"formsEnabled": false,
"name": ".MainAbility",
"srcLanguage": "js",
"srcPath": "MainAbility",
"icon": "$media:icon",
"description": "$string:MainAbility_desc",
"label": "$string:MainAbility_label",
"type": "page",
"visible": true,
"launchType": "standard"
},
{
"orientation": "unspecified",
"formsEnabled": false,
"name": ".TestAbility",
"srcLanguage": "js",
"srcPath": "TestAbility",
"icon": "$media:icon",
"description": "$string:TestAbility_desc",
"label": "$string:TestAbility_label",
"type": "page",
"visible": true,
"launchType": "standard"
}
],
"js": [
{
"pages": [
"pages/index/index"
],
"name": "default",
"window": {
"designWidth": 720,
"autoDesignWidth": false
}
},
{
"pages": [
"pages/index/index"
],
"name": ".TestAbility",
"window": {
"designWidth": 720,
"autoDesignWidth": false
}
}
],
"testRunner": {
"name": "OpenHarmonyTestRunner",
"srcPath": "TestRunner"
},
"mainAbility": ".MainAbility",
"srcPath": ""
}
}
\ No newline at end of file
/*
* Copyright (C) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export default {
onCreate() {
console.info('AceApplication onCreate');
},
onDestroy() {
console.info('AceApplication onDestroy');
}
};
.container {
flex-direction: column;
justify-content: center;
align-items: center;
}
.title {
font-size: 100px;
}
.titleST {
font-size: 32px;
}
\ No newline at end of file
<div class="container">
<text class="title">
{{ $t('strings.hello') }} {{ title }}
</text>
<text class="titleST">
STDataAbility
</text>
</div>
/*
* Copyright (C) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import file from '@system.file'
import app from '@system.app'
export default {
data: {
title: ""
},
onInit() {
this.title = this.$t('strings.world');
},
onShow() {
console.info('====onShow finish====<')
},
onReady() {
},
}
\ No newline at end of file
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
import { Hypium } from '@ohos/hypium'
import testsuite from '../test/List.test'
export default {
onCreate() {
console.info('TestApplication onCreate')
var abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
var abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
console.info('start run testcase!!!')
Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite)
},
onDestroy() {
console.info("TestApplication onDestroy");
}
};
{
"strings": {
"hello": "Hello",
"world": "World"
},
"Files": {
}
}
\ No newline at end of file
{
"strings": {
"hello": "您好",
"world": "世界"
},
"Files": {
}
}
\ No newline at end of file
.container {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
left: 0px;
top: 0px;
width: 100%;
height: 100%;
}
.title {
font-size: 60px;
text-align: center;
width: 100%;
height: 40%;
margin: 10px;
}
@media screen and (device-type: phone) and (orientation: landscape) {
.title {
font-size: 60px;
}
}
@media screen and (device-type: tablet) and (orientation: landscape) {
.title {
font-size: 100px;
}
}
\ No newline at end of file
<div class="container">
<text class="title">
{{ $t('strings.hello') }} {{ title }}
</text>
</div>
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export default {
data: {
title: ""
},
onInit() {
this.title = this.$t('strings.world');
}
}
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
function translateParamsToString(parameters) {
const keySet = new Set([
'-s class', '-s notClass', '-s suite', '-s itName',
'-s level', '-s testType', '-s size', '-s timeout',
'-s package', '-s dryRun'
])
let targetParams = '';
for (const key in parameters) {
if (keySet.has(key)) {
targetParams += ' ' + key + ' ' + parameters[key]
}
}
return targetParams.trim()
}
export default {
onPrepare() {
console.info('OpenHarmonyTestRunner OnPrepare')
},
onRun() {
console.log('OpenHarmonyTestRunner onRun run')
var abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
var abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
var testAbilityName = abilityDelegatorArguments.parameters['-p'] + '.TestAbility'
var cmd = 'aa start -d 0 -a ' + testAbilityName + ' -b ' + abilityDelegatorArguments.bundleName
cmd += ' ' + translateParamsToString(abilityDelegatorArguments.parameters)
var debug = abilityDelegatorArguments.parameters["-D"]
console.info('debug value : '+debug)
if (debug == 'true')
{
cmd += ' -D'
}
console.info('cmd : '+cmd)
abilityDelegator.executeShellCommand(cmd, (err, data) => {
console.info('executeShellCommand : err : ' + JSON.stringify(err));
console.info('executeShellCommand : data : ' + data.stdResult);
console.info('executeShellCommand : data : ' + data.exitCode);
})
}
};
/*
* Copyright (C) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import featureAbility from '@ohos.ability.featureAbility'
import ohosDataAbility from '@ohos.data.dataAbility'
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'
export default function ActsDataAbilityHelperTest() {
describe('ActsDataAbilityHelperTest', function () {
let dataAbilityUri = ("dataability:///com.example.dataabilityserver_fa.DataAbility");
let DAHelper;
let gSetTimeout = 500;
let index = 1;
beforeAll(async (done) => {
console.debug('= ACTS_beforeAll ====<begin');
try {
DAHelper = featureAbility.acquireDataAbilityHelper(dataAbilityUri);
console.debug('ACTS_beforeAll DAHelper ====>: ' + DAHelper + " ,JSON. " + JSON.stringify(DAHelper));
if(DAHelper == null){
console.debug('ACTS_beforeAll DAHelper ====>: DAHelper == null');
return;
}
} catch (err) {
console.error('=ACTS_beforeAll acquireDataAbilityHelper catch(err)====>:' + err);
}
console.debug('= ACTS_beforeAll ====<end');
done();
})
afterAll((done) => {
console.debug('= ACTS_afterAll ====<begin');
console.debug('= ACTS_afterAll ====<end');
done();
})
/*
* @tc.number: ACTS_DataAbilityAccessDataShare_Inset_0100
* @tc.name: insert : insert data to DataShare by DataAbilityHelper
* @tc.desc: Check the return value of the interface (by AsyncCallback)
*/
it('ACTS_DataAbilityAccessDataShare_Inset_0100', 0, async function (done) {
console.log('ACTS_DataAbilityAccessDataShare_Inset_0100====<begin');
console.debug("=ACTS_DataAbilityAccessDataShare_Inset_0100 dataAbilityUri====>" + dataAbilityUri)
try {
if(DAHelper == null){
var abilityHelper = featureAbility.acquireDataAbilityHelper(dataAbilityUri)
console.log('ACTS_DataAbilityAccessDataShare_Inset_0100 abilityHelper ====>: '
+ abilityHelper + " ,JSON. " + JSON.stringify(abilityHelper))
DAHelper = abilityHelper;
}
expect(typeof (DAHelper)).assertEqual("object");
} catch (err) {
console.error('=ACTS_DataAbilityAccessDataShare_Inset_0100 acquireDataAbilityHelper catch(err)====>:' + err);
expect(false).assertTrue();
}
let insertValuesBucket = {'name':'C++', 'introduction':'Primer'}
DAHelper.insert(
dataAbilityUri,
insertValuesBucket,
(error, data) => {
console.log('ACTS_DataAbilityAccessDataShare_Inset_0100 DAHelper insert result: ' + data)
expect(data).assertEqual(index);
index++;
})
done();
console.log('ACTS_DataAbilityAccessDataShare_Inset_0100====<end')
})
})}
\ No newline at end of file
/*
* Copyright (C) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import ActsDataAbilityHelperTest from './DataAbilityHelperJsSt.test.js'
export default function testsuite() {
ActsDataAbilityHelperTest()
}
{
"string": [
{
"name": "app_name",
"value": "STDataAbility"
},
{
"name": "mainability_description",
"value": "JS_Phone_Empty Feature Ability"
},
{
"name": "MainAbility_desc",
"value": "description"
},
{
"name": "MainAbility_label",
"value": "label"
},
{
"name": "TestAbility_desc",
"value": "description"
},
{
"name": "TestAbility_label",
"value": "label"
}
]
}
\ No newline at end of file
{
"app": {
"bundleName": "com.example.datashareserver_stage",
"vendor": "example",
"versionCode": 1000000,
"versionName": "1.0.0",
"icon": "$media:app_icon",
"label": "$string:app_name",
"distributedNotificationEnabled": true
}
}
# Copyright (c) 2022 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import("//test/xts/tools/build/suite.gni")
ohos_hap_assist_suite("DataShareServerHap") {
hap_name = "DataShareServerHap"
js_build_mode = "debug"
testonly = true
hap_profile = "entry/src/main/module.json"
deps = [
":datashareserverhap_js_assets",
":datashareserverhap_resources",
]
ets2abc = true
certificate_profile = "signature/openharmony_sx.p7b"
subsystem_name = "ability"
part_name = "ability_runtime"
}
ohos_app_scope("datashareserverhap_app_profile") {
app_profile = "AppScope/app.json"
sources = [ "AppScope/resources" ]
}
ohos_js_assets("datashareserverhap_js_assets") {
source_dir = "entry/src/main/ets"
}
ohos_resources("datashareserverhap_resources") {
sources = [ "entry/src/main/resources" ]
deps = [ ":datashareserverhap_app_profile" ]
hap_profile = "entry/src/main/module.json"
}
/*
* Copyright (C) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import AbilityStage from "@ohos.application.AbilityStage"
export default class MyAbilityStage extends AbilityStage {
onCreate() {
console.log("[DataShareServer]: MyAbilityStage onCreate")
}
}
\ No newline at end of file
/*
* Copyright (C) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import Extension from '@ohos.application.DataShareExtensionAbility'
import rdb from '@ohos.data.rdb';
let DB_NAME = "book.db";
let TBL_NAME = "book";
let DDL_TBL_CREATE = "CREATE TABLE IF NOT EXISTS "
+ TBL_NAME
+ " (id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT NOT NULL, introduction TEXT NOT NULL)";
let rdbStore;
function sleep(time) {
return new Promise(resolve =>
setTimeout(resolve,time)
) } async function output() {
let out = await sleep(1000);
console.log('1');
return out;
}
export default class DataShareExtAbility extends Extension {
async onCreate(want, callback) {
console.log('[DataShareServer]: DataShareExtAbility onCreate, want:' + want.abilityName);
console.log('[DataShareServer]: DataShareExtAbility onCreate this.context.databaseDir:' + this.context.databaseDir);
// @ts-ignore
rdbStore = await rdb.getRdbStore(this.context, { name: DB_NAME }, 1);
console.log('[DataShareServer]: DataShareExtAbility getRdbStore done');
await rdbStore.executeSql(DDL_TBL_CREATE, []);
console.log('[DataShareServer]: DataShareExtAbility executeSql done');
let err = {"code":0};
callback(err);
console.log('[DataShareServer]: DataShareExtAbility onCreate end');
}
async getFileTypes(uri: string, mimeTypeFilter: string, callback) {
console.log('[DataShareServer]: [getFileTypes] enter');
let ret = new Array("type01", "type00", "type03");
console.log('[DataShareServer]: [getFileTypes] leave, ret:' + ret);
let err = {"code":0};
await callback(err,ret);
return ret;
}
async openFile(uri: string, mode: string, callback) {
console.log('[DataShareServer]: [openFile] enter');
let ret = 1;
let err = {"code":0};
await callback(err,ret);
console.log('[DataShareServer]: [openFile] leave, ret:' + ret);
}
async insert(uri, value, callback) {
console.log('[DataShareServer]: [insert] enter');
if (value == null) {
console.error('[DataShareServer]: [insert] invalid valueBuckets');
return;
}
console.log('[DataShareServer]: [insert] value = ' + value);
console.log('[DataShareServer]: [insert] value = ' + JSON.stringify(value));
await rdbStore.insert(TBL_NAME, value, function (err, ret) {
console.log('zhoujun: [DataShareTest] <<Provider>> [insert] callback ret:' + ret);
if (callback != undefined) {
callback(err, ret);
}
});
console.log('[DataShareServer]: [insert] leave');
}
async update(uri, predicates, value, callback) {
console.log('[DataShareServer]: [update] enter');
if (predicates == null || predicates == undefined) {
console.error('zhoujun: [DataShareTest] <<Provider>> [update] invalid predicates');
return;
}
console.log('[DataShareServer]: [update] values = ' + value);
console.log('[DataShareServer]: [update] values = ' + JSON.stringify(value));
console.log('[DataShareServer]: [update] predicates = ' + predicates);
console.log('[DataShareServer]: [update] predicates = ' + JSON.stringify(predicates));
try {
await rdbStore.update(TBL_NAME, value, predicates, function (err, ret) {
console.log('[DataShareServer]: [update] callback ret:' + ret);
console.log('[DataShareServer]: [update] callback err:' + err);
if (callback != undefined) {
callback(err, ret);
}
});
} catch (err) {
console.error('[DataShareServer]: [update] error' + err);
}
sleep(1);
console.log('[DataShareServer]: [update] leave');
}
async delete(uri, predicates, callback) {
console.log('[DataShareServer]: [delete] enter');
if (predicates == null || predicates == undefined) {
console.error('[DataShareServer]: [delete] invalid predicates');
return;
}
console.log('[DataShareServer]: [delete] predicates = ' + predicates);
console.log('[DataShareServer]: [delete] predicates = ' + JSON.stringify(predicates));
try {
await rdbStore.delete(TBL_NAME, predicates, function (err, ret) {
console.log('[DataShareServer]: [delete] ret:' + ret);
if (callback != undefined) {
callback(err, ret);
}
});
} catch (err) {
console.error('[DataShareServer]: [delete] error' + err);
}
console.log('[DataShareServer]: [delete] leave');
}
async query(uri, predicates, columns, callback) {
console.log('[DataShareServer]: [query] enter');
if (predicates == null || predicates == undefined) {
console.error('[DataShareServer]: [query] invalid predicates');
}
console.log('[DataShareServer]: [query] values = ' + columns);
console.log('[DataShareServer]: [query] values = ' + JSON.stringify(columns));
console.log('[DataShareServer]: [query] predicates = ' + predicates);
console.log('[DataShareServer]: [query] predicates = ' + JSON.stringify(predicates));
try {
await rdbStore.query(TBL_NAME, predicates, columns, function (err, resultSet) {
console.log('[DataShareServer]: [query] ret: ' + resultSet);
if (resultSet != undefined) {
console.log('[DataShareServer]: [query] resultSet.rowCount: ' + resultSet.rowCount);
}
if (callback != undefined) {
callback(err, resultSet);
}
});
} catch (err) {
console.error('[DataShareServer]: [query] error' + err);
}
console.log('[DataShareServer]: [query] leave');
}
async getType(uri: string, callback) {
console.log('[DataShareServer]: [getType] enter');
let ret = "image";
console.log('[DataShareServer]: [getType] leave, ret:' + ret);
let err = {"code":0};
await callback(err,ret);
return ret;
}
async batchInsert(uri: string, valueBuckets, callback) {
console.log('[DataShareServer]: [batchInsert] enter');
if (valueBuckets == null || valueBuckets.length == undefined) {
console.error('zhoujun: [DataShareTest] <<Provider>> [batchInsert] invalid valueBuckets');
return;
}
console.log('[DataShareServer]: [batchInsert] valueBuckets.length:' + valueBuckets.length);
let resultNum = valueBuckets.length
await valueBuckets.forEach(vb => {
console.log('[DataShareServer]: [batchInsert] vb:' + JSON.stringify(vb));
rdbStore.insert(TBL_NAME, vb, function (err, ret) {
console.log('[DataShareServer]: [batchInsert] callback ret:' + ret);
if (callback != undefined) {
callback(err, resultNum);
}
});
});
console.log('[DataShareServer]: [batchInsert] leave');
}
async normalizeUri(uri: string, callback) {
console.log('[DataShareServer]: [normalizeUri] enter');
let ret = "normalize+" + uri;
let err = {"code":0};
await callback(err, ret);
console.log('[DataShareServer]: [normalizeUri] leave, ret:' + ret);
}
async denormalizeUri(uri: string, callback) {
console.log('[DataShareServer]: [denormalizeUri] enter');
let ret = "denormalize+" + uri;
let err = {"code":0};
await callback(err, ret);
console.log('[DataShareServer]: [denormalizeUri] leave, ret:' + ret);
}
};
\ No newline at end of file
/*
* Copyright (C) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import Ability from '@ohos.application.Ability'
export default class MainAbility extends Ability {
onCreate(want, launchParam) {
console.log("[DataShareServer]: MainAbility onCreate")
globalThis.abilityWant = want;
}
onDestroy() {
console.log("[DataShareServer]: MainAbility onDestroy")
}
onWindowStageCreate(windowStage) {
// Main window is created, set main page for this ability
console.log("[DataShareServer]: MainAbility onWindowStageCreate")
windowStage.loadContent("pages/index", (err, data) => {
if (err.code) {
console.error("[DataShareServer]: Failed to load the content. Cause: " + JSON.stringify(err));
return;
}
console.log("[DataShareServer]: Succeeded in loading the content. Data: " + JSON.stringify(data))
});
}
onWindowStageDestroy() {
// Main window is destroyed, release UI related resources
console.log("[DataShareServer]: MainAbility onWindowStageDestroy")
}
onForeground() {
// Ability has brought to foreground
console.log("[DataShareServer]: MainAbility onForeground")
}
onBackground() {
// Ability has back to background
console.log("[DataShareServer]: MainAbility onBackground")
}
};
/*
* Copyright (C) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
@Entry
@Component
struct Index {
@State message: string = 'stagemode: datashare server'
build() {
Row() {
Column() {
Text(this.message)
.fontSize(50)
.fontWeight(FontWeight.Bold)
}
.width('100%')
}
.height('100%')
}
}
\ No newline at end of file
{
"module": {
"name": "entry",
"type": "entry",
"srcEntrance": "./ets/Application/MyAbilityStage.ts",
"description": "$string:entry_desc",
"mainElement": "MainAbility",
"deviceTypes": [
"default",
"tablet"
],
"deliveryWithInstall": true,
"installationFree": false,
"pages": "$profile:main_pages",
"uiSyntax": "ets",
"abilities": [
{
"name": "MainAbility",
"srcEntrance": "./ets/MainAbility/MainAbility.ts",
"description": "$string:MainAbility_desc",
"icon": "$media:icon",
"label": "$string:MainAbility_label",
"startWindowIcon": "$media:icon",
"startWindowBackground": "$color:white",
"visible": true,
"skills": [
{
"entities": [
"entity.system.home"
],
"actions": [
"action.system.home"
]
}
]
}
],
"extensionAbilities": [
{
"srcEntrance": "./ets/DataShareExtAbility/DataShareExtAbility.ts",
"name": "DataShareExtAbility",
"icon": "$media:icon",
"description": "$string:DataShareExtAbility_desc",
"type": "dataShare",
"uri": "datashare://com.example.dataabilityserver_fa.DataAbility",
"visible": true
}
]
}
}
\ No newline at end of file
{
"string": [
{
"name": "entry_desc",
"value": "description"
},
{
"name": "MainAbility_desc",
"value": "description"
},
{
"name": "MainAbility_label",
"value": "label"
},
{
"name": "DataShareExtAbility_desc",
"value": "description"
},
{
"name": "DataShareExtAbility_label",
"value": "label"
}
]
}
\ No newline at end of file
{
"forms": [
{
"name": "widget",
"description": "This is a service widget.",
"src": "./js/widget/pages/index/index",
"window": {
"designWidth": 720,
"autoDesignWidth": true
},
"colorMode": "auto",
"isDefault": true,
"updateEnabled": true,
"scheduledUpdateTime": "10:30",
"updateDuration": 1,
"defaultDimension": "2*2",
"supportDimensions": [
"2*2"
]
},
{
"name": "widget",
"description": "This is a service widget.",
"src": "./js/widget/pages/index/index",
"window": {
"designWidth": 720,
"autoDesignWidth": true
},
"colorMode": "auto",
"isDefault": true,
"updateEnabled": true,
"scheduledUpdateTime": "10:30",
"updateDuration": 1,
"defaultDimension": "2*2",
"supportDimensions": [
"2*2"
]
}
]
}
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册