@harmonyos-arkts/droid2hmos 0.0.9 → 0.0.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -21
- package/README.md +249 -249
- package/config/preflight-checklist.json +65 -65
- package/dist/cli.js +190 -26
- package/dist/cli.js.map +1 -1
- package/package.json +36 -36
- package/templates/ohos/AppScope/app.json5 +10 -10
- package/templates/ohos/AppScope/resources/base/element/string.json +8 -8
- package/templates/ohos/AppScope/resources/base/media/layered_image.json +6 -6
- package/templates/ohos/build-profile.json5 +41 -41
- package/templates/ohos/code-linter.json5 +31 -31
- package/templates/ohos/entry/build-profile.json5 +32 -32
- package/templates/ohos/entry/hvigorfile.ts +5 -5
- package/templates/ohos/entry/obfuscation-rules.txt +22 -22
- package/templates/ohos/entry/oh-package.json5 +10 -10
- package/templates/ohos/entry/src/main/ets/entryability/EntryAbility.ets +47 -47
- package/templates/ohos/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets +15 -15
- package/templates/ohos/entry/src/main/ets/pages/Index.ets +22 -22
- package/templates/ohos/entry/src/main/module.json5 +49 -49
- package/templates/ohos/entry/src/main/resources/base/element/color.json +7 -7
- package/templates/ohos/entry/src/main/resources/base/element/float.json +8 -8
- package/templates/ohos/entry/src/main/resources/base/element/string.json +15 -15
- package/templates/ohos/entry/src/main/resources/base/media/layered_image.json +6 -6
- package/templates/ohos/entry/src/main/resources/base/profile/backup_config.json +2 -2
- package/templates/ohos/entry/src/main/resources/base/profile/main_pages.json +5 -5
- package/templates/ohos/entry/src/main/resources/dark/element/color.json +7 -7
- package/templates/ohos/entry/src/mock/mock-config.json5 +1 -1
- package/templates/ohos/entry/src/ohosTest/ets/test/Ability.test.ets +34 -34
- package/templates/ohos/entry/src/ohosTest/ets/test/List.test.ets +4 -4
- package/templates/ohos/entry/src/ohosTest/ets/testability/TestAbility.ets +48 -48
- package/templates/ohos/entry/src/ohosTest/ets/testability/pages/Index.ets +14 -14
- package/templates/ohos/entry/src/ohosTest/ets/testrunner/OpenHarmonyTestRunner.ets +41 -41
- package/templates/ohos/entry/src/ohosTest/module.json5 +25 -25
- package/templates/ohos/entry/src/ohosTest/resources/base/element/color.json +7 -7
- package/templates/ohos/entry/src/ohosTest/resources/base/element/string.json +12 -12
- package/templates/ohos/entry/src/ohosTest/resources/base/profile/test_pages.json +5 -5
- package/templates/ohos/entry/src/test/List.test.ets +4 -4
- package/templates/ohos/entry/src/test/LocalUnit.test.ets +32 -32
- package/templates/ohos/hvigor/hvigor-config.json5 +23 -23
- package/templates/ohos/hvigorfile.ts +5 -5
- package/templates/ohos/oh-package-lock.json5 +27 -27
- package/templates/ohos/oh-package.json5 +10 -10
package/package.json
CHANGED
|
@@ -1,36 +1,36 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@harmonyos-arkts/droid2hmos",
|
|
3
|
-
"version": "0.0.
|
|
4
|
-
"description": "Report-driven Android to HarmonyOS migration CLI",
|
|
5
|
-
"type": "module",
|
|
6
|
-
"bin": {
|
|
7
|
-
"droid2hmos": "dist/cli.js"
|
|
8
|
-
},
|
|
9
|
-
"files": [
|
|
10
|
-
"dist/",
|
|
11
|
-
"config/",
|
|
12
|
-
"templates/",
|
|
13
|
-
"README.md",
|
|
14
|
-
"LICENSE"
|
|
15
|
-
],
|
|
16
|
-
"scripts": {
|
|
17
|
-
"typecheck": "tsc --noEmit",
|
|
18
|
-
"build": "tsup",
|
|
19
|
-
"test": "npm run build && tsx --test test/*.test.ts",
|
|
20
|
-
"verify": "npm run typecheck && npm run build && tsx --test test/*.test.ts"
|
|
21
|
-
},
|
|
22
|
-
"dependencies": {
|
|
23
|
-
"jpeg-js": "^0.4.4",
|
|
24
|
-
"json5": "^2.2.3"
|
|
25
|
-
},
|
|
26
|
-
"engines": {
|
|
27
|
-
"node": ">=20 <25"
|
|
28
|
-
},
|
|
29
|
-
"license": "MIT",
|
|
30
|
-
"devDependencies": {
|
|
31
|
-
"@types/node": "^26.4.0",
|
|
32
|
-
"tsup": "^8.5.1",
|
|
33
|
-
"tsx": "^4.23.13",
|
|
34
|
-
"typescript": "^7.0.2"
|
|
35
|
-
}
|
|
36
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@harmonyos-arkts/droid2hmos",
|
|
3
|
+
"version": "0.0.10",
|
|
4
|
+
"description": "Report-driven Android to HarmonyOS migration CLI",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"bin": {
|
|
7
|
+
"droid2hmos": "dist/cli.js"
|
|
8
|
+
},
|
|
9
|
+
"files": [
|
|
10
|
+
"dist/",
|
|
11
|
+
"config/",
|
|
12
|
+
"templates/",
|
|
13
|
+
"README.md",
|
|
14
|
+
"LICENSE"
|
|
15
|
+
],
|
|
16
|
+
"scripts": {
|
|
17
|
+
"typecheck": "tsc --noEmit",
|
|
18
|
+
"build": "tsup",
|
|
19
|
+
"test": "npm run build && tsx --test test/*.test.ts",
|
|
20
|
+
"verify": "npm run typecheck && npm run build && tsx --test test/*.test.ts"
|
|
21
|
+
},
|
|
22
|
+
"dependencies": {
|
|
23
|
+
"jpeg-js": "^0.4.4",
|
|
24
|
+
"json5": "^2.2.3"
|
|
25
|
+
},
|
|
26
|
+
"engines": {
|
|
27
|
+
"node": ">=20 <25"
|
|
28
|
+
},
|
|
29
|
+
"license": "MIT",
|
|
30
|
+
"devDependencies": {
|
|
31
|
+
"@types/node": "^26.4.0",
|
|
32
|
+
"tsup": "^8.5.1",
|
|
33
|
+
"tsx": "^4.23.13",
|
|
34
|
+
"typescript": "^7.0.2"
|
|
35
|
+
}
|
|
36
|
+
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
{
|
|
2
|
-
"app": {
|
|
3
|
-
"bundleName": "com.zj67.myapplication",
|
|
4
|
-
"vendor": "example",
|
|
5
|
-
"versionCode": 1000000,
|
|
6
|
-
"versionName": "1.0.0",
|
|
7
|
-
"icon": "$media:layered_image",
|
|
8
|
-
"label": "$string:app_name"
|
|
9
|
-
}
|
|
10
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"app": {
|
|
3
|
+
"bundleName": "com.zj67.myapplication",
|
|
4
|
+
"vendor": "example",
|
|
5
|
+
"versionCode": 1000000,
|
|
6
|
+
"versionName": "1.0.0",
|
|
7
|
+
"icon": "$media:layered_image",
|
|
8
|
+
"label": "$string:app_name"
|
|
9
|
+
}
|
|
10
|
+
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
{
|
|
2
|
-
"string": [
|
|
3
|
-
{
|
|
4
|
-
"name": "app_name",
|
|
5
|
-
"value": "ohos"
|
|
6
|
-
}
|
|
7
|
-
]
|
|
8
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"string": [
|
|
3
|
+
{
|
|
4
|
+
"name": "app_name",
|
|
5
|
+
"value": "ohos"
|
|
6
|
+
}
|
|
7
|
+
]
|
|
8
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
{
|
|
2
|
-
"layered-image":
|
|
3
|
-
{
|
|
4
|
-
"background" : "$media:background",
|
|
5
|
-
"foreground" : "$media:foreground"
|
|
6
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"layered-image":
|
|
3
|
+
{
|
|
4
|
+
"background" : "$media:background",
|
|
5
|
+
"foreground" : "$media:foreground"
|
|
6
|
+
}
|
|
7
7
|
}
|
|
@@ -1,42 +1,42 @@
|
|
|
1
|
-
{
|
|
2
|
-
"app": {
|
|
3
|
-
"signingConfigs": [],
|
|
4
|
-
"products": [
|
|
5
|
-
{
|
|
6
|
-
"name": "default",
|
|
7
|
-
"signingConfig": "default",
|
|
8
|
-
"targetSdkVersion": "6.0.2(22)",
|
|
9
|
-
"compatibleSdkVersion": "5.0.0(12)",
|
|
10
|
-
"runtimeOS": "HarmonyOS",
|
|
11
|
-
"buildOption": {
|
|
12
|
-
"strictMode": {
|
|
13
|
-
"caseSensitiveCheck": true,
|
|
14
|
-
"useNormalizedOHMUrl": true
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
],
|
|
19
|
-
"buildModeSet": [
|
|
20
|
-
{
|
|
21
|
-
"name": "debug",
|
|
22
|
-
},
|
|
23
|
-
{
|
|
24
|
-
"name": "release"
|
|
25
|
-
}
|
|
26
|
-
]
|
|
27
|
-
},
|
|
28
|
-
"modules": [
|
|
29
|
-
{
|
|
30
|
-
"name": "entry",
|
|
31
|
-
"srcPath": "./entry",
|
|
32
|
-
"targets": [
|
|
33
|
-
{
|
|
34
|
-
"name": "default",
|
|
35
|
-
"applyToProducts": [
|
|
36
|
-
"default"
|
|
37
|
-
]
|
|
38
|
-
}
|
|
39
|
-
]
|
|
40
|
-
}
|
|
41
|
-
]
|
|
1
|
+
{
|
|
2
|
+
"app": {
|
|
3
|
+
"signingConfigs": [],
|
|
4
|
+
"products": [
|
|
5
|
+
{
|
|
6
|
+
"name": "default",
|
|
7
|
+
"signingConfig": "default",
|
|
8
|
+
"targetSdkVersion": "6.0.2(22)",
|
|
9
|
+
"compatibleSdkVersion": "5.0.0(12)",
|
|
10
|
+
"runtimeOS": "HarmonyOS",
|
|
11
|
+
"buildOption": {
|
|
12
|
+
"strictMode": {
|
|
13
|
+
"caseSensitiveCheck": true,
|
|
14
|
+
"useNormalizedOHMUrl": true
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
],
|
|
19
|
+
"buildModeSet": [
|
|
20
|
+
{
|
|
21
|
+
"name": "debug",
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
"name": "release"
|
|
25
|
+
}
|
|
26
|
+
]
|
|
27
|
+
},
|
|
28
|
+
"modules": [
|
|
29
|
+
{
|
|
30
|
+
"name": "entry",
|
|
31
|
+
"srcPath": "./entry",
|
|
32
|
+
"targets": [
|
|
33
|
+
{
|
|
34
|
+
"name": "default",
|
|
35
|
+
"applyToProducts": [
|
|
36
|
+
"default"
|
|
37
|
+
]
|
|
38
|
+
}
|
|
39
|
+
]
|
|
40
|
+
}
|
|
41
|
+
]
|
|
42
42
|
}
|
|
@@ -1,32 +1,32 @@
|
|
|
1
|
-
{
|
|
2
|
-
"files": [
|
|
3
|
-
"**/*.ets"
|
|
4
|
-
],
|
|
5
|
-
"ignore": [
|
|
6
|
-
"**/src/ohosTest/**/*",
|
|
7
|
-
"**/src/test/**/*",
|
|
8
|
-
"**/src/mock/**/*",
|
|
9
|
-
"**/node_modules/**/*",
|
|
10
|
-
"**/oh_modules/**/*",
|
|
11
|
-
"**/build/**/*",
|
|
12
|
-
"**/.preview/**/*"
|
|
13
|
-
],
|
|
14
|
-
"ruleSet": [
|
|
15
|
-
"plugin:@performance/recommended",
|
|
16
|
-
"plugin:@typescript-eslint/recommended"
|
|
17
|
-
],
|
|
18
|
-
"rules": {
|
|
19
|
-
"@security/no-unsafe-aes": "error",
|
|
20
|
-
"@security/no-unsafe-hash": "error",
|
|
21
|
-
"@security/no-unsafe-mac": "warn",
|
|
22
|
-
"@security/no-unsafe-dh": "error",
|
|
23
|
-
"@security/no-unsafe-dsa": "error",
|
|
24
|
-
"@security/no-unsafe-ecdsa": "error",
|
|
25
|
-
"@security/no-unsafe-rsa-encrypt": "error",
|
|
26
|
-
"@security/no-unsafe-rsa-sign": "error",
|
|
27
|
-
"@security/no-unsafe-rsa-key": "error",
|
|
28
|
-
"@security/no-unsafe-dsa-key": "error",
|
|
29
|
-
"@security/no-unsafe-dh-key": "error",
|
|
30
|
-
"@security/no-unsafe-3des": "error"
|
|
31
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"files": [
|
|
3
|
+
"**/*.ets"
|
|
4
|
+
],
|
|
5
|
+
"ignore": [
|
|
6
|
+
"**/src/ohosTest/**/*",
|
|
7
|
+
"**/src/test/**/*",
|
|
8
|
+
"**/src/mock/**/*",
|
|
9
|
+
"**/node_modules/**/*",
|
|
10
|
+
"**/oh_modules/**/*",
|
|
11
|
+
"**/build/**/*",
|
|
12
|
+
"**/.preview/**/*"
|
|
13
|
+
],
|
|
14
|
+
"ruleSet": [
|
|
15
|
+
"plugin:@performance/recommended",
|
|
16
|
+
"plugin:@typescript-eslint/recommended"
|
|
17
|
+
],
|
|
18
|
+
"rules": {
|
|
19
|
+
"@security/no-unsafe-aes": "error",
|
|
20
|
+
"@security/no-unsafe-hash": "error",
|
|
21
|
+
"@security/no-unsafe-mac": "warn",
|
|
22
|
+
"@security/no-unsafe-dh": "error",
|
|
23
|
+
"@security/no-unsafe-dsa": "error",
|
|
24
|
+
"@security/no-unsafe-ecdsa": "error",
|
|
25
|
+
"@security/no-unsafe-rsa-encrypt": "error",
|
|
26
|
+
"@security/no-unsafe-rsa-sign": "error",
|
|
27
|
+
"@security/no-unsafe-rsa-key": "error",
|
|
28
|
+
"@security/no-unsafe-dsa-key": "error",
|
|
29
|
+
"@security/no-unsafe-dh-key": "error",
|
|
30
|
+
"@security/no-unsafe-3des": "error"
|
|
31
|
+
}
|
|
32
32
|
}
|
|
@@ -1,33 +1,33 @@
|
|
|
1
|
-
{
|
|
2
|
-
"apiType": "stageMode",
|
|
3
|
-
"buildOption": {
|
|
4
|
-
"resOptions": {
|
|
5
|
-
"copyCodeResource": {
|
|
6
|
-
"enable": false
|
|
7
|
-
}
|
|
8
|
-
}
|
|
9
|
-
},
|
|
10
|
-
"buildOptionSet": [
|
|
11
|
-
{
|
|
12
|
-
"name": "release",
|
|
13
|
-
"arkOptions": {
|
|
14
|
-
"obfuscation": {
|
|
15
|
-
"ruleOptions": {
|
|
16
|
-
"enable": false,
|
|
17
|
-
"files": [
|
|
18
|
-
"./obfuscation-rules.txt"
|
|
19
|
-
]
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
},
|
|
24
|
-
],
|
|
25
|
-
"targets": [
|
|
26
|
-
{
|
|
27
|
-
"name": "default"
|
|
28
|
-
},
|
|
29
|
-
{
|
|
30
|
-
"name": "ohosTest",
|
|
31
|
-
}
|
|
32
|
-
]
|
|
1
|
+
{
|
|
2
|
+
"apiType": "stageMode",
|
|
3
|
+
"buildOption": {
|
|
4
|
+
"resOptions": {
|
|
5
|
+
"copyCodeResource": {
|
|
6
|
+
"enable": false
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
},
|
|
10
|
+
"buildOptionSet": [
|
|
11
|
+
{
|
|
12
|
+
"name": "release",
|
|
13
|
+
"arkOptions": {
|
|
14
|
+
"obfuscation": {
|
|
15
|
+
"ruleOptions": {
|
|
16
|
+
"enable": false,
|
|
17
|
+
"files": [
|
|
18
|
+
"./obfuscation-rules.txt"
|
|
19
|
+
]
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
],
|
|
25
|
+
"targets": [
|
|
26
|
+
{
|
|
27
|
+
"name": "default"
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
"name": "ohosTest",
|
|
31
|
+
}
|
|
32
|
+
]
|
|
33
33
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { hapTasks } from '@ohos/hvigor-ohos-plugin';
|
|
2
|
-
|
|
3
|
-
export default {
|
|
4
|
-
system: hapTasks, /* Built-in plugin of Hvigor. It cannot be modified. */
|
|
5
|
-
plugins: [] /* Custom plugin to extend the functionality of Hvigor. */
|
|
1
|
+
import { hapTasks } from '@ohos/hvigor-ohos-plugin';
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
system: hapTasks, /* Built-in plugin of Hvigor. It cannot be modified. */
|
|
5
|
+
plugins: [] /* Custom plugin to extend the functionality of Hvigor. */
|
|
6
6
|
}
|
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
# Define project specific obfuscation rules here.
|
|
2
|
-
# You can include the obfuscation configuration files in the current module's build-profile.json5.
|
|
3
|
-
#
|
|
4
|
-
# For more details, see
|
|
5
|
-
# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides/source-obfuscation
|
|
6
|
-
|
|
7
|
-
# Obfuscation options:
|
|
8
|
-
# -disable-obfuscation: disable all obfuscations
|
|
9
|
-
# -enable-property-obfuscation: obfuscate the property names
|
|
10
|
-
# -enable-toplevel-obfuscation: obfuscate the names in the global scope
|
|
11
|
-
# -compact: remove unnecessary blank spaces and all line feeds
|
|
12
|
-
# -remove-log: remove all console.* statements
|
|
13
|
-
# -print-namecache: print the name cache that contains the mapping from the old names to new names
|
|
14
|
-
# -apply-namecache: reuse the given cache file
|
|
15
|
-
|
|
16
|
-
# Keep options:
|
|
17
|
-
# -keep-property-name: specifies property names that you want to keep
|
|
18
|
-
# -keep-global-name: specifies names that you want to keep in the global scope
|
|
19
|
-
|
|
20
|
-
-enable-property-obfuscation
|
|
21
|
-
-enable-toplevel-obfuscation
|
|
22
|
-
-enable-filename-obfuscation
|
|
1
|
+
# Define project specific obfuscation rules here.
|
|
2
|
+
# You can include the obfuscation configuration files in the current module's build-profile.json5.
|
|
3
|
+
#
|
|
4
|
+
# For more details, see
|
|
5
|
+
# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides/source-obfuscation
|
|
6
|
+
|
|
7
|
+
# Obfuscation options:
|
|
8
|
+
# -disable-obfuscation: disable all obfuscations
|
|
9
|
+
# -enable-property-obfuscation: obfuscate the property names
|
|
10
|
+
# -enable-toplevel-obfuscation: obfuscate the names in the global scope
|
|
11
|
+
# -compact: remove unnecessary blank spaces and all line feeds
|
|
12
|
+
# -remove-log: remove all console.* statements
|
|
13
|
+
# -print-namecache: print the name cache that contains the mapping from the old names to new names
|
|
14
|
+
# -apply-namecache: reuse the given cache file
|
|
15
|
+
|
|
16
|
+
# Keep options:
|
|
17
|
+
# -keep-property-name: specifies property names that you want to keep
|
|
18
|
+
# -keep-global-name: specifies names that you want to keep in the global scope
|
|
19
|
+
|
|
20
|
+
-enable-property-obfuscation
|
|
21
|
+
-enable-toplevel-obfuscation
|
|
22
|
+
-enable-filename-obfuscation
|
|
23
23
|
-enable-export-obfuscation
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "entry",
|
|
3
|
-
"version": "1.0.0",
|
|
4
|
-
"description": "Please describe the basic information.",
|
|
5
|
-
"main": "",
|
|
6
|
-
"author": "",
|
|
7
|
-
"license": "",
|
|
8
|
-
"dependencies": {}
|
|
9
|
-
}
|
|
10
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "entry",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Please describe the basic information.",
|
|
5
|
+
"main": "",
|
|
6
|
+
"author": "",
|
|
7
|
+
"license": "",
|
|
8
|
+
"dependencies": {}
|
|
9
|
+
}
|
|
10
|
+
|
|
@@ -1,48 +1,48 @@
|
|
|
1
|
-
import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit';
|
|
2
|
-
import { hilog } from '@kit.PerformanceAnalysisKit';
|
|
3
|
-
import { window } from '@kit.ArkUI';
|
|
4
|
-
|
|
5
|
-
const DOMAIN = 0x0000;
|
|
6
|
-
|
|
7
|
-
export default class EntryAbility extends UIAbility {
|
|
8
|
-
onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void {
|
|
9
|
-
try {
|
|
10
|
-
this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET);
|
|
11
|
-
} catch (err) {
|
|
12
|
-
hilog.error(DOMAIN, 'testTag', 'Failed to set colorMode. Cause: %{public}s', JSON.stringify(err));
|
|
13
|
-
}
|
|
14
|
-
hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onCreate');
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
onDestroy(): void {
|
|
18
|
-
hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onDestroy');
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
onWindowStageCreate(windowStage: window.WindowStage): void {
|
|
22
|
-
// Main window is created, set main page for this ability
|
|
23
|
-
hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onWindowStageCreate');
|
|
24
|
-
|
|
25
|
-
windowStage.loadContent('pages/Index', (err) => {
|
|
26
|
-
if (err.code) {
|
|
27
|
-
hilog.error(DOMAIN, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err));
|
|
28
|
-
return;
|
|
29
|
-
}
|
|
30
|
-
hilog.info(DOMAIN, 'testTag', 'Succeeded in loading the content.');
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
onWindowStageDestroy(): void {
|
|
35
|
-
// Main window is destroyed, release UI related resources
|
|
36
|
-
hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onWindowStageDestroy');
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
onForeground(): void {
|
|
40
|
-
// Ability has brought to foreground
|
|
41
|
-
hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onForeground');
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
onBackground(): void {
|
|
45
|
-
// Ability has back to background
|
|
46
|
-
hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onBackground');
|
|
47
|
-
}
|
|
1
|
+
import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit';
|
|
2
|
+
import { hilog } from '@kit.PerformanceAnalysisKit';
|
|
3
|
+
import { window } from '@kit.ArkUI';
|
|
4
|
+
|
|
5
|
+
const DOMAIN = 0x0000;
|
|
6
|
+
|
|
7
|
+
export default class EntryAbility extends UIAbility {
|
|
8
|
+
onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void {
|
|
9
|
+
try {
|
|
10
|
+
this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET);
|
|
11
|
+
} catch (err) {
|
|
12
|
+
hilog.error(DOMAIN, 'testTag', 'Failed to set colorMode. Cause: %{public}s', JSON.stringify(err));
|
|
13
|
+
}
|
|
14
|
+
hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onCreate');
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
onDestroy(): void {
|
|
18
|
+
hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onDestroy');
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
onWindowStageCreate(windowStage: window.WindowStage): void {
|
|
22
|
+
// Main window is created, set main page for this ability
|
|
23
|
+
hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onWindowStageCreate');
|
|
24
|
+
|
|
25
|
+
windowStage.loadContent('pages/Index', (err) => {
|
|
26
|
+
if (err.code) {
|
|
27
|
+
hilog.error(DOMAIN, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err));
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
hilog.info(DOMAIN, 'testTag', 'Succeeded in loading the content.');
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
onWindowStageDestroy(): void {
|
|
35
|
+
// Main window is destroyed, release UI related resources
|
|
36
|
+
hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onWindowStageDestroy');
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
onForeground(): void {
|
|
40
|
+
// Ability has brought to foreground
|
|
41
|
+
hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onForeground');
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
onBackground(): void {
|
|
45
|
+
// Ability has back to background
|
|
46
|
+
hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onBackground');
|
|
47
|
+
}
|
|
48
48
|
}
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { hilog } from '@kit.PerformanceAnalysisKit';
|
|
2
|
-
import { BackupExtensionAbility, BundleVersion } from '@kit.CoreFileKit';
|
|
3
|
-
|
|
4
|
-
const DOMAIN = 0x0000;
|
|
5
|
-
|
|
6
|
-
export default class EntryBackupAbility extends BackupExtensionAbility {
|
|
7
|
-
async onBackup() {
|
|
8
|
-
hilog.info(DOMAIN, 'testTag', 'onBackup ok');
|
|
9
|
-
await Promise.resolve();
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
async onRestore(bundleVersion: BundleVersion) {
|
|
13
|
-
hilog.info(DOMAIN, 'testTag', 'onRestore ok %{public}s', JSON.stringify(bundleVersion));
|
|
14
|
-
await Promise.resolve();
|
|
15
|
-
}
|
|
1
|
+
import { hilog } from '@kit.PerformanceAnalysisKit';
|
|
2
|
+
import { BackupExtensionAbility, BundleVersion } from '@kit.CoreFileKit';
|
|
3
|
+
|
|
4
|
+
const DOMAIN = 0x0000;
|
|
5
|
+
|
|
6
|
+
export default class EntryBackupAbility extends BackupExtensionAbility {
|
|
7
|
+
async onBackup() {
|
|
8
|
+
hilog.info(DOMAIN, 'testTag', 'onBackup ok');
|
|
9
|
+
await Promise.resolve();
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
async onRestore(bundleVersion: BundleVersion) {
|
|
13
|
+
hilog.info(DOMAIN, 'testTag', 'onRestore ok %{public}s', JSON.stringify(bundleVersion));
|
|
14
|
+
await Promise.resolve();
|
|
15
|
+
}
|
|
16
16
|
}
|
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
@Entry
|
|
2
|
-
@Component
|
|
3
|
-
struct Index {
|
|
4
|
-
@State message: string = 'Hello World';
|
|
5
|
-
|
|
6
|
-
build() {
|
|
7
|
-
RelativeContainer() {
|
|
8
|
-
Text(this.message)
|
|
9
|
-
.id('HelloWorld')
|
|
10
|
-
.fontSize($r('app.float.page_text_font_size'))
|
|
11
|
-
.fontWeight(FontWeight.Bold)
|
|
12
|
-
.alignRules({
|
|
13
|
-
center: { anchor: '__container__', align: VerticalAlign.Center },
|
|
14
|
-
middle: { anchor: '__container__', align: HorizontalAlign.Center }
|
|
15
|
-
})
|
|
16
|
-
.onClick(() => {
|
|
17
|
-
this.message = 'Welcome';
|
|
18
|
-
})
|
|
19
|
-
}
|
|
20
|
-
.height('100%')
|
|
21
|
-
.width('100%')
|
|
22
|
-
}
|
|
1
|
+
@Entry
|
|
2
|
+
@Component
|
|
3
|
+
struct Index {
|
|
4
|
+
@State message: string = 'Hello World';
|
|
5
|
+
|
|
6
|
+
build() {
|
|
7
|
+
RelativeContainer() {
|
|
8
|
+
Text(this.message)
|
|
9
|
+
.id('HelloWorld')
|
|
10
|
+
.fontSize($r('app.float.page_text_font_size'))
|
|
11
|
+
.fontWeight(FontWeight.Bold)
|
|
12
|
+
.alignRules({
|
|
13
|
+
center: { anchor: '__container__', align: VerticalAlign.Center },
|
|
14
|
+
middle: { anchor: '__container__', align: HorizontalAlign.Center }
|
|
15
|
+
})
|
|
16
|
+
.onClick(() => {
|
|
17
|
+
this.message = 'Welcome';
|
|
18
|
+
})
|
|
19
|
+
}
|
|
20
|
+
.height('100%')
|
|
21
|
+
.width('100%')
|
|
22
|
+
}
|
|
23
23
|
}
|