diff --git a/code/BasicFeature/ApplicationModels/AbilityStartMode/.gitignore b/code/BasicFeature/ApplicationModels/AbilityStartMode/.gitignore index 91d237bb144c7fb1777e50271857ef0f593286fc..40bf74cf5cf5b5d5684f825894771423088a8936 100644 --- a/code/BasicFeature/ApplicationModels/AbilityStartMode/.gitignore +++ b/code/BasicFeature/ApplicationModels/AbilityStartMode/.gitignore @@ -2,4 +2,5 @@ /local.properties /.idea **/build -/.hvigor \ No newline at end of file +/.hvigor +**/package-lock.json \ No newline at end of file diff --git a/code/BasicFeature/ApplicationModels/AbilityStartMode/README_zh.md b/code/BasicFeature/ApplicationModels/AbilityStartMode/README_zh.md index 299c14c006bc396b7aa196a7be20d33952ae25f0..2e4cabc07e27eeab2f56fa6b2cac838ffc76806c 100644 --- a/code/BasicFeature/ApplicationModels/AbilityStartMode/README_zh.md +++ b/code/BasicFeature/ApplicationModels/AbilityStartMode/README_zh.md @@ -51,6 +51,6 @@ 1.本示例仅支持标准系统上运行,支持设备:RK3568。 -2.本示例仅支持API version 9版本SDK,版本号:3.2.5.6。 +2.本示例仅支持API version 9版本SDK,版本号:3.2.10.6。 -3.本示例需要使用DevEco Studio 3.0 Beta4 (Build Version: 3.0.0.992, built on July 14, 2022)才可编译运行。 \ No newline at end of file +3.本示例需要使用DevEco Studio 3.1 Canary1 (Build Version: 3.1.0.100)及以上才可编译运行。 \ No newline at end of file diff --git a/code/BasicFeature/ApplicationModels/AbilityStartMode/entry/package.json b/code/BasicFeature/ApplicationModels/AbilityStartMode/entry/package.json index db08bbf9d7439623fcfa4093ab7f013633c62d48..29732ffea047ab4e9d897d4cc7092f5e7fe3493f 100644 --- a/code/BasicFeature/ApplicationModels/AbilityStartMode/entry/package.json +++ b/code/BasicFeature/ApplicationModels/AbilityStartMode/entry/package.json @@ -11,4 +11,4 @@ "repository": {}, "version": "1.0.0", "dependencies": {} -} \ No newline at end of file +} diff --git a/code/BasicFeature/ApplicationModels/AbilityStartMode/entry/src/main/ets/Application/MyAbilityStage.ts b/code/BasicFeature/ApplicationModels/AbilityStartMode/entry/src/main/ets/Application/MyAbilityStage.ts index 1efd20540eecc8c8476df9b959e4f13baf267e67..b5d95a68ba57d91441c5037d455e934130ce5f7f 100644 --- a/code/BasicFeature/ApplicationModels/AbilityStartMode/entry/src/main/ets/Application/MyAbilityStage.ts +++ b/code/BasicFeature/ApplicationModels/AbilityStartMode/entry/src/main/ets/Application/MyAbilityStage.ts @@ -13,7 +13,7 @@ * limitations under the License. */ -import AbilityStage from "@ohos.application.AbilityStage" +import AbilityStage from '@ohos.app.ability.AbilityStage' import Want from '@ohos.application.Want' import Logger from '../common/Logger' diff --git a/code/BasicFeature/ApplicationModels/AbilityStartMode/entry/src/main/ets/MainAbility/MainAbility.ts b/code/BasicFeature/ApplicationModels/AbilityStartMode/entry/src/main/ets/MainAbility/MainAbility.ts index de9472dc5995fb0415f201d98cf65581a9e5c763..e171d91460ff772d37bcf3726b4d861acbd96b05 100644 --- a/code/BasicFeature/ApplicationModels/AbilityStartMode/entry/src/main/ets/MainAbility/MainAbility.ts +++ b/code/BasicFeature/ApplicationModels/AbilityStartMode/entry/src/main/ets/MainAbility/MainAbility.ts @@ -13,12 +13,12 @@ * limitations under the License. */ -import Ability from '@ohos.application.Ability' +import UIAbility from '@ohos.app.ability.UIAbility' import Logger from '../common/Logger' const TAG = '[Sample_StartMode]' -export default class MainAbility extends Ability { +export default class MainAbility extends UIAbility { onCreate(want, launchParam) { Logger.info(TAG, 'MainAbility onCreate') const that = this diff --git a/code/BasicFeature/ApplicationModels/AbilityStartMode/entry/src/main/ets/SingletonAbility/SingletonAbility.ts b/code/BasicFeature/ApplicationModels/AbilityStartMode/entry/src/main/ets/SingletonAbility/SingletonAbility.ts index 372696940b0003c3579cf9c1239869511605b5ae..221386fc47633dc3b1c65dcafe7f0896a3bf9a01 100644 --- a/code/BasicFeature/ApplicationModels/AbilityStartMode/entry/src/main/ets/SingletonAbility/SingletonAbility.ts +++ b/code/BasicFeature/ApplicationModels/AbilityStartMode/entry/src/main/ets/SingletonAbility/SingletonAbility.ts @@ -13,7 +13,7 @@ * limitations under the License. */ -import Ability from '@ohos.application.Ability' +import UIAbility from '@ohos.app.ability.UIAbility' import emitter from '@ohos.events.emitter' import Logger from '../common/Logger' @@ -21,7 +21,7 @@ const TAG = '[Sample_StartMode]' const eventId = 1 // 设置一个Id,用来emitter传输 -export default class SingletonAbility extends Ability { +export default class SingletonAbility extends UIAbility { onCreate(want) { Logger.info(TAG, 'SingletonAbility onCreate') const that = this diff --git a/code/BasicFeature/ApplicationModels/AbilityStartMode/entry/src/main/ets/SpecifiedAbility/SpecifiedAbility.ts b/code/BasicFeature/ApplicationModels/AbilityStartMode/entry/src/main/ets/SpecifiedAbility/SpecifiedAbility.ts index 599101cf84aa3347c8d9e19279b8154f586a27b2..8f586a31ba523a3e23a2d044db3e12bffe27933e 100644 --- a/code/BasicFeature/ApplicationModels/AbilityStartMode/entry/src/main/ets/SpecifiedAbility/SpecifiedAbility.ts +++ b/code/BasicFeature/ApplicationModels/AbilityStartMode/entry/src/main/ets/SpecifiedAbility/SpecifiedAbility.ts @@ -13,13 +13,13 @@ * limitations under the License. */ -import Ability from '@ohos.application.Ability' +import UIAbility from '@ohos.app.ability.UIAbility' import Want from '@ohos.application.Want' import Logger from '../common/Logger' const TAG = '[Sample_StartMode]' -export default class SpecifiedAbility extends Ability { +export default class SpecifiedAbility extends UIAbility { private want: Want onCreate(want, launchParam) { diff --git a/code/BasicFeature/ApplicationModels/AbilityStartMode/entry/src/main/ets/StandardAbility/StandardAbility.ts b/code/BasicFeature/ApplicationModels/AbilityStartMode/entry/src/main/ets/StandardAbility/StandardAbility.ts index a4085f25674bbb1cee80f25aab216324d5da765d..d20497f628cc209c28c3269381136ca34808cded 100644 --- a/code/BasicFeature/ApplicationModels/AbilityStartMode/entry/src/main/ets/StandardAbility/StandardAbility.ts +++ b/code/BasicFeature/ApplicationModels/AbilityStartMode/entry/src/main/ets/StandardAbility/StandardAbility.ts @@ -13,13 +13,13 @@ * limitations under the License. */ -import Ability from '@ohos.application.Ability' -import AbilityConstant from '@ohos.application.AbilityConstant' +import UIAbility from '@ohos.app.ability.UIAbility' +import AbilityConstant from '@ohos.app.ability.AbilityConstant' import Logger from '../common/Logger' const TAG = '[Sample_StartMode]' -export default class StandardAbility extends Ability { +export default class StandardAbility extends UIAbility { onCreate(want, launchParam) { Logger.info(TAG, 'StandardAbility onCreate') const that = this diff --git a/code/BasicFeature/ApplicationModels/AbilityStartMode/package.json b/code/BasicFeature/ApplicationModels/AbilityStartMode/package.json index 880a9c29440e4f18bcc6fa2673126de9d8c929ea..fa727ec74dd41f2fe6c671625f04692bb0301f9f 100644 --- a/code/BasicFeature/ApplicationModels/AbilityStartMode/package.json +++ b/code/BasicFeature/ApplicationModels/AbilityStartMode/package.json @@ -11,8 +11,8 @@ "repository": {}, "version": "1.0.0", "dependencies": { - "@ohos/hypium": "1.0.1", - "@ohos/hvigor-ohos-plugin": "1.1.6", - "@ohos/hvigor": "1.1.6" + "@ohos/hypium": "1.0.3", + "@ohos/hvigor-ohos-plugin": "1.3.1", + "@ohos/hvigor": "1.3.1" } } \ No newline at end of file diff --git a/code/BasicFeature/ApplicationModels/CustomShare/.gitignore b/code/BasicFeature/ApplicationModels/CustomShare/.gitignore index 91d237bb144c7fb1777e50271857ef0f593286fc..40bf74cf5cf5b5d5684f825894771423088a8936 100644 --- a/code/BasicFeature/ApplicationModels/CustomShare/.gitignore +++ b/code/BasicFeature/ApplicationModels/CustomShare/.gitignore @@ -2,4 +2,5 @@ /local.properties /.idea **/build -/.hvigor \ No newline at end of file +/.hvigor +**/package-lock.json \ No newline at end of file diff --git a/code/BasicFeature/ApplicationModels/CustomShare/README_zh.md b/code/BasicFeature/ApplicationModels/CustomShare/README_zh.md index 43274e93b6fe79b362e850396633c2857716d656..30ff073be47a2b28a0aefab20372f2756897d831 100644 --- a/code/BasicFeature/ApplicationModels/CustomShare/README_zh.md +++ b/code/BasicFeature/ApplicationModels/CustomShare/README_zh.md @@ -46,9 +46,9 @@ 1.本示例仅支持标准系统上运行,支持设备:RK3568。 -2.本示例为Stage模型,仅支持API9版本SDK,版本号:3.2.6.5。 +2.本示例为Stage模型,仅支持API9版本SDK,版本号:3.2.10.6。 -3.本示例需要使用DevEco Studio 3.0 Beta4 (Build Version: 3.0.0.992, built on July 14, 2022)才可编译运行。 +3.本示例需要使用DevEco Studio 3.1 Canary1 (Build Version: 3.1.0.100)及以上才可编译运行。 4.本示例使用的screenshot API属于SystemAPI,需要使用Full SDK 手动从镜像站点获取,并在DevEco Studio中替换,具体操作可参考[替换指南](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/quick-start/full-sdk-switch-guide.md) diff --git a/code/BasicFeature/Connectivity/Http/http/hvigorfile.js b/code/BasicFeature/ApplicationModels/CustomShare/ShareComponent/hvigorfile.ts similarity index 100% rename from code/BasicFeature/Connectivity/Http/http/hvigorfile.js rename to code/BasicFeature/ApplicationModels/CustomShare/ShareComponent/hvigorfile.ts diff --git a/code/BasicFeature/ApplicationModels/CustomShare/ShareComponent/package.json b/code/BasicFeature/ApplicationModels/CustomShare/ShareComponent/package.json index f773b3d6bae4de24d082f711e2208182a1aef56d..216cd8c10fdfd07fe898b777a50b90ac51ab65de 100644 --- a/code/BasicFeature/ApplicationModels/CustomShare/ShareComponent/package.json +++ b/code/BasicFeature/ApplicationModels/CustomShare/ShareComponent/package.json @@ -1,14 +1,15 @@ { - "license": "ISC", - "types": "", - "devDependencies": {}, - "name": "@ohos/sharecomponent", - "description": "a npm package which contains arkUI2.0 page", - "ohos": { - "org": "" - }, - "main": "index.ets", - "repository": {}, - "version": "1.0.1", - "dependencies": {} -} + "license": "ISC", + "types": "", + "devDependencies": {}, + "name": "@ohos/sharecomponent", + "description": "a npm package which contains arkUI2.0 page", + "ohos": { + "org": "" + }, + "main": "index.ets", + "repository": {}, + "type": "module", + "version": "1.0.1", + "dependencies": {} +} \ No newline at end of file diff --git a/code/BasicFeature/ApplicationModels/CustomShare/ShareComponent/src/ohosTest/ets/test/Ability.test.ets b/code/BasicFeature/ApplicationModels/CustomShare/ShareComponent/src/ohosTest/ets/test/Ability.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..c3802bbfe8b74da44c76b52b121203e55a61b088 --- /dev/null +++ b/code/BasicFeature/ApplicationModels/CustomShare/ShareComponent/src/ohosTest/ets/test/Ability.test.ets @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2023 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 hilog from '@ohos.hilog'; +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium' + +export default function abilityTest() { + describe('ActsAbilityTest', function () { + // Defines a test suite. Two parameters are supported: test suite name and test suite function. + beforeAll(function () { + // Presets an action, which is performed only once before all test cases of the test suite start. + // This API supports only one parameter: preset action function. + }) + beforeEach(function () { + // Presets an action, which is performed before each unit test case starts. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: preset action function. + }) + afterEach(function () { + // Presets a clear action, which is performed after each unit test case ends. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: clear action function. + }) + afterAll(function () { + // Presets a clear action, which is performed after all test cases of the test suite end. + // This API supports only one parameter: clear action function. + }) + it('assertContain',0, function () { + // Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function. + hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO); + hilog.info(0x0000, 'testTag', '%{public}s', 'it begin'); + let a = 'abc' + let b = 'b' + // Defines a variety of assertion methods, which are used to declare expected boolean conditions. + expect(a).assertContain(b) + expect(a).assertEqual(a) + }) + }) +} \ No newline at end of file diff --git a/code/BasicFeature/ApplicationModels/CustomShare/ShareComponent/src/ohosTest/ets/test/List.test.ets b/code/BasicFeature/ApplicationModels/CustomShare/ShareComponent/src/ohosTest/ets/test/List.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..27c07a1a174f6862ea84c4bb5f45bc1789234441 --- /dev/null +++ b/code/BasicFeature/ApplicationModels/CustomShare/ShareComponent/src/ohosTest/ets/test/List.test.ets @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2023 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 abilityTest from './Ability.test' + +export default function testsuite() { + abilityTest() +} \ No newline at end of file diff --git a/code/BasicFeature/ApplicationModels/CustomShare/ShareComponent/src/ohosTest/ets/testability/TestAbility.ets b/code/BasicFeature/ApplicationModels/CustomShare/ShareComponent/src/ohosTest/ets/testability/TestAbility.ets new file mode 100644 index 0000000000000000000000000000000000000000..c04d49d5314b5a6cd8c7812b723b4ffa58523daa --- /dev/null +++ b/code/BasicFeature/ApplicationModels/CustomShare/ShareComponent/src/ohosTest/ets/testability/TestAbility.ets @@ -0,0 +1,72 @@ +/* + * Copyright (c) 2023 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 hilog from '@ohos.hilog'; +import UIAbility from '@ohos.app.ability.UIAbility' +import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' +import { Hypium } from '@ohos/hypium' +import testsuite from '../test/List.test' +import Window from '@ohos.window' + +export default class TestAbility extends UIAbility { + onCreate(want, launchParam) { + hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO); + hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onCreate'); + hilog.info(0x0000, 'testTag', '%{public}s', 'want param:' + JSON.stringify(want) ?? ''); + hilog.info(0x0000, 'testTag', '%{public}s', 'launchParam:'+ JSON.stringify(launchParam) ?? ''); + var abilityDelegator: any + abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + var abilityDelegatorArguments: any + abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() + hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO); + hilog.info(0x0000, 'testTag', '%{public}s', 'start run testcase!!!'); + Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite) + } + + onDestroy() { + hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO); + hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onDestroy'); + } + + onWindowStageCreate(windowStage: Window.WindowStage) { + hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO); + hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onWindowStageCreate'); + windowStage.loadContent('testability/pages/Index', (err, data) => { + if (err.code) { + hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.ERROR); + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO); + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', + JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy() { + hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO); + hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onWindowStageDestroy'); + } + + onForeground() { + hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO); + hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onForeground'); + } + + onBackground() { + hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO); + hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onBackground'); + } +} \ No newline at end of file diff --git a/code/BasicFeature/ApplicationModels/CustomShare/ShareComponent/src/ohosTest/ets/testability/pages/Index.ets b/code/BasicFeature/ApplicationModels/CustomShare/ShareComponent/src/ohosTest/ets/testability/pages/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..392e701ad007dbeee15d2757c28bc0d9c79cc5d1 --- /dev/null +++ b/code/BasicFeature/ApplicationModels/CustomShare/ShareComponent/src/ohosTest/ets/testability/pages/Index.ets @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2023 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 hilog from '@ohos.hilog'; + +@Entry +@Component +struct Index { + aboutToAppear() { + hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO); + hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility index aboutToAppear'); + } + @State message: string = 'Hello World' + build() { + Row() { + Column() { + Text(this.message) + .fontSize(50) + .fontWeight(FontWeight.Bold) + Button() { + Text('next page') + .fontSize(20) + .fontWeight(FontWeight.Bold) + }.type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .backgroundColor('#0D9FFB') + .width('35%') + .height('5%') + .onClick(()=>{ + }) + } + .width('100%') + } + .height('100%') + } + } \ No newline at end of file diff --git a/code/BasicFeature/ApplicationModels/CustomShare/ShareComponent/src/ohosTest/ets/testrunner/OpenHarmonyTestRunner.ts b/code/BasicFeature/ApplicationModels/CustomShare/ShareComponent/src/ohosTest/ets/testrunner/OpenHarmonyTestRunner.ts new file mode 100644 index 0000000000000000000000000000000000000000..13f3712e7b1ee891bb5dee9917cface15fc4a547 --- /dev/null +++ b/code/BasicFeature/ApplicationModels/CustomShare/ShareComponent/src/ohosTest/ets/testrunner/OpenHarmonyTestRunner.ts @@ -0,0 +1,86 @@ +/* + * Copyright (c) 2023 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 hilog from '@ohos.hilog'; +import TestRunner from '@ohos.application.testRunner' +import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' + +var abilityDelegator = undefined +var abilityDelegatorArguments = undefined + +function translateParamsToString(parameters) { + const keySet = new Set([ + '-s class', '-s notClass', '-s suite', '-s it', + '-s level', '-s testType', '-s size', '-s timeout', + '-s dryRun' + ]) + let targetParams = ''; + for (const key in parameters) { + if (keySet.has(key)) { + targetParams = `${targetParams} ${key} ${parameters[key]}` + } + } + return targetParams.trim() +} + +async function onAbilityCreateCallback() { + hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO); + hilog.info(0x0000, 'testTag', '%{public}s', 'onAbilityCreateCallback'); +} + +async function addAbilityMonitorCallback(err: any) { + hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO); + hilog.info(0x0000, 'testTag', 'addAbilityMonitorCallback : %{public}s', JSON.stringify(err) ?? ''); +} + +export default class OpenHarmonyTestRunner implements TestRunner { + constructor() { + } + + onPrepare() { + hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO); + hilog.info(0x0000, 'testTag', '%{public}s', 'OpenHarmonyTestRunner OnPrepare '); + } + + async onRun() { + hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO); + hilog.info(0x0000, 'testTag', '%{public}s', 'OpenHarmonyTestRunner onRun run'); + abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() + abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + var testAbilityName = abilityDelegatorArguments.bundleName + '.TestAbility' + let lMonitor = { + abilityName: testAbilityName, + onAbilityCreate: onAbilityCreateCallback, + }; + abilityDelegator.addAbilityMonitor(lMonitor, addAbilityMonitorCallback) + var cmd = 'aa start -d 0 -a TestAbility' + ' -b ' + abilityDelegatorArguments.bundleName + cmd += ' '+translateParamsToString(abilityDelegatorArguments.parameters) + var debug = abilityDelegatorArguments.parameters['-D'] + if (debug == 'true') + { + cmd += ' -D' + } + hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO); + hilog.info(0x0000, 'testTag', 'cmd : %{public}s', cmd); + abilityDelegator.executeShellCommand(cmd, + (err: any, d: any) => { + hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO); + hilog.info(0x0000, 'testTag', 'executeShellCommand : err : %{public}s', JSON.stringify(err) ?? ''); + hilog.info(0x0000, 'testTag', 'executeShellCommand : data : %{public}s', d.stdResult ?? ''); + hilog.info(0x0000, 'testTag', 'executeShellCommand : data : %{public}s', d.exitCode ?? ''); + }) + hilog.info(0x0000, 'testTag', '%{public}s', 'OpenHarmonyTestRunner onRun end'); + } +} \ No newline at end of file diff --git a/code/BasicFeature/ApplicationModels/CustomShare/ShareComponent/src/ohosTest/module.json5 b/code/BasicFeature/ApplicationModels/CustomShare/ShareComponent/src/ohosTest/module.json5 new file mode 100644 index 0000000000000000000000000000000000000000..f5fed4700ea651c3e5ad1c6262dae4fa048fad1b --- /dev/null +++ b/code/BasicFeature/ApplicationModels/CustomShare/ShareComponent/src/ohosTest/module.json5 @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2023 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. + */ +{ + "module": { + "name": "entry_test", + "type": "feature", + "description": "$string:module_test_desc", + "mainElement": "TestAbility", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:test_pages", + "abilities": [ + { + "name": "TestAbility", + "srcEntrance": "./ets/testability/TestAbility.ets", + "description": "$string:TestAbility_desc", + "icon": "$media:icon", + "label": "$string:TestAbility_label", + "visible": true, + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:start_window_background", + "skills": [ + { + "actions": [ + "action.system.home" + ], + "entities": [ + "entity.system.home" + ] + } + ] + } + ] + } +} diff --git a/code/BasicFeature/ApplicationModels/CustomShare/ShareComponent/src/ohosTest/resources/base/element/color.json b/code/BasicFeature/ApplicationModels/CustomShare/ShareComponent/src/ohosTest/resources/base/element/color.json new file mode 100644 index 0000000000000000000000000000000000000000..3c712962da3c2751c2b9ddb53559afcbd2b54a02 --- /dev/null +++ b/code/BasicFeature/ApplicationModels/CustomShare/ShareComponent/src/ohosTest/resources/base/element/color.json @@ -0,0 +1,8 @@ +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + } + ] +} \ No newline at end of file diff --git a/code/BasicFeature/ApplicationModels/CustomShare/ShareComponent/src/ohosTest/resources/base/element/string.json b/code/BasicFeature/ApplicationModels/CustomShare/ShareComponent/src/ohosTest/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..65d8fa5a7cf54aa3943dcd0214f58d1771bc1f6c --- /dev/null +++ b/code/BasicFeature/ApplicationModels/CustomShare/ShareComponent/src/ohosTest/resources/base/element/string.json @@ -0,0 +1,16 @@ +{ + "string": [ + { + "name": "module_test_desc", + "value": "test ability description" + }, + { + "name": "TestAbility_desc", + "value": "the test ability" + }, + { + "name": "TestAbility_label", + "value": "test label" + } + ] +} \ No newline at end of file diff --git a/code/BasicFeature/ApplicationModels/CustomShare/ShareComponent/src/ohosTest/resources/base/media/icon.png b/code/BasicFeature/ApplicationModels/CustomShare/ShareComponent/src/ohosTest/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/code/BasicFeature/ApplicationModels/CustomShare/ShareComponent/src/ohosTest/resources/base/media/icon.png differ diff --git a/code/BasicFeature/ApplicationModels/CustomShare/ShareComponent/src/ohosTest/resources/base/profile/test_pages.json b/code/BasicFeature/ApplicationModels/CustomShare/ShareComponent/src/ohosTest/resources/base/profile/test_pages.json new file mode 100644 index 0000000000000000000000000000000000000000..b7e7343cacb32ce982a45e76daad86e435e054fe --- /dev/null +++ b/code/BasicFeature/ApplicationModels/CustomShare/ShareComponent/src/ohosTest/resources/base/profile/test_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "testability/pages/Index" + ] +} diff --git a/code/BasicFeature/ApplicationModels/CustomShare/entry/package.json b/code/BasicFeature/ApplicationModels/CustomShare/entry/package.json index d6ee6a55dffd192fe903c87cfbced1e439c5c845..b014a62ef71d3f0a36deb3328e83f4e59ffb7616 100644 --- a/code/BasicFeature/ApplicationModels/CustomShare/entry/package.json +++ b/code/BasicFeature/ApplicationModels/CustomShare/entry/package.json @@ -1,16 +1,16 @@ { - "license": "ISC", - "devDependencies": {}, - "name": "entry", - "ohos": { - "org": "huawei", - "directoryLevel": "module", - "buildTool": "hvigor" - }, - "description": "example description", - "repository": {}, - "version": "1.0.0", - "dependencies": { - "@ohos/sharecomponent": "file:../ShareComponent" - } -} + "license": "ISC", + "devDependencies": {}, + "name": "entry", + "ohos": { + "org": "huawei", + "directoryLevel": "module", + "buildTool": "hvigor" + }, + "description": "example description", + "repository": {}, + "version": "1.0.0", + "dependencies": { + "@ohos/sharecomponent": "file:../ShareComponent" + } +} \ No newline at end of file diff --git a/code/BasicFeature/ApplicationModels/CustomShare/entry/src/main/ets/Application/MyAbilityStage.ts b/code/BasicFeature/ApplicationModels/CustomShare/entry/src/main/ets/Application/MyAbilityStage.ts index d27b21f94187074644d8d22c400b7f228dba1172..c987c4acab4df5865f642923d59442d6576c7229 100644 --- a/code/BasicFeature/ApplicationModels/CustomShare/entry/src/main/ets/Application/MyAbilityStage.ts +++ b/code/BasicFeature/ApplicationModels/CustomShare/entry/src/main/ets/Application/MyAbilityStage.ts @@ -13,7 +13,7 @@ * limitations under the License. */ -import AbilityStage from '@ohos.application.AbilityStage' +import AbilityStage from '@ohos.app.ability.AbilityStage' import Logger from '../model/Logger' const TAG:string = 'MyAbilityStage' diff --git a/code/BasicFeature/ApplicationModels/CustomShare/entry/src/main/ets/MainAbility/MainAbility.ts b/code/BasicFeature/ApplicationModels/CustomShare/entry/src/main/ets/MainAbility/MainAbility.ts index 340cc4d875b224ddca5b5c92128a91cfbebeeedf..9971deb92df14a59fb705ed579fc1e2271e28e70 100644 --- a/code/BasicFeature/ApplicationModels/CustomShare/entry/src/main/ets/MainAbility/MainAbility.ts +++ b/code/BasicFeature/ApplicationModels/CustomShare/entry/src/main/ets/MainAbility/MainAbility.ts @@ -13,26 +13,25 @@ * limitations under the License. */ -import Ability from '@ohos.application.Ability' +import UIAbility from '@ohos.app.ability.UIAbility' +import abilityAccessCtrl from '@ohos.abilityAccessCtrl' import Logger from '../model/Logger' -const PERMISSIONS: Array = [ - 'ohos.permission.CAPTURE_SCREEN', - 'ohos.permission.READ_MEDIA', - 'ohos.permission.WRITE_MEDIA', - 'ohos.permission.MEDIA_LOCATION', - 'ohos.permission.INTERNET' -] - const TAG: string = 'MainAbility' -export default class MainAbility extends Ability { +export default class MainAbility extends UIAbility { onCreate(want, launchParam) { Logger.info(TAG, `MainAbility onCreate`) - AppStorage.SetOrCreate('context', this.context) - this.context.requestPermissionsFromUser(PERMISSIONS, (err, data) => { - Logger.info(TAG, `request data: ${JSON.stringify(data)}, request error code: ${JSON.stringify(err.code)}`) - }) + let atManager = abilityAccessCtrl.createAtManager() + try { + atManager.requestPermissionsFromUser(this.context,['ohos.permission.CAPTURE_SCREEN','ohos.permission.READ_MEDIA','ohos.permission.WRITE_MEDIA','ohos.permission.MEDIA_LOCATION','ohos.permission.INTERNET']).then((data) => { + Logger.info(TAG, `data: ${JSON.stringify(data)}`) + }).catch((err) => { + Logger.info(TAG, `err: ${JSON.stringify(err)}`) + }) + } catch (err) { + Logger.info(TAG, `catch err->${JSON.stringify(err)}`); + } const that = this this.context.eventHub.on("getAbilityData", (data) => { data.context = that.context diff --git a/code/BasicFeature/ApplicationModels/CustomShare/entry/src/ohosTest/ets/Application/TestAbilityStage.ts b/code/BasicFeature/ApplicationModels/CustomShare/entry/src/ohosTest/ets/Application/TestAbilityStage.ts index d64f4db5883398167fd39c3d80589c953c2a25aa..779cb2ee744b497012197efbf31c99a34b044e4a 100644 --- a/code/BasicFeature/ApplicationModels/CustomShare/entry/src/ohosTest/ets/Application/TestAbilityStage.ts +++ b/code/BasicFeature/ApplicationModels/CustomShare/entry/src/ohosTest/ets/Application/TestAbilityStage.ts @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 Huawei Device Co., Ltd. + * Copyright (c) 2022-2023 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 @@ -12,7 +12,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import AbilityStage from '@ohos.application.AbilityStage' +import AbilityStage from '@ohos.app.ability.AbilityStage' import Logger from '../../../main/ets/model/Logger' const TAG: string = 'TestAbilityStage' diff --git a/code/BasicFeature/ApplicationModels/CustomShare/package.json b/code/BasicFeature/ApplicationModels/CustomShare/package.json index 94aea36c1874eac7d483ee91c0e7249207591331..3a0ebd99160432c81ef66397a5aadc21a4812aa7 100644 --- a/code/BasicFeature/ApplicationModels/CustomShare/package.json +++ b/code/BasicFeature/ApplicationModels/CustomShare/package.json @@ -1,18 +1,18 @@ { - "license":"ISC", - "devDependencies":{}, - "name":"share", - "ohos":{ - "org":"huawei", - "directoryLevel":"project", - "buildTool":"hvigor" - }, - "description":"example description", - "repository":{}, - "version":"1.0.0", - "dependencies":{ - "@ohos/hypium":"1.0.1", - "@ohos/hvigor-ohos-plugin":"1.1.6", - "@ohos/hvigor":"1.1.6" - } + "license": "ISC", + "devDependencies": {}, + "name": "share", + "ohos": { + "org": "huawei", + "directoryLevel": "project", + "buildTool": "hvigor" + }, + "description": "example description", + "repository": {}, + "version": "1.0.0", + "dependencies": { + "@ohos/hypium": "1.0.3", + "@ohos/hvigor-ohos-plugin": "1.3.1", + "@ohos/hvigor": "1.3.1" + } } \ No newline at end of file diff --git a/code/BasicFeature/ApplicationModels/FaModel/README_zh.md b/code/BasicFeature/ApplicationModels/FaModel/README_zh.md index 5c9bc26d79bcaad497997874f18eafb9afe7d158..4199b1e61fb115dc0c2054fd37a4121e83c9c379 100644 --- a/code/BasicFeature/ApplicationModels/FaModel/README_zh.md +++ b/code/BasicFeature/ApplicationModels/FaModel/README_zh.md @@ -151,7 +151,7 @@ FaModel升级StageModel,对应的StageModel参考[StageModel](../StageModel) 1.本示例仅支持在标准系统上运行,支持设备:RK3568。 -2.本示例仅支持API9版本SDK,版本号:3.2.5.5。 +2.本示例仅支持API9版本SDK,版本号:3.2.10.6 及以上。 -3.本示例需要使用DevEco Studio 3.0 Beta4 (Build Version: 3.0.0.992, built on July 14, 2022)才可编译运行。 +3.本示例需要使用DevEco Studio 3.1 Canary1 (Build Version: 3.1.0.100)及以上才可编译运行。 diff --git a/code/BasicFeature/ApplicationModels/FaModel/entry/package.json b/code/BasicFeature/ApplicationModels/FaModel/entry/package.json index 29732ffea047ab4e9d897d4cc7092f5e7fe3493f..db08bbf9d7439623fcfa4093ab7f013633c62d48 100644 --- a/code/BasicFeature/ApplicationModels/FaModel/entry/package.json +++ b/code/BasicFeature/ApplicationModels/FaModel/entry/package.json @@ -11,4 +11,4 @@ "repository": {}, "version": "1.0.0", "dependencies": {} -} +} \ No newline at end of file diff --git a/code/BasicFeature/ApplicationModels/FaModel/package.json b/code/BasicFeature/ApplicationModels/FaModel/package.json index 75f0f27744152d9dc3c500651183271e7c46ef2d..82e193a12c1024cd9677b4400362335d786a62c1 100644 --- a/code/BasicFeature/ApplicationModels/FaModel/package.json +++ b/code/BasicFeature/ApplicationModels/FaModel/package.json @@ -11,8 +11,8 @@ "repository": {}, "version": "1.0.0", "dependencies": { - "@ohos/hypium": "1.0.1", - "@ohos/hvigor-ohos-plugin": "1.1.6", - "@ohos/hvigor": "1.1.6" + "@ohos/hypium": "1.0.3", + "@ohos/hvigor-ohos-plugin": "1.3.1", + "@ohos/hvigor": "1.3.1" } } \ No newline at end of file diff --git a/code/BasicFeature/ApplicationModels/StageModel/README.md b/code/BasicFeature/ApplicationModels/StageModel/README.md index 4bedbd3dfcece1ffc5686cc6ddf74d871d9960c6..97b5463b1985cecd8256aa579e9f4d3e374c15d6 100644 --- a/code/BasicFeature/ApplicationModels/StageModel/README.md +++ b/code/BasicFeature/ApplicationModels/StageModel/README.md @@ -171,4 +171,4 @@ The stage model is upgraded from the FA model. For details about the FA model, s 2. **ServiceExtensionAbility** and **DataShareExtensionAbility** are system APIs and require the use of the Full SDK. To use the Full SDK, you must manually obtain it from the mirror and switch to it in DevEco Studio. For details, see [Guide to Switching to Full SDK](https://gitee.com/openharmony/docs/blob/master/en/application-dev/quick-start/full-sdk-switch-guide.md). -3. DevEco Studio 3.0 Beta4 (Build version: 3.0.0.992, built on July 14, 2022) must be used. +3. DevEco Studio 3.1 Canary1 (Build Version: 3.1.0.100) must be used. diff --git a/code/BasicFeature/ApplicationModels/StageModel/README_zh.md b/code/BasicFeature/ApplicationModels/StageModel/README_zh.md index c04529390e85d129054da0d931f52cf4d39a5bce..1191fd64c154fa0efc28a677abb659c9703ac38d 100644 --- a/code/BasicFeature/ApplicationModels/StageModel/README_zh.md +++ b/code/BasicFeature/ApplicationModels/StageModel/README_zh.md @@ -173,4 +173,4 @@ FaModel升级StageModel,对应的FaModel参考[FaModel](../FaModel)。 3.本示例使用了 ServiceExtensionAbility、DataShareExtensionAbility,需要在签名证书UnsgnedReleasedProfileTemplate.json中配置"app-privilege-capabilities": ["AllowAppUsePrivilegeExtension"],否则安装失败。具体操作指南可参考[应用特权配置指南](https://gitee.com/openharmony/docs/blob/eb73c9e9dcdd421131f33bb8ed6ddc030881d06f/zh-cn/device-dev/subsystems/subsys-app-privilege-config-guide.md)。 -4.本示例需要使用DevEco Studio 3.0 Beta4 (Build Version: 3.0.0.992, built on July 14, 2022)版本进行编译。 \ No newline at end of file +4.本示例需要使用DevEco Studio 3.1 Canary1 (Build Version: 3.1.0.100)及以上版本进行编译。 \ No newline at end of file diff --git a/code/BasicFeature/ApplicationModels/StageModel/entry/package.json b/code/BasicFeature/ApplicationModels/StageModel/entry/package.json index c7685ac4e7c0d79df04c96744f0d8f22cb4a9025..db08bbf9d7439623fcfa4093ab7f013633c62d48 100644 --- a/code/BasicFeature/ApplicationModels/StageModel/entry/package.json +++ b/code/BasicFeature/ApplicationModels/StageModel/entry/package.json @@ -1,14 +1,14 @@ { - "license": "ISC", - "devDependencies": {}, - "name": "entry", - "ohos": { - "org": "huawei", - "directoryLevel": "module", - "buildTool": "hvigor" - }, - "description": "example description", - "repository": {}, - "version": "1.0.0", - "dependencies": {} -} + "license": "ISC", + "devDependencies": {}, + "name": "entry", + "ohos": { + "org": "huawei", + "directoryLevel": "module", + "buildTool": "hvigor" + }, + "description": "example description", + "repository": {}, + "version": "1.0.0", + "dependencies": {} +} \ No newline at end of file diff --git a/code/BasicFeature/ApplicationModels/StageModel/entry/src/main/ets/Application/MyAbilityStage.ts b/code/BasicFeature/ApplicationModels/StageModel/entry/src/main/ets/Application/MyAbilityStage.ts index 97448d85a84bbbb16b39e43705d77d7e33753207..9aedf7b2658d274d8829c261c6c03d4c69905f70 100644 --- a/code/BasicFeature/ApplicationModels/StageModel/entry/src/main/ets/Application/MyAbilityStage.ts +++ b/code/BasicFeature/ApplicationModels/StageModel/entry/src/main/ets/Application/MyAbilityStage.ts @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 Huawei Device Co., Ltd. + * Copyright (c) 2022-2023 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 @@ -13,7 +13,7 @@ * limitations under the License. */ -import AbilityStage from '@ohos.application.AbilityStage' +import AbilityStage from '@ohos.app.ability.AbilityStage' import Logger from '../util/Logger' const TAG: string = 'MyAbilityStage' diff --git a/code/BasicFeature/ApplicationModels/StageModel/entry/src/main/ets/FormAbility/FormAbility.ts b/code/BasicFeature/ApplicationModels/StageModel/entry/src/main/ets/FormAbility/FormAbility.ts index 7ad4e13e6844109fc7c6ab5c1a58f15b98c84246..3acdb3ca1508c865db503c6027ac0056695befcc 100644 --- a/code/BasicFeature/ApplicationModels/StageModel/entry/src/main/ets/FormAbility/FormAbility.ts +++ b/code/BasicFeature/ApplicationModels/StageModel/entry/src/main/ets/FormAbility/FormAbility.ts @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 Huawei Device Co., Ltd. + * Copyright (c) 2022-2023 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 @@ -13,9 +13,9 @@ * limitations under the License. */ -import FormExtension from '@ohos.application.FormExtension' -import formBindingData from '@ohos.application.formBindingData' -import formInfo from '@ohos.application.formInfo' +import FormExtension from '@ohos.app.form.FormExtensionAbility' +import formBindingData from '@ohos.app.form.formBindingData' +import formInfo from '@ohos.app.form.formInfo' export default class FormAbility extends FormExtension { onCreate(want) { diff --git a/code/BasicFeature/ApplicationModels/StageModel/entry/src/main/ets/MainAbility/MainAbility.ts b/code/BasicFeature/ApplicationModels/StageModel/entry/src/main/ets/MainAbility/MainAbility.ts index 3c3a56fdfce85a353e4d30e0c182cf55547c7ab4..b8fc96fc321719ed378ee309f29bffcd35865298 100644 --- a/code/BasicFeature/ApplicationModels/StageModel/entry/src/main/ets/MainAbility/MainAbility.ts +++ b/code/BasicFeature/ApplicationModels/StageModel/entry/src/main/ets/MainAbility/MainAbility.ts @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 Huawei Device Co., Ltd. + * Copyright (c) 2022-2023 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 @@ -13,12 +13,12 @@ * limitations under the License. */ -import Ability from '@ohos.application.Ability' +import UIAbility from '@ohos.app.ability.UIAbility' import Logger from '../util/Logger' const TAG = 'MainAbility' -export default class MainAbility extends Ability { +export default class MainAbility extends UIAbility { onCreate(want, launchParam) { Logger.info(TAG, `MainAbility onCreate`) } diff --git a/code/BasicFeature/ApplicationModels/StageModel/entry/src/main/ets/ServiceExtAbility/ServiceExtAbility.ts b/code/BasicFeature/ApplicationModels/StageModel/entry/src/main/ets/ServiceExtAbility/ServiceExtAbility.ts index bca601ebca9987f8ede7ae8f81c7366679922ac7..b44f321b02a1aec5c313764f6ad6c44b11b2c40e 100644 --- a/code/BasicFeature/ApplicationModels/StageModel/entry/src/main/ets/ServiceExtAbility/ServiceExtAbility.ts +++ b/code/BasicFeature/ApplicationModels/StageModel/entry/src/main/ets/ServiceExtAbility/ServiceExtAbility.ts @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 Huawei Device Co., Ltd. + * Copyright (c) 2022-2023 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 @@ -13,8 +13,8 @@ * limitations under the License. */ -import Extension from '@ohos.application.ServiceExtensionAbility' -import Notification from '@ohos.notification' +import Extension from '@ohos.app.ability.ServiceExtensionAbility' +import Notification from '@ohos.notificationManager' import rpc from '@ohos.rpc' import Logger from '../util/Logger' diff --git a/code/BasicFeature/ApplicationModels/StageModel/entry/src/main/ets/TestAbility/TestAbility.ts b/code/BasicFeature/ApplicationModels/StageModel/entry/src/main/ets/TestAbility/TestAbility.ts index 5ee33109f1a3e9a6a23c81526a82949f5dfe4a24..082c2f401d2afe4a604530f636c57276b95e3d8f 100644 --- a/code/BasicFeature/ApplicationModels/StageModel/entry/src/main/ets/TestAbility/TestAbility.ts +++ b/code/BasicFeature/ApplicationModels/StageModel/entry/src/main/ets/TestAbility/TestAbility.ts @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 Huawei Device Co., Ltd. + * Copyright (c) 2022-2023 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 @@ -13,9 +13,9 @@ * limitations under the License. */ -import Ability from '@ohos.application.Ability' +import UIAbility from '@ohos.app.ability.UIAbility' import commonEvent from '@ohos.commonEvent' -import notification from '@ohos.notification' +import notification from '@ohos.notificationManager' import Logger from '../util/Logger' const TAG: string = '[SecondAbility]' @@ -32,7 +32,7 @@ let request = { content: windowCreateContent } -export default class TestAbility extends Ability { +export default class TestAbility extends UIAbility { onCreate(want, launchParam) { Logger.info(TAG, `onCreate, want is: ${JSON.stringify(want)}`) } diff --git a/code/BasicFeature/ApplicationModels/StageModel/entry/src/main/ets/feature/BundleController.ts b/code/BasicFeature/ApplicationModels/StageModel/entry/src/main/ets/feature/BundleController.ts index 981235d1df0fad4de172c478bb3bfec44ee0147f..4725ed9f6d7221532b56b37ee5d7251fd1753e3a 100644 --- a/code/BasicFeature/ApplicationModels/StageModel/entry/src/main/ets/feature/BundleController.ts +++ b/code/BasicFeature/ApplicationModels/StageModel/entry/src/main/ets/feature/BundleController.ts @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 Huawei Device Co., Ltd. + * Copyright (c) 2022-2023 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 @@ -74,7 +74,7 @@ export default class BundleController { // 获取应用程序的本地根目录,对应FA模型的getOrCreateLocalDir() entryDir() { bundle.getApplicationInfo('ohos.samples.stagemodel', 0, (error, data) => { - let entryDirData = data.entryDir + let entryDirData = data.codePath if (entryDirData === null || error.code != 0) { Logger.info(TAG, `codePath error: ${error}`) return diff --git a/code/BasicFeature/ApplicationModels/StageModel/package.json b/code/BasicFeature/ApplicationModels/StageModel/package.json index 67f552d0ab49e7c36805b5074a415518573a4cba..b53283d2c86316e366410269b7d0ca97b5e0d079 100644 --- a/code/BasicFeature/ApplicationModels/StageModel/package.json +++ b/code/BasicFeature/ApplicationModels/StageModel/package.json @@ -11,8 +11,8 @@ "repository": {}, "version": "1.0.0", "dependencies": { - "@ohos/hypium": "1.0.1", - "@ohos/hvigor-ohos-plugin": "1.1.6", - "@ohos/hvigor": "1.1.6" + "@ohos/hypium": "1.0.3", + "@ohos/hvigor-ohos-plugin": "1.3.1", + "@ohos/hvigor": "1.3.1" } -} +} \ No newline at end of file diff --git a/code/BasicFeature/Connectivity/Http/.gitignore b/code/BasicFeature/Connectivity/Http/.gitignore index 91d237bb144c7fb1777e50271857ef0f593286fc..f66a48f7ecf449cdd529bb12c3277097c4a7790e 100644 --- a/code/BasicFeature/Connectivity/Http/.gitignore +++ b/code/BasicFeature/Connectivity/Http/.gitignore @@ -2,4 +2,6 @@ /local.properties /.idea **/build -/.hvigor \ No newline at end of file +/.hvigor +**/package-lock.json +**/node_modules \ No newline at end of file diff --git a/code/BasicFeature/Connectivity/Http/README.md b/code/BasicFeature/Connectivity/Http/README.md index b980a8d8f6304f4e2b7606886f4a0ab272d88a35..d4db60d9ab7a7864210418561f78b035f8279ec0 100644 --- a/code/BasicFeature/Connectivity/Http/README.md +++ b/code/BasicFeature/Connectivity/Http/README.md @@ -32,8 +32,8 @@ N/A 1. This sample can only be run on standard-system devices that use the Rockchip RK3568 chip. -2. This sample demonstrates the stage model, which supports only the SDK of API version 9 (SDK version: 3.2.5.5 Beta2). +2. This sample demonstrates the stage model, which supports only the SDK of API version 9 (SDK version: 3.2.10.6). -3. DevEco Studio 3.0 Beta4 (Build version: 3.0.0.992, built on July 14, 2022) must be used. +3. DevEco Studio 3.1 Canary1 (Build Version: 3.1.0.100) must be used. 4. This sample requires network connection throughout the entire process. diff --git a/code/BasicFeature/Connectivity/Http/README_zh.md b/code/BasicFeature/Connectivity/Http/README_zh.md index 249b62ded7905d5c5311fe62598e1635e75bace4..1ef1aeaace83a0b1b80dd0e3304f09c9dc8f4576 100644 --- a/code/BasicFeature/Connectivity/Http/README_zh.md +++ b/code/BasicFeature/Connectivity/Http/README_zh.md @@ -32,8 +32,8 @@ 1.本示例仅支持标准系统上运行,支持设备:RK3568。 -2.本示例仅支持API9版本SDK,版本号:3.2.5.5 Beta2。 +2.本示例仅支持API9版本SDK,版本号:3.2.10.6 及以上。 -3.本示例需要使用DevEco Studio 3.0 Beta4 (Build Version: 3.0.0.992, built on July 14, 2022)才可编译运行。 +3.本示例需要使用DevEco Studio 3.1 Canary1 (Build Version: 3.1.0.100)及以上才可编译运行。 4.运行本示例需全程联网。 \ No newline at end of file diff --git a/code/BasicFeature/Connectivity/Http/entry/src/main/ets/Application/MyAbilityStage.ts b/code/BasicFeature/Connectivity/Http/entry/src/main/ets/Application/MyAbilityStage.ts index 248dfbe5af526094973cdc791e3c59228322b2d6..16603a0e76bf618db7d98db33b25a9372257d276 100644 --- a/code/BasicFeature/Connectivity/Http/entry/src/main/ets/Application/MyAbilityStage.ts +++ b/code/BasicFeature/Connectivity/Http/entry/src/main/ets/Application/MyAbilityStage.ts @@ -13,7 +13,7 @@ * limitations under the License. */ -import AbilityStage from "@ohos.application.AbilityStage" +import AbilityStage from '@ohos.app.ability.AbilityStage' import Logger from '../util/Logger' const TAG: string = 'MyAbilityStage' diff --git a/code/BasicFeature/Connectivity/Http/entry/src/main/ets/MainAbility/MainAbility.ts b/code/BasicFeature/Connectivity/Http/entry/src/main/ets/MainAbility/MainAbility.ts index a7564c3fa28aaa0becee213ffd3c6a6cbec246c6..b3f98a6eeaaf1a07ff7f6f25ab6a9b678738275f 100644 --- a/code/BasicFeature/Connectivity/Http/entry/src/main/ets/MainAbility/MainAbility.ts +++ b/code/BasicFeature/Connectivity/Http/entry/src/main/ets/MainAbility/MainAbility.ts @@ -13,15 +13,25 @@ * limitations under the License. */ -import Ability from '@ohos.application.Ability' +import UIAbility from '@ohos.app.ability.UIAbility' +import abilityAccessCtrl from '@ohos.abilityAccessCtrl' import Logger from '../util/Logger' const TAG: string = 'MainAbility' -export default class MainAbility extends Ability { +export default class MainAbility extends UIAbility { async onCreate(want, launchParam) { Logger.info(TAG, '[Demo] MainAbility onCreate') - await this.context.requestPermissionsFromUser(['ohos.permission.INTERNET']) + let atManager = abilityAccessCtrl.createAtManager() + try { + atManager.requestPermissionsFromUser(this.context, ['ohos.permission.INTERNET']).then((data) => { + Logger.info(TAG,`data:${JSON.stringify(data)}`) + }).catch((err) => { + Logger.info(TAG,`err:${JSON.stringify(err)}`) + }) + } catch(err) { + Logger.info(TAG,`catch err->${JSON.stringify(err)}`) + } const that = this this.context.eventHub.on('getAbilityData', (data) => { data.context = that.context diff --git a/code/BasicFeature/DeviceManagement/Location/position/hvigorfile.js b/code/BasicFeature/Connectivity/Http/http/hvigorfile.ts similarity index 100% rename from code/BasicFeature/DeviceManagement/Location/position/hvigorfile.js rename to code/BasicFeature/Connectivity/Http/http/hvigorfile.ts diff --git a/code/BasicFeature/Connectivity/Http/http/package.json b/code/BasicFeature/Connectivity/Http/http/package.json index bd4043a66529c420da9da97dc424525a906b0f71..40e996de98f1ef607448d45591b8ddbb1d6c86fd 100644 --- a/code/BasicFeature/Connectivity/Http/http/package.json +++ b/code/BasicFeature/Connectivity/Http/http/package.json @@ -9,6 +9,7 @@ }, "main": "src/main/ets/components/MainPage/MainPage.ets", "repository": {}, + "type": "module", "version": "1.0.0", "dependencies": {} } \ No newline at end of file diff --git a/code/BasicFeature/Connectivity/Http/package.json b/code/BasicFeature/Connectivity/Http/package.json index 548133002820dde807d7ee976bbb48d0feb2a16e..0742184cc6bcf292a0147b9ade5f50b0715e7a51 100644 --- a/code/BasicFeature/Connectivity/Http/package.json +++ b/code/BasicFeature/Connectivity/Http/package.json @@ -11,9 +11,9 @@ "repository": {}, "version": "1.0.0", "dependencies": { - "@ohos/hvigor": "1.1.6", - "@ohos/hvigor-ohos-plugin": "1.1.6", - "@ohos/hypium": "1.0.1", - "hypium": "^1.0.0" + "@ohos/hypium": "1.0.3", + "@ohos/hvigor-ohos-plugin": "1.3.1", + "hypium": "^1.0.0", + "@ohos/hvigor": "1.3.1" } } \ No newline at end of file diff --git a/code/BasicFeature/Connectivity/RPC/README_zh.md b/code/BasicFeature/Connectivity/RPC/README_zh.md index 4af87026f9e71a5424e58822298c0fc76da8130a..f09b764cb321a70fe294cecb6d6358c9eb4e81d5 100644 --- a/code/BasicFeature/Connectivity/RPC/README_zh.md +++ b/code/BasicFeature/Connectivity/RPC/README_zh.md @@ -32,4 +32,4 @@ 2.本示例需要使用DevEco Studio 3.1 Canary1 (Build Version: 3.1.0.100, built on November 3, 2022)才可编译运行。 -3.本示例仅支持API9版本SDK,版本号:3.2.9.2。 \ No newline at end of file +3.本示例仅支持API9版本SDK,版本号:3.2.10.6。 \ No newline at end of file diff --git a/code/BasicFeature/Connectivity/RPC/build-profile.json5 b/code/BasicFeature/Connectivity/RPC/build-profile.json5 index 2c047fe025bd2cb0fe372dea3dc1e46fb20baa10..53f11cb1896746f4fe85a5386d12c7f0fbb8165d 100644 --- a/code/BasicFeature/Connectivity/RPC/build-profile.json5 +++ b/code/BasicFeature/Connectivity/RPC/build-profile.json5 @@ -22,9 +22,8 @@ "name": "default", "signingConfig": "default" } - ] - }, ], + "signingConfigs": [] }, "modules": [ { diff --git a/code/BasicFeature/Connectivity/RPC/entry/src/main/ets/entryability/EntryAbility.ets b/code/BasicFeature/Connectivity/RPC/entry/src/main/ets/entryability/EntryAbility.ets index e1477e49fc39654a5692a3ddf9d3e4d1237184bf..0fa7a688a87367e58519dbb14555e1b98a2d6d6e 100644 --- a/code/BasicFeature/Connectivity/RPC/entry/src/main/ets/entryability/EntryAbility.ets +++ b/code/BasicFeature/Connectivity/RPC/entry/src/main/ets/entryability/EntryAbility.ets @@ -13,11 +13,11 @@ * limitations under the License. */ -import Ability from '@ohos.application.Ability' +import UIAbility from '@ohos.app.ability.UIAbility' import Window from '@ohos.window' import { Logger } from '../common/Logger' -export default class EntryAbility extends Ability { +export default class EntryAbility extends UIAbility { onCreate(want, launchParam) { Logger.info('Ability onCreate') } diff --git a/code/BasicFeature/DFX/Debug/.gitignore b/code/BasicFeature/DFX/Debug/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..b6986dc03c7b3549275e2745e98fdfab2741cca5 --- /dev/null +++ b/code/BasicFeature/DFX/Debug/.gitignore @@ -0,0 +1,10 @@ +/node_modules +/local.properties +/.idea +**/build +/.hvigor +.cxx +/.clangd +/.clang-format +/.clang-tidy +**/package-lock.json \ No newline at end of file diff --git a/code/BasicFeature/DFX/Debug/README.md b/code/BasicFeature/DFX/Debug/README.md index a638c83a475c451b57be20b7f97a8f293f6363cb..7dc254875d3b7b0860e94910b83a9c473ea32315 100644 --- a/code/BasicFeature/DFX/Debug/README.md +++ b/code/BasicFeature/DFX/Debug/README.md @@ -30,4 +30,4 @@ N/A 2. This sample is based on the stage model, which is supported from API version 9. -3. DevEco Studio 3.0 Beta4 (Build version: 3.0.0.992, built on July 14, 2022) must be used. +3. DevEco Studio 3.1 Canary1 (Build Version: 3.1.0.100) must be used. diff --git a/code/BasicFeature/DFX/Debug/README_zh.md b/code/BasicFeature/DFX/Debug/README_zh.md index 7d44e998539f3d8e2799234ee2344fa880f1b2b2..f206b639c38f9d19055b251b261d298f60d42ed9 100644 --- a/code/BasicFeature/DFX/Debug/README_zh.md +++ b/code/BasicFeature/DFX/Debug/README_zh.md @@ -31,4 +31,4 @@ Stack:堆叠容器,子组件按照顺序依次入栈,后一个子组件覆 2.本示例仅支持API9版本SDK,版本号:3.2.9.2。 -3.本示例需要使用DevEco Studio 3.1 Canary1 (Build Version: 3.1.0.100, built on November 3, 2022)才可编译运行。 \ No newline at end of file +3.本示例需要使用DevEco Studio 3.1 Canary1 (Build Version: 3.1.0.100)及以上才可编译运行。 \ No newline at end of file diff --git a/code/BasicFeature/DFX/Debug/entry/src/main/ets/Application/MyAbilityStage.ts b/code/BasicFeature/DFX/Debug/entry/src/main/ets/Application/MyAbilityStage.ts index 7ad5863c34da92d63b6a0cf6e7a5ce1f1d9487ce..52af3317e96e15084e23dd906831a874aafa5201 100644 --- a/code/BasicFeature/DFX/Debug/entry/src/main/ets/Application/MyAbilityStage.ts +++ b/code/BasicFeature/DFX/Debug/entry/src/main/ets/Application/MyAbilityStage.ts @@ -13,7 +13,7 @@ * limitations under the License. */ -import AbilityStage from '@ohos.application.AbilityStage' +import AbilityStage from '@ohos.app.ability.AbilityStage' import Logger from '../data/Logger' const TAG: string = 'AbilityStage' diff --git a/code/BasicFeature/DFX/Debug/entry/src/main/ets/MainAbility/MainAbility.ts b/code/BasicFeature/DFX/Debug/entry/src/main/ets/MainAbility/MainAbility.ts index 6a25777f7267b2f3a06c430cbc86b28ad4096d1b..588080b66a81cdcfc5adb8bedf74836e26bd0bcf 100644 --- a/code/BasicFeature/DFX/Debug/entry/src/main/ets/MainAbility/MainAbility.ts +++ b/code/BasicFeature/DFX/Debug/entry/src/main/ets/MainAbility/MainAbility.ts @@ -13,12 +13,12 @@ * limitations under the License. */ -import Ability from '@ohos.application.Ability' +import UIAbility from '@ohos.app.ability.UIAbility' import Logger from '../data/Logger' const TAG: string = 'MainAbility' -export default class MainAbility extends Ability { +export default class MainAbility extends UIAbility { onCreate(want, launchParam) { Logger.info(TAG, '[Demo] MainAbility onCreate') } diff --git a/code/BasicFeature/DFX/Debug/package.json b/code/BasicFeature/DFX/Debug/package.json index 785677eb8b09d9a8d56db76a1d28c924a20e7640..cb7f29aef9c24b6eb102f2bca5aaca83f81b54d0 100644 --- a/code/BasicFeature/DFX/Debug/package.json +++ b/code/BasicFeature/DFX/Debug/package.json @@ -11,8 +11,8 @@ "repository": {}, "version": "1.0.0", "dependencies": { - "@ohos/hypium": "1.0.1", - "@ohos/hvigor-ohos-plugin": "1.1.6", - "@ohos/hvigor": "1.1.6" + "@ohos/hypium": "1.0.3", + "@ohos/hvigor-ohos-plugin": "1.3.1", + "@ohos/hvigor": "1.3.1" } } \ No newline at end of file diff --git a/code/BasicFeature/DFX/DotTest/.gitignore b/code/BasicFeature/DFX/DotTest/.gitignore index dc4e6353bf3caf74c5953d0bec81c72a3635bf33..b6986dc03c7b3549275e2745e98fdfab2741cca5 100644 --- a/code/BasicFeature/DFX/DotTest/.gitignore +++ b/code/BasicFeature/DFX/DotTest/.gitignore @@ -6,4 +6,5 @@ .cxx /.clangd /.clang-format -/.clang-tidy \ No newline at end of file +/.clang-tidy +**/package-lock.json \ No newline at end of file diff --git a/code/BasicFeature/DFX/DotTest/README_zh.md b/code/BasicFeature/DFX/DotTest/README_zh.md index 38797db36a7d37ab7d503eeb449a7bf98665cb59..e786709004ca12ac332fc2711b52b9b7a380da01 100644 --- a/code/BasicFeature/DFX/DotTest/README_zh.md +++ b/code/BasicFeature/DFX/DotTest/README_zh.md @@ -28,6 +28,6 @@ 2.性能打点验证只能通过上述命令获取日志来进行验证。 -3.本示例仅支持API version 9版本SDK,版本号:3.2.9.2。 +3.本示例仅支持API version 9版本SDK,版本号:3.2.10.6。 -4.本示例需要使用DevEco Studio 3.1 Canary1 (Build Version: 3.1.0.100, built on November 3, 2022)才可编译运行。 \ No newline at end of file +4.本示例需要使用DevEco Studio 3.1 Canary1 (Build Version: 3.1.0.100)及以上才可编译运行。 \ No newline at end of file diff --git a/code/BasicFeature/DFX/DotTest/entry/src/main/ets/entryability/EntryAbility.ts b/code/BasicFeature/DFX/DotTest/entry/src/main/ets/entryability/EntryAbility.ts index e66b690ff58253c9580c9f0f9ef243ec3d579112..704664b1d3291941b34eaa115863ae8bb2e66443 100644 --- a/code/BasicFeature/DFX/DotTest/entry/src/main/ets/entryability/EntryAbility.ts +++ b/code/BasicFeature/DFX/DotTest/entry/src/main/ets/entryability/EntryAbility.ts @@ -13,13 +13,13 @@ * limitations under the License. */ -import Ability from '@ohos.application.Ability' +import UIAbility from '@ohos.app.ability.UIAbility' import Window from '@ohos.window' import Logger from '../model/Logger' const TAG = 'EntryAbility' -export default class EntryAbility extends Ability { +export default class EntryAbility extends UIAbility { onCreate(want, launchParam) { Logger.info(TAG, 'Ability onCreate') Logger.info(TAG, `want param: ${JSON.stringify(want)}`) diff --git a/code/BasicFeature/DFX/FaultLogger/README.md b/code/BasicFeature/DFX/FaultLogger/README.md index 8ea660593299f259429dfbfad97a1ff60725d3d3..94607a9225e968e8cc1fdab3e11cf153f01788d0 100644 --- a/code/BasicFeature/DFX/FaultLogger/README.md +++ b/code/BasicFeature/DFX/FaultLogger/README.md @@ -12,4 +12,4 @@ This example illustrates how to obtain application fault information in eTS. ### Constraints -This sample can only be run on standard-system devices. The SDK version must be 3.1.5.5 or later. +This sample can only be run on standard-system devices. The SDK version must be 3.2.10.6 or later. diff --git a/code/BasicFeature/DFX/FaultLogger/README_zh.md b/code/BasicFeature/DFX/FaultLogger/README_zh.md index 67fb165d072bdaf3b759e73e5c5d9c1a4a7f7096..169ed013bf7023262ce59c7a8eeb2fee170a58da 100644 --- a/code/BasicFeature/DFX/FaultLogger/README_zh.md +++ b/code/BasicFeature/DFX/FaultLogger/README_zh.md @@ -25,6 +25,6 @@ ### 约束与限制 1. 本示例仅支持标准系统上运行,支持设备:RK3568; -2. 本示例仅支持API9版本SDK,版本号:3.2.9.2 +2. 本示例仅支持API9版本SDK,版本号:3.2.10.6 3. 本示例需要使用DevEco Studio 3.1 Canary1 (Build Version: 3.1.0.100, built on November 3, 2022)才可编译运行。 diff --git a/code/BasicFeature/DFX/FaultLogger/build-profile.json5 b/code/BasicFeature/DFX/FaultLogger/build-profile.json5 index 78cec1b3eca0b6412eacbac3fbce46f18d1c9eb7..7b9532cba89c63c3e39e202b9f68079265f87c49 100644 --- a/code/BasicFeature/DFX/FaultLogger/build-profile.json5 +++ b/code/BasicFeature/DFX/FaultLogger/build-profile.json5 @@ -20,9 +20,10 @@ "products": [ { "name": "default", - "signingConfig": "default", + "signingConfig": "default" } - ] + ], + "signingConfigs": [] }, "modules": [ { diff --git a/code/BasicFeature/DFX/FaultLogger/entry/package.json b/code/BasicFeature/DFX/FaultLogger/entry/package.json index 29732ffea047ab4e9d897d4cc7092f5e7fe3493f..db08bbf9d7439623fcfa4093ab7f013633c62d48 100644 --- a/code/BasicFeature/DFX/FaultLogger/entry/package.json +++ b/code/BasicFeature/DFX/FaultLogger/entry/package.json @@ -11,4 +11,4 @@ "repository": {}, "version": "1.0.0", "dependencies": {} -} +} \ No newline at end of file diff --git a/code/BasicFeature/DFX/FaultLogger/entry/src/main/ets/common/FaultDialog.ets b/code/BasicFeature/DFX/FaultLogger/entry/src/main/ets/common/FaultDialog.ets index 720d3fac2e83a3f9742e71804c6e49b49ff23eb8..853b084007e687223d1d7515010958c0c632828a 100644 --- a/code/BasicFeature/DFX/FaultLogger/entry/src/main/ets/common/FaultDialog.ets +++ b/code/BasicFeature/DFX/FaultLogger/entry/src/main/ets/common/FaultDialog.ets @@ -42,6 +42,7 @@ export struct FaultDialog { setTimeout(() => { // 此处是为了构造cpp_crash,故意写的有问题的接口调用,因此添加了@ts-ignore let module = 'ohos.samples.faultlogger' + //@ts-ignore faultLogger.addFaultLog(0, faultLogger.FaultType.CPP_CRASH, module, 'faultloggertestsummary02') router.back() }, DURATION) diff --git a/code/BasicFeature/DFX/FaultLogger/entry/src/main/ets/entryability/EntryAbility.ets b/code/BasicFeature/DFX/FaultLogger/entry/src/main/ets/entryability/EntryAbility.ets index 6a0cd3cf7a431c4817eda80e62cdac12f83a4812..e6df86006bc466b9b1ec78bd03a67501d92a980a 100644 --- a/code/BasicFeature/DFX/FaultLogger/entry/src/main/ets/entryability/EntryAbility.ets +++ b/code/BasicFeature/DFX/FaultLogger/entry/src/main/ets/entryability/EntryAbility.ets @@ -13,13 +13,13 @@ * limitations under the License. */ -import Ability from '@ohos.application.Ability' +import UIAbility from '@ohos.app.ability.UIAbility' import Window from '@ohos.window' import Logger from '../model/Logger' const TAG = '[Entry]' -export default class EntryAbility extends Ability { +export default class EntryAbility extends UIAbility { onWindowStageCreate(windowStage: Window.WindowStage) { // Main window is created, set main page for this ability Logger.info(TAG, 'Ability onWindowStageCreate') diff --git a/code/BasicFeature/DFX/FaultLogger/package.json b/code/BasicFeature/DFX/FaultLogger/package.json index 59871a7f6d5b2eb8d45a4dd0c3de2ba19d50e24b..107af3e41e535676079329c5f5397f4fda321ec2 100644 --- a/code/BasicFeature/DFX/FaultLogger/package.json +++ b/code/BasicFeature/DFX/FaultLogger/package.json @@ -15,4 +15,4 @@ "@ohos/hvigor-ohos-plugin": "1.3.1", "@ohos/hvigor": "1.3.1" } -} +} \ No newline at end of file diff --git a/code/BasicFeature/DFX/Logger/.gitignore b/code/BasicFeature/DFX/Logger/.gitignore index 5d2b9e2a3466c73f683354a700d2fcb1925f1db2..034035551cef713b36f904c513ea4d8566846fe8 100644 --- a/code/BasicFeature/DFX/Logger/.gitignore +++ b/code/BasicFeature/DFX/Logger/.gitignore @@ -7,5 +7,5 @@ /.clangd /.clang-format /.clang-tidy -/package-lock.json +**/package-lock.json /entry/package-lock.json diff --git a/code/BasicFeature/DFX/Logger/README.md b/code/BasicFeature/DFX/Logger/README.md index 6e1b89d49c80843d4060bbf5c27e4670cab12beb..0ee26d474fb05faf4236afa001795b4c200a63bb 100644 --- a/code/BasicFeature/DFX/Logger/README.md +++ b/code/BasicFeature/DFX/Logger/README.md @@ -76,4 +76,4 @@ This sample shows how to use log APIs to print log information and save the info 1. This sample requires API version 8 or later. -2. This sample requires DevEco Studio 3.0 Beta4 (Build Version: 3.0.0.992, built on July 14, 2022) to compile and run. +2. This sample requires DevEco Studio 3.1 Canary1 (Build Version: 3.1.0.100) to compile and run. diff --git a/code/BasicFeature/DFX/Logger/README_zh.md b/code/BasicFeature/DFX/Logger/README_zh.md index e6fa8ce38d8337e05a420af44af77991bb51414e..d0b529f578565d7818ffe79e5aed1a8027e7fc2e 100644 --- a/code/BasicFeature/DFX/Logger/README_zh.md +++ b/code/BasicFeature/DFX/Logger/README_zh.md @@ -24,6 +24,6 @@ ### 约束与限制 -1.本示例仅支持API9版本SDK,版本号:3.2.9.2; +1.本示例仅支持API9版本SDK,版本号:3.2.10.6; -2.本示例需要使用DevEco Studio 3.1 Canary1 (Build Version: 3.1.0.100, built on November 3, 2022)才可编译运行。 \ No newline at end of file +2.本示例需要使用DevEco Studio 3.1 Canary1 (Build Version: 3.1.0.100)及以上才可编译运行。 \ No newline at end of file diff --git a/code/BasicFeature/DFX/Logger/build-profile.json5 b/code/BasicFeature/DFX/Logger/build-profile.json5 index 3e0ce63cc4086c723827e3c0c55bf7eb58db4f82..a1ce05aa8095477481b275038c829ff44cc2dbcb 100644 --- a/code/BasicFeature/DFX/Logger/build-profile.json5 +++ b/code/BasicFeature/DFX/Logger/build-profile.json5 @@ -23,6 +23,7 @@ "signingConfig": "default" } ], + "signingConfigs": [] }, "modules": [ { diff --git a/code/BasicFeature/DFX/Logger/entry/src/main/ets/entryability/EntryAbility.ets b/code/BasicFeature/DFX/Logger/entry/src/main/ets/entryability/EntryAbility.ets index ba5515d1ad7438f550d06f3521f73957ca893232..55c237f86a49ae29caee2f23eb7ad2dc7747786e 100644 --- a/code/BasicFeature/DFX/Logger/entry/src/main/ets/entryability/EntryAbility.ets +++ b/code/BasicFeature/DFX/Logger/entry/src/main/ets/entryability/EntryAbility.ets @@ -13,11 +13,11 @@ * limitations under the License. */ -import Ability from '@ohos.application.Ability' +import UIAbility from '@ohos.app.ability.UIAbility' import Window from '@ohos.window' import { Logger } from '@ohos/Log' -export default class EntryAbility extends Ability { +export default class EntryAbility extends UIAbility { onWindowStageCreate(windowStage: Window.WindowStage) { // Main window is created, set main page for this ability let logger = new Logger(this.context) diff --git a/code/BasicFeature/DataManagement/Preferences/.gitignore b/code/BasicFeature/DataManagement/Preferences/.gitignore index 0798b36a1bfe2a32f31414ac9d532a7bc578607c..3ccb1c01047c1231b6974f9bbd4f497931fb1af5 100644 --- a/code/BasicFeature/DataManagement/Preferences/.gitignore +++ b/code/BasicFeature/DataManagement/Preferences/.gitignore @@ -4,4 +4,5 @@ **/build /.hvigor /package-lock.json -/entry/package-lock.json \ No newline at end of file +/entry/package-lock.json +**/.preview \ No newline at end of file diff --git a/code/BasicFeature/DataManagement/Preferences/README.md b/code/BasicFeature/DataManagement/Preferences/README.md index bd6cdf53847c8fbdfee8ec996efcc7eb316250aa..9bcd626b9126b7f5fd219b02680aec76bcb1d919 100644 --- a/code/BasicFeature/DataManagement/Preferences/README.md +++ b/code/BasicFeature/DataManagement/Preferences/README.md @@ -26,4 +26,4 @@ N/A. - This sample is based on the stage model, which is supported from API version 9. -- This sample requires DevEco Studio 3.0 Beta4 (Build Version: 3.0.0.992, built on July 14, 2022) to compile and run. +- This sample requires DevEco Studio 3.1 Canary1 (Build Version: 3.1.0.100) to compile and run. diff --git a/code/BasicFeature/DataManagement/Preferences/README_zh.md b/code/BasicFeature/DataManagement/Preferences/README_zh.md index 9a19eb2d1a75e2a571cf2e8ecbd082722217ad59..8a4f2e0def6f834c5b1a405caad10ba444351834 100644 --- a/code/BasicFeature/DataManagement/Preferences/README_zh.md +++ b/code/BasicFeature/DataManagement/Preferences/README_zh.md @@ -26,4 +26,4 @@ 2.本示例为Stage模型,从API version 9开始支持。 -3.本示例需要使用DevEco Studio 3.0 Beta4 (Build Version: 3.0.0.992, built on July 14, 2022)才可编译运行。 \ No newline at end of file +3.本示例需要使用DevEco Studio 3.1 Canary1 (Build Version: 3.1.0.100)及以上才可编译运行。 \ No newline at end of file diff --git a/code/BasicFeature/DataManagement/Preferences/entry/package.json b/code/BasicFeature/DataManagement/Preferences/entry/package.json index 29732ffea047ab4e9d897d4cc7092f5e7fe3493f..db08bbf9d7439623fcfa4093ab7f013633c62d48 100644 --- a/code/BasicFeature/DataManagement/Preferences/entry/package.json +++ b/code/BasicFeature/DataManagement/Preferences/entry/package.json @@ -11,4 +11,4 @@ "repository": {}, "version": "1.0.0", "dependencies": {} -} +} \ No newline at end of file diff --git a/code/BasicFeature/DataManagement/Preferences/entry/src/main/ets/Application/AbilityStage.ts b/code/BasicFeature/DataManagement/Preferences/entry/src/main/ets/Application/AbilityStage.ts index a244854212e2abb21d5df9a706b588b4657f8471..0a422a462cb8a6a10aaaa3c9cf15932c269b0914 100644 --- a/code/BasicFeature/DataManagement/Preferences/entry/src/main/ets/Application/AbilityStage.ts +++ b/code/BasicFeature/DataManagement/Preferences/entry/src/main/ets/Application/AbilityStage.ts @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 Huawei Device Co., Ltd. + * Copyright (c) 2022-2023 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 @@ -14,7 +14,7 @@ */ import Logger from '../model/Logger' -import AbilityStage from '@ohos.application.AbilityStage' +import AbilityStage from '@ohos.app.ability.AbilityStage' export default class MyAbilityStage extends AbilityStage { onCreate() { diff --git a/code/BasicFeature/DataManagement/Preferences/entry/src/main/ets/MainAbility/MainAbility.ts b/code/BasicFeature/DataManagement/Preferences/entry/src/main/ets/MainAbility/MainAbility.ts index 1723ae4d5ad43131fa31633b1ef39dd9ba92e3e5..d03aa5e3ed3a9012face60199bd1ac84cf5b0cce 100644 --- a/code/BasicFeature/DataManagement/Preferences/entry/src/main/ets/MainAbility/MainAbility.ts +++ b/code/BasicFeature/DataManagement/Preferences/entry/src/main/ets/MainAbility/MainAbility.ts @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 Huawei Device Co., Ltd. + * Copyright (c) 2022-2023 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 @@ -13,35 +13,35 @@ * limitations under the License. */ -import Ability from '@ohos.application.Ability' +import UIAbility from '@ohos.app.ability.UIAbility' import Logger from '../model/Logger' const TAG: string = '[MainAbility]' -export default class MainAbility extends Ability { - onCreate(want) { - Logger.info(TAG, 'MainAbility onCreate is called') - } +export default class MainAbility extends UIAbility { + onCreate(want) { + Logger.info(TAG, 'MainAbility onCreate is called') + } - onDestroy() { - Logger.info(TAG, 'MainAbility onDestroy is called') - } + onDestroy() { + Logger.info(TAG, 'MainAbility onDestroy is called') + } - onWindowStageCreate(windowStage) { - Logger.info(TAG, 'MainAbility onWindowStageCreate is called') - const context = this.context - windowStage.setUIContent(context, 'pages/Index', null) - } + onWindowStageCreate(windowStage) { + Logger.info(TAG, 'MainAbility onWindowStageCreate is called') + const context = this.context + windowStage.setUIContent(context, 'pages/Index', null) + } - onWindowStageDestroy() { - Logger.info(TAG, 'MainAbility onWindowStageDestroy is called') - } + onWindowStageDestroy() { + Logger.info(TAG, 'MainAbility onWindowStageDestroy is called') + } - onForeground() { - Logger.info(TAG, 'MainAbility onForeground is called') - } + onForeground() { + Logger.info(TAG, 'MainAbility onForeground is called') + } - onBackground() { - Logger.info(TAG, 'MainAbility onBackground is called') - } + onBackground() { + Logger.info(TAG, 'MainAbility onBackground is called') + } }; \ No newline at end of file diff --git a/code/BasicFeature/DataManagement/Preferences/package.json b/code/BasicFeature/DataManagement/Preferences/package.json index 73dbc16193d3ba72f7d0340d49822c79c0d0b309..4c3e5f94f52e361ed5b5d620cb2575b2acebee41 100644 --- a/code/BasicFeature/DataManagement/Preferences/package.json +++ b/code/BasicFeature/DataManagement/Preferences/package.json @@ -11,8 +11,8 @@ "repository": {}, "version": "1.0.0", "dependencies": { - "@ohos/hypium": "1.0.1", - "@ohos/hvigor-ohos-plugin": "1.1.6", - "@ohos/hvigor": "1.1.6" + "@ohos/hypium": "1.0.3", + "@ohos/hvigor-ohos-plugin": "1.3.1", + "@ohos/hvigor": "1.3.1" } } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Location/.gitignore b/code/BasicFeature/DeviceManagement/Location/.gitignore index 91d237bb144c7fb1777e50271857ef0f593286fc..f66a48f7ecf449cdd529bb12c3277097c4a7790e 100644 --- a/code/BasicFeature/DeviceManagement/Location/.gitignore +++ b/code/BasicFeature/DeviceManagement/Location/.gitignore @@ -2,4 +2,6 @@ /local.properties /.idea **/build -/.hvigor \ No newline at end of file +/.hvigor +**/package-lock.json +**/node_modules \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Location/README.md b/code/BasicFeature/DeviceManagement/Location/README.md index 5bfa8d42387dc15fc18bab80473b20bb668bfc35..23d0df34ee4d496b0deca93f94755a829b445bfe 100644 --- a/code/BasicFeature/DeviceManagement/Location/README.md +++ b/code/BasicFeature/DeviceManagement/Location/README.md @@ -33,6 +33,6 @@ N/A 1. This sample can only be run on standard-system devices. To use GPS positioning, the test device must support the GPS function. -2. This sample demonstrates the stage model, which supports only the SDK of API version 9 (SDK version: 3.2.5.5). +2. This sample demonstrates the stage model, which supports only the SDK of API version 9 (SDK version: 3.2.10.6). -3. DevEco Studio 3.0 Beta4 (Build version: 3.0.0.992, built on July 14, 2022) must be used. +3. DevEco Studio 3.1 Canary1 (Build Version: 3.1.0.100) must be used. diff --git a/code/BasicFeature/DeviceManagement/Location/README_zh.md b/code/BasicFeature/DeviceManagement/Location/README_zh.md index d47b0a91962208adb4094ffd2dd5479db7bd8681..6bd97f9fd1c46487c99619618bef8f424533f839 100644 --- a/code/BasicFeature/DeviceManagement/Location/README_zh.md +++ b/code/BasicFeature/DeviceManagement/Location/README_zh.md @@ -35,6 +35,6 @@ 1.本示例仅支持标准系统上运行,支持设备:GPS定位功能仅支持部分机型。 -2.本示例为Stage模型,仅支持API9版本SDK,版本号:3.2.5.5。 +2.本示例为Stage模型,仅支持API9版本SDK,版本号:3.2.10.6。 -3.本示例需要使用DevEco Studio 3.0 Beta4 (Build Version: 3.0.0.992, built on July 14, 2022)才可编译运行。 +3.本示例需要使用DevEco Studio 3.1 Canary1 (Build Version: 3.1.0.100)及以上才可编译运行。 diff --git a/code/BasicFeature/DeviceManagement/Location/entry/src/main/ets/Application/MyAbilityStage.ts b/code/BasicFeature/DeviceManagement/Location/entry/src/main/ets/Application/MyAbilityStage.ts index b6dabfd10e247a4e3748e61b0ac6bd1234f3fc4e..65b2e0364ec59eab570497904a5063042420a419 100644 --- a/code/BasicFeature/DeviceManagement/Location/entry/src/main/ets/Application/MyAbilityStage.ts +++ b/code/BasicFeature/DeviceManagement/Location/entry/src/main/ets/Application/MyAbilityStage.ts @@ -13,7 +13,7 @@ * limitations under the License. */ -import AbilityStage from '@ohos.application.AbilityStage' +import AbilityStage from '@ohos.app.ability.AbilityStage' import Logger from '../../../../../position/src/main/ets/components/util/Logger' const TAG:string = 'MyAbilityStage' diff --git a/code/BasicFeature/DeviceManagement/Location/entry/src/main/ets/MainAbility/MainAbility.ts b/code/BasicFeature/DeviceManagement/Location/entry/src/main/ets/MainAbility/MainAbility.ts index 5f7bd271c0a3c96a5e60303d6ae585a0554c49c1..71153d30cce07f3b1598e13313905ca418d25a4d 100644 --- a/code/BasicFeature/DeviceManagement/Location/entry/src/main/ets/MainAbility/MainAbility.ts +++ b/code/BasicFeature/DeviceManagement/Location/entry/src/main/ets/MainAbility/MainAbility.ts @@ -13,15 +13,25 @@ * limitations under the License. */ -import Ability from '@ohos.application.Ability' +import UIAbility from '@ohos.app.ability.UIAbility' +import abilityAccessCtrl from '@ohos.abilityAccessCtrl' import Logger from '../../../../../position/src/main/ets/components/util/Logger' const TAG: string = 'MainAbility' -export default class MainAbility extends Ability { +export default class MainAbility extends UIAbility { async onCreate(want, launchParam) { Logger.info(TAG, `[Demo] MainAbility onCreate`) - await this.context.requestPermissionsFromUser(['ohos.permission.INTERNET','ohos.permission.LOCATION','ohos.permission.LOCATION_IN_BACKGROUND','ohos.permission.APPROXIMATELY_LOCATION']) + let atManager = abilityAccessCtrl.createAtManager() + try { + atManager.requestPermissionsFromUser(this.context, ['ohos.permission.INTERNET','ohos.permission.LOCATION','ohos.permission.LOCATION_IN_BACKGROUND','ohos.permission.APPROXIMATELY_LOCATION']).then((data) => { + Logger.info(TAG, `data: ${JSON.stringify(data)}`) + }).catch((err) => { + Logger.info(TAG, `err: ${JSON.stringify(err)}`) + }) + } catch(err) { + Logger.info(TAG, `catch err->${JSON.stringify(err)}`) + } } onDestroy() { diff --git a/code/BasicFeature/DeviceManagement/Location/package.json b/code/BasicFeature/DeviceManagement/Location/package.json index 83b0924d5cfeba56c9e19d9ae2c1785b8a859c00..1c113ffaddab98edb5cc2774406e3649e6e810e1 100644 --- a/code/BasicFeature/DeviceManagement/Location/package.json +++ b/code/BasicFeature/DeviceManagement/Location/package.json @@ -11,8 +11,8 @@ "repository": {}, "version": "1.0.0", "dependencies": { - "@ohos/hypium": "1.0.1", - "@ohos/hvigor-ohos-plugin": "1.1.6", - "@ohos/hvigor": "1.1.6" + "@ohos/hypium": "1.0.3", + "@ohos/hvigor-ohos-plugin": "1.3.1", + "@ohos/hvigor": "1.3.1" } -} +} \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Location/position/hvigorfile.ts b/code/BasicFeature/DeviceManagement/Location/position/hvigorfile.ts new file mode 100644 index 0000000000000000000000000000000000000000..42ed4b4a54a873e2b53441556aae93fab24b794f --- /dev/null +++ b/code/BasicFeature/DeviceManagement/Location/position/hvigorfile.ts @@ -0,0 +1,3 @@ +// Script for compiling build behavior. It is built in the build plug-in and cannot be modified currently. +module.exports = require('@ohos/hvigor-ohos-plugin').harTasks + diff --git a/code/BasicFeature/DeviceManagement/Location/position/package.json b/code/BasicFeature/DeviceManagement/Location/position/package.json index f56f161a9bab8bfe4643fca408cd4d0d95441a4d..4a7746468f83ee8099ef2fe95d4d97cdb1490b43 100644 --- a/code/BasicFeature/DeviceManagement/Location/position/package.json +++ b/code/BasicFeature/DeviceManagement/Location/position/package.json @@ -9,6 +9,7 @@ }, "main": "index.ets", "repository": {}, + "type": "module", "version": "1.0.0", "dependencies": {} } \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Runninglock/README_zh.md b/code/BasicFeature/DeviceManagement/Runninglock/README_zh.md index 75d11d67a93274381c66452f14a56b84f1927f23..fe60b664c3471da13feb9a107802e14bd955fc4f 100644 --- a/code/BasicFeature/DeviceManagement/Runninglock/README_zh.md +++ b/code/BasicFeature/DeviceManagement/Runninglock/README_zh.md @@ -29,5 +29,5 @@ ### 约束与限制 1.本示例仅支持在标准系统上运行; -2.本示例仅支持API9版本SDK,版本号:3.2.9.2; -3.本示例需要使用DevEco Studio 3.1 Canary1 (Build Version: 3.1.0.100, built on November 3, 2022)才可编译运行。 \ No newline at end of file +2.本示例仅支持API9版本SDK,版本号:3.2.10.6; +3.本示例需要使用DevEco Studio 3.1 Canary1 (Build Version: 3.1.0.100)及以上才可编译运行。 \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Runninglock/build-profile.json5 b/code/BasicFeature/DeviceManagement/Runninglock/build-profile.json5 index 78cec1b3eca0b6412eacbac3fbce46f18d1c9eb7..7b9532cba89c63c3e39e202b9f68079265f87c49 100644 --- a/code/BasicFeature/DeviceManagement/Runninglock/build-profile.json5 +++ b/code/BasicFeature/DeviceManagement/Runninglock/build-profile.json5 @@ -20,9 +20,10 @@ "products": [ { "name": "default", - "signingConfig": "default", + "signingConfig": "default" } - ] + ], + "signingConfigs": [] }, "modules": [ { diff --git a/code/BasicFeature/DeviceManagement/Runninglock/entry/src/main/ets/entryability/EntryAbility.ets b/code/BasicFeature/DeviceManagement/Runninglock/entry/src/main/ets/entryability/EntryAbility.ets index eba1c796e6903a5880ee969b3a409314c9fea926..930227d7e78c8debd6065ed9fd86d3e1dec620c7 100644 --- a/code/BasicFeature/DeviceManagement/Runninglock/entry/src/main/ets/entryability/EntryAbility.ets +++ b/code/BasicFeature/DeviceManagement/Runninglock/entry/src/main/ets/entryability/EntryAbility.ets @@ -13,13 +13,13 @@ * limitations under the License. */ -import Ability from '@ohos.application.Ability' +import UIAbility from '@ohos.app.ability.UIAbility' import Window from '@ohos.window' import Logger from '../util/Logger' const TAG = '[Entry]' -export default class EntryAbility extends Ability { +export default class EntryAbility extends UIAbility { onCreate(want, launchParam) { Logger.info(TAG, 'Ability onCreate') } diff --git a/code/BasicFeature/DeviceManagement/ScreenDetector/.gitignore b/code/BasicFeature/DeviceManagement/ScreenDetector/.gitignore index 91d237bb144c7fb1777e50271857ef0f593286fc..40bf74cf5cf5b5d5684f825894771423088a8936 100644 --- a/code/BasicFeature/DeviceManagement/ScreenDetector/.gitignore +++ b/code/BasicFeature/DeviceManagement/ScreenDetector/.gitignore @@ -2,4 +2,5 @@ /local.properties /.idea **/build -/.hvigor \ No newline at end of file +/.hvigor +**/package-lock.json \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/ScreenDetector/README_zh.md b/code/BasicFeature/DeviceManagement/ScreenDetector/README_zh.md index 86c31e7034394285777209eb53a57a2670e3c17f..dcf2d0410612dd1d5853359f412dc4db4dab881e 100644 --- a/code/BasicFeature/DeviceManagement/ScreenDetector/README_zh.md +++ b/code/BasicFeature/DeviceManagement/ScreenDetector/README_zh.md @@ -36,5 +36,5 @@ ### 约束与限制 1. 本示例仅支持标准系统上运行,支持设备:RK3568; -2. 本示例仅支持API9版本SDK,版本号:3.2.7.5; -3. 本示例需要使用DevEco Studio 3.0 Beta4 (Build Version: 3.0.0.993, built on Spet 04, 2022)才可编译运行; +2. 本示例仅支持API9版本SDK,版本号:3.2.10.6; +3. 本示例需要使用DevEco Studio 3.1 Canary1 (Build Version: 3.1.0.100)才可编译运行; diff --git a/code/BasicFeature/DeviceManagement/ScreenDetector/build-profile.json5 b/code/BasicFeature/DeviceManagement/ScreenDetector/build-profile.json5 index 5e71f467e59211a0845c4d6a9aa79818bc8d12d3..ca880b1036f5b8b8c9d26640bb3194c0f34b9dfb 100644 --- a/code/BasicFeature/DeviceManagement/ScreenDetector/build-profile.json5 +++ b/code/BasicFeature/DeviceManagement/ScreenDetector/build-profile.json5 @@ -23,6 +23,7 @@ "signingConfig": "default" } ], + "signingConfigs": [] }, "modules": [ { diff --git a/code/BasicFeature/DeviceManagement/ScreenDetector/entry/package.json b/code/BasicFeature/DeviceManagement/ScreenDetector/entry/package.json index 29732ffea047ab4e9d897d4cc7092f5e7fe3493f..db08bbf9d7439623fcfa4093ab7f013633c62d48 100644 --- a/code/BasicFeature/DeviceManagement/ScreenDetector/entry/package.json +++ b/code/BasicFeature/DeviceManagement/ScreenDetector/entry/package.json @@ -11,4 +11,4 @@ "repository": {}, "version": "1.0.0", "dependencies": {} -} +} \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/ScreenDetector/entry/src/main/ets/Application/MyAbilityStage.ts b/code/BasicFeature/DeviceManagement/ScreenDetector/entry/src/main/ets/Application/MyAbilityStage.ts index ced8edf0e138dcf0d93be8280cb874aaa7e180d5..7622be1ef93103241de65af3a6ed91378aa44c3c 100644 --- a/code/BasicFeature/DeviceManagement/ScreenDetector/entry/src/main/ets/Application/MyAbilityStage.ts +++ b/code/BasicFeature/DeviceManagement/ScreenDetector/entry/src/main/ets/Application/MyAbilityStage.ts @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 Huawei Device Co., Ltd. + * Copyright (c) 2022-2023 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 @@ -14,7 +14,7 @@ */ import hilog from '@ohos.hilog'; -import AbilityStage from "@ohos.application.AbilityStage" +import AbilityStage from "@ohos.app.ability.AbilityStage" export default class MyAbilityStage extends AbilityStage { onCreate() { diff --git a/code/BasicFeature/DeviceManagement/ScreenDetector/entry/src/main/ets/MainAbility/MainAbility.ts b/code/BasicFeature/DeviceManagement/ScreenDetector/entry/src/main/ets/MainAbility/MainAbility.ts index 6e0cebd00360820a1caf3ca03e1f7648d01a65b9..79a137a9ab6b6c91d73cb163a913874db50aa881 100644 --- a/code/BasicFeature/DeviceManagement/ScreenDetector/entry/src/main/ets/MainAbility/MainAbility.ts +++ b/code/BasicFeature/DeviceManagement/ScreenDetector/entry/src/main/ets/MainAbility/MainAbility.ts @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 Huawei Device Co., Ltd. + * Copyright (c) 2022-2023 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 @@ -13,13 +13,13 @@ * limitations under the License. */ -import Ability from '@ohos.application.Ability' +import UIAbility from '@ohos.app.ability.UIAbility' import Window from '@ohos.window' import Logger from '../Common/Logger' const TAG: string = '[ScreenDetector]' -export default class MainAbility extends Ability { +export default class MainAbility extends UIAbility { onCreate(want, launchParam) { Logger.info(TAG, 'Ability onCreate'); Logger.info(TAG, 'want param:' + JSON.stringify(want)); diff --git a/code/BasicFeature/DeviceManagement/Sensor/.gitignore b/code/BasicFeature/DeviceManagement/Sensor/.gitignore index dc4e6353bf3caf74c5953d0bec81c72a3635bf33..5fe37acd3126ab803182349927be17b6180de22c 100644 --- a/code/BasicFeature/DeviceManagement/Sensor/.gitignore +++ b/code/BasicFeature/DeviceManagement/Sensor/.gitignore @@ -1,4 +1,4 @@ -/node_modules +**/node_modules /local.properties /.idea **/build @@ -6,4 +6,5 @@ .cxx /.clangd /.clang-format -/.clang-tidy \ No newline at end of file +/.clang-tidy +**/package-lock.json \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Sensor/README_zh.md b/code/BasicFeature/DeviceManagement/Sensor/README_zh.md index 2df4901a8381d402e58fa0e653d3c311817ebe0a..609d4f3339e9fa0695a35c01236283cfb4f82c0c 100644 --- a/code/BasicFeature/DeviceManagement/Sensor/README_zh.md +++ b/code/BasicFeature/DeviceManagement/Sensor/README_zh.md @@ -26,8 +26,8 @@ 2.本示例仅支持在标准系统上运行。 -3.本示例需要使用DevEco Studio 3.1 Canary1 (Build Version: 3.1.0.100, built on November 3, 2022)才可编译运行。 +3.本示例需要使用DevEco Studio 3.1 Canary1 (Build Version: 3.1.0.100)及以上才可编译运行。 4.本示例需要特殊模块与特定传感器,目前该功能仅支持部分机型。 -5.本示例仅支持API9版本SDK,版本号:3.2.7.6。 \ No newline at end of file +5.本示例仅支持API9版本SDK,版本号:3.2.10.6。 \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Sensor/build-profile.json5 b/code/BasicFeature/DeviceManagement/Sensor/build-profile.json5 index 30cf3f95fa2facd457252aaa2303f61b8891f15e..cebcede0c652ed8757bb7d6a7642bc4db81b040b 100644 --- a/code/BasicFeature/DeviceManagement/Sensor/build-profile.json5 +++ b/code/BasicFeature/DeviceManagement/Sensor/build-profile.json5 @@ -22,7 +22,8 @@ "name": "default", "signingConfig": "default" } - ] + ], + "signingConfigs": [] }, "modules": [ { diff --git a/code/BasicFeature/DeviceManagement/Sensor/entry/package.json b/code/BasicFeature/DeviceManagement/Sensor/entry/package.json index 29732ffea047ab4e9d897d4cc7092f5e7fe3493f..db08bbf9d7439623fcfa4093ab7f013633c62d48 100644 --- a/code/BasicFeature/DeviceManagement/Sensor/entry/package.json +++ b/code/BasicFeature/DeviceManagement/Sensor/entry/package.json @@ -11,4 +11,4 @@ "repository": {}, "version": "1.0.0", "dependencies": {} -} +} \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Sensor/entry/src/main/ets/entryability/EntryAbility.ets b/code/BasicFeature/DeviceManagement/Sensor/entry/src/main/ets/entryability/EntryAbility.ets index b21133fdfd29290741d6c0b106a0e9751b7c64b1..b8b6b8fefc505552a9a4be50e62bf774722c9e8a 100644 --- a/code/BasicFeature/DeviceManagement/Sensor/entry/src/main/ets/entryability/EntryAbility.ets +++ b/code/BasicFeature/DeviceManagement/Sensor/entry/src/main/ets/entryability/EntryAbility.ets @@ -13,11 +13,11 @@ * limitations under the License. */ -import Ability from '@ohos.application.Ability' +import UIAbility from '@ohos.app.ability.UIAbility' import Window from '@ohos.window' import Logger from '../util/Logger' -export default class EntryAbility extends Ability { +export default class EntryAbility extends UIAbility { onCreate(want, launchParam) { Logger.info('Ability onCreate') } diff --git a/code/BasicFeature/DeviceManagement/Sensor/package.json b/code/BasicFeature/DeviceManagement/Sensor/package.json index ac5a91e67a868723dbfe424760bbbb85fa025356..625aadb6ff42e2fa58776593432e26847f49525d 100644 --- a/code/BasicFeature/DeviceManagement/Sensor/package.json +++ b/code/BasicFeature/DeviceManagement/Sensor/package.json @@ -15,4 +15,4 @@ "@ohos/hvigor-ohos-plugin": "1.3.1", "@ohos/hvigor": "1.3.1" } -} +} \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/USBManager/README.md b/code/BasicFeature/DeviceManagement/USBManager/README.md index 9d1ccb2db1bea4f2a84a3f43f8433eea3294457e..be0ba8842587e883cea652d8612104bc8a7602c5 100644 --- a/code/BasicFeature/DeviceManagement/USBManager/README.md +++ b/code/BasicFeature/DeviceManagement/USBManager/README.md @@ -30,4 +30,4 @@ Not involved 1. This sample is only supported to run on standard systems. -2. This sample requires DevEco Studio 3.0 Beta4 (Build Version: 3.0.0.992, built on July 14, 2022) to compile and run. +2. This sample requires DevEco Studio 3.1 Canary1 (Build Version: 3.1.0.100) to compile and run. diff --git a/code/BasicFeature/DeviceManagement/USBManager/README_zh.md b/code/BasicFeature/DeviceManagement/USBManager/README_zh.md index c181496a3ad73238bc239087a7c0af7adb2c717c..13630c88dcdf234de3c41a90bbdd9c7c7b14021c 100644 --- a/code/BasicFeature/DeviceManagement/USBManager/README_zh.md +++ b/code/BasicFeature/DeviceManagement/USBManager/README_zh.md @@ -29,6 +29,6 @@ 1. 本示例仅支持在标准系统上运行; -2. 本示例仅支持API9版本SDK,版本号:3.2.9.2; +2. 本示例仅支持API9版本SDK,版本号:3.2.10.6; -3. 本示例需要使用DevEco Studio 3.1 Canary1 (Build Version: 3.1.0.100, built on November 3, 2022)才可编译运行。 \ No newline at end of file +3. 本示例需要使用DevEco Studio 3.1 Canary1 (Build Version: 3.1.0.100)及以上才可编译运行。 \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/USBManager/build-profile.json5 b/code/BasicFeature/DeviceManagement/USBManager/build-profile.json5 index 0e9f1cb0b0ef1c85120aaa833ec940ba0f760378..cebcede0c652ed8757bb7d6a7642bc4db81b040b 100644 --- a/code/BasicFeature/DeviceManagement/USBManager/build-profile.json5 +++ b/code/BasicFeature/DeviceManagement/USBManager/build-profile.json5 @@ -20,9 +20,10 @@ "products": [ { "name": "default", - "signingConfig": "default", + "signingConfig": "default" } - ] + ], + "signingConfigs": [] }, "modules": [ { diff --git a/code/BasicFeature/DeviceManagement/USBManager/entry/src/main/ets/entryability/EntryAbility.ets b/code/BasicFeature/DeviceManagement/USBManager/entry/src/main/ets/entryability/EntryAbility.ets index ff988830760382528763c08ef808ce10920bcba1..961c15f7939061e51563d8e7d7f3eee7a18de8bf 100644 --- a/code/BasicFeature/DeviceManagement/USBManager/entry/src/main/ets/entryability/EntryAbility.ets +++ b/code/BasicFeature/DeviceManagement/USBManager/entry/src/main/ets/entryability/EntryAbility.ets @@ -13,13 +13,13 @@ * limitations under the License. */ -import Ability from '@ohos.application.Ability' +import UIAbility from '@ohos.app.ability.UIAbility' import Window from '@ohos.window' import Logger from '../model/Logger' const TAG = '[Entry]' -export default class EntryAbility extends Ability { +export default class EntryAbility extends UIAbility { onWindowStageCreate(windowStage: Window.WindowStage) { // Main window is created, set main page for this ability Logger.info(TAG, 'Ability onWindowStageCreate') diff --git a/code/BasicFeature/DeviceManagement/Vibrator/README.md b/code/BasicFeature/DeviceManagement/Vibrator/README.md index 3c4e5543e94791d734c0bfaf9e820b21463c55b3..74db6f91294bfff42732959ce9b960d0bbdc3ca8 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/README.md +++ b/code/BasicFeature/DeviceManagement/Vibrator/README.md @@ -28,5 +28,5 @@ ohos.permission.VIBRATE 2. This sample requires a device with a vibrator. -3. This sample requires DevEco Studio 3.0 Beta4 (Build Version: 3.0.0.992, built on July 14, 2022) to compile and run. +3. This sample requires DevEco Studio 3.1 Canary1 (Build Version: 3.1.0.100) to compile and run. diff --git a/code/BasicFeature/DeviceManagement/Vibrator/README_zh.md b/code/BasicFeature/DeviceManagement/Vibrator/README_zh.md index b22f546849bc880310e7375a438dd98725ba3960..8b98b2d1fae596f1d2e429df76e0f8e4aba65d95 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/README_zh.md +++ b/code/BasicFeature/DeviceManagement/Vibrator/README_zh.md @@ -28,4 +28,4 @@ 2.本示例需要使用有振动器的设备测试。 -3.本示例需要使用DevEco Studio 3.0 Beta4 (Build Version: 3.0.0.992, built on July 14, 2022)才可编译运行。 \ No newline at end of file +3.本示例需要使用DevEco Studio 3.1 Canary1 (Build Version: 3.1.0.100)及以上才可编译运行。 \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/entry/package.json b/code/BasicFeature/DeviceManagement/Vibrator/entry/package.json index 29732ffea047ab4e9d897d4cc7092f5e7fe3493f..db08bbf9d7439623fcfa4093ab7f013633c62d48 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/entry/package.json +++ b/code/BasicFeature/DeviceManagement/Vibrator/entry/package.json @@ -11,4 +11,4 @@ "repository": {}, "version": "1.0.0", "dependencies": {} -} +} \ No newline at end of file diff --git a/code/BasicFeature/DeviceManagement/Vibrator/package.json b/code/BasicFeature/DeviceManagement/Vibrator/package.json index 70eb40d30d3148c26783064b6c2bc9662e0ec9b9..8ef29ce45500201dff202620a359ea363d304188 100644 --- a/code/BasicFeature/DeviceManagement/Vibrator/package.json +++ b/code/BasicFeature/DeviceManagement/Vibrator/package.json @@ -11,9 +11,9 @@ "repository": {}, "version": "1.0.0", "dependencies": { - "@ohos/hypium": "1.0.1", - "@ohos/hvigor-ohos-plugin": "1.1.6", + "@ohos/hypium": "1.0.3", + "@ohos/hvigor-ohos-plugin": "1.3.1", "hypium": "^1.0.0", - "@ohos/hvigor": "1.1.6" + "@ohos/hvigor": "1.3.1" } -} +} \ No newline at end of file diff --git a/code/BasicFeature/DeviceUsageStatistics/DeviceUsageStatistics/README_zh.md b/code/BasicFeature/DeviceUsageStatistics/DeviceUsageStatistics/README_zh.md index ba948a7baa1316b44011f3985a6840376cf2dbeb..947ca273ed775fd1618e2afdb4a6704612ccfa83 100644 --- a/code/BasicFeature/DeviceUsageStatistics/DeviceUsageStatistics/README_zh.md +++ b/code/BasicFeature/DeviceUsageStatistics/DeviceUsageStatistics/README_zh.md @@ -30,9 +30,9 @@ 1.本示例仅支持在标准系统上运行。 -2.本示例仅支持API9版本SDK,版本号:3.2.7.6。 +2.本示例仅支持API9版本SDK,版本号:3.2.10.6。 -3.本示例需要使用DevEco Studio 3.1 Canary1 (Build Version: 3.1.0.100, built on November 3, 2022)才可编译运行。 +3.本示例需要使用DevEco Studio 3.1 Canary1 (Build Version: 3.1.0.100)及以上才可编译运行。 4.本示例涉及使用系统接口:queryBundleStateInfos(),需要手动替换Full SDK才能编译通过,具体操作可参考[替换指南](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/quick-start/full-sdk-switch-guide.md)。 diff --git a/code/BasicFeature/DeviceUsageStatistics/DeviceUsageStatistics/entry/src/main/ets/entryability/EntryAbility.ts b/code/BasicFeature/DeviceUsageStatistics/DeviceUsageStatistics/entry/src/main/ets/entryability/EntryAbility.ts index 37eeecafce1539948dbc83fc0082a230bee2bfcf..e00418957a702443eb11f6e6c83e0f306f63e19d 100644 --- a/code/BasicFeature/DeviceUsageStatistics/DeviceUsageStatistics/entry/src/main/ets/entryability/EntryAbility.ts +++ b/code/BasicFeature/DeviceUsageStatistics/DeviceUsageStatistics/entry/src/main/ets/entryability/EntryAbility.ts @@ -14,12 +14,12 @@ */ import Logger from '../model/Logger' -import Ability from '@ohos.application.Ability' +import UIAbility from '@ohos.app.ability.UIAbility' import Window from '@ohos.window' const TAG: string = '[Index]' -export default class EntryAbility extends Ability { +export default class EntryAbility extends UIAbility { onCreate(want, launchParam) { Logger.info(TAG, `Ability onCreate want param: ` + JSON.stringify(want) ?? '' + 'launchParam:' + JSON.stringify(launchParam) ?? '') } diff --git a/code/BasicFeature/FileManagement/FileManager/.gitignore b/code/BasicFeature/FileManagement/FileManager/.gitignore index fa58a00e5f73f75113fc2a69761744cc93b4f1dd..40bf74cf5cf5b5d5684f825894771423088a8936 100644 --- a/code/BasicFeature/FileManagement/FileManager/.gitignore +++ b/code/BasicFeature/FileManagement/FileManager/.gitignore @@ -3,4 +3,4 @@ /.idea **/build /.hvigor -/package-lock.json \ No newline at end of file +**/package-lock.json \ No newline at end of file diff --git a/code/BasicFeature/FileManagement/FileManager/Library/package.json b/code/BasicFeature/FileManagement/FileManager/Library/package.json index 3dd5540db9b7f05870a2c875ca792924b73a0ce2..50b11b129c40d968bdcf71d201a9112d30d51928 100644 --- a/code/BasicFeature/FileManagement/FileManager/Library/package.json +++ b/code/BasicFeature/FileManagement/FileManager/Library/package.json @@ -12,4 +12,4 @@ "type": "module", "version": "1.0.0", "dependencies": {} -} +} \ No newline at end of file diff --git a/code/BasicFeature/FileManagement/FileManager/Library/src/main/ets/filemanager/fileio/FileIoManager.ets b/code/BasicFeature/FileManagement/FileManager/Library/src/main/ets/filemanager/fileio/FileIoManager.ets index 09415ef0beaaa4afb580c20cfec07393442d2591..485083130ca210707ce62e021c464d5763d55fb1 100644 --- a/code/BasicFeature/FileManagement/FileManager/Library/src/main/ets/filemanager/fileio/FileIoManager.ets +++ b/code/BasicFeature/FileManagement/FileManager/Library/src/main/ets/filemanager/fileio/FileIoManager.ets @@ -13,7 +13,7 @@ * limitations under the License. */ -import storageStatistics from '@ohos.storageStatistics' +import storageStatistics from '@ohos.file.storageStatistics' import fileio from '@ohos.fileio' import Logger from '../../utils/Logger' import { FileType, SubDirectoryType } from '../../mock/local/FileData' diff --git a/code/BasicFeature/FileManagement/FileManager/build-profile.json5 b/code/BasicFeature/FileManagement/FileManager/build-profile.json5 index b33eaf5dcccd52a2d2471b8cc1de8d95edd5ad92..b962fad134ece259de1625d21f889438b6a673df 100644 --- a/code/BasicFeature/FileManagement/FileManager/build-profile.json5 +++ b/code/BasicFeature/FileManagement/FileManager/build-profile.json5 @@ -22,6 +22,7 @@ "signingConfig": "default" } ], + "signingConfigs": [] }, "modules": [ { diff --git a/code/BasicFeature/FileManagement/FileManager/entry/package.json b/code/BasicFeature/FileManagement/FileManager/entry/package.json index 8026061d9a6021004e82b498c7348383eef0250d..cb217068ff719d2ac472106b55411eabd77ec5f8 100644 --- a/code/BasicFeature/FileManagement/FileManager/entry/package.json +++ b/code/BasicFeature/FileManagement/FileManager/entry/package.json @@ -13,4 +13,4 @@ "dependencies": { "@ohos/feature-file-manager": "file:../Library" } -} +} \ No newline at end of file diff --git a/code/BasicFeature/FileManagement/FileManager/entry/src/main/ets/Application/MyAbilityStage.ts b/code/BasicFeature/FileManagement/FileManager/entry/src/main/ets/Application/MyAbilityStage.ts index 0a413b6b4cf1cd361ac53cf8b4146bdda9aa8ba8..852efd0263ccd308c580b76dc4ef236ee9d9384b 100644 --- a/code/BasicFeature/FileManagement/FileManager/entry/src/main/ets/Application/MyAbilityStage.ts +++ b/code/BasicFeature/FileManagement/FileManager/entry/src/main/ets/Application/MyAbilityStage.ts @@ -14,7 +14,7 @@ */ import hilog from '@ohos.hilog' -import AbilityStage from "@ohos.application.AbilityStage" +import AbilityStage from "@ohos.app.ability.AbilityStage" export default class MyAbilityStage extends AbilityStage { onCreate() { diff --git a/code/BasicFeature/FileManagement/FileManager/entry/src/main/ets/MainAbility/MainAbility.ts b/code/BasicFeature/FileManagement/FileManager/entry/src/main/ets/MainAbility/MainAbility.ts index 643093fe081d5a1631a9ffbb2a8b8cb34df4148c..3d5cb7a4d573765aea3091a34d5b2b7748e0e66d 100644 --- a/code/BasicFeature/FileManagement/FileManager/entry/src/main/ets/MainAbility/MainAbility.ts +++ b/code/BasicFeature/FileManagement/FileManager/entry/src/main/ets/MainAbility/MainAbility.ts @@ -13,7 +13,7 @@ * limitations under the License. */ -import Ability from '@ohos.application.Ability' +import Ability from '@ohos.app.ability.UIAbility' import hilog from '@ohos.hilog' export default class MainAbility extends Ability { diff --git a/code/BasicFeature/FileManagement/FileManager/package.json b/code/BasicFeature/FileManagement/FileManager/package.json index 86c89d1851ef09acda0bdd7b9a756a27f6aab8c3..1504c23bf65b104d3376ba045f1e394686c67e49 100644 --- a/code/BasicFeature/FileManagement/FileManager/package.json +++ b/code/BasicFeature/FileManagement/FileManager/package.json @@ -15,4 +15,4 @@ "@ohos/hvigor-ohos-plugin": "1.3.1", "@ohos/hvigor": "1.3.1" } -} +} \ No newline at end of file diff --git a/code/BasicFeature/FileManagement/MediaCollections/README_zh.md b/code/BasicFeature/FileManagement/MediaCollections/README_zh.md index f7d972aecd2de91a55374f9eb469f105acdf265f..cbc750d12d2c9546d4a342d7017696483fdc95c3 100644 --- a/code/BasicFeature/FileManagement/MediaCollections/README_zh.md +++ b/code/BasicFeature/FileManagement/MediaCollections/README_zh.md @@ -42,4 +42,4 @@ 2.本示例仅支持API9版本SDK,本示例涉及使用系统接口:getXComponentSurfaceId(),需要手动替换Full SDK才能编译通过,具体操作可参考[替换指南](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/quick-start/full-sdk-switch-guide.md)。 -3.本示例需要使用DevEco Studio 3.0 Beta4 (Build Version: 3.0.0.992, built on July 14, 2022)才可编译运行。 \ No newline at end of file +3.本示例需要使用DevEco Studio 3.1 Canary1 (Build Version: 3.1.0.100)及以上才可编译运行。 \ No newline at end of file diff --git a/code/BasicFeature/FileManagement/MediaCollections/entry/package.json b/code/BasicFeature/FileManagement/MediaCollections/entry/package.json index 29732ffea047ab4e9d897d4cc7092f5e7fe3493f..db08bbf9d7439623fcfa4093ab7f013633c62d48 100644 --- a/code/BasicFeature/FileManagement/MediaCollections/entry/package.json +++ b/code/BasicFeature/FileManagement/MediaCollections/entry/package.json @@ -11,4 +11,4 @@ "repository": {}, "version": "1.0.0", "dependencies": {} -} +} \ No newline at end of file diff --git a/code/BasicFeature/FileManagement/MediaCollections/entry/src/main/ets/Application/MyAbilityStage.ts b/code/BasicFeature/FileManagement/MediaCollections/entry/src/main/ets/Application/MyAbilityStage.ts index 8048c5bbbb2ac7b19779d9ca02d489b51f347ba6..f2ab17da2aad1f023e68e01d5ac1e2328bcad6cc 100644 --- a/code/BasicFeature/FileManagement/MediaCollections/entry/src/main/ets/Application/MyAbilityStage.ts +++ b/code/BasicFeature/FileManagement/MediaCollections/entry/src/main/ets/Application/MyAbilityStage.ts @@ -13,7 +13,7 @@ * limitations under the License. */ -import AbilityStage from "@ohos.application.AbilityStage" +import AbilityStage from '@ohos.app.ability.AbilityStage' export default class MyAbilityStage extends AbilityStage { onCreate() { diff --git a/code/BasicFeature/FileManagement/MediaCollections/entry/src/main/ets/MainAbility/MainAbility.ts b/code/BasicFeature/FileManagement/MediaCollections/entry/src/main/ets/MainAbility/MainAbility.ts index 08e50ca24a45afb9f1c590c7d5d63b46749fca47..87c487c9a682645f1b0a5d53ee66c7ab55462708 100644 --- a/code/BasicFeature/FileManagement/MediaCollections/entry/src/main/ets/MainAbility/MainAbility.ts +++ b/code/BasicFeature/FileManagement/MediaCollections/entry/src/main/ets/MainAbility/MainAbility.ts @@ -13,10 +13,10 @@ * limitations under the License. */ -import Ability from '@ohos.application.Ability' +import UIAbility from '@ohos.app.ability.UIAbility' import display from '@ohos.display' -export default class MainAbility extends Ability { +export default class MainAbility extends UIAbility { async onCreate(want, launchParam) { console.log("[Demo] MainAbility onCreate") } @@ -27,7 +27,7 @@ export default class MainAbility extends Ability { async onWindowStageCreate(windowStage) { console.log("[Demo] MainAbility onWindowStageCreate") - let abilityDisplay = await display.getDefaultDisplay() + let abilityDisplay = await display.getDefaultDisplaySync() let abilityDisplayWidth = abilityDisplay.width const displayWidth: number = 2500 if (abilityDisplayWidth > displayWidth) { diff --git a/code/BasicFeature/FileManagement/MediaCollections/entry/src/main/ets/phoneView/TitleBar.ets b/code/BasicFeature/FileManagement/MediaCollections/entry/src/main/ets/phoneView/TitleBar.ets index 8eaa2d77438767e3661a6921c0b25a00756e2fc0..17dac52989a4287895ee6c79c40c71d9144a111a 100644 --- a/code/BasicFeature/FileManagement/MediaCollections/entry/src/main/ets/phoneView/TitleBar.ets +++ b/code/BasicFeature/FileManagement/MediaCollections/entry/src/main/ets/phoneView/TitleBar.ets @@ -23,7 +23,7 @@ const TAG = 'InputDialog: ' @Component export struct TitleBar { - @Link isPlaying: $isPlaying + @Link isPlaying: boolean @Link currentTime: number @Link myMedia: myMedia @Prop httpUrl: string diff --git a/code/BasicFeature/FileManagement/MediaCollections/package.json b/code/BasicFeature/FileManagement/MediaCollections/package.json index 452cfd37457efb67c7ed98b8f0ea14a910485fd6..ae72abfe24f3f98464835cd411b37f8a9f260fea 100644 --- a/code/BasicFeature/FileManagement/MediaCollections/package.json +++ b/code/BasicFeature/FileManagement/MediaCollections/package.json @@ -11,8 +11,8 @@ "repository": {}, "version": "1.0.0", "dependencies": { - "@ohos/hypium": "1.0.2", - "@ohos/hvigor-ohos-plugin": "1.2.2", - "@ohos/hvigor": "1.2.2" + "@ohos/hypium": "1.0.3", + "@ohos/hvigor-ohos-plugin": "1.3.1", + "@ohos/hvigor": "1.3.1" } -} +} \ No newline at end of file diff --git a/code/BasicFeature/IDL/AbilityConnectServiceExtension/.gitignore b/code/BasicFeature/IDL/AbilityConnectServiceExtension/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..40bf74cf5cf5b5d5684f825894771423088a8936 --- /dev/null +++ b/code/BasicFeature/IDL/AbilityConnectServiceExtension/.gitignore @@ -0,0 +1,6 @@ +/node_modules +/local.properties +/.idea +**/build +/.hvigor +**/package-lock.json \ No newline at end of file diff --git a/code/BasicFeature/IDL/AbilityConnectServiceExtension/README_zh.md b/code/BasicFeature/IDL/AbilityConnectServiceExtension/README_zh.md index 5021e8534f4b8fba79122635a23bee19ac12126c..11984ad563cafe22773316f89318fc05816a2ad6 100644 --- a/code/BasicFeature/IDL/AbilityConnectServiceExtension/README_zh.md +++ b/code/BasicFeature/IDL/AbilityConnectServiceExtension/README_zh.md @@ -24,9 +24,9 @@ 1.本示例仅支持标准系统上运行。 -2.本示例为stage模型,仅支持API9版本SDK,版本号:3.2.5.6 Beta2。 +2.本示例为stage模型,仅支持API9版本SDK,版本号:3.2.10.6。 -3.本示例需要使用DevEco Studio 3.0 Release (Build Version: 3.0.0.993, built on September 4, 2022)才可编译运行。 +3.本示例需要使用DevEco Studio 3.1 Canary1 (Build Version: 3.1.0.100)才可编译运行。 4.本示例使用了ServiceExtensionAbility相关系统接口,需要替换Full SDK,使用Full SDK时需要手动从镜像站点获取,并在DevEco Studio中替换,具体操作可参考[替换指南](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/quick-start/full-sdk-switch-guide.md)。 diff --git a/code/BasicFeature/IDL/AbilityConnectServiceExtension/entry/src/main/ets/Application/MyAbilityStage.ts b/code/BasicFeature/IDL/AbilityConnectServiceExtension/entry/src/main/ets/Application/MyAbilityStage.ts index 790335755e9fcb43f8ff87180c5743575feb4eec..162bedd6db6e0bf6648891ea4d3c23dae39a9fd6 100644 --- a/code/BasicFeature/IDL/AbilityConnectServiceExtension/entry/src/main/ets/Application/MyAbilityStage.ts +++ b/code/BasicFeature/IDL/AbilityConnectServiceExtension/entry/src/main/ets/Application/MyAbilityStage.ts @@ -14,7 +14,7 @@ */ import Logger from '../util/Logger' -import AbilityStage from "@ohos.application.AbilityStage" +import AbilityStage from '@ohos.app.ability.AbilityStage' export default class MyAbilityStage extends AbilityStage { onCreate() { diff --git a/code/BasicFeature/IDL/AbilityConnectServiceExtension/entry/src/main/ets/MainAbility/MainAbility.ts b/code/BasicFeature/IDL/AbilityConnectServiceExtension/entry/src/main/ets/MainAbility/MainAbility.ts index 3ee04ff1bdbb01d414449b41075e8c4ea60ab762..59642e0ca1852187d6d89097ac90c8ab74abd2c5 100644 --- a/code/BasicFeature/IDL/AbilityConnectServiceExtension/entry/src/main/ets/MainAbility/MainAbility.ts +++ b/code/BasicFeature/IDL/AbilityConnectServiceExtension/entry/src/main/ets/MainAbility/MainAbility.ts @@ -13,13 +13,13 @@ * limitations under the License. */ -import Ability from '@ohos.application.Ability' +import UIAbility from '@ohos.app.ability.UIAbility' import Window from '@ohos.window' import Logger from '../util/Logger' const TAG: string = 'MainAbility' -export default class MainAbility extends Ability { +export default class MainAbility extends UIAbility { onCreate(want, launchParam) { Logger.info(TAG, 'MainAbility onCreate') } diff --git a/code/BasicFeature/IDL/AbilityConnectServiceExtension/entry/src/main/ets/serviceExtensionAbility/ServiceExtAbility.ts b/code/BasicFeature/IDL/AbilityConnectServiceExtension/entry/src/main/ets/serviceExtensionAbility/ServiceExtAbility.ts index e304897c4cbc34f8e2469ab93f43e0b3d40e4551..456756aff4cf9c045248f0c2d983901e25b30dd7 100644 --- a/code/BasicFeature/IDL/AbilityConnectServiceExtension/entry/src/main/ets/serviceExtensionAbility/ServiceExtAbility.ts +++ b/code/BasicFeature/IDL/AbilityConnectServiceExtension/entry/src/main/ets/serviceExtensionAbility/ServiceExtAbility.ts @@ -13,7 +13,7 @@ * limitations under the License. */ -import Extension from '@ohos.application.ServiceExtensionAbility' +import ServiceExtension from '@ohos.app.ability.ServiceExtensionAbility' import IdlWeatherServiceStub from '../MainAbility/data/IIdlWeatherServiceTS/idl_weather_service_stub' import { updateWeatherCallback } from "../MainAbility/data/IIdlWeatherServiceTS/i_idl_weather_service" import { getUpdateTemperature } from '../mock/RequestData' @@ -31,7 +31,7 @@ class WeatherServiceStub extends IdlWeatherServiceStub { } } -export default class ServiceExtAbility extends Extension { +export default class ServiceExtAbility extends ServiceExtension { onCreate(want) { Logger.info(`onCreate, want: ${want.abilityName}`) } diff --git a/code/BasicFeature/IDL/AbilityConnectServiceExtension/package.json b/code/BasicFeature/IDL/AbilityConnectServiceExtension/package.json index 3c9b041f7ff57554656a60a56769448641954147..f07f964762d36b917b479780ed98632c6012f0e7 100644 --- a/code/BasicFeature/IDL/AbilityConnectServiceExtension/package.json +++ b/code/BasicFeature/IDL/AbilityConnectServiceExtension/package.json @@ -11,8 +11,8 @@ "repository": {}, "version": "1.0.0", "dependencies": { - "@ohos/hypium": "1.0.2", - "@ohos/hvigor-ohos-plugin": "1.2.2", - "@ohos/hvigor": "1.2.2" + "@ohos/hypium": "1.0.3", + "@ohos/hvigor-ohos-plugin": "1.3.1", + "@ohos/hvigor": "1.3.1" } } \ No newline at end of file diff --git a/code/BasicFeature/Internationalnation/ResourceManager/README_zh.md b/code/BasicFeature/Internationalnation/ResourceManager/README_zh.md index 438ea8de0f89bed8a7cb5229339cc4765c7ad6dd..6c426754cc2b33697642a7a168b2ed1907b607f4 100644 --- a/code/BasicFeature/Internationalnation/ResourceManager/README_zh.md +++ b/code/BasicFeature/Internationalnation/ResourceManager/README_zh.md @@ -26,4 +26,4 @@ 2.本示例需要使用DevEco Studio 3.1 Canary1 (Build Version: 3.1.0.100, built on November 3, 2022)才可编译运行。 -3.本示例仅支持API9版本SDK,版本号:3.2.9.2。 \ No newline at end of file +3.本示例仅支持API9版本SDK,版本号:3.2.10.6。 \ No newline at end of file diff --git a/code/BasicFeature/Internationalnation/ResourceManager/build-profile.json5 b/code/BasicFeature/Internationalnation/ResourceManager/build-profile.json5 index 6b703d87602ec60dc39bb36b8532c343729228a0..7b9532cba89c63c3e39e202b9f68079265f87c49 100644 --- a/code/BasicFeature/Internationalnation/ResourceManager/build-profile.json5 +++ b/code/BasicFeature/Internationalnation/ResourceManager/build-profile.json5 @@ -22,7 +22,8 @@ "name": "default", "signingConfig": "default" } - ] + ], + "signingConfigs": [] }, "modules": [ { diff --git a/code/BasicFeature/Internationalnation/ResourceManager/entry/src/main/ets/entryability/EntryAbility.ets b/code/BasicFeature/Internationalnation/ResourceManager/entry/src/main/ets/entryability/EntryAbility.ets index ee24c2363bdf62a64b99c39dacee3372b6a4b643..153abec5927c57305f9da20c66e525d1aa729d7b 100644 --- a/code/BasicFeature/Internationalnation/ResourceManager/entry/src/main/ets/entryability/EntryAbility.ets +++ b/code/BasicFeature/Internationalnation/ResourceManager/entry/src/main/ets/entryability/EntryAbility.ets @@ -13,11 +13,11 @@ * limitations under the License. */ -import Ability from '@ohos.application.Ability' +import UIAbility from '@ohos.app.ability.UIAbility' import Window from '@ohos.window' import { Logger } from '../utils/Logger' -export default class EntryAbility extends Ability { +export default class EntryAbility extends UIAbility { onCreate(want, launchParam) { Logger.info('Ability onCreate') } diff --git a/code/BasicFeature/Media/Image/entry/src/main/ets/Application/MyAbilityStage.ts b/code/BasicFeature/Media/Image/entry/src/main/ets/Application/MyAbilityStage.ts index 205015bb60b53230ca0b2a86cebad4aa207068dc..71db7ffc7d1137e8d3e218b82b276f311726874d 100644 --- a/code/BasicFeature/Media/Image/entry/src/main/ets/Application/MyAbilityStage.ts +++ b/code/BasicFeature/Media/Image/entry/src/main/ets/Application/MyAbilityStage.ts @@ -13,7 +13,7 @@ * limitations under the License. */ -import AbilityStage from '@ohos.application.AbilityStage' +import AbilityStage from '@ohos.app.ability.AbilityStage' import { logger } from '../../../../../photomodify/src/main/ets/components/util/Logger' const TAG: string = 'MyAbilityStage' diff --git a/code/BasicFeature/Media/Image/entry/src/main/ets/MainAbility/MainAbility.ts b/code/BasicFeature/Media/Image/entry/src/main/ets/MainAbility/MainAbility.ts index ad00e88f884c54c23927a91d8a3e2c6b435fec30..1b28daf35ad3c117d214ed41b264a23ca5ca01a8 100644 --- a/code/BasicFeature/Media/Image/entry/src/main/ets/MainAbility/MainAbility.ts +++ b/code/BasicFeature/Media/Image/entry/src/main/ets/MainAbility/MainAbility.ts @@ -13,15 +13,25 @@ * limitations under the License. */ -import Ability from '@ohos.application.Ability' +import UIAbility from '@ohos.app.ability.UIAbility' +import abilityAccessCtrl from '@ohos.abilityAccessCtrl' import { logger } from '../../../../../photomodify/src/main/ets/components/util/Logger' const TAG: string = 'MainAbility' -export default class MainAbility extends Ability { +export default class MainAbility extends UIAbility { onCreate(want, launchParam) { logger.info(TAG, `[Demo] MainAbility onCreate`) - this.context.requestPermissionsFromUser(['ohos.permission.READ_MEDIA','ohos.permission.WRITE_MEDIA','ohos.permission.MEDIA_LOCATION']) + let atManager = abilityAccessCtrl.createAtManager() + try { + atManager.requestPermissionsFromUser(this.context, ['ohos.permission.READ_MEDIA','ohos.permission.WRITE_MEDIA','ohos.permission.MEDIA_LOCATION']).then((data) => { + logger.info(TAG, `data: ${JSON.stringify(data)}`) + }).catch((err) => { + logger.info(TAG, `err: ${JSON.stringify(err)}`) + }) + } catch (err) { + logger.info(TAG, `catch err->${JSON.stringify(err)}`); + } } onDestroy() { diff --git a/code/BasicFeature/Media/QRCodeScan/.gitignore b/code/BasicFeature/Media/QRCodeScan/.gitignore index 91d237bb144c7fb1777e50271857ef0f593286fc..09751df37c41c009064094c98d5311173795823d 100644 --- a/code/BasicFeature/Media/QRCodeScan/.gitignore +++ b/code/BasicFeature/Media/QRCodeScan/.gitignore @@ -1,5 +1,6 @@ -/node_modules +**/node_modules /local.properties /.idea **/build -/.hvigor \ No newline at end of file +/.hvigor +**/package-lock.json \ No newline at end of file diff --git a/code/BasicFeature/Media/QRCodeScan/Feature/package.json b/code/BasicFeature/Media/QRCodeScan/Feature/package.json index 7fbb5414b6e6912dda46c701c184e6a2ce1456e8..e91295375c34bead1d5d9e7d39cfdae76b0dddca 100644 --- a/code/BasicFeature/Media/QRCodeScan/Feature/package.json +++ b/code/BasicFeature/Media/QRCodeScan/Feature/package.json @@ -9,8 +9,9 @@ }, "main": "Index.ets", "repository": {}, + "type": "module", "version": "1.0.0", "dependencies": { "jsqr": "^1.4.0" } -} +} \ No newline at end of file diff --git a/code/BasicFeature/Media/QRCodeScan/Feature/src/main/ets/qrcodescan/CameraService.ets b/code/BasicFeature/Media/QRCodeScan/Feature/src/main/ets/qrcodescan/CameraService.ets index fdfb1e173c3c2ebb715b26fffebc26678ce044da..3ee2105d1f027521c6ea4287e52d33d52bba7e6f 100644 --- a/code/BasicFeature/Media/QRCodeScan/Feature/src/main/ets/qrcodescan/CameraService.ets +++ b/code/BasicFeature/Media/QRCodeScan/Feature/src/main/ets/qrcodescan/CameraService.ets @@ -97,7 +97,7 @@ class CameraService { */ async releaseCamera() { await this.captureSession.release() - await this.cameraInput.release() + await this.cameraInput.close() await this.photoOutput.release() await this.previewOutput.release() await this.imageReceiver.release() diff --git a/code/BasicFeature/Media/QRCodeScan/Feature/src/main/ets/qrcodescan/QRCodeParser.ets b/code/BasicFeature/Media/QRCodeScan/Feature/src/main/ets/qrcodescan/QRCodeParser.ets index edd96e0195d74116cf60305830e3b5b79d3bcb14..439975fff894be276a4988030a44e656c61bb3be 100644 --- a/code/BasicFeature/Media/QRCodeScan/Feature/src/main/ets/qrcodescan/QRCodeParser.ets +++ b/code/BasicFeature/Media/QRCodeScan/Feature/src/main/ets/qrcodescan/QRCodeParser.ets @@ -17,7 +17,7 @@ import jsQR from 'jsqr' import fileio from '@ohos.fileio' import image from '@ohos.multimedia.image' import mediaLibrary from '@ohos.multimedia.mediaLibrary' -import context from '@ohos.application.context' +import common from '@ohos.app.ability.common' import DateTimeUtil from '../utils/DateTimeUtil' import { CameraService } from './CameraService' import { QRCodeScanConst } from './QRCodeScanConst' @@ -81,7 +81,7 @@ class QRCodeParser { /** * 从相册中获取单张图片 */ - async getSingleImageFromAlbum(context: context.AbilityContext): Promise { + async getSingleImageFromAlbum(context: common.UIAbilityContext): Promise { Logger.info("getSingleImageFromAlbum start") let abilityResult = await context.startAbilityForResult({ bundleName: 'com.ohos.photos', diff --git a/code/BasicFeature/Media/QRCodeScan/Feature/src/main/ets/qrcodescan/components/QRCodeScanComponent.ets b/code/BasicFeature/Media/QRCodeScan/Feature/src/main/ets/qrcodescan/components/QRCodeScanComponent.ets index 764844f11512f5822bf6f329c82c2768e2ac7f7b..2f17dc9835854db6dfcb3bba5c53987f851ff31a 100644 --- a/code/BasicFeature/Media/QRCodeScan/Feature/src/main/ets/qrcodescan/components/QRCodeScanComponent.ets +++ b/code/BasicFeature/Media/QRCodeScan/Feature/src/main/ets/qrcodescan/components/QRCodeScanComponent.ets @@ -16,7 +16,7 @@ import router from '@ohos.router' import image from '@ohos.multimedia.image' import prompt from '@ohos.promptAction' -import context from '@ohos.application.context' +import common from '@ohos.app.ability.common' import { CameraService } from '../CameraService' import { QRCodeScanConst } from '../QRCodeScanConst' import { QRCodeParser } from '../QRCodeParser' @@ -147,7 +147,7 @@ export default struct QRCodeScanComponent { .onClick(async () => { // 打开相册获取图片 this.isQRCodeScanStopped = true - let context = AppStorage.Get('context') as context.AbilityContext + let context = AppStorage.Get('context') as common.UIAbilityContext let image = await this.qrCodeParser.getSingleImageFromAlbum(context) if (image === null) { prompt.showToast({ diff --git a/code/BasicFeature/Media/QRCodeScan/README_zh.md b/code/BasicFeature/Media/QRCodeScan/README_zh.md index 625d5022dfb3cd4828f4ba9c4e2cf74d8dccb017..07b8ca3511460e222426f2982dc32af1b2cc5a72 100644 --- a/code/BasicFeature/Media/QRCodeScan/README_zh.md +++ b/code/BasicFeature/Media/QRCodeScan/README_zh.md @@ -36,6 +36,6 @@ 1.本示例仅支持标准系统上运行,支持设备:RK3568。 -2.本示例仅支持API9版本SDK,本示例涉及使用系统接口:xcomponent.d.ts,需要手动替换Full SDK(3.2.5.6)才能编译通过,具体操作可参考[替换指南](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/quick-start/full-sdk-switch-guide.md)。 +2.本示例仅支持API9版本SDK,本示例涉及使用系统接口:xcomponent.d.ts,需要手动替换Full SDK(3.2.10.6)才能编译通过,具体操作可参考[替换指南](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/quick-start/full-sdk-switch-guide.md)。 -3.本示例需要使用DevEco Studio 3.0 Release (Build Version: 3.0.0.993, built on September 06, 2022)才可编译运行。 \ No newline at end of file +3.本示例需要使用DevEco Studio 3.1 Canary1 (Build Version: 3.1.0.100)才可编译运行。 \ No newline at end of file diff --git a/code/BasicFeature/Media/QRCodeScan/build-profile.json5 b/code/BasicFeature/Media/QRCodeScan/build-profile.json5 index 3bef2b42eb686a7ce38ffafd3a1e969169417c08..f43322f32b9f56a00cc3b63a5fada8abdb6d2b6e 100644 --- a/code/BasicFeature/Media/QRCodeScan/build-profile.json5 +++ b/code/BasicFeature/Media/QRCodeScan/build-profile.json5 @@ -22,7 +22,8 @@ "name": "default", "signingConfig": "default" } - ] + ], + "signingConfigs": [] }, "modules": [ { diff --git a/code/BasicFeature/Media/QRCodeScan/entry/package.json b/code/BasicFeature/Media/QRCodeScan/entry/package.json index c7e95454ab45bdc03abcd34aff9e94e4cd1278d8..8e9397043d132aec20692fa2fde17042421eb994 100644 --- a/code/BasicFeature/Media/QRCodeScan/entry/package.json +++ b/code/BasicFeature/Media/QRCodeScan/entry/package.json @@ -11,7 +11,7 @@ "repository": {}, "version": "1.0.0", "dependencies": { - "jsqr": "^1.4.0", - "@ohos/feature-qr-code-scan": "file:../Feature" + "@ohos/feature-qr-code-scan": "file:../Feature", + "jsqr": "^1.4.0" } -} +} \ No newline at end of file diff --git a/code/BasicFeature/Media/QRCodeScan/entry/src/main/ets/Application/MyAbilityStage.ts b/code/BasicFeature/Media/QRCodeScan/entry/src/main/ets/Application/MyAbilityStage.ts index cff25869dd6013abe42b30c28a9b5580b3956c0a..919a0a97b4b3833642d38e3736a41529d4ab81b2 100644 --- a/code/BasicFeature/Media/QRCodeScan/entry/src/main/ets/Application/MyAbilityStage.ts +++ b/code/BasicFeature/Media/QRCodeScan/entry/src/main/ets/Application/MyAbilityStage.ts @@ -13,7 +13,7 @@ * limitations under the License. */ -import AbilityStage from '@ohos.application.AbilityStage' +import AbilityStage from '@ohos.app.ability.AbilityStage' import { Logger } from '@ohos/feature-qr-code-scan' export default class MyAbilityStage extends AbilityStage { diff --git a/code/BasicFeature/Media/QRCodeScan/entry/src/main/ets/MainAbility/MainAbility.ts b/code/BasicFeature/Media/QRCodeScan/entry/src/main/ets/MainAbility/MainAbility.ts index 75193f2c5259b8fbf923ff2652280c5b7985e02d..64f8c45e342cd50be9b6434b4119907882141e47 100644 --- a/code/BasicFeature/Media/QRCodeScan/entry/src/main/ets/MainAbility/MainAbility.ts +++ b/code/BasicFeature/Media/QRCodeScan/entry/src/main/ets/MainAbility/MainAbility.ts @@ -13,20 +13,26 @@ * limitations under the License. */ -import Ability from '@ohos.application.Ability' +import UIAbility from '@ohos.app.ability.UIAbility' import { Logger, QRCodeScanConst } from '@ohos/feature-qr-code-scan' +import abilityAccessCtrl from '@ohos.abilityAccessCtrl' -const PERMISSIONS: Array = [ - 'ohos.permission.CAMERA', - 'ohos.permission.READ_MEDIA', - 'ohos.permission.WRITE_MEDIA', - 'ohos.permission.MEDIA_LOCATION' -] +const TAG = 'MainAbility' -export default class MainAbility extends Ability { +export default class MainAbility extends UIAbility { async onCreate(want, launchParam) { Logger.info('MainAbility onCreate') - let permissionRequestResult = await this.context.requestPermissionsFromUser(PERMISSIONS) + let atManager = abilityAccessCtrl.createAtManager() + let permissionRequestResult + try { + permissionRequestResult = atManager.requestPermissionsFromUser(this.context, ['ohos.permission.CAMERA', 'ohos.permission.READ_MEDIA', 'ohos.permission.WRITE_MEDIA', 'ohos.permission.MEDIA_LOCATION']).then((data) => { + Logger.info(TAG, `data: ${JSON.stringify(data)}`) + }).catch((err) => { + Logger.info(TAG, `err: ${JSON.stringify(err)}`) + }) + } catch (err) { + Logger.info(TAG, `catch err->${JSON.stringify(err)}`) + } // 如果权限列表中有-1,说明用户拒绝了授权 if (permissionRequestResult.authResults[0] === 0) { // 控制相机是否打开 diff --git a/code/BasicFeature/Media/QRCodeScan/package.json b/code/BasicFeature/Media/QRCodeScan/package.json index 3a75c8c837d8c4c4c2777083c7a375cbcabab8d6..b4fc1a539bca3a4c8c9af9e5eecb0625db1a45f5 100644 --- a/code/BasicFeature/Media/QRCodeScan/package.json +++ b/code/BasicFeature/Media/QRCodeScan/package.json @@ -11,8 +11,8 @@ "repository": {}, "version": "1.0.0", "dependencies": { - "@ohos/hypium": "1.0.2", - "@ohos/hvigor-ohos-plugin": "1.2.2", - "@ohos/hvigor": "1.2.2" + "@ohos/hypium": "1.0.3", + "@ohos/hvigor-ohos-plugin": "1.3.1", + "@ohos/hvigor": "1.3.1" } -} +} \ No newline at end of file diff --git a/code/BasicFeature/Media/VideoShow/.gitignore b/code/BasicFeature/Media/VideoShow/.gitignore index 91d237bb144c7fb1777e50271857ef0f593286fc..09751df37c41c009064094c98d5311173795823d 100644 --- a/code/BasicFeature/Media/VideoShow/.gitignore +++ b/code/BasicFeature/Media/VideoShow/.gitignore @@ -1,5 +1,6 @@ -/node_modules +**/node_modules /local.properties /.idea **/build -/.hvigor \ No newline at end of file +/.hvigor +**/package-lock.json \ No newline at end of file diff --git a/code/BasicFeature/Media/VideoShow/README_zh.md b/code/BasicFeature/Media/VideoShow/README_zh.md index 34e9ee047b45c3e1f01ec9dbfa301c3b1ba3321a..1b86d7e339b390e470b2508b0f50affaff88389a 100644 --- a/code/BasicFeature/Media/VideoShow/README_zh.md +++ b/code/BasicFeature/Media/VideoShow/README_zh.md @@ -30,6 +30,6 @@ 1.本示例仅支持标准系统上运行,支持设备:RK3568。 -2.本示例仅支持API version 9版本SDK,版本号:3.2.5.5。 +2.本示例仅支持API version 9版本SDK,版本号:3.2.10.6。 -3.本示例需要使用DevEco Studio 3.0 Beta4 (Build Version: 3.0.0.992, built on July 14, 2022)才可编译运行。 \ No newline at end of file +3.本示例需要使用DevEco Studio 3.1 Canary1 (Build Version: 3.1.0.100)及以上才可编译运行。 \ No newline at end of file diff --git a/code/BasicFeature/Media/VideoShow/VideoComponent/package.json b/code/BasicFeature/Media/VideoShow/VideoComponent/package.json index ad95962b8606f1e1addf1c4fe7b7ae8fa62de729..08f83c1aaeb4d88876c5c2048dff31b852e51f24 100644 --- a/code/BasicFeature/Media/VideoShow/VideoComponent/package.json +++ b/code/BasicFeature/Media/VideoShow/VideoComponent/package.json @@ -12,4 +12,4 @@ "type": "module", "version": "1.0.3", "dependencies": {} -} +} \ No newline at end of file diff --git a/code/BasicFeature/Media/VideoShow/build-profile.json5 b/code/BasicFeature/Media/VideoShow/build-profile.json5 index d478ba2fafdd512b210b77d29b21a0f55c3e185c..7617475ea187e1c9d23a8c38cd6f719e42f921f6 100644 --- a/code/BasicFeature/Media/VideoShow/build-profile.json5 +++ b/code/BasicFeature/Media/VideoShow/build-profile.json5 @@ -23,6 +23,7 @@ "signingConfig": "default" } ], + "signingConfigs": [] }, "modules": [ { diff --git a/code/BasicFeature/Media/VideoShow/entry/package.json b/code/BasicFeature/Media/VideoShow/entry/package.json index 54395994274107a286199d109bbc5611ae7765ff..5f0a5a4c4d0fb3190bd7e446214b6cf8cf3a06a3 100644 --- a/code/BasicFeature/Media/VideoShow/entry/package.json +++ b/code/BasicFeature/Media/VideoShow/entry/package.json @@ -13,4 +13,4 @@ "dependencies": { "@ohos/video-component": "file:../VideoComponent" } -} +} \ No newline at end of file diff --git a/code/BasicFeature/Media/VideoShow/entry/src/main/ets/Application/MyAbilityStage.ts b/code/BasicFeature/Media/VideoShow/entry/src/main/ets/Application/MyAbilityStage.ts index 6ceb0c290ae831a45143a5e2b42d4351f2fc3d7e..96b3bafbd9bf3ea45742b10669bb03dd324e9750 100644 --- a/code/BasicFeature/Media/VideoShow/entry/src/main/ets/Application/MyAbilityStage.ts +++ b/code/BasicFeature/Media/VideoShow/entry/src/main/ets/Application/MyAbilityStage.ts @@ -12,7 +12,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import AbilityStage from "@ohos.application.AbilityStage" +import AbilityStage from '@ohos.app.ability.AbilityStage' export default class MyAbilityStage extends AbilityStage { onCreate() { diff --git a/code/BasicFeature/Media/VideoShow/entry/src/main/ets/MainAbility/MainAbility.ts b/code/BasicFeature/Media/VideoShow/entry/src/main/ets/MainAbility/MainAbility.ts index 508b7a97605e9e920fe1a8ad6e79b2344654e464..06adbecfe1551f06f3daa8b8a751637b1e2e6c4b 100644 --- a/code/BasicFeature/Media/VideoShow/entry/src/main/ets/MainAbility/MainAbility.ts +++ b/code/BasicFeature/Media/VideoShow/entry/src/main/ets/MainAbility/MainAbility.ts @@ -12,9 +12,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import Ability from '@ohos.application.Ability' +import UIAbility from '@ohos.app.ability.UIAbility' -export default class MainAbility extends Ability { +export default class MainAbility extends UIAbility { onCreate(want, launchParam) { console.log("[Demo] MainAbility onCreate") } diff --git a/code/BasicFeature/Notification/CustomCommonEvent/.gitignore b/code/BasicFeature/Notification/CustomCommonEvent/.gitignore index 91d237bb144c7fb1777e50271857ef0f593286fc..09751df37c41c009064094c98d5311173795823d 100644 --- a/code/BasicFeature/Notification/CustomCommonEvent/.gitignore +++ b/code/BasicFeature/Notification/CustomCommonEvent/.gitignore @@ -1,5 +1,6 @@ -/node_modules +**/node_modules /local.properties /.idea **/build -/.hvigor \ No newline at end of file +/.hvigor +**/package-lock.json \ No newline at end of file diff --git a/code/BasicFeature/Notification/CustomCommonEvent/README_zh.md b/code/BasicFeature/Notification/CustomCommonEvent/README_zh.md index 9aaf566dca5e41483bf35549c30ae204a668ff01..478f1abd6c80a32099e4c475c7122fb55bd0a92e 100644 --- a/code/BasicFeature/Notification/CustomCommonEvent/README_zh.md +++ b/code/BasicFeature/Notification/CustomCommonEvent/README_zh.md @@ -48,6 +48,6 @@ 2.本示例为Stage模型,从API version 9开始支持。 -3.本示例需要使用DevEco Studio 3.0 Beta4 (Build Version: 3.0.0.992, built on July 14, 2022)才可编译运行。 +3.本示例需要使用DevEco Studio 3.1 Canary1 (Build Version: 3.1.0.100)及以上才可编译运行。 4.本示例运行需要具有系统应用签名,因此需要手动配置系统应用的权限签名(具体操作可查看[自动化签名方案](https://developer.harmonyos.com/cn/docs/documentation/doc-guides/ohos-auto-configuring-signature-information-0000001271659465)),需要注意的是,在修改签名json文件时,不需要调整“apl”字段,需要调整“app-feature”字段为“hos_system_app”。 diff --git a/code/BasicFeature/Notification/CustomCommonEvent/entry/package.json b/code/BasicFeature/Notification/CustomCommonEvent/entry/package.json index 29732ffea047ab4e9d897d4cc7092f5e7fe3493f..db08bbf9d7439623fcfa4093ab7f013633c62d48 100644 --- a/code/BasicFeature/Notification/CustomCommonEvent/entry/package.json +++ b/code/BasicFeature/Notification/CustomCommonEvent/entry/package.json @@ -11,4 +11,4 @@ "repository": {}, "version": "1.0.0", "dependencies": {} -} +} \ No newline at end of file diff --git a/code/BasicFeature/Notification/CustomCommonEvent/entry/src/main/ets/Application/MyAbilityStage.ts b/code/BasicFeature/Notification/CustomCommonEvent/entry/src/main/ets/Application/MyAbilityStage.ts index 83d2be7264e09d2382b59bee219a9d91e14a69ee..0b8f194a9906ddb7bf173a7d44b1f88e4ac84119 100644 --- a/code/BasicFeature/Notification/CustomCommonEvent/entry/src/main/ets/Application/MyAbilityStage.ts +++ b/code/BasicFeature/Notification/CustomCommonEvent/entry/src/main/ets/Application/MyAbilityStage.ts @@ -13,7 +13,7 @@ * limitations under the License. */ -import AbilityStage from "@ohos.application.AbilityStage" +import AbilityStage from '@ohos.app.ability.AbilityStage' import Logger from '../module/Logger' export default class MyAbilityStage extends AbilityStage { diff --git a/code/BasicFeature/Notification/CustomCommonEvent/entry/src/main/ets/LauncherAbility/LauncherAbility.ts b/code/BasicFeature/Notification/CustomCommonEvent/entry/src/main/ets/LauncherAbility/LauncherAbility.ts index 7dbeb5fe1d19e1ae66b1710fe7e18e92873b1025..04259496432cd80e6faad3d21dfac14ef19944e6 100644 --- a/code/BasicFeature/Notification/CustomCommonEvent/entry/src/main/ets/LauncherAbility/LauncherAbility.ts +++ b/code/BasicFeature/Notification/CustomCommonEvent/entry/src/main/ets/LauncherAbility/LauncherAbility.ts @@ -13,14 +13,14 @@ * limitations under the License. */ -import Ability from '@ohos.application.Ability' +import UIAbility from '@ohos.app.ability.UIAbility' import commonEvent from '@ohos.commonEvent' import consts from '../module/Consts' import dataPreferences from '@ohos.data.preferences' import surveillanceEventsManager from '../module/SurveillanceEventsManager' import Logger from '../module/Logger' -export default class LauncherAbility extends Ability { +export default class LauncherAbility extends UIAbility { onCreate(want) { globalThis.abilityWant = want let settings: Map = new Map() diff --git a/code/BasicFeature/Notification/CustomCommonEvent/entry/src/main/ets/MainAbility/MainAbility.ts b/code/BasicFeature/Notification/CustomCommonEvent/entry/src/main/ets/MainAbility/MainAbility.ts index 8e879368eb52d06eab59e5893a172384e61c5fac..490757d737f3afb4edeec435c1c7e9ae221a0687 100644 --- a/code/BasicFeature/Notification/CustomCommonEvent/entry/src/main/ets/MainAbility/MainAbility.ts +++ b/code/BasicFeature/Notification/CustomCommonEvent/entry/src/main/ets/MainAbility/MainAbility.ts @@ -13,10 +13,10 @@ * limitations under the License. */ -import Ability from '@ohos.application.Ability' +import UIAbility from '@ohos.app.ability.UIAbility' import Logger from '../module/Logger' -export default class MainAbility extends Ability { +export default class MainAbility extends UIAbility { onCreate(want, launchParam) { Logger.info("MainAbility onCreate") globalThis.abilityWant = want; diff --git a/code/BasicFeature/Notification/CustomCommonEvent/entry/src/main/ets/feature/HistoryFeature.ts b/code/BasicFeature/Notification/CustomCommonEvent/entry/src/main/ets/feature/HistoryFeature.ts index 87ef06b870a8c7a33b516be235692a1d6c4e47b5..3cf8fc228506259617f412f2b914eb6136b6e8e0 100644 --- a/code/BasicFeature/Notification/CustomCommonEvent/entry/src/main/ets/feature/HistoryFeature.ts +++ b/code/BasicFeature/Notification/CustomCommonEvent/entry/src/main/ets/feature/HistoryFeature.ts @@ -13,12 +13,12 @@ * limitations under the License. */ -import context from '@ohos.application.context' +import common from '@ohos.app.ability.common' import consts from '../module/Consts' import dataPreferences from '@ohos.data.preferences' export default class HistoryFeature { - constructor(abilityContext: context.AbilityContext) { + constructor(abilityContext: common.UIAbilityContext) { this.innerContext = abilityContext } @@ -46,5 +46,5 @@ export default class HistoryFeature { } private dataSource: Array> = [] - private innerContext: context.AbilityContext = null + private innerContext: common.UIAbilityContext = null } \ No newline at end of file diff --git a/code/BasicFeature/Notification/CustomCommonEvent/entry/src/main/ets/feature/LaunchFeature.ts b/code/BasicFeature/Notification/CustomCommonEvent/entry/src/main/ets/feature/LaunchFeature.ts index 633c14e66a81d9235f05f838f4d7276a0781e539..814213cd2afbcafbd7283918aa71f01cdbb91395 100644 --- a/code/BasicFeature/Notification/CustomCommonEvent/entry/src/main/ets/feature/LaunchFeature.ts +++ b/code/BasicFeature/Notification/CustomCommonEvent/entry/src/main/ets/feature/LaunchFeature.ts @@ -13,7 +13,7 @@ * limitations under the License. */ -import context from '@ohos.application.context' +import common from '@ohos.app.ability.common' import commonEvent from '@ohos.commonEvent' import consts from '../module/Consts' import dataPreferences from '@ohos.data.preferences' @@ -21,13 +21,13 @@ import Logger from '../module/Logger' import router from '@ohos.router' export default class LaunchFeature { - private innerContext: context.AbilityContext = null + private innerContext: common.UIAbilityContext = null private pref: dataPreferences.Preferences = null private subscriber = null private subscriberLow = null private currentRecordTimes: number = 0 - constructor(abilityContext: context.AbilityContext) { + constructor(abilityContext: common.UIAbilityContext) { this.innerContext = abilityContext } diff --git a/code/BasicFeature/Notification/CustomCommonEvent/entry/src/main/ets/feature/SettingFeature.ts b/code/BasicFeature/Notification/CustomCommonEvent/entry/src/main/ets/feature/SettingFeature.ts index 27b2640d135611b4a8866d2a35e6ccf6b48fb124..f6fec15988b8a75846e3a0b9c310c13b616dd75e 100644 --- a/code/BasicFeature/Notification/CustomCommonEvent/entry/src/main/ets/feature/SettingFeature.ts +++ b/code/BasicFeature/Notification/CustomCommonEvent/entry/src/main/ets/feature/SettingFeature.ts @@ -14,17 +14,17 @@ */ import commonEvent from '@ohos.commonEvent' -import context from '@ohos.application.context' +import common from '@ohos.app.ability.common' import consts from '../module/Consts' import dataPreferences from '@ohos.data.preferences' import Logger from '../module/Logger' import surveillanceEventsManager from '../module/SurveillanceEventsManager' export default class SettingFeature { - private innerContext: context.AbilityContext = null + private innerContext: common.UIAbilityContext = null private pref: dataPreferences.Preferences = null - constructor(abilityContext: context.AbilityContext) { + constructor(abilityContext: common.UIAbilityContext) { this.innerContext = abilityContext } diff --git a/code/BasicFeature/Notification/CustomCommonEvent/entry/src/main/ets/pages/History.ets b/code/BasicFeature/Notification/CustomCommonEvent/entry/src/main/ets/pages/History.ets index 9fcde39b68b55f2bf7413102f22bbd2c27551e35..91d30efb60ca33baf089f335ac61c33a2b817122 100644 --- a/code/BasicFeature/Notification/CustomCommonEvent/entry/src/main/ets/pages/History.ets +++ b/code/BasicFeature/Notification/CustomCommonEvent/entry/src/main/ets/pages/History.ets @@ -13,14 +13,14 @@ * limitations under the License. */ -import context from '@ohos.application.context' +import common from '@ohos.app.ability.common' import historyFeature from '../feature/HistoryFeature' import { Header } from '../component/Header' @Entry @Component struct History { - private feature: historyFeature = new historyFeature(getContext() as context.AbilityContext) + private feature: historyFeature = new historyFeature(getContext() as common.UIAbilityContext) @State arr: Array> = [] async onPageShow() { diff --git a/code/BasicFeature/Notification/CustomCommonEvent/entry/src/main/ets/pages/Launch.ets b/code/BasicFeature/Notification/CustomCommonEvent/entry/src/main/ets/pages/Launch.ets index 4d1aa3c504dab46437d0347aa78397d2f2da44eb..a8df8baa0dfd5dca258d65a6ec5b4e1674c2c70a 100644 --- a/code/BasicFeature/Notification/CustomCommonEvent/entry/src/main/ets/pages/Launch.ets +++ b/code/BasicFeature/Notification/CustomCommonEvent/entry/src/main/ets/pages/Launch.ets @@ -13,13 +13,13 @@ * limitations under the License. */ -import context from '@ohos.application.context' +import common from '@ohos.app.ability.common' import launchFeature from '../feature/LaunchFeature' @Entry @Component struct Launch { - private feature :launchFeature = new launchFeature(getContext() as context.AbilityContext) + private feature :launchFeature = new launchFeature(getContext() as common.UIAbilityContext) async onPageShow() { await this.feature.init() diff --git a/code/BasicFeature/Notification/CustomCommonEvent/entry/src/main/ets/pages/Setting.ets b/code/BasicFeature/Notification/CustomCommonEvent/entry/src/main/ets/pages/Setting.ets index 1bedd19dc26f34c30e0f193ad58619d202f46267..28dc11788edf97f39d9dfd782b25f15a2d52a49d 100644 --- a/code/BasicFeature/Notification/CustomCommonEvent/entry/src/main/ets/pages/Setting.ets +++ b/code/BasicFeature/Notification/CustomCommonEvent/entry/src/main/ets/pages/Setting.ets @@ -14,7 +14,7 @@ */ import commonEvent from '@ohos.commonEvent' -import context from '@ohos.application.context' +import common from '@ohos.app.ability.common' import settingFeature from '../feature/SettingFeature' import surveillanceEventsManager from '../module/SurveillanceEventsManager' import { Header } from '../component/Header' @@ -22,7 +22,7 @@ import { Header } from '../component/Header' @Entry @Component struct Setting { - private feature:settingFeature = new settingFeature(getContext() as context.AbilityContext) + private feature:settingFeature = new settingFeature(getContext() as common.UIAbilityContext) private dataSource: Array> = [ [commonEvent.Support.COMMON_EVENT_WIFI_POWER_STATE, $r('app.string.enable_wifi')], [commonEvent.Support.COMMON_EVENT_SCREEN_OFF, $r('app.string.enable_screen_off')], diff --git a/code/BasicFeature/Notification/CustomCommonEvent/package.json b/code/BasicFeature/Notification/CustomCommonEvent/package.json index 9bb8cab2057158348a29aa064933181949a983a1..bdea5bc8c40f47c17f718b0ee4678a971b78ae80 100644 --- a/code/BasicFeature/Notification/CustomCommonEvent/package.json +++ b/code/BasicFeature/Notification/CustomCommonEvent/package.json @@ -11,8 +11,8 @@ "repository": {}, "version": "1.0.0", "dependencies": { - "@ohos/hypium": "1.0.1", - "@ohos/hvigor-ohos-plugin": "1.1.6", - "@ohos/hvigor": "1.1.6" + "@ohos/hypium": "1.0.3", + "@ohos/hvigor-ohos-plugin": "1.3.1", + "@ohos/hvigor": "1.3.1" } } \ No newline at end of file diff --git a/code/BasicFeature/Notification/CustomEmitter/.gitignore b/code/BasicFeature/Notification/CustomEmitter/.gitignore index 91d237bb144c7fb1777e50271857ef0f593286fc..09751df37c41c009064094c98d5311173795823d 100644 --- a/code/BasicFeature/Notification/CustomEmitter/.gitignore +++ b/code/BasicFeature/Notification/CustomEmitter/.gitignore @@ -1,5 +1,6 @@ -/node_modules +**/node_modules /local.properties /.idea **/build -/.hvigor \ No newline at end of file +/.hvigor +**/package-lock.json \ No newline at end of file diff --git a/code/BasicFeature/Notification/CustomEmitter/README_zh.md b/code/BasicFeature/Notification/CustomEmitter/README_zh.md index 9068dced8b7d178afbcc47db4fffd08846d7befa..355003efe976ce68c9adecc3ee9c9f308152ead7 100644 --- a/code/BasicFeature/Notification/CustomEmitter/README_zh.md +++ b/code/BasicFeature/Notification/CustomEmitter/README_zh.md @@ -31,6 +31,6 @@ 1.本示例仅支持标准系统上运行,支持设备:RK3568。 -2.本示例仅支持API9版本SDK,版本号:3.2.7.6 Beta3。 +2.本示例仅支持API9版本SDK,版本号:3.2.10.6。 -3.本示例需要使用DevEco Studio 3.0.0.993 Release (Build Version: 3.0.0.993, built on September 4, 2022)才可编译运行。 \ No newline at end of file +3.本示例需要使用DevEco Studio 3.1 Canary1 (Build Version: 3.1.0.100)及以上才可编译运行。 \ No newline at end of file diff --git a/code/BasicFeature/Notification/CustomEmitter/entry/package.json b/code/BasicFeature/Notification/CustomEmitter/entry/package.json index 761cc293a55bcec6e55f2cefa76122b9dbcc8fcd..a6702a9278f71245c611acc5d398729aa46faa6f 100644 --- a/code/BasicFeature/Notification/CustomEmitter/entry/package.json +++ b/code/BasicFeature/Notification/CustomEmitter/entry/package.json @@ -13,4 +13,4 @@ "dependencies": { "@ohos/emitter": "../feature/emitter" } -} +} \ No newline at end of file diff --git a/code/BasicFeature/Notification/CustomEmitter/entry/src/main/ets/Application/MyAbilityStage.ts b/code/BasicFeature/Notification/CustomEmitter/entry/src/main/ets/Application/MyAbilityStage.ts index f7599d903e553308de5ccd62151cc75e5a1ed095..12dd9ecf55851241d89b48723382731b01408311 100644 --- a/code/BasicFeature/Notification/CustomEmitter/entry/src/main/ets/Application/MyAbilityStage.ts +++ b/code/BasicFeature/Notification/CustomEmitter/entry/src/main/ets/Application/MyAbilityStage.ts @@ -14,7 +14,7 @@ */ import Logger from '../util/Logger' -import AbilityStage from '@ohos.application.AbilityStage' +import AbilityStage from '@ohos.app.ability.AbilityStage' const TAG: string = 'MyAbilityStage' diff --git a/code/BasicFeature/Notification/CustomEmitter/entry/src/main/ets/MainAbility/MainAbility.ts b/code/BasicFeature/Notification/CustomEmitter/entry/src/main/ets/MainAbility/MainAbility.ts index d05aed8db14a896d2b7f12f0d9fb653fa706dc7c..c3f04b303aef9239b8cbb2e7464cc9930433dd55 100644 --- a/code/BasicFeature/Notification/CustomEmitter/entry/src/main/ets/MainAbility/MainAbility.ts +++ b/code/BasicFeature/Notification/CustomEmitter/entry/src/main/ets/MainAbility/MainAbility.ts @@ -14,12 +14,12 @@ */ import Logger from '../util/Logger' -import Ability from '@ohos.application.Ability' +import UIAbility from '@ohos.app.ability.UIAbility' import Window from '@ohos.window' const TAG: string = 'MainAbility' -export default class MainAbility extends Ability { +export default class MainAbility extends UIAbility { onCreate(want, launchParam) { Logger.info(TAG, `Ability onCreate want param: ${JSON.stringify(want)} launchParam: ${JSON.stringify(launchParam)}`) } diff --git a/code/BasicFeature/Notification/CustomEmitter/feature/emitter/hvigorfile.ts b/code/BasicFeature/Notification/CustomEmitter/feature/emitter/hvigorfile.ts new file mode 100644 index 0000000000000000000000000000000000000000..42ed4b4a54a873e2b53441556aae93fab24b794f --- /dev/null +++ b/code/BasicFeature/Notification/CustomEmitter/feature/emitter/hvigorfile.ts @@ -0,0 +1,3 @@ +// Script for compiling build behavior. It is built in the build plug-in and cannot be modified currently. +module.exports = require('@ohos/hvigor-ohos-plugin').harTasks + diff --git a/code/BasicFeature/Notification/CustomEmitter/feature/emitter/package.json b/code/BasicFeature/Notification/CustomEmitter/feature/emitter/package.json index 165e0126c3294da3373775e59ee1a4435a9e7c6f..0da4b746716e0d8bd9675cc93c0a3576947098e6 100644 --- a/code/BasicFeature/Notification/CustomEmitter/feature/emitter/package.json +++ b/code/BasicFeature/Notification/CustomEmitter/feature/emitter/package.json @@ -9,6 +9,7 @@ }, "main": "index.ets", "repository": {}, + "type": "module", "version": "1.0.0", "dependencies": {} } \ No newline at end of file diff --git a/code/BasicFeature/Notification/CustomEmitter/package.json b/code/BasicFeature/Notification/CustomEmitter/package.json index 0fd41701dc0134c0d43700524bbbfc0992d40aaa..a02cf1689d6db1fe8b0d97d6d768edaea793616f 100644 --- a/code/BasicFeature/Notification/CustomEmitter/package.json +++ b/code/BasicFeature/Notification/CustomEmitter/package.json @@ -11,8 +11,8 @@ "repository": {}, "version": "1.0.0", "dependencies": { - "@ohos/hypium": "1.0.2", - "@ohos/hvigor-ohos-plugin": "1.2.2", - "@ohos/hvigor": "1.2.2" + "@ohos/hypium": "1.0.3", + "@ohos/hvigor-ohos-plugin": "1.3.1", + "@ohos/hvigor": "1.3.1" } -} +} \ No newline at end of file diff --git a/code/BasicFeature/Notification/CustomNotification/entry/src/main/ets/Application/MyAbilityStage.ts b/code/BasicFeature/Notification/CustomNotification/entry/src/main/ets/Application/MyAbilityStage.ts index f2f28d3e0f868b11cf10aba9d616f04a0a5a9f87..c394767f13b1b490bce0c9f8e21390b5c0c02298 100644 --- a/code/BasicFeature/Notification/CustomNotification/entry/src/main/ets/Application/MyAbilityStage.ts +++ b/code/BasicFeature/Notification/CustomNotification/entry/src/main/ets/Application/MyAbilityStage.ts @@ -13,7 +13,7 @@ * limitations under the License. */ -import AbilityStage from "@ohos.application.AbilityStage" +import AbilityStage from '@ohos.app.ability.AbilityStage' import { logger } from '@ohos/notification' export default class MyAbilityStage extends AbilityStage { diff --git a/code/BasicFeature/Notification/CustomNotification/entry/src/main/ets/MainAbility/MainAbility.ts b/code/BasicFeature/Notification/CustomNotification/entry/src/main/ets/MainAbility/MainAbility.ts index 968139388062bb677b6827e0633f49e8ccf55b98..d654eb9dfab23b0217255668f4e1242d10661aca 100644 --- a/code/BasicFeature/Notification/CustomNotification/entry/src/main/ets/MainAbility/MainAbility.ts +++ b/code/BasicFeature/Notification/CustomNotification/entry/src/main/ets/MainAbility/MainAbility.ts @@ -13,13 +13,13 @@ * limitations under the License. */ -import Ability from '@ohos.application.Ability' +import UIAbility from '@ohos.app.ability.UIAbility' import Window from '@ohos.window' import { logger } from '@ohos/notification' const TAG: string = 'MainAbility' -export default class MainAbility extends Ability { +export default class MainAbility extends UIAbility { onCreate(want, launchParam) { logger.info(TAG, 'Ability onCreate') } diff --git a/code/BasicFeature/Notification/CustomNotification/entry/src/main/ets/feature/NotificationOperations.ets b/code/BasicFeature/Notification/CustomNotification/entry/src/main/ets/feature/NotificationOperations.ets index 47e8ca9c292f821b24b62787544ae3fbbb34e7ee..b228ca74fe23ef9762fb43336efb7e820a813918 100644 --- a/code/BasicFeature/Notification/CustomNotification/entry/src/main/ets/feature/NotificationOperations.ets +++ b/code/BasicFeature/Notification/CustomNotification/entry/src/main/ets/feature/NotificationOperations.ets @@ -21,7 +21,7 @@ import { notificationRequestUtil, wantAgentUtil } from '@ohos/notification' -import notification from '@ohos.notification' +import notification from '@ohos.notificationManager' const TAG: string = 'NotificationOperations' const BUNDLE_NAME: string = 'ohos.samples.customnotification' diff --git a/code/BasicFeature/Notification/CustomNotification/notification/src/main/ets/notification/NotificationContentUtil.ets b/code/BasicFeature/Notification/CustomNotification/notification/src/main/ets/notification/NotificationContentUtil.ets index eb961398602f1a6447ca0bd1d60c62f7edcd3b3c..fc5df2520a84c899841c1a27e9f1d4d698361f8f 100644 --- a/code/BasicFeature/Notification/CustomNotification/notification/src/main/ets/notification/NotificationContentUtil.ets +++ b/code/BasicFeature/Notification/CustomNotification/notification/src/main/ets/notification/NotificationContentUtil.ets @@ -14,14 +14,14 @@ */ import image from '@ohos.multimedia.image' -import notification from '@ohos.notification' +import notification from '@ohos.notificationManager' class NotificationContentUtil { - /** - * init basic notification content - * @param basicContent - * @return return the created NotificationContent - */ + /** + * init basic notification content + * @param basicContent + * @return return the created NotificationContent + */ initBasicNotificationContent(basicContent: notification.NotificationBasicContent) { return { contentType: notification.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, // 通知内容类型 @@ -29,15 +29,15 @@ class NotificationContentUtil { } } - /** - * init longText notification content - * - * @param basicContent - * @param notificationLongText - * @param notificationBriefText - * @param notificationExpandedTitle - * @return return the created NotificationContent - */ + /** + * init longText notification content + * + * @param basicContent + * @param notificationLongText + * @param notificationBriefText + * @param notificationExpandedTitle + * @return return the created NotificationContent + */ initNotificationLongTextContent(basicContent: notification.NotificationBasicContent, notificationLongText: string, notificationBriefText: string, notificationExpandedTitle: string) { return { contentType: notification.ContentType.NOTIFICATION_CONTENT_LONG_TEXT, // 通知内容类型 diff --git a/code/BasicFeature/Notification/CustomNotification/notification/src/main/ets/notification/NotificationRequestUtil.ets b/code/BasicFeature/Notification/CustomNotification/notification/src/main/ets/notification/NotificationRequestUtil.ets index 0a462b701891275d8686264dfa4da6391fbad24e..e09a4f6534a9a0084957ba9a3402218d7b538605 100644 --- a/code/BasicFeature/Notification/CustomNotification/notification/src/main/ets/notification/NotificationRequestUtil.ets +++ b/code/BasicFeature/Notification/CustomNotification/notification/src/main/ets/notification/NotificationRequestUtil.ets @@ -13,7 +13,7 @@ * limitations under the License. */ -import notification from '@ohos.notification' +import notification from '@ohos.notificationManager' import { WantAgent } from '@ohos.wantAgent' class NotificationRequestUtil { diff --git a/code/BasicFeature/Notification/CustomNotification/notification/src/main/ets/notification/NotificationUtil.ets b/code/BasicFeature/Notification/CustomNotification/notification/src/main/ets/notification/NotificationUtil.ets index adc6d8b987f3465fd05c0042832abbb7189e4b73..a82ded0ad3906105e256fc2355c384e59d0ae55d 100644 --- a/code/BasicFeature/Notification/CustomNotification/notification/src/main/ets/notification/NotificationUtil.ets +++ b/code/BasicFeature/Notification/CustomNotification/notification/src/main/ets/notification/NotificationUtil.ets @@ -13,7 +13,7 @@ * limitations under the License. */ -import notification from '@ohos.notification' +import notification from '@ohos.notificationManager' import { logger } from '../util/Logger' const TAG: string = 'NotificationUtilModel' diff --git a/code/BasicFeature/Security/AppAccountManager/README_zh.md b/code/BasicFeature/Security/AppAccountManager/README_zh.md index 06d46f744292eae235e1f03bd848a790d49fee31..aa702acc30537946b2637c18dac78146843467ab 100644 --- a/code/BasicFeature/Security/AppAccountManager/README_zh.md +++ b/code/BasicFeature/Security/AppAccountManager/README_zh.md @@ -31,6 +31,6 @@ 1.本示例仅支持在标准系统上运行。 -2.本示例仅支持API9版本SDK,版本号:3.2.9.2。 +2.本示例仅支持API9版本SDK,版本号:3.2.10.6。 3.本示例需要使用DevEco Studio 3.1 Canary1 (Build Version: 3.1.0.100, built on November 3, 2022)才可编译运行。 \ No newline at end of file diff --git a/code/BasicFeature/Security/AppAccountManager/entry/src/main/ets/entryability/EntryAbility.ts b/code/BasicFeature/Security/AppAccountManager/entry/src/main/ets/entryability/EntryAbility.ts index 202bbb09044acddb6ffe4fbc8c82f2f528498d21..0e910c820528645e0c094901c336db7eef492d65 100644 --- a/code/BasicFeature/Security/AppAccountManager/entry/src/main/ets/entryability/EntryAbility.ts +++ b/code/BasicFeature/Security/AppAccountManager/entry/src/main/ets/entryability/EntryAbility.ts @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 Huawei Device Co., Ltd. + * Copyright (c) 2022-2023 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 @@ -14,12 +14,12 @@ */ import Logger from '../model/Logger' -import Ability from '@ohos.application.Ability' +import UIAbility from '@ohos.app.ability.UIAbility' import Window from '@ohos.window' const TAG: string = '[Index]' -export default class EntryAbility extends Ability { +export default class EntryAbility extends UIAbility { onCreate(want, launchParam) { Logger.info(TAG, `Ability onCreate want param: ` + JSON.stringify(want) ?? '' + 'launchParam:' + JSON.stringify(launchParam) ?? '') } diff --git a/code/BasicFeature/Security/AppAccountManager/entry/src/main/ets/model/AccountData.ts b/code/BasicFeature/Security/AppAccountManager/entry/src/main/ets/model/AccountData.ts index 8bd63881c580e1100a936cdbc951d87b80bf71d5..a9a3917e41ba7e22dae9f5c8402ffe4359d39896 100644 --- a/code/BasicFeature/Security/AppAccountManager/entry/src/main/ets/model/AccountData.ts +++ b/code/BasicFeature/Security/AppAccountManager/entry/src/main/ets/model/AccountData.ts @@ -14,7 +14,7 @@ */ import Logger from '../model/Logger' -import appContext from '@ohos.application.context' +import common from '@ohos.app.ability.common' import preferences from '@ohos.data.preferences' @@ -31,7 +31,7 @@ export class AccountData { return this.instance } - async getFromStorage(context: appContext.Context, url: string) { + async getFromStorage(context: common.Context, url: string) { let name = url Logger.info(TAG, `Name is ${name}`) try { @@ -44,13 +44,13 @@ export class AccountData { } } - async getStorage(context: appContext.Context, url: string) { + async getStorage(context: common.Context, url: string) { this.storage = null await this.getFromStorage(context, url) return this.storage } - async putStorageValue(context: appContext.Context, key: string, value: string, url: string) { + async putStorageValue(context: common.Context, key: string, value: string, url: string) { this.storage = await this.getStorage(context, url) try { await this.storage.put(key, value) @@ -62,7 +62,7 @@ export class AccountData { return } - async hasStorageValue(context: appContext.Context, key: string, url: string) { + async hasStorageValue(context: common.Context, key: string, url: string) { this.storage = await this.getStorage(context, url) let result try { @@ -74,7 +74,7 @@ export class AccountData { return result } - async getStorageValue(context: appContext.Context, key: string, url: string) { + async getStorageValue(context: common.Context, key: string, url: string) { this.storage = await this.getStorage(context, url) let getValue try { @@ -86,7 +86,7 @@ export class AccountData { return getValue } - async deleteStorageValue(context: appContext.Context, key: string, url: string) { + async deleteStorageValue(context: common.Context, key: string, url: string) { this.storage = await this.getStorage(context, url) try { await this.storage.delete(key) diff --git a/code/BasicFeature/Security/Cipher/README.md b/code/BasicFeature/Security/Cipher/README.md index 91fa03edd8376f7e2d0f08b1174417c40cffc349..23685e9e938e05476a5223d484531a005856b467 100644 --- a/code/BasicFeature/Security/Cipher/README.md +++ b/code/BasicFeature/Security/Cipher/README.md @@ -34,4 +34,4 @@ N/A. - This sample can only be run on standard-system devices. -- This sample requires DevEco Studio 3.0 Beta4 (Build Version: 3.0.0.992, built on July 14, 2022) to compile and run. +- This sample requires DevEco Studio 3.1 Canary1 (Build Version: 3.1.0.100) to compile and run. diff --git a/code/BasicFeature/Security/Cipher/README_zh.md b/code/BasicFeature/Security/Cipher/README_zh.md index 4b0acf3ae9171839a99e8261e99981b739131cd2..bab46706dda6657224f9bfbbade277e5d1eb7222 100644 --- a/code/BasicFeature/Security/Cipher/README_zh.md +++ b/code/BasicFeature/Security/Cipher/README_zh.md @@ -38,7 +38,7 @@ AES加密算法:AES密码学中的高级加密标准,又称Rijndael加密法 1.本示例仅支持在标准系统上运行。 -2.本示例仅支持API9版本SDK,版本号:3.2.7.6。 +2.本示例仅支持API9版本SDK,版本号:3.2.10.6。 -3.本示例需要使用DevEco Studio 3.1 Canary1 (Build Version: 3.1.0.100, built on November 3, 2022)才可编译运行。 +3.本示例需要使用DevEco Studio 3.1 Canary1 (Build Version: 3.1.0.100)及以上才可编译运行。 diff --git a/code/BasicFeature/Security/Cipher/build-profile.json5 b/code/BasicFeature/Security/Cipher/build-profile.json5 index 69c4a71a96e14a6f75cdddb1fe35b2e7779f970f..956b202bee75f50ae79d7ff01ce70751673429bd 100644 --- a/code/BasicFeature/Security/Cipher/build-profile.json5 +++ b/code/BasicFeature/Security/Cipher/build-profile.json5 @@ -16,8 +16,8 @@ { "app": { "signingConfigs": [], - "compileSdkVersion": 8, - "compatibleSdkVersion": 8, + "compileSdkVersion": 9, + "compatibleSdkVersion": 9, "products": [ { "name": "default", diff --git a/code/BasicFeature/Security/Cipher/entry/package.json b/code/BasicFeature/Security/Cipher/entry/package.json index 29732ffea047ab4e9d897d4cc7092f5e7fe3493f..db08bbf9d7439623fcfa4093ab7f013633c62d48 100644 --- a/code/BasicFeature/Security/Cipher/entry/package.json +++ b/code/BasicFeature/Security/Cipher/entry/package.json @@ -11,4 +11,4 @@ "repository": {}, "version": "1.0.0", "dependencies": {} -} +} \ No newline at end of file diff --git a/code/BasicFeature/Security/Cipher/entry/src/main/ets/entryability/EntryAbility.ts b/code/BasicFeature/Security/Cipher/entry/src/main/ets/entryability/EntryAbility.ts index 3e04a8ab4a844e856fb8c88c1754bde62bd16d62..c74c3fc23f1d729c5a487fa1bdc88e7dc4267f76 100644 --- a/code/BasicFeature/Security/Cipher/entry/src/main/ets/entryability/EntryAbility.ts +++ b/code/BasicFeature/Security/Cipher/entry/src/main/ets/entryability/EntryAbility.ts @@ -14,12 +14,12 @@ */ import Logger from '../model/Logger' -import Ability from '@ohos.application.Ability' +import UIAbility from '@ohos.app.ability.UIAbility' import Window from '@ohos.window' const TAG: string = '[Index]' -export default class EntryAbility extends Ability { +export default class EntryAbility extends UIAbility { onCreate(want, launchParam) { Logger.info(TAG, `Ability onCreate want param: ` + JSON.stringify(want) ?? '' + 'launchParam:' + JSON.stringify(launchParam) ?? '') } diff --git a/code/BasicFeature/Security/Cipher/package.json b/code/BasicFeature/Security/Cipher/package.json index b7f0c60a76d6d6b41bc47f646c85c54dc7ecf40f..a09aa5296269b31ef03c1b53b84d843a8f0e2f88 100644 --- a/code/BasicFeature/Security/Cipher/package.json +++ b/code/BasicFeature/Security/Cipher/package.json @@ -15,4 +15,4 @@ "@ohos/hvigor-ohos-plugin": "1.3.1", "@ohos/hvigor": "1.3.1" } -} +} \ No newline at end of file diff --git a/code/BasicFeature/TaskManagement/ReminderAgentManager/.gitignore b/code/BasicFeature/TaskManagement/ReminderAgentManager/.gitignore index 91d237bb144c7fb1777e50271857ef0f593286fc..09751df37c41c009064094c98d5311173795823d 100644 --- a/code/BasicFeature/TaskManagement/ReminderAgentManager/.gitignore +++ b/code/BasicFeature/TaskManagement/ReminderAgentManager/.gitignore @@ -1,5 +1,6 @@ -/node_modules +**/node_modules /local.properties /.idea **/build -/.hvigor \ No newline at end of file +/.hvigor +**/package-lock.json \ No newline at end of file diff --git a/code/BasicFeature/TaskManagement/ReminderAgentManager/README_zh.md b/code/BasicFeature/TaskManagement/ReminderAgentManager/README_zh.md index 15260ce9d7278da6dc8d7f41e3d5275b8bc6b1ff..e53ddf51f044ca9abad921dfdbfa07f224244e44 100644 --- a/code/BasicFeature/TaskManagement/ReminderAgentManager/README_zh.md +++ b/code/BasicFeature/TaskManagement/ReminderAgentManager/README_zh.md @@ -54,6 +54,6 @@ 1.本示例仅支持标准系统上运行,支持设备:RK3568。 -2.本示例仅支持API9版本SDK,版本号:3.2.7.5。 +2.本示例仅支持API9版本SDK,版本号:3.2.10.6。 -3.本示例需要使用DevEco Studio 3.0 Release (Build Version: 3.0.0.993, built on September 4, 2022)才可编译运行。 \ No newline at end of file +3.本示例需要使用DevEco Studio 3.1 Canary1 (Build Version: 3.1.0.100)及以上才可编译运行。 \ No newline at end of file diff --git a/code/BasicFeature/TaskManagement/ReminderAgentManager/entry/package.json b/code/BasicFeature/TaskManagement/ReminderAgentManager/entry/package.json index c4e988f30f2ec9e3430a4d0c8f05e89fabbc2659..db08bbf9d7439623fcfa4093ab7f013633c62d48 100644 --- a/code/BasicFeature/TaskManagement/ReminderAgentManager/entry/package.json +++ b/code/BasicFeature/TaskManagement/ReminderAgentManager/entry/package.json @@ -1,13 +1,14 @@ { + "license": "ISC", + "devDependencies": {}, "name": "entry", - "version": "1.0.0", "ohos": { "org": "huawei", - "buildTool": "hvigor", - "directoryLevel": "module" + "directoryLevel": "module", + "buildTool": "hvigor" }, "description": "example description", "repository": {}, - "license": "ISC", + "version": "1.0.0", "dependencies": {} -} +} \ No newline at end of file diff --git a/code/BasicFeature/TaskManagement/ReminderAgentManager/entry/src/main/ets/Application/MyAbilityStage.ts b/code/BasicFeature/TaskManagement/ReminderAgentManager/entry/src/main/ets/Application/MyAbilityStage.ts index 8129f862d2186ef931d2841449b7d36439558142..2dd40211abd924fdfae195199b55c8381b5034b3 100644 --- a/code/BasicFeature/TaskManagement/ReminderAgentManager/entry/src/main/ets/Application/MyAbilityStage.ts +++ b/code/BasicFeature/TaskManagement/ReminderAgentManager/entry/src/main/ets/Application/MyAbilityStage.ts @@ -13,12 +13,12 @@ * limitations under the License. */ -import abilityStage from '@ohos.application.AbilityStage' +import AbilityStage from '@ohos.app.ability.AbilityStage' import Logger from '../util/Logger' const TAG: string = 'MyAbilityStage' -export default class MyAbilityStage extends abilityStage { +export default class MyAbilityStage extends AbilityStage { onCreate() { Logger.info(TAG, `onCreate`) } diff --git a/code/BasicFeature/TaskManagement/ReminderAgentManager/entry/src/main/ets/MainAbility/MainAbility.ts b/code/BasicFeature/TaskManagement/ReminderAgentManager/entry/src/main/ets/MainAbility/MainAbility.ts index 2b55aeec4ebd41f197fd5ac9b679dfd9d2570ba5..6049f3d1cce7d250c8dbeb55082d9c31ded14d49 100644 --- a/code/BasicFeature/TaskManagement/ReminderAgentManager/entry/src/main/ets/MainAbility/MainAbility.ts +++ b/code/BasicFeature/TaskManagement/ReminderAgentManager/entry/src/main/ets/MainAbility/MainAbility.ts @@ -13,14 +13,14 @@ * limitations under the License. */ -import ability from '@ohos.application.Ability' +import UIAbility from '@ohos.app.ability.UIAbility' import notification from '@ohos.notification' import window from '@ohos.window' import Logger from '../util/Logger' const TAG: string = 'MainAbility' -export default class MainAbility extends ability { +export default class MainAbility extends UIAbility { async onCreate(want, launchParam) { Logger.info(TAG, 'onCreate') await notification.requestEnableNotification() diff --git a/code/BasicFeature/TaskManagement/ReminderAgentManager/entry/src/ohosTest/ets/test/Ability.test.ets b/code/BasicFeature/TaskManagement/ReminderAgentManager/entry/src/ohosTest/ets/test/Ability.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..c3802bbfe8b74da44c76b52b121203e55a61b088 --- /dev/null +++ b/code/BasicFeature/TaskManagement/ReminderAgentManager/entry/src/ohosTest/ets/test/Ability.test.ets @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2023 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 hilog from '@ohos.hilog'; +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium' + +export default function abilityTest() { + describe('ActsAbilityTest', function () { + // Defines a test suite. Two parameters are supported: test suite name and test suite function. + beforeAll(function () { + // Presets an action, which is performed only once before all test cases of the test suite start. + // This API supports only one parameter: preset action function. + }) + beforeEach(function () { + // Presets an action, which is performed before each unit test case starts. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: preset action function. + }) + afterEach(function () { + // Presets a clear action, which is performed after each unit test case ends. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: clear action function. + }) + afterAll(function () { + // Presets a clear action, which is performed after all test cases of the test suite end. + // This API supports only one parameter: clear action function. + }) + it('assertContain',0, function () { + // Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function. + hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO); + hilog.info(0x0000, 'testTag', '%{public}s', 'it begin'); + let a = 'abc' + let b = 'b' + // Defines a variety of assertion methods, which are used to declare expected boolean conditions. + expect(a).assertContain(b) + expect(a).assertEqual(a) + }) + }) +} \ No newline at end of file diff --git a/code/BasicFeature/TaskManagement/ReminderAgentManager/entry/src/ohosTest/ets/test/List.test.ets b/code/BasicFeature/TaskManagement/ReminderAgentManager/entry/src/ohosTest/ets/test/List.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..27c07a1a174f6862ea84c4bb5f45bc1789234441 --- /dev/null +++ b/code/BasicFeature/TaskManagement/ReminderAgentManager/entry/src/ohosTest/ets/test/List.test.ets @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2023 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 abilityTest from './Ability.test' + +export default function testsuite() { + abilityTest() +} \ No newline at end of file diff --git a/code/BasicFeature/TaskManagement/ReminderAgentManager/entry/src/ohosTest/ets/testability/TestAbility.ets b/code/BasicFeature/TaskManagement/ReminderAgentManager/entry/src/ohosTest/ets/testability/TestAbility.ets new file mode 100644 index 0000000000000000000000000000000000000000..c04d49d5314b5a6cd8c7812b723b4ffa58523daa --- /dev/null +++ b/code/BasicFeature/TaskManagement/ReminderAgentManager/entry/src/ohosTest/ets/testability/TestAbility.ets @@ -0,0 +1,72 @@ +/* + * Copyright (c) 2023 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 hilog from '@ohos.hilog'; +import UIAbility from '@ohos.app.ability.UIAbility' +import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' +import { Hypium } from '@ohos/hypium' +import testsuite from '../test/List.test' +import Window from '@ohos.window' + +export default class TestAbility extends UIAbility { + onCreate(want, launchParam) { + hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO); + hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onCreate'); + hilog.info(0x0000, 'testTag', '%{public}s', 'want param:' + JSON.stringify(want) ?? ''); + hilog.info(0x0000, 'testTag', '%{public}s', 'launchParam:'+ JSON.stringify(launchParam) ?? ''); + var abilityDelegator: any + abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + var abilityDelegatorArguments: any + abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() + hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO); + hilog.info(0x0000, 'testTag', '%{public}s', 'start run testcase!!!'); + Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite) + } + + onDestroy() { + hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO); + hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onDestroy'); + } + + onWindowStageCreate(windowStage: Window.WindowStage) { + hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO); + hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onWindowStageCreate'); + windowStage.loadContent('testability/pages/Index', (err, data) => { + if (err.code) { + hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.ERROR); + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO); + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', + JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy() { + hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO); + hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onWindowStageDestroy'); + } + + onForeground() { + hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO); + hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onForeground'); + } + + onBackground() { + hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO); + hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onBackground'); + } +} \ No newline at end of file diff --git a/code/BasicFeature/TaskManagement/ReminderAgentManager/entry/src/ohosTest/ets/testability/pages/Index.ets b/code/BasicFeature/TaskManagement/ReminderAgentManager/entry/src/ohosTest/ets/testability/pages/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..392e701ad007dbeee15d2757c28bc0d9c79cc5d1 --- /dev/null +++ b/code/BasicFeature/TaskManagement/ReminderAgentManager/entry/src/ohosTest/ets/testability/pages/Index.ets @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2023 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 hilog from '@ohos.hilog'; + +@Entry +@Component +struct Index { + aboutToAppear() { + hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO); + hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility index aboutToAppear'); + } + @State message: string = 'Hello World' + build() { + Row() { + Column() { + Text(this.message) + .fontSize(50) + .fontWeight(FontWeight.Bold) + Button() { + Text('next page') + .fontSize(20) + .fontWeight(FontWeight.Bold) + }.type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .backgroundColor('#0D9FFB') + .width('35%') + .height('5%') + .onClick(()=>{ + }) + } + .width('100%') + } + .height('100%') + } + } \ No newline at end of file diff --git a/code/BasicFeature/TaskManagement/ReminderAgentManager/entry/src/ohosTest/ets/testrunner/OpenHarmonyTestRunner.ts b/code/BasicFeature/TaskManagement/ReminderAgentManager/entry/src/ohosTest/ets/testrunner/OpenHarmonyTestRunner.ts new file mode 100644 index 0000000000000000000000000000000000000000..13f3712e7b1ee891bb5dee9917cface15fc4a547 --- /dev/null +++ b/code/BasicFeature/TaskManagement/ReminderAgentManager/entry/src/ohosTest/ets/testrunner/OpenHarmonyTestRunner.ts @@ -0,0 +1,86 @@ +/* + * Copyright (c) 2023 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 hilog from '@ohos.hilog'; +import TestRunner from '@ohos.application.testRunner' +import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' + +var abilityDelegator = undefined +var abilityDelegatorArguments = undefined + +function translateParamsToString(parameters) { + const keySet = new Set([ + '-s class', '-s notClass', '-s suite', '-s it', + '-s level', '-s testType', '-s size', '-s timeout', + '-s dryRun' + ]) + let targetParams = ''; + for (const key in parameters) { + if (keySet.has(key)) { + targetParams = `${targetParams} ${key} ${parameters[key]}` + } + } + return targetParams.trim() +} + +async function onAbilityCreateCallback() { + hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO); + hilog.info(0x0000, 'testTag', '%{public}s', 'onAbilityCreateCallback'); +} + +async function addAbilityMonitorCallback(err: any) { + hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO); + hilog.info(0x0000, 'testTag', 'addAbilityMonitorCallback : %{public}s', JSON.stringify(err) ?? ''); +} + +export default class OpenHarmonyTestRunner implements TestRunner { + constructor() { + } + + onPrepare() { + hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO); + hilog.info(0x0000, 'testTag', '%{public}s', 'OpenHarmonyTestRunner OnPrepare '); + } + + async onRun() { + hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO); + hilog.info(0x0000, 'testTag', '%{public}s', 'OpenHarmonyTestRunner onRun run'); + abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() + abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + var testAbilityName = abilityDelegatorArguments.bundleName + '.TestAbility' + let lMonitor = { + abilityName: testAbilityName, + onAbilityCreate: onAbilityCreateCallback, + }; + abilityDelegator.addAbilityMonitor(lMonitor, addAbilityMonitorCallback) + var cmd = 'aa start -d 0 -a TestAbility' + ' -b ' + abilityDelegatorArguments.bundleName + cmd += ' '+translateParamsToString(abilityDelegatorArguments.parameters) + var debug = abilityDelegatorArguments.parameters['-D'] + if (debug == 'true') + { + cmd += ' -D' + } + hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO); + hilog.info(0x0000, 'testTag', 'cmd : %{public}s', cmd); + abilityDelegator.executeShellCommand(cmd, + (err: any, d: any) => { + hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO); + hilog.info(0x0000, 'testTag', 'executeShellCommand : err : %{public}s', JSON.stringify(err) ?? ''); + hilog.info(0x0000, 'testTag', 'executeShellCommand : data : %{public}s', d.stdResult ?? ''); + hilog.info(0x0000, 'testTag', 'executeShellCommand : data : %{public}s', d.exitCode ?? ''); + }) + hilog.info(0x0000, 'testTag', '%{public}s', 'OpenHarmonyTestRunner onRun end'); + } +} \ No newline at end of file diff --git a/code/BasicFeature/TaskManagement/ReminderAgentManager/entry/src/ohosTest/module.json5 b/code/BasicFeature/TaskManagement/ReminderAgentManager/entry/src/ohosTest/module.json5 new file mode 100644 index 0000000000000000000000000000000000000000..f5fed4700ea651c3e5ad1c6262dae4fa048fad1b --- /dev/null +++ b/code/BasicFeature/TaskManagement/ReminderAgentManager/entry/src/ohosTest/module.json5 @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2023 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. + */ +{ + "module": { + "name": "entry_test", + "type": "feature", + "description": "$string:module_test_desc", + "mainElement": "TestAbility", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:test_pages", + "abilities": [ + { + "name": "TestAbility", + "srcEntrance": "./ets/testability/TestAbility.ets", + "description": "$string:TestAbility_desc", + "icon": "$media:icon", + "label": "$string:TestAbility_label", + "visible": true, + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:start_window_background", + "skills": [ + { + "actions": [ + "action.system.home" + ], + "entities": [ + "entity.system.home" + ] + } + ] + } + ] + } +} diff --git a/code/BasicFeature/TaskManagement/ReminderAgentManager/entry/src/ohosTest/resources/base/element/color.json b/code/BasicFeature/TaskManagement/ReminderAgentManager/entry/src/ohosTest/resources/base/element/color.json new file mode 100644 index 0000000000000000000000000000000000000000..3c712962da3c2751c2b9ddb53559afcbd2b54a02 --- /dev/null +++ b/code/BasicFeature/TaskManagement/ReminderAgentManager/entry/src/ohosTest/resources/base/element/color.json @@ -0,0 +1,8 @@ +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + } + ] +} \ No newline at end of file diff --git a/code/BasicFeature/TaskManagement/ReminderAgentManager/entry/src/ohosTest/resources/base/element/string.json b/code/BasicFeature/TaskManagement/ReminderAgentManager/entry/src/ohosTest/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..65d8fa5a7cf54aa3943dcd0214f58d1771bc1f6c --- /dev/null +++ b/code/BasicFeature/TaskManagement/ReminderAgentManager/entry/src/ohosTest/resources/base/element/string.json @@ -0,0 +1,16 @@ +{ + "string": [ + { + "name": "module_test_desc", + "value": "test ability description" + }, + { + "name": "TestAbility_desc", + "value": "the test ability" + }, + { + "name": "TestAbility_label", + "value": "test label" + } + ] +} \ No newline at end of file diff --git a/code/BasicFeature/TaskManagement/ReminderAgentManager/entry/src/ohosTest/resources/base/media/icon.png b/code/BasicFeature/TaskManagement/ReminderAgentManager/entry/src/ohosTest/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/code/BasicFeature/TaskManagement/ReminderAgentManager/entry/src/ohosTest/resources/base/media/icon.png differ diff --git a/code/BasicFeature/TaskManagement/ReminderAgentManager/entry/src/ohosTest/resources/base/profile/test_pages.json b/code/BasicFeature/TaskManagement/ReminderAgentManager/entry/src/ohosTest/resources/base/profile/test_pages.json new file mode 100644 index 0000000000000000000000000000000000000000..b7e7343cacb32ce982a45e76daad86e435e054fe --- /dev/null +++ b/code/BasicFeature/TaskManagement/ReminderAgentManager/entry/src/ohosTest/resources/base/profile/test_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "testability/pages/Index" + ] +} diff --git a/code/BasicFeature/TaskManagement/ReminderAgentManager/package.json b/code/BasicFeature/TaskManagement/ReminderAgentManager/package.json index 565da49b1d0a88e0416e15d9f917c4ef5390374f..8389023aaf19e37c3d5b384009afada3c0079c80 100644 --- a/code/BasicFeature/TaskManagement/ReminderAgentManager/package.json +++ b/code/BasicFeature/TaskManagement/ReminderAgentManager/package.json @@ -1,17 +1,18 @@ { + "license": "ISC", + "devDependencies": {}, "name": "reminderagentmanager", - "version": "1.0.0", "ohos": { "org": "huawei", - "buildTool": "hvigor", - "directoryLevel": "project" + "directoryLevel": "project", + "buildTool": "hvigor" }, "description": "example description", "repository": {}, - "license": "ISC", + "version": "1.0.0", "dependencies": { - "@ohos/hypium": "1.0.2", - "@ohos/hvigor": "1.2.2", - "@ohos/hvigor-ohos-plugin": "1.2.2" + "@ohos/hypium": "1.0.3", + "@ohos/hvigor-ohos-plugin": "1.3.1", + "@ohos/hvigor": "1.3.1" } -} +} \ No newline at end of file diff --git a/code/BasicFeature/TaskManagement/WorkScheduler/.gitignore b/code/BasicFeature/TaskManagement/WorkScheduler/.gitignore index 91d237bb144c7fb1777e50271857ef0f593286fc..09751df37c41c009064094c98d5311173795823d 100644 --- a/code/BasicFeature/TaskManagement/WorkScheduler/.gitignore +++ b/code/BasicFeature/TaskManagement/WorkScheduler/.gitignore @@ -1,5 +1,6 @@ -/node_modules +**/node_modules /local.properties /.idea **/build -/.hvigor \ No newline at end of file +/.hvigor +**/package-lock.json \ No newline at end of file diff --git a/code/BasicFeature/TaskManagement/WorkScheduler/AppScope/app.json5 b/code/BasicFeature/TaskManagement/WorkScheduler/AppScope/app.json5 index 481dcb6cc26146ecc50f9166e53d856eebc13566..de68be4d3e87f46331fd97aa7d6cae914eb23367 100644 --- a/code/BasicFeature/TaskManagement/WorkScheduler/AppScope/app.json5 +++ b/code/BasicFeature/TaskManagement/WorkScheduler/AppScope/app.json5 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 Huawei Device Co., Ltd. + * Copyright (c) 2023 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 @@ -15,13 +15,12 @@ { "app": { - "bundleName": "ohos.samples.workscheduler", + "bundleName": "ohos.samples.workschedulerextensionability", "vendor": "samples", "versionCode": 1000000, "versionName": "1.0.0", "icon": "$media:app_icon", "label": "$string:app_name", - "singleton": true, "distributedNotificationEnabled": true } -} +} \ No newline at end of file diff --git a/code/BasicFeature/TaskManagement/WorkScheduler/AppScope/resources/base/element/string.json b/code/BasicFeature/TaskManagement/WorkScheduler/AppScope/resources/base/element/string.json index 9691e065415e46a7848512fdbb60508798561b18..c2777a72852070b52f19768fa693fbc17af2b696 100644 --- a/code/BasicFeature/TaskManagement/WorkScheduler/AppScope/resources/base/element/string.json +++ b/code/BasicFeature/TaskManagement/WorkScheduler/AppScope/resources/base/element/string.json @@ -2,7 +2,7 @@ "string": [ { "name": "app_name", - "value": "WorkScheduler" + "value": "workSchedulerExtensionAbility" } ] } diff --git a/code/BasicFeature/TaskManagement/WorkScheduler/ReadMe.md b/code/BasicFeature/TaskManagement/WorkScheduler/ReadMe.md new file mode 100644 index 0000000000000000000000000000000000000000..88f3286bbce7c5f6219e6e801aff27a002b84f94 --- /dev/null +++ b/code/BasicFeature/TaskManagement/WorkScheduler/ReadMe.md @@ -0,0 +1,93 @@ +# 任务延时调度 + +### 介绍 + +本示例使用[@ohos.WorkSchedulerExtensionAbility](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis/js-apis-WorkSchedulerExtensionAbility.md) +、[@ohos.net.http](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis/js-apis-http.md) +、[@ohos.notification](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis/js-apis-notification.md) +、[@ohos.bundle](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis/js-apis-Bundle.md) +、[@ohos.fileio](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis/js-apis-fileio.md) 等接口,实现了设置后台任务、下载更新包 +、保存更新包、发送通知 、安装更新包实现升级的功能。 + +### 效果预览 + +|当前版本首页 |提示弹窗 |最新版本 | +|---------------------------------------|---------------------------------------|---------------------------------------| +|![image](screenshots/device/oldVersion.png)|![image](screenshots/device/dialog.png)|![image](screenshots/device/newVersion.png)| + +使用说明 + +1. 未连接wifi状态下进入应用; +2. 进入首页后连接wifi; +3. 后台判断版本号后会下载最新的升级包,并在页面中给出弹窗询问是否安装,点击“确定”按钮; +4. 应用会安装已经下载的升级包,实现版本更新,安装后会回到设备桌面,此时点击应用图标,可以看到版本已经是最新版了。 + +### 工程目录 +``` +entry/src/main/ets/ +|---Application +| |---MyAbilityStage.ets // 入口文件 +|---feature +| |---WorkSchedulerSystem.ets // 封装各个功能接口 +|---MainAbility +| |---MainAbility.ets // 请求权限 +|---pages +| |---Index.ets // 首页 +|---util +| |---Logger.ets // 日志文件 +|---WorkSchedulerAbility +| |---WorkSchedulerAbility.ets // 延时任务触发后的回调 +``` + +### 具体实现 + +* 设置延时任务、下载更新包、保存更新包、发送通知、安装更新包的功能接口都封装在WorkSchedulerSystem中, +源码参考:[WorkSchedulerSystem.ets](https://gitee.com/openharmony/applications_app_samples/blob/master/code/BasicFeature/TaskManagement/WorkScheduler/entry/src/main/ets/feature/WorkSchedulerSystem.ets) + + * 设置延时任务:在运行示例时会在[MainAbility.ets](https://gitee.com/openharmony/applications_app_samples/blob/master/code/BasicFeature/TaskManagement/WorkScheduler/entry/src/main/ets/MainAbility/MainAbility.ets) + 通过WorkSchedulerSystem.startUpdateSample()方法调用workScheduler.startWork()建立任务; + * 下载更新包:当任务条件满足后,会在[WorkSchedulerAbility.ets](https://gitee.com/openharmony/applications_app_samples/blob/master/code/BasicFeature/TaskManagement/WorkScheduler/entry/src/main/ets/WorkSchedulerAbility/WorkSchedulerAbility.ets) + 通过WorkSchedulerSystem.getNewHap()方法调用http.createHttp().request()接口下载我们需要的文件; + * 保存更新包:通过WorkSchedulerSystem.saveFile()来实现,受限调用fileio.openSync()创建文件,然后调用fileio.writeSync()将下载的内容写入指定文件内; + * 发送通知:在[WorkSchedulerAbility.ets](https://gitee.com/openharmony/applications_app_samples/blob/master/code/BasicFeature/TaskManagement/WorkScheduler/entry/src/main/ets/WorkSchedulerAbility/WorkSchedulerAbility.ets) + 中通过WorkSchedulerSystem.publishNotification()方法,调用Notification.publish()接口发送指定内容的信息; + * 接收通知:在[MainAbility.ets](https://gitee.com/openharmony/applications_app_samples/blob/master/code/BasicFeature/TaskManagement/WorkScheduler/entry/src/main/ets/MainAbility/MainAbility.ets) + 中通过WorkSchedulerSystem.handleNotification()方法调用Notification.subscribe()接口获取信息,根据信息内容决定是否提示用户升级; + * 安装更新包:在[WorkSchedulerAbility.ets](https://gitee.com/openharmony/applications_app_samples/blob/master/code/BasicFeature/TaskManagement/WorkScheduler/entry/src/main/ets/WorkSchedulerAbility/WorkSchedulerAbility.ets) + 通过WorkSchedulerSystem.installBundle()方法实现,首先调用bundle.getBundleInstaller()获取Installer对象,然后调用bundleInstall.install()接口实现装包,完成升级。 + +### 相关权限 + +[ohos.permission.INTERNET](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/security/permission-list.md#ohospermissioninternet) + +[ohos.permission.INSTALL_BUNDLE](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/security/permission-list.md#ohospermissioninstall_bundle) + +[ohos.permission.NOTIFICATION_CONTROLLER](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/security/permission-list.md#ohospermissionnotification_controller) + +### 依赖 + +不涉及。 + +### 约束与限制 + +1. 本示例仅支持标准系统上运行。 + +2. 本示例仅支持API9版本SDK,本示例涉及使用系统接口:@ohos.bundle,需要手动替换Full + SDK才能编译通过,具体操作可参考[替换指南](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/quick-start/full-sdk-switch-guide.md)。 + +3. 本示例需要使用DevEco Studio 3.1 Canary1 (Build Version: 3.1.0.100, built on November 3, 2022)才可编译运行。 + +4. 本示例所配置的权限ohos.permission.INSTALL_BUNDLE与ohos.permission.NOTIFICATION_CONTROLLER为system_core级别( + 相关权限级别可通过[权限定义列表](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/security/permission-list.md)查看),需要手动配置对应级别的权限签名(具体操作可查看[自动化签名方案](https://developer.harmonyos.com/cn/docs/documentation/doc-guides/ohos-auto-configuring-signature-information-0000001271659465))。 + +### 下载 + +如需单独下载本工程,执行如下命令: + + ``` + git init + git config core.sparsecheckout true + echo code/BasicFeature/TaskManagement/WorkScheduler/ > .git/info/sparse-checkout + git remote add origin https://gitee.com/openharmony/applications_app_samples.git + git pull origin master + ``` \ No newline at end of file diff --git a/code/BasicFeature/TaskManagement/WorkScheduler/build-profile.json5 b/code/BasicFeature/TaskManagement/WorkScheduler/build-profile.json5 index 61bf8dfb876a84a55d0b3bf69c05912141fc5de0..ca880b1036f5b8b8c9d26640bb3194c0f34b9dfb 100644 --- a/code/BasicFeature/TaskManagement/WorkScheduler/build-profile.json5 +++ b/code/BasicFeature/TaskManagement/WorkScheduler/build-profile.json5 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 Huawei Device Co., Ltd. + * Copyright (c) 2023 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 @@ -15,15 +15,15 @@ { "app": { - "signingConfigs": [], "compileSdkVersion": 9, "compatibleSdkVersion": 9, "products": [ { "name": "default", - "signingConfig": "default", + "signingConfig": "default" } - ] + ], + "signingConfigs": [] }, "modules": [ { @@ -37,14 +37,6 @@ ] } ] - }, - { - "name": "library", - "srcPath": "./library" - }, - { - "name": "Notification", - "srcPath": "./Notification" } ] } \ No newline at end of file diff --git a/code/BasicFeature/TaskManagement/WorkScheduler/entry/build-profile.json5 b/code/BasicFeature/TaskManagement/WorkScheduler/entry/build-profile.json5 index 2e52bcec39776cf0b7df3dc769c2f2e1db2ab27c..ddd6e5f1ac23a18a1d1d0d8d7470c6d4726ef66e 100644 --- a/code/BasicFeature/TaskManagement/WorkScheduler/entry/build-profile.json5 +++ b/code/BasicFeature/TaskManagement/WorkScheduler/entry/build-profile.json5 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 Huawei Device Co., Ltd. + * Copyright (c) 2023 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 diff --git a/code/BasicFeature/TaskManagement/WorkScheduler/entry/package.json b/code/BasicFeature/TaskManagement/WorkScheduler/entry/package.json index f516b4dc7a2ef764c42e4855c998778504aca8cb..db08bbf9d7439623fcfa4093ab7f013633c62d48 100644 --- a/code/BasicFeature/TaskManagement/WorkScheduler/entry/package.json +++ b/code/BasicFeature/TaskManagement/WorkScheduler/entry/package.json @@ -10,8 +10,5 @@ "description": "example description", "repository": {}, "version": "1.0.0", - "dependencies": { - "@ohos/notification": "file:../Notification", - "@ohos/library": "file:../library" - } -} + "dependencies": {} +} \ No newline at end of file diff --git a/code/BasicFeature/TaskManagement/WorkScheduler/entry/src/main/ets/Application/MyAbilityStage.ets b/code/BasicFeature/TaskManagement/WorkScheduler/entry/src/main/ets/Application/MyAbilityStage.ets new file mode 100644 index 0000000000000000000000000000000000000000..bd19e88c205ec60521380cb3a8418bdd8e767b9c --- /dev/null +++ b/code/BasicFeature/TaskManagement/WorkScheduler/entry/src/main/ets/Application/MyAbilityStage.ets @@ -0,0 +1,19 @@ +/* + * Copyright (c) 2023 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.app.ability.AbilityStage' + +export default class MyAbilityStage extends AbilityStage { +} \ No newline at end of file diff --git a/code/BasicFeature/TaskManagement/WorkScheduler/entry/src/main/ets/MainAbility/MainAbility.ets b/code/BasicFeature/TaskManagement/WorkScheduler/entry/src/main/ets/MainAbility/MainAbility.ets new file mode 100644 index 0000000000000000000000000000000000000000..2c8511ad1aae12c66ca00c2de055763e12a47785 --- /dev/null +++ b/code/BasicFeature/TaskManagement/WorkScheduler/entry/src/main/ets/MainAbility/MainAbility.ets @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2023 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 UIAbility from '@ohos.app.ability.UIAbility' +import Window from '@ohos.window' +import { Logger } from '../utils/Logger' +import { WorkSchedulerSystem } from '../feature/WorkSchedulerSystem' +import abilityAccessCtrl, { Permissions } from '@ohos.abilityAccessCtrl' + +const TAG: string = 'MainAbility' +const VERSION: string = '1.0' +const BUNDLE_NAME = 'ohos.samples.workschedulerextensionability' +const PERMISSIONS: Array = [ + 'ohos.permission.INTERNET', + 'ohos.permission.INSTALL_BUNDLE', + 'ohos.permission.NOTIFICATION_CONTROLLER' +] + +export default class MainAbility extends UIAbility { + onCreate(want, launchParam) { + let atManager = abilityAccessCtrl.createAtManager() + try { + atManager.requestPermissionsFromUser(this.context, PERMISSIONS).then((data) => { + Logger.info(TAG, `data: ${JSON.stringify(data)}`) + }).catch((err) => { + Logger.info(TAG, `err: ${JSON.stringify(err)}`) + }) + } catch (err) { + Logger.info(TAG, `catch err->${JSON.stringify(err)}`); + } + AppStorage.SetOrCreate('filePath', this.context.filesDir) + } + + onWindowStageCreate(windowStage: Window.WindowStage) { + WorkSchedulerSystem.handleNotification(BUNDLE_NAME) + WorkSchedulerSystem.startUpdateSample(VERSION, BUNDLE_NAME, this.context.filesDir) + windowStage.loadContent('pages/Index', (err, data) => { + if (err.code) { + Logger.error('Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? '') + return + } + Logger.info('Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? '') + }) + } +} \ No newline at end of file diff --git a/code/BasicFeature/TaskManagement/WorkScheduler/entry/src/main/ets/WorkSchedulerAbility/WorkSchedulerAbility.ets b/code/BasicFeature/TaskManagement/WorkScheduler/entry/src/main/ets/WorkSchedulerAbility/WorkSchedulerAbility.ets new file mode 100644 index 0000000000000000000000000000000000000000..b27ec7186d0e3183ab2947a0cb8039d34452f975 --- /dev/null +++ b/code/BasicFeature/TaskManagement/WorkScheduler/entry/src/main/ets/WorkSchedulerAbility/WorkSchedulerAbility.ets @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2023 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 WorkSchedulerExtensionAbility from '@ohos.WorkSchedulerExtensionAbility' +import http from '@ohos.net.http' +import Notification from '@ohos.notification' +import { WorkSchedulerSystem } from '../feature/WorkSchedulerSystem' +import { Logger } from '../utils/Logger' + +const VERSION: string = '1.0' +const HTTP_STATUS_CODE: number = 200 +const URL: string = 'https://gitee.com/two-thousand-or-three-thousand/applications_app_samples_12/raw/OpenHarmony_' + + '4.X_Dev/DataMock/WorkScheduler/updateWorkScheduler.hap' +const BUNDLE_NAME = ['ohos.samples.workschedulerextensionability'] + +export default class WorkSchedulerAbility extends WorkSchedulerExtensionAbility { + onWorkStart(workInfo) { + Logger.info(`LSQ: get info === ${JSON.stringify(workInfo)}`) + let filePath = JSON.parse(workInfo.parameters).filePath + if (JSON.parse(workInfo.parameters).version === VERSION) { + let result: Promise = WorkSchedulerSystem.getNewHap(URL) + result.then(data => { + if (data.responseCode === HTTP_STATUS_CODE) { + WorkSchedulerSystem.saveFile(filePath, data.result as ArrayBuffer) + WorkSchedulerSystem.publishNotification('download', 'isReady', 'download hap to update the application') + Notification.subscribe({ + onConsume: (data) => { + if (data.request.content.normal.text === 'allow') { + let path: string[] = [] + path.push(filePath) + WorkSchedulerSystem.installBundle(path) + } + } + }, { + bundleNames: BUNDLE_NAME + }) + } + }) + } + } +} \ No newline at end of file diff --git a/code/BasicFeature/TaskManagement/WorkScheduler/entry/src/main/ets/feature/WorkSchedulerSystem.ets b/code/BasicFeature/TaskManagement/WorkScheduler/entry/src/main/ets/feature/WorkSchedulerSystem.ets new file mode 100644 index 0000000000000000000000000000000000000000..9b8a0ffa1cafe3a1860ac6c26b5ddd5262375eba --- /dev/null +++ b/code/BasicFeature/TaskManagement/WorkScheduler/entry/src/main/ets/feature/WorkSchedulerSystem.ets @@ -0,0 +1,159 @@ +/* + * Copyright (c) 2023 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 fileio from '@ohos.fileio' +import Notification from '@ohos.notification' +import bundle from '@ohos.bundle' +import account from '@ohos.account.osAccount' +import workScheduler from '@ohos.resourceschedule.workScheduler' +import http from '@ohos.net.http' +import { Logger } from '../utils/Logger' + +const FILE_NAME = '/updateWorkScheduler.hap' +const BUNDLE_NAMES = ['ohos.samples.workschedulerextensionability'] +const INSTALL_PARAMETER = 1 + +export namespace WorkSchedulerSystem { + /** + * Store the file to the specified directory. + * + * @param pathDir Path to save the file. + * @param content The contents of the file to be saved. + */ + export function saveFile(pathDir: string, content: ArrayBuffer): void { + try { + let filePath = pathDir + FILE_NAME + let fd = fileio.openSync(filePath, 0o100 | 0o2, 0o664) + fileio.writeSync(fd, content) + fileio.closeSync(fd) + } catch (err) { + Logger.error(`saveFile failed, code is ${err.code}, message is ${err.message}`) + } + } + + /** + * Sending a Notification. + * + * @param bundleName Check the name of the application that has permission. + * @permission ohos.permission.NOTIFICATION_CONTROLLER + */ + export async function handleNotification(bundleName: string): Promise { + let isHavePermission = await Notification.isNotificationEnabled({ + bundle: bundleName + }) + if (!isHavePermission) { + await Notification.enableNotification({ + bundle: bundleName + }, true) + } + Notification.subscribe({ + onConsume: (data) => { + if (data.request.content.normal.text === 'isReady') { + AppStorage.SetOrCreate('isShowDialog', true) + } + } + }, { + bundleNames: BUNDLE_NAMES + }) + } + + /** + * Publishes a notification of the specified content. + * + * @param title Title of Notice. + * @param text Content of Notification Text. + * @param additionalText Additional text. + * @permission ohos.permission.NOTIFICATION_CONTROLLER + */ + export function publishNotification(title: string, text: string, additionalText: string): void { + Notification.publish({ + content: { + contentType: Notification.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, + normal: { + title, + text, + additionalText + } + } + }) + } + + /** + * Install the application package in the specified path. + * + * @param filePath An array of paths to hold the installation package. + * @permission ohos.permission.INSTALL_BUNDLE + */ + export async function installBundle(filePath: Array): Promise { + try { + let bundleInstall = await bundle.getBundleInstaller() + let userId = await account.getAccountManager().getOsAccountLocalIdFromProcess() + bundleInstall.install(filePath, { + userId: userId, + installFlag: INSTALL_PARAMETER, + isKeepData: false + }, (status, statusMessage) => { + Logger.info(`code is ${status.code}, message is ${JSON.stringify(statusMessage)}`) + }) + } catch (err) { + Logger.error(`installBundle failed, code is ${err.code}, message is ${err.message}`) + } + } + + /** + * Register the delayed task and pass the parameters. + * + * @param version Current application version. + * @param bundleName The name of the application package for which the task needs to be registered. + * @param filePath Storage address of the application package. + */ + export async function startUpdateSample(version: string, bundleName: string, filePath: string): Promise { + try { + let workInfo = { + workId: 1, + bundleName: bundleName, + abilityName: 'FormAbility', + networkType: workScheduler.NetworkType.NETWORK_TYPE_WIFI, + parameters: { + version: version, + filePath: filePath + } + } + Logger.info(`LSQ: info is ${JSON.stringify(workInfo)}`) + workScheduler.startWork(workInfo) + } + catch (err) { + Logger.error(`startWork failed, code is ${err.code}, message is ${err.message}`) + } + } + + /** + * Register the delayed task and pass the parameters. + * + * @param url Url of the application package. + * @permission ohos.permission.INTERNET + */ + export async function getNewHap(url: string): Promise { + try { + return await http.createHttp().request( + url, + { + expectDataType: http.HttpDataType.ARRAY_BUFFER + }) + } catch (err) { + Logger.error(`get result failed, code is ${err.code}, message is ${err.message}`) + } + } +} diff --git a/code/BasicFeature/TaskManagement/WorkScheduler/entry/src/main/ets/pages/Index.ets b/code/BasicFeature/TaskManagement/WorkScheduler/entry/src/main/ets/pages/Index.ets index 312e2512505cf0e4cd09b4814de7480052e278e2..b9ac9bf7a350376e55a4ddaab5c34e916260597d 100644 --- a/code/BasicFeature/TaskManagement/WorkScheduler/entry/src/main/ets/pages/Index.ets +++ b/code/BasicFeature/TaskManagement/WorkScheduler/entry/src/main/ets/pages/Index.ets @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 Huawei Device Co., Ltd. + * Copyright (c) 2023 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 @@ -13,44 +13,194 @@ * limitations under the License. */ -import notification from '@ohos.notification' -import { DelayWork } from '@ohos/library' -import { Logger } from '@ohos/notification' +import { WorkSchedulerSystem } from '../feature/WorkSchedulerSystem' +import promptAction from '@ohos.promptAction' -const TAG: string = 'index' +const VERSION: string = '1.0' +const FONT_WEIGHT: number = 700 +const LASTEST_VERSION: string = '1.1' @Entry @Component struct Index { - private work = new DelayWork() + @StorageLink('isShowDialog') isShowDialog: boolean = false build() { - Row() { + Column() { Column() { - Button($r('app.string.upgrade')) - .width('60%') - .height(40) - .fontSize(30) + Row() { + Text($r('app.string.sampleName')) + .fontSize(20) + .fontColor($r('app.color.fontColor')) + .fontWeight(FONT_WEIGHT) + .margin({ top: 10 }) + } + .width('100%') + .padding({ top: 10 }) + + Image($r('app.media.app_icon')) + .width(100) + .height(100) + .margin({ top: 100 }) + + Row() { + Text($r('app.string.version')) + .fontSize(20) + .fontColor($r('app.color.fontColor')) + + Text(`:${VERSION}`) + .fontSize(20) + .fontColor($r('app.color.fontColor')) + } + .margin({ top: 10 }) + + Column() { + Row() { + Column({ space: 10 }) { + Text($r('app.string.title1')) + .fontSize(16) + .fontWeight(FONT_WEIGHT) + + Text(VERSION === LASTEST_VERSION ? $r('app.string.isLatest') : LASTEST_VERSION) + .fontSize(16) + .fontColor($r('app.color.fontColor')) + } + .flexShrink(1) + .flexGrow(1) + .alignItems(HorizontalAlign.Start) + + Image($r('app.media.right')) + .width(20) + .height(20) + } + .width('100%') + .justifyContent(FlexAlign.SpaceBetween) + + Divider() + .width('100%') + .strokeWidth(0.5) + .color($r('app.color.fontColor')) + .margin({ top: 12, bottom: 12 }) + + Row() { + Column({ space: 10 }) { + Text($r('app.string.title2')) + .fontSize(16) + .fontWeight(FONT_WEIGHT) + + Text('https://www.openharmony.cn') + .fontSize(16) + .fontColor($r('app.color.fontColor')) + } + .flexShrink(1) + .flexGrow(1) + .alignItems(HorizontalAlign.Start) + + Image($r('app.media.right')) + .width(20) + .height(20) + } + .width('100%') + .justifyContent(FlexAlign.SpaceBetween) .onClick(() => { - this.work.startWork('ohos.samples.workscheduler', 'WorkTest') + promptAction.showToast({ message: $r('app.string.is_develop') }) }) + + Divider() + .width('100%') + .strokeWidth(0.5) + .color($r('app.color.fontColor')) + .margin({ top: 12, bottom: 12 }) + + Row() { + Column({ space: 10 }) { + Text($r('app.string.title3')) + .fontSize(16) + .fontWeight(FONT_WEIGHT) + + Text('web@openharmony.io') + .fontSize(16) + .fontColor($r('app.color.fontColor')) + } + .flexShrink(1) + .flexGrow(1) + .alignItems(HorizontalAlign.Start) + + Image($r('app.media.right')) + .width(20) + .height(20) + } + .width('100%') + .justifyContent(FlexAlign.SpaceBetween) + .onClick(() => { + promptAction.showToast({ message: $r('app.string.is_develop') }) + }) + } + .width('100%') + .padding(12) + .margin({ top: 50 }) + .backgroundColor(Color.White) + .borderRadius(16) + } .width('100%') - } - .height('100%') - } + .height('100%') + .alignItems(HorizontalAlign.Center) + .backgroundColor($r('app.color.bg1')) + .padding({ left: 12, right: 12 }) - aboutToAppear() { - Logger.info(TAG, `aboutToAppear start`) - notification.requestEnableNotification((err) => { - if (err) { - Logger.error(TAG, `notification requestEnableNotification err ${JSON.stringify(err)}`) - } - Logger.info(TAG, 'requestEnableNotification success') - }) - } + if (this.isShowDialog) { + Column() + .width('100%') + .height('100%') + .backgroundColor(Color.Black) + .opacity(.5) + .position({ x: 0, y: 0 }) + + Column() { + Column() { + Row() { + Text($r('app.string.dialogTitle')) + .fontSize(20) + .letterSpacing(1) + }.padding({ top: 30, bottom: 30 }) - aboutToDisappear() { - this.work.stopWork('ohos.samples.workscheduler', 'WorkTest') + Row() { + Text($r('app.string.btn1')) + // 弹窗按钮需要占据一半宽度,这里使用50% + .width('50%') + .padding({ top: 10, bottom: 10 }) + .textAlign(TextAlign.Center) + .fontSize(16) + .letterSpacing(1) + .backgroundColor($r('app.color.btn1')) + .onClick(() => { + this.isShowDialog = false + WorkSchedulerSystem.publishNotification('permission', 'allow', 'allow install hap to update the application') + }) + + Text($r('app.string.btn2')) + // 弹窗按钮需要占据一半宽度,这里使用50% + .width('50%') + .textAlign(TextAlign.Center) + .padding({ top: 10, bottom: 10 }) + .fontSize(16) + .letterSpacing(1) + .backgroundColor($r('app.color.btn2')) + .onClick(() => { + this.isShowDialog = false + }) + } + } + .borderWidth(1) + .borderColor($r('app.color.btn2')) + .borderRadius(20) + .backgroundColor(Color.White) + .clip(true) + } + .padding(20) + .position({ x: 0, y: '40%' }) + } + } } } \ No newline at end of file diff --git a/code/BasicFeature/TaskManagement/WorkScheduler/entry/src/main/ets/utils/Logger.ets b/code/BasicFeature/TaskManagement/WorkScheduler/entry/src/main/ets/utils/Logger.ets new file mode 100644 index 0000000000000000000000000000000000000000..f394fc632830340635d982c7d68928724cbb1166 --- /dev/null +++ b/code/BasicFeature/TaskManagement/WorkScheduler/entry/src/main/ets/utils/Logger.ets @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2023 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 hilog from '@ohos.hilog' + +class LoggerModel { + private domain: number + private prefix: string + private format: string = '%{public}s, %{public}s' + + constructor(prefix: string) { + this.prefix = prefix + this.domain = 0xFF00 + } + + debug(...args: string[]) { + hilog.debug(this.domain, this.prefix, this.format, args) + } + + info(...args: string[]) { + hilog.info(this.domain, this.prefix, this.format, args) + } + + warn(...args: string[]) { + hilog.warn(this.domain, this.prefix, this.format, args) + } + + error(...args: string[]) { + hilog.error(this.domain, this.prefix, this.format, args) + } +} + +export let Logger = new LoggerModel('[Sample_workSchedulerExtensionAbility]') \ No newline at end of file diff --git a/code/BasicFeature/TaskManagement/WorkScheduler/entry/src/main/module.json5 b/code/BasicFeature/TaskManagement/WorkScheduler/entry/src/main/module.json5 index d774c2ff888006faee1de5738d4c08d250a559fd..2f5c5cd27d9a213bcb0128938dddb50942eeee5b 100644 --- a/code/BasicFeature/TaskManagement/WorkScheduler/entry/src/main/module.json5 +++ b/code/BasicFeature/TaskManagement/WorkScheduler/entry/src/main/module.json5 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022-2023 Huawei Device Co., Ltd. + * Copyright (c) 2023 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 @@ -17,7 +17,7 @@ "module": { "name": "entry", "type": "entry", - "srcEntrance": "./ets/Application/MyAbilityStage.ts", + "srcEntrance": "./ets/Application/MyAbilityStage.ets", "description": "$string:entry_desc", "mainElement": "MainAbility", "deviceTypes": [ @@ -27,17 +27,21 @@ "deliveryWithInstall": true, "installationFree": false, "pages": "$profile:main_pages", - "uiSyntax": "ets", - "metadata": [ + "requestPermissions": [ { - "name": "ArkTSPartialUpdate", - "value": "true" + "name": "ohos.permission.INTERNET" + }, + { + "name": "ohos.permission.INSTALL_BUNDLE" + }, + { + "name": "ohos.permission.NOTIFICATION_CONTROLLER" } ], "abilities": [ { "name": "MainAbility", - "srcEntrance": "./ets/MainAbility/MainAbility.ts", + "srcEntrance": "./ets/MainAbility/MainAbility.ets", "description": "$string:MainAbility_desc", "icon": "$media:icon", "label": "$string:MainAbility_label", @@ -58,12 +62,17 @@ ], "extensionAbilities": [ { - "name": "WorkTest", - "srcEntrance": "./ets/workAbility/WorkTest.ets", - "label": "$string:WorkSchedulerExtensionAbility_label", - "description": "$string:WorkSchedulerExtensionAbility_desc", + "name": "FormAbility", + "srcEntrance": "./ets/WorkSchedulerAbility/WorkSchedulerAbility.ets", + "label": "$string:form_FormAbility_label", + "description": "$string:form_FormAbility_desc", "type": "workScheduler", - "visible": true + "metadata": [ + { + "name": "ohos.extension.form", + "resource": "$profile:form_config" + } + ] } ] } diff --git a/code/BasicFeature/TaskManagement/WorkScheduler/entry/src/main/resources/base/element/color.json b/code/BasicFeature/TaskManagement/WorkScheduler/entry/src/main/resources/base/element/color.json index 1bbc9aa9617e97c45440e1d3d66afc1154837012..c4e209b700ea7bb432e981b77f7803773d03f55e 100644 --- a/code/BasicFeature/TaskManagement/WorkScheduler/entry/src/main/resources/base/element/color.json +++ b/code/BasicFeature/TaskManagement/WorkScheduler/entry/src/main/resources/base/element/color.json @@ -3,6 +3,22 @@ { "name": "white", "value": "#FFFFFF" + }, + { + "name": "bg1", + "value": "#f2f2f2" + }, + { + "name": "fontColor", + "value": "#66696d" + }, + { + "name": "btn1", + "value": "#65cce1" + }, + { + "name": "btn2", + "value": "#ccc" } ] } \ No newline at end of file diff --git a/code/BasicFeature/TaskManagement/WorkScheduler/entry/src/main/resources/base/element/string.json b/code/BasicFeature/TaskManagement/WorkScheduler/entry/src/main/resources/base/element/string.json index 284b7de36144486996e7be53cb390f1a7d2df6c9..dcb2a08f38aa0a67f505fe7dec97b096d4ae1300 100644 --- a/code/BasicFeature/TaskManagement/WorkScheduler/entry/src/main/resources/base/element/string.json +++ b/code/BasicFeature/TaskManagement/WorkScheduler/entry/src/main/resources/base/element/string.json @@ -13,20 +13,64 @@ "value": "WorkScheduler" }, { - "name": "WorkSchedulerExtensionAbility_label", - "value": "WorkSchedulerExtensionAbility" + "name": "WorkSchedulerAbility_desc", + "value": "description" + }, + { + "name": "WorkSchedulerAbility_label", + "value": "label" + }, + { + "name": "form_FormAbility_desc", + "value": "form_description" + }, + { + "name": "form_FormAbility_label", + "value": "form_label" + }, + { + "name": "sampleName", + "value": "workScheduler" + }, + { + "name": "version", + "value": "version" + }, + { + "name": "title1", + "value": "versionUpdate" + }, + { + "name": "isLatest", + "value": "It is the latest version" + }, + { + "name": "title2", + "value": "website" + }, + { + "name": "title3", + "value": "contact us" + }, + { + "name": "dialogText", + "value": "Features in development, please look forward to!" + }, + { + "name": "dialogTitle", + "value": "A new version has been downloaded. Do you want to update it?" }, { - "name": "WorkSchedulerExtensionAbility_desc", - "value": "system schedules the task execution time" + "name": "btn1", + "value": "confirm" }, { - "name": "notification_permission", - "value": "允许应用管理通知和订阅通知。" + "name": "btn2", + "value": "cancel" }, { - "name": "upgrade", - "value": "升级" + "name": "is_develop", + "value": "Features are still under development" } ] } \ No newline at end of file diff --git a/code/BasicFeature/TaskManagement/WorkScheduler/entry/src/main/resources/base/media/right.png b/code/BasicFeature/TaskManagement/WorkScheduler/entry/src/main/resources/base/media/right.png new file mode 100644 index 0000000000000000000000000000000000000000..e56d1c321c125d809b59cef1c8333ab53bd9363d Binary files /dev/null and b/code/BasicFeature/TaskManagement/WorkScheduler/entry/src/main/resources/base/media/right.png differ diff --git a/code/BasicFeature/TaskManagement/WorkScheduler/entry/src/main/resources/base/profile/form_config.json b/code/BasicFeature/TaskManagement/WorkScheduler/entry/src/main/resources/base/profile/form_config.json new file mode 100644 index 0000000000000000000000000000000000000000..e98f1a23965147b2bff9da93d740a884e4224416 --- /dev/null +++ b/code/BasicFeature/TaskManagement/WorkScheduler/entry/src/main/resources/base/profile/form_config.json @@ -0,0 +1,22 @@ +{ + "forms": [ + { + "name": "WorkSchedulerAbility", + "description": "This is a service widget.", + "src": "./js/WorkSchedulerAbility/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 diff --git a/code/BasicFeature/TaskManagement/WorkScheduler/entry/src/main/resources/en/element/string.json b/code/BasicFeature/TaskManagement/WorkScheduler/entry/src/main/resources/en/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..dcb2a08f38aa0a67f505fe7dec97b096d4ae1300 --- /dev/null +++ b/code/BasicFeature/TaskManagement/WorkScheduler/entry/src/main/resources/en/element/string.json @@ -0,0 +1,76 @@ +{ + "string": [ + { + "name": "entry_desc", + "value": "description" + }, + { + "name": "MainAbility_desc", + "value": "description" + }, + { + "name": "MainAbility_label", + "value": "WorkScheduler" + }, + { + "name": "WorkSchedulerAbility_desc", + "value": "description" + }, + { + "name": "WorkSchedulerAbility_label", + "value": "label" + }, + { + "name": "form_FormAbility_desc", + "value": "form_description" + }, + { + "name": "form_FormAbility_label", + "value": "form_label" + }, + { + "name": "sampleName", + "value": "workScheduler" + }, + { + "name": "version", + "value": "version" + }, + { + "name": "title1", + "value": "versionUpdate" + }, + { + "name": "isLatest", + "value": "It is the latest version" + }, + { + "name": "title2", + "value": "website" + }, + { + "name": "title3", + "value": "contact us" + }, + { + "name": "dialogText", + "value": "Features in development, please look forward to!" + }, + { + "name": "dialogTitle", + "value": "A new version has been downloaded. Do you want to update it?" + }, + { + "name": "btn1", + "value": "confirm" + }, + { + "name": "btn2", + "value": "cancel" + }, + { + "name": "is_develop", + "value": "Features are still under development" + } + ] +} \ No newline at end of file diff --git a/code/BasicFeature/TaskManagement/WorkScheduler/entry/src/main/resources/zh/element/string.json b/code/BasicFeature/TaskManagement/WorkScheduler/entry/src/main/resources/zh/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..b0d51c6d18869513c0d8f2a44427bbd6ba8b83e3 --- /dev/null +++ b/code/BasicFeature/TaskManagement/WorkScheduler/entry/src/main/resources/zh/element/string.json @@ -0,0 +1,76 @@ +{ + "string": [ + { + "name": "entry_desc", + "value": "入口描述" + }, + { + "name": "MainAbility_desc", + "value": "能力描述" + }, + { + "name": "MainAbility_label", + "value": "延时任务" + }, + { + "name": "WorkSchedulerAbility_desc", + "value": "描述" + }, + { + "name": "WorkSchedulerAbility_label", + "value": "标签" + }, + { + "name": "form_FormAbility_desc", + "value": "表单描述" + }, + { + "name": "form_FormAbility_label", + "value": "表单标签" + }, + { + "name": "sampleName", + "value": "延迟任务调度" + }, + { + "name": "version", + "value": "版本" + }, + { + "name": "title1", + "value": "版本更新" + }, + { + "name": "isLatest", + "value": "已经是最新版本" + }, + { + "name": "title2", + "value": "官网" + }, + { + "name": "title3", + "value": "联系我们" + }, + { + "name": "dialogText", + "value": "功能开发中,敬请期待!" + }, + { + "name": "dialogTitle", + "value": "已下载新版本,是否更新?" + }, + { + "name": "btn1", + "value": "确定" + }, + { + "name": "btn2", + "value": "取消" + }, + { + "name": "is_develop", + "value": "功能尚在开发中" + } + ] +} \ No newline at end of file diff --git a/code/BasicFeature/TaskManagement/WorkScheduler/entry/src/ohosTest/ets/TestAbility/TestAbility.ets b/code/BasicFeature/TaskManagement/WorkScheduler/entry/src/ohosTest/ets/TestAbility/TestAbility.ets new file mode 100644 index 0000000000000000000000000000000000000000..898fded3084f1a4e3e180b14191f775cab077cac --- /dev/null +++ b/code/BasicFeature/TaskManagement/WorkScheduler/entry/src/ohosTest/ets/TestAbility/TestAbility.ets @@ -0,0 +1,72 @@ +/* + * Copyright (c) 2023 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 hilog from '@ohos.hilog' +import Ability from '@ohos.application.Ability' +import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' +import { Hypium } from '@ohos/hypium' +import testsuite from '../test/List.test' +import Window from '@ohos.window' + +export default class TestAbility extends Ability { + onCreate(want, launchParam) { + hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO) + hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onCreate') + hilog.info(0x0000, 'testTag', '%{public}s', 'want param:' + JSON.stringify(want) ?? '') + hilog.info(0x0000, 'testTag', '%{public}s', 'launchParam:' + JSON.stringify(launchParam) ?? '') + var abilityDelegator: any + abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + var abilityDelegatorArguments: any + abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() + hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO) + hilog.info(0x0000, 'testTag', '%{public}s', 'start run testcase!!!') + Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite) + } + + onDestroy() { + hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO) + hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onDestroy') + } + + onWindowStageCreate(windowStage: Window.WindowStage) { + hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO) + hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onWindowStageCreate') + windowStage.loadContent('testability/pages/Index', (err, data) => { + if (err.code) { + hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.ERROR) + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? '') + return + } + hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO) + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', + JSON.stringify(data) ?? '') + }) + } + + onWindowStageDestroy() { + hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO) + hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onWindowStageDestroy') + } + + onForeground() { + hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO) + hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onForeground') + } + + onBackground() { + hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO) + hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onBackground') + } +} \ No newline at end of file diff --git a/code/BasicFeature/TaskManagement/WorkScheduler/entry/src/ohosTest/ets/TestAbility/pages/index.ets b/code/BasicFeature/TaskManagement/WorkScheduler/entry/src/ohosTest/ets/TestAbility/pages/index.ets index b812d3fe405c160e0e840996bd5c4f7e842e71ee..838863ec18f69a85b2124570fe8f21230bfc48ba 100644 --- a/code/BasicFeature/TaskManagement/WorkScheduler/entry/src/ohosTest/ets/TestAbility/pages/index.ets +++ b/code/BasicFeature/TaskManagement/WorkScheduler/entry/src/ohosTest/ets/TestAbility/pages/index.ets @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 Huawei Device Co., Ltd. + * Copyright (c) 2023 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 @@ -13,15 +13,14 @@ * limitations under the License. */ -import { Logger } from '@ohos/notification' - -const TAG: string = 'Index' +import hilog from '@ohos.hilog' @Entry @Component struct Index { aboutToAppear() { - Logger.info(TAG, `TestAbility index aboutToAppear`) + hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO) + hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility index aboutToAppear') } @State message: string = 'Hello World' diff --git a/code/BasicFeature/TaskManagement/WorkScheduler/entry/src/ohosTest/ets/TestRunner/OpenHarmonyTestRunner.ts b/code/BasicFeature/TaskManagement/WorkScheduler/entry/src/ohosTest/ets/TestRunner/OpenHarmonyTestRunner.ts index 16c9099c5b0878097ff5acf9de6ee2263cc2ec90..1d4cc0e938b8aa073872903ba4cf4bcaab6e37a7 100644 --- a/code/BasicFeature/TaskManagement/WorkScheduler/entry/src/ohosTest/ets/TestRunner/OpenHarmonyTestRunner.ts +++ b/code/BasicFeature/TaskManagement/WorkScheduler/entry/src/ohosTest/ets/TestRunner/OpenHarmonyTestRunner.ts @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 Huawei Device Co., Ltd. + * Copyright (c) 2023 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 @@ -13,14 +13,12 @@ * limitations under the License. */ +import hilog from '@ohos.hilog' import TestRunner from '@ohos.application.testRunner' import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' -import { Logger } from '@ohos/notification' -const TAG: string = 'OpenHarmonyTestRunner' - -let abilityDelegator = undefined -let abilityDelegatorArguments = undefined +var abilityDelegator = undefined +var abilityDelegatorArguments = undefined function translateParamsToString(parameters) { const keySet = new Set([ @@ -28,7 +26,7 @@ function translateParamsToString(parameters) { '-s level', '-s testType', '-s size', '-s timeout', '-s dryRun' ]) - let targetParams = ''; + let targetParams = '' for (const key in parameters) { if (keySet.has(key)) { targetParams = `${targetParams} ${key} ${parameters[key]}` @@ -38,11 +36,13 @@ function translateParamsToString(parameters) { } async function onAbilityCreateCallback() { - Logger.info(TAG, `onAbilityCreateCallback`) + hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO) + hilog.info(0x0000, 'testTag', '%{public}s', 'onAbilityCreateCallback') } async function addAbilityMonitorCallback(err: any) { - Logger.info(TAG, `addAbilityMonitorCallback: ${JSON.stringify(err)}`) + hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO) + hilog.info(0x0000, 'testTag', 'addAbilityMonitorCallback : %{public}s', JSON.stringify(err) ?? '') } export default class OpenHarmonyTestRunner implements TestRunner { @@ -50,32 +50,36 @@ export default class OpenHarmonyTestRunner implements TestRunner { } onPrepare() { - Logger.info(TAG, `OpenHarmonyTestRunner OnPrepare`) + hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO) + hilog.info(0x0000, 'testTag', '%{public}s', 'OpenHarmonyTestRunner OnPrepare ') } async onRun() { - Logger.info(TAG, `OpenHarmonyTestRunner onRun run`) + hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO) + hilog.info(0x0000, 'testTag', '%{public}s', 'OpenHarmonyTestRunner onRun run') abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() var testAbilityName = abilityDelegatorArguments.bundleName + '.TestAbility' let lMonitor = { abilityName: testAbilityName, onAbilityCreate: onAbilityCreateCallback, - }; + } abilityDelegator.addAbilityMonitor(lMonitor, addAbilityMonitorCallback) var cmd = 'aa start -d 0 -a TestAbility' + ' -b ' + abilityDelegatorArguments.bundleName cmd += ' ' + translateParamsToString(abilityDelegatorArguments.parameters) - var debug = abilityDelegatorArguments.parameters["-D"] + var debug = abilityDelegatorArguments.parameters['-D'] if (debug == 'true') { cmd += ' -D' } - Logger.info(TAG, `cmd: ${cmd}`) + hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO) + hilog.info(0x0000, 'testTag', 'cmd : %{public}s', cmd) abilityDelegator.executeShellCommand(cmd, (err: any, d: any) => { - Logger.info(TAG, `executeShellCommand : err: ${JSON.stringify(err)}`) - Logger.info(TAG, `executeShellCommand : data: ${JSON.stringify(d.stdResult)}`) - Logger.info(TAG, `executeShellCommand : data: ${JSON.stringify(d.exitCode)}`) + hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO) + hilog.info(0x0000, 'testTag', 'executeShellCommand : err : %{public}s', JSON.stringify(err) ?? '') + hilog.info(0x0000, 'testTag', 'executeShellCommand : data : %{public}s', d.stdResult ?? '') + hilog.info(0x0000, 'testTag', 'executeShellCommand : data : %{public}s', d.exitCode ?? '') }) - Logger.info(TAG, `OpenHarmonyTestRunner onRun end`) + hilog.info(0x0000, 'testTag', '%{public}s', 'OpenHarmonyTestRunner onRun end') } -}; \ No newline at end of file +} \ No newline at end of file diff --git a/code/BasicFeature/TaskManagement/WorkScheduler/entry/src/ohosTest/ets/test/Ability.test.ets b/code/BasicFeature/TaskManagement/WorkScheduler/entry/src/ohosTest/ets/test/Ability.test.ets index c3724d4ca336eaca7e89e33320f3cf103cd32653..9c56e32c506a0dd838a97445a859e396f75ee174 100644 --- a/code/BasicFeature/TaskManagement/WorkScheduler/entry/src/ohosTest/ets/test/Ability.test.ets +++ b/code/BasicFeature/TaskManagement/WorkScheduler/entry/src/ohosTest/ets/test/Ability.test.ets @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 Huawei Device Co., Ltd. + * Copyright (c) 2023 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 @@ -13,17 +13,37 @@ * limitations under the License. */ +import hilog from '@ohos.hilog'; import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium' -import { Logger } from '@ohos/notification' - -const TAG: string = 'abilityTest' export default function abilityTest() { describe('ActsAbilityTest', function () { + // Defines a test suite. Two parameters are supported: test suite name and test suite function. + beforeAll(function () { + // Presets an action, which is performed only once before all test cases of the test suite start. + // This API supports only one parameter: preset action function. + }) + beforeEach(function () { + // Presets an action, which is performed before each unit test case starts. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: preset action function. + }) + afterEach(function () { + // Presets a clear action, which is performed after each unit test case ends. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: clear action function. + }) + afterAll(function () { + // Presets a clear action, which is performed after all test cases of the test suite end. + // This API supports only one parameter: clear action function. + }) it('assertContain', 0, function () { - Logger.info(TAG, `it begin`) + // Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function. + hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO); + hilog.info(0x0000, 'testTag', '%{public}s', 'it begin'); let a = 'abc' let b = 'b' + // Defines a variety of assertion methods, which are used to declare expected boolean conditions. expect(a).assertContain(b) expect(a).assertEqual(a) }) diff --git a/code/BasicFeature/TaskManagement/WorkScheduler/entry/src/ohosTest/ets/test/List.test.ets b/code/BasicFeature/TaskManagement/WorkScheduler/entry/src/ohosTest/ets/test/List.test.ets index 7e05ea60952f76d30ba3268f238352215f062110..27c07a1a174f6862ea84c4bb5f45bc1789234441 100644 --- a/code/BasicFeature/TaskManagement/WorkScheduler/entry/src/ohosTest/ets/test/List.test.ets +++ b/code/BasicFeature/TaskManagement/WorkScheduler/entry/src/ohosTest/ets/test/List.test.ets @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 Huawei Device Co., Ltd. + * Copyright (c) 2023 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 diff --git a/code/BasicFeature/TaskManagement/WorkScheduler/entry/src/ohosTest/module.json5 b/code/BasicFeature/TaskManagement/WorkScheduler/entry/src/ohosTest/module.json5 index 7a63ae7f49d2053d7220ab8ec46e1c0a04e675db..22e2c611f379dbb0fddf452b259ef27c508d058b 100644 --- a/code/BasicFeature/TaskManagement/WorkScheduler/entry/src/ohosTest/module.json5 +++ b/code/BasicFeature/TaskManagement/WorkScheduler/entry/src/ohosTest/module.json5 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 Huawei Device Co., Ltd. + * Copyright (c) 2023 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 @@ -17,8 +17,7 @@ "module": { "name": "entry_test", "type": "feature", - "srcEntrance": "./ets/Application/TestAbilityStage.ts", - "description": "$string:entry_test_desc", + "description": "$string:module_test_desc", "mainElement": "TestAbility", "deviceTypes": [ "default", @@ -27,17 +26,16 @@ "deliveryWithInstall": true, "installationFree": false, "pages": "$profile:test_pages", - "uiSyntax": "ets", "abilities": [ { "name": "TestAbility", - "srcEntrance": "./ets/TestAbility/TestAbility.ts", + "srcEntrance": "./ets/testability/TestAbility.ets", "description": "$string:TestAbility_desc", "icon": "$media:icon", "label": "$string:TestAbility_label", "visible": true, "startWindowIcon": "$media:icon", - "startWindowBackground": "$color:white", + "startWindowBackground": "$color:start_window_background", "skills": [ { "actions": [ diff --git a/code/BasicFeature/TaskManagement/WorkScheduler/entry/src/ohosTest/resources/base/element/color.json b/code/BasicFeature/TaskManagement/WorkScheduler/entry/src/ohosTest/resources/base/element/color.json index 1bbc9aa9617e97c45440e1d3d66afc1154837012..3c712962da3c2751c2b9ddb53559afcbd2b54a02 100644 --- a/code/BasicFeature/TaskManagement/WorkScheduler/entry/src/ohosTest/resources/base/element/color.json +++ b/code/BasicFeature/TaskManagement/WorkScheduler/entry/src/ohosTest/resources/base/element/color.json @@ -1,7 +1,7 @@ { "color": [ { - "name": "white", + "name": "start_window_background", "value": "#FFFFFF" } ] diff --git a/code/BasicFeature/TaskManagement/WorkScheduler/entry/src/ohosTest/resources/base/element/string.json b/code/BasicFeature/TaskManagement/WorkScheduler/entry/src/ohosTest/resources/base/element/string.json index 36d4230c53e9f5a07ae343ad8dc9808341975e3b..65d8fa5a7cf54aa3943dcd0214f58d1771bc1f6c 100644 --- a/code/BasicFeature/TaskManagement/WorkScheduler/entry/src/ohosTest/resources/base/element/string.json +++ b/code/BasicFeature/TaskManagement/WorkScheduler/entry/src/ohosTest/resources/base/element/string.json @@ -1,7 +1,7 @@ { "string": [ { - "name": "entry_test_desc", + "name": "module_test_desc", "value": "test ability description" }, { diff --git a/code/BasicFeature/TaskManagement/WorkScheduler/entry/src/ohosTest/resources/base/profile/test_pages.json b/code/BasicFeature/TaskManagement/WorkScheduler/entry/src/ohosTest/resources/base/profile/test_pages.json index fcef82b4dfc18e28106ff9ecd1c8b48ec74d18a4..b7e7343cacb32ce982a45e76daad86e435e054fe 100644 --- a/code/BasicFeature/TaskManagement/WorkScheduler/entry/src/ohosTest/resources/base/profile/test_pages.json +++ b/code/BasicFeature/TaskManagement/WorkScheduler/entry/src/ohosTest/resources/base/profile/test_pages.json @@ -1,5 +1,5 @@ { "src": [ - "TestAbility/pages/index" + "testability/pages/Index" ] } diff --git a/code/BasicFeature/TaskManagement/WorkScheduler/package.json b/code/BasicFeature/TaskManagement/WorkScheduler/package.json index 387cab327e73c58e3ba6deecbb2b84c12074bc17..49b756a5c2a01fdc27214b65ed9c44ac85e20f42 100644 --- a/code/BasicFeature/TaskManagement/WorkScheduler/package.json +++ b/code/BasicFeature/TaskManagement/WorkScheduler/package.json @@ -1,7 +1,7 @@ { "license": "ISC", "devDependencies": {}, - "name": "workscheduler", + "name": "workSchedulerExtensionAbility", "ohos": { "org": "huawei", "directoryLevel": "project", @@ -11,8 +11,8 @@ "repository": {}, "version": "1.0.0", "dependencies": { - "@ohos/hypium": "1.0.1", - "@ohos/hvigor-ohos-plugin": "1.1.6", - "@ohos/hvigor": "1.1.6" + "@ohos/hypium": "1.0.3", + "@ohos/hvigor-ohos-plugin": "1.3.1", + "@ohos/hvigor": "1.3.1" } -} +} \ No newline at end of file diff --git a/code/BasicFeature/TaskManagement/WorkScheduler/screenshots/device/dialog.png b/code/BasicFeature/TaskManagement/WorkScheduler/screenshots/device/dialog.png new file mode 100644 index 0000000000000000000000000000000000000000..61d856da538f0abc3404ed41152ea0b456446bfd Binary files /dev/null and b/code/BasicFeature/TaskManagement/WorkScheduler/screenshots/device/dialog.png differ diff --git a/code/BasicFeature/TaskManagement/WorkScheduler/screenshots/device/newVersion.png b/code/BasicFeature/TaskManagement/WorkScheduler/screenshots/device/newVersion.png new file mode 100644 index 0000000000000000000000000000000000000000..20be7d0f0aab3cbcdcb82a2e67e2c64e6150bfda Binary files /dev/null and b/code/BasicFeature/TaskManagement/WorkScheduler/screenshots/device/newVersion.png differ diff --git a/code/BasicFeature/TaskManagement/WorkScheduler/screenshots/device/oldVersion.png b/code/BasicFeature/TaskManagement/WorkScheduler/screenshots/device/oldVersion.png new file mode 100644 index 0000000000000000000000000000000000000000..b4509fe804ca9c03c1b07bee3005186064b8ca59 Binary files /dev/null and b/code/BasicFeature/TaskManagement/WorkScheduler/screenshots/device/oldVersion.png differ diff --git a/code/BasicFeature/Telephony/Call/README_zh.md b/code/BasicFeature/Telephony/Call/README_zh.md index 7847cde39666a8e2c64364b429f78129dd1fc96c..12c5b9a5fb8a5522841d61344003277a1e30589c 100644 --- a/code/BasicFeature/Telephony/Call/README_zh.md +++ b/code/BasicFeature/Telephony/Call/README_zh.md @@ -30,8 +30,8 @@ 2.本示例需要插入SIM卡,目前该功能仅支持部分机型。 -3.本示例仅支持API9版本SDK,版本号:3.2.7.6。 +3.本示例仅支持API9版本SDK,版本号:3.2.10.6。 -4.本示例需要使用DevEco Studio 3.1 Canary1 (Build Version: 3.1.0.100, built on November 3, 2022)才可编译运行。 +4.本示例需要使用DevEco Studio 3.1 Canary1 (Build Version: 3.1.0.100)及以上才可编译运行。 5.本示例所配置的权限ohos.permission.PLACE_CALL为system_basic级别(相关权限级别可通过[权限定义列表](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/security/permission-list.md)查看),需要手动配置对应级别的权限签名(具体操作可查看[自动化签名方案](https://docs.openharmony.cn/pages/v3.2Beta/zh-cn/application-dev/security/hapsigntool-overview.md/))。 \ No newline at end of file diff --git a/code/BasicFeature/Telephony/Call/entry/package.json b/code/BasicFeature/Telephony/Call/entry/package.json index 29732ffea047ab4e9d897d4cc7092f5e7fe3493f..db08bbf9d7439623fcfa4093ab7f013633c62d48 100644 --- a/code/BasicFeature/Telephony/Call/entry/package.json +++ b/code/BasicFeature/Telephony/Call/entry/package.json @@ -11,4 +11,4 @@ "repository": {}, "version": "1.0.0", "dependencies": {} -} +} \ No newline at end of file diff --git a/code/BasicFeature/Telephony/Call/entry/src/main/ets/entryability/EntryAbility.ts b/code/BasicFeature/Telephony/Call/entry/src/main/ets/entryability/EntryAbility.ts index 37eeecafce1539948dbc83fc0082a230bee2bfcf..e00418957a702443eb11f6e6c83e0f306f63e19d 100644 --- a/code/BasicFeature/Telephony/Call/entry/src/main/ets/entryability/EntryAbility.ts +++ b/code/BasicFeature/Telephony/Call/entry/src/main/ets/entryability/EntryAbility.ts @@ -14,12 +14,12 @@ */ import Logger from '../model/Logger' -import Ability from '@ohos.application.Ability' +import UIAbility from '@ohos.app.ability.UIAbility' import Window from '@ohos.window' const TAG: string = '[Index]' -export default class EntryAbility extends Ability { +export default class EntryAbility extends UIAbility { onCreate(want, launchParam) { Logger.info(TAG, `Ability onCreate want param: ` + JSON.stringify(want) ?? '' + 'launchParam:' + JSON.stringify(launchParam) ?? '') } diff --git a/code/BasicFeature/Telephony/Call/package.json b/code/BasicFeature/Telephony/Call/package.json index 07768484c756906dbf040d1088421ac08d7aa53c..3f4756852aba9e11613d6af40928ba256e8464f0 100644 --- a/code/BasicFeature/Telephony/Call/package.json +++ b/code/BasicFeature/Telephony/Call/package.json @@ -15,4 +15,4 @@ "@ohos/hvigor-ohos-plugin": "1.3.1", "@ohos/hvigor": "1.3.1" } -} +} \ No newline at end of file diff --git a/code/Solutions/IM/Chat/README_zh.md b/code/Solutions/IM/Chat/README_zh.md index b1b5f00964c2f576280f79b433352cde60994243..6efad7def7689e648a9c0099c2a15fbdbc043aa5 100644 --- a/code/Solutions/IM/Chat/README_zh.md +++ b/code/Solutions/IM/Chat/README_zh.md @@ -36,6 +36,6 @@ ### 约束与限制 -1.sdk版本要求使用3.1.5.5及以上版本。 +1.sdk版本要求使用3.2.10.6及以上版本。 -2.本示例需要使用DevEco Studio 3.0 Beta4 (Build Version: 3.0.0.992, built on July 14, 2022)才可编译运行。 +2.本示例需要使用DevEco Studio 3.1 Canary1 (Build Version: 3.1.0.100)及以上才可编译运行。 diff --git a/code/Solutions/IM/Chat/entry/package.json b/code/Solutions/IM/Chat/entry/package.json index 29732ffea047ab4e9d897d4cc7092f5e7fe3493f..db08bbf9d7439623fcfa4093ab7f013633c62d48 100644 --- a/code/Solutions/IM/Chat/entry/package.json +++ b/code/Solutions/IM/Chat/entry/package.json @@ -11,4 +11,4 @@ "repository": {}, "version": "1.0.0", "dependencies": {} -} +} \ No newline at end of file diff --git a/code/Solutions/IM/Chat/package.json b/code/Solutions/IM/Chat/package.json index 95012f5a1fb6ff9d6b7cca84364ea93c6ec03bc5..6c3ac1a0969d0f4ee8a47fe02908cd9433ac5419 100644 --- a/code/Solutions/IM/Chat/package.json +++ b/code/Solutions/IM/Chat/package.json @@ -11,8 +11,8 @@ "repository": {}, "version": "1.0.0", "dependencies": { - "@ohos/hypium": "1.0.1", - "@ohos/hvigor-ohos-plugin": "1.1.6", - "@ohos/hvigor": "1.1.6" + "@ohos/hypium": "1.0.3", + "@ohos/hvigor-ohos-plugin": "1.3.1", + "@ohos/hvigor": "1.3.1" } } \ No newline at end of file