diff --git a/OAT.xml b/OAT.xml new file mode 100644 index 0000000000000000000000000000000000000000..921de7086caf44239a6f03c7c981eb9b37468f88 --- /dev/null +++ b/OAT.xml @@ -0,0 +1,159 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/packages/package_info_plus/package_info_plus/example/ohos/.gitignore b/packages/package_info_plus/package_info_plus/example/ohos/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..11784662aacd838dd06d8d80504c161b73904865 --- /dev/null +++ b/packages/package_info_plus/package_info_plus/example/ohos/.gitignore @@ -0,0 +1,16 @@ +/node_modules +/oh_modules +/local.properties +/.idea +**/build +/.hvigor +.cxx +/.clangd +/.clang-format +/.clang-tidy +**/.test +entry/libs/arm64-v8a/libapp.so +entry/libs/arm64-v8a/libflutter.so +entry/libs/arm64-v8a/libvmservice_snapshot.so +entry/src/main/resources/rawfile/flutter_assets/ +har/flutter_embedding.har diff --git a/packages/package_info_plus/package_info_plus/example/ohos/AppScope/app.json5 b/packages/package_info_plus/package_info_plus/example/ohos/AppScope/app.json5 new file mode 100644 index 0000000000000000000000000000000000000000..b837a97566e39ae860ce3c218e9f6df9871a0e83 --- /dev/null +++ b/packages/package_info_plus/package_info_plus/example/ohos/AppScope/app.json5 @@ -0,0 +1,10 @@ +{ + "app": { + "bundleName": "io.flutter.plugins.example", + "vendor": "example", + "versionCode": 4, + "versionName": "1.2.3", + "icon": "$media:app_icon", + "label": "$string:app_name" + } +} \ No newline at end of file diff --git a/packages/package_info_plus/package_info_plus/example/ohos/AppScope/resources/base/element/string.json b/packages/package_info_plus/package_info_plus/example/ohos/AppScope/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..810f4a362c1d177309eec4f2efe5cac2f4558c28 --- /dev/null +++ b/packages/package_info_plus/package_info_plus/example/ohos/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "example" + } + ] +} diff --git a/packages/package_info_plus/package_info_plus/example/ohos/AppScope/resources/base/media/app_icon.png b/packages/package_info_plus/package_info_plus/example/ohos/AppScope/resources/base/media/app_icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/packages/package_info_plus/package_info_plus/example/ohos/AppScope/resources/base/media/app_icon.png differ diff --git a/packages/package_info_plus/package_info_plus/example/ohos/build-profile.json5 b/packages/package_info_plus/package_info_plus/example/ohos/build-profile.json5 new file mode 100644 index 0000000000000000000000000000000000000000..6fb0c59b76d090432b5f2d463aad2c83deb4381c --- /dev/null +++ b/packages/package_info_plus/package_info_plus/example/ohos/build-profile.json5 @@ -0,0 +1,27 @@ +{ + "app": { + "signingConfigs": [], + "products": [ + { + "name": "default", + "signingConfig": "default", + "compatibleSdkVersion": "5.0.0(12)", + "runtimeOS": "HarmonyOS" + } + ] + }, + "modules": [ + { + "name": "entry", + "srcPath": "./entry", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + } + ] +} diff --git a/packages/package_info_plus/package_info_plus/example/ohos/dependencies/hvigor-3.2.1-s.tgz b/packages/package_info_plus/package_info_plus/example/ohos/dependencies/hvigor-3.2.1-s.tgz new file mode 100644 index 0000000000000000000000000000000000000000..192fd1cc134a755f681480b2d1d0fd0200e0b987 Binary files /dev/null and b/packages/package_info_plus/package_info_plus/example/ohos/dependencies/hvigor-3.2.1-s.tgz differ diff --git a/packages/package_info_plus/package_info_plus/example/ohos/dependencies/hvigor-ohos-arkui-x-plugin-2.3.0-s.tgz b/packages/package_info_plus/package_info_plus/example/ohos/dependencies/hvigor-ohos-arkui-x-plugin-2.3.0-s.tgz new file mode 100644 index 0000000000000000000000000000000000000000..f68ba481042f63665474b9cc85557cd4e67b765d Binary files /dev/null and b/packages/package_info_plus/package_info_plus/example/ohos/dependencies/hvigor-ohos-arkui-x-plugin-2.3.0-s.tgz differ diff --git a/packages/package_info_plus/package_info_plus/example/ohos/dependencies/hvigor-ohos-plugin-3.2.1-s.tgz b/packages/package_info_plus/package_info_plus/example/ohos/dependencies/hvigor-ohos-plugin-3.2.1-s.tgz new file mode 100644 index 0000000000000000000000000000000000000000..7c2f096f190c1d951ddec98e4b161ffa11664d75 Binary files /dev/null and b/packages/package_info_plus/package_info_plus/example/ohos/dependencies/hvigor-ohos-plugin-3.2.1-s.tgz differ diff --git a/packages/package_info_plus/package_info_plus/example/ohos/dta/icudtl.dat b/packages/package_info_plus/package_info_plus/example/ohos/dta/icudtl.dat new file mode 100644 index 0000000000000000000000000000000000000000..d1f10917ab52e3ebd251abd7f5377d7196b80d67 Binary files /dev/null and b/packages/package_info_plus/package_info_plus/example/ohos/dta/icudtl.dat differ diff --git a/packages/package_info_plus/package_info_plus/example/ohos/entry/.gitignore b/packages/package_info_plus/package_info_plus/example/ohos/entry/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..2795a1c5b1fe53659dd1b71d90ba0592eaf7e043 --- /dev/null +++ b/packages/package_info_plus/package_info_plus/example/ohos/entry/.gitignore @@ -0,0 +1,7 @@ + +/node_modules +/oh_modules +/.preview +/build +/.cxx +/.test \ No newline at end of file diff --git a/packages/package_info_plus/package_info_plus/example/ohos/entry/build-profile.json5 b/packages/package_info_plus/package_info_plus/example/ohos/entry/build-profile.json5 new file mode 100644 index 0000000000000000000000000000000000000000..633d360fbc91a3186a23b66ab71b27e5618944cb --- /dev/null +++ b/packages/package_info_plus/package_info_plus/example/ohos/entry/build-profile.json5 @@ -0,0 +1,29 @@ +/* +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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. +*/ + +{ + "apiType": 'stageMode', + "buildOption": { + }, + "targets": [ + { + "name": "default", + "runtimeOS": "HarmonyOS" + }, + { + "name": "ohosTest", + } + ] +} \ No newline at end of file diff --git a/packages/package_info_plus/package_info_plus/example/ohos/entry/hvigorfile.ts b/packages/package_info_plus/package_info_plus/example/ohos/entry/hvigorfile.ts new file mode 100644 index 0000000000000000000000000000000000000000..894fc15c6b793f085e6c8506e43d719af658e8ff --- /dev/null +++ b/packages/package_info_plus/package_info_plus/example/ohos/entry/hvigorfile.ts @@ -0,0 +1,17 @@ +/* +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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. +*/ + +// Script for compiling build behavior. It is built in the build plug-in and cannot be modified currently. +export { hapTasks } from '@ohos/hvigor-ohos-plugin'; diff --git a/packages/package_info_plus/package_info_plus/example/ohos/entry/libs/arm64-v8a/libc++_shared.so b/packages/package_info_plus/package_info_plus/example/ohos/entry/libs/arm64-v8a/libc++_shared.so new file mode 100644 index 0000000000000000000000000000000000000000..831c9353702073d45889352a4dafb93103d67d20 Binary files /dev/null and b/packages/package_info_plus/package_info_plus/example/ohos/entry/libs/arm64-v8a/libc++_shared.so differ diff --git a/packages/package_info_plus/package_info_plus/example/ohos/entry/oh-package.json5 b/packages/package_info_plus/package_info_plus/example/ohos/entry/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..6aa2676d3336323c82a1889c728e00f71f0a1def --- /dev/null +++ b/packages/package_info_plus/package_info_plus/example/ohos/entry/oh-package.json5 @@ -0,0 +1,12 @@ +{ + "name": "entry", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": { + "integration_test": "file:../har/integration_test.har", + "package_info_plus": "file:../har/package_info_plus.har" + } +} \ No newline at end of file diff --git a/packages/package_info_plus/package_info_plus/example/ohos/entry/src/main/ets/entryability/EntryAbility.ets b/packages/package_info_plus/package_info_plus/example/ohos/entry/src/main/ets/entryability/EntryAbility.ets new file mode 100644 index 0000000000000000000000000000000000000000..a00049282e93c69f1b3dcd987538024f47e40ace --- /dev/null +++ b/packages/package_info_plus/package_info_plus/example/ohos/entry/src/main/ets/entryability/EntryAbility.ets @@ -0,0 +1,25 @@ +/* +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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 { FlutterAbility } from '@ohos/flutter_ohos' +import { GeneratedPluginRegistrant } from '../plugins/GeneratedPluginRegistrant'; +import FlutterEngine from '@ohos/flutter_ohos/src/main/ets/embedding/engine/FlutterEngine'; + +export default class EntryAbility extends FlutterAbility { + configureFlutterEngine(flutterEngine: FlutterEngine) { + super.configureFlutterEngine(flutterEngine) + GeneratedPluginRegistrant.registerWith(flutterEngine) + } +} diff --git a/packages/package_info_plus/package_info_plus/example/ohos/entry/src/main/ets/pages/Index.ets b/packages/package_info_plus/package_info_plus/example/ohos/entry/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..1125f9fdd95f4310a182c1c9e3680f37f73686c9 --- /dev/null +++ b/packages/package_info_plus/package_info_plus/example/ohos/entry/src/main/ets/pages/Index.ets @@ -0,0 +1,38 @@ +/* +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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 common from '@ohos.app.ability.common'; +import { FlutterPage } from '@ohos/flutter_ohos' + +let storage = LocalStorage.getShared() +const EVENT_BACK_PRESS = 'EVENT_BACK_PRESS' + +@Entry(storage) +@Component +struct Index { + private context = getContext(this) as common.UIAbilityContext + @LocalStorageLink('viewId') viewId: string = ""; + + build() { + Column() { + FlutterPage({ viewId: this.viewId }) + } + } + + onBackPress(): boolean { + this.context.eventHub.emit(EVENT_BACK_PRESS) + return true + } +} \ No newline at end of file diff --git a/packages/package_info_plus/package_info_plus/example/ohos/entry/src/main/ets/plugins/GeneratedPluginRegistrant.ets b/packages/package_info_plus/package_info_plus/example/ohos/entry/src/main/ets/plugins/GeneratedPluginRegistrant.ets new file mode 100644 index 0000000000000000000000000000000000000000..3b2b7a84ae32d805e64a95d0a8c7b2b9d938f817 --- /dev/null +++ b/packages/package_info_plus/package_info_plus/example/ohos/entry/src/main/ets/plugins/GeneratedPluginRegistrant.ets @@ -0,0 +1,28 @@ +import { FlutterEngine, Log } from '@ohos/flutter_ohos'; +import IntegrationTestPlugin from 'integration_test'; +import PackageInfoPlugin from 'package_info_plus'; + +/** + * Generated file. Do not edit. + * This file is generated by the Flutter tool based on the + * plugins that support the Ohos platform. + */ + +const TAG = "GeneratedPluginRegistrant"; + +export class GeneratedPluginRegistrant { + + static registerWith(flutterEngine: FlutterEngine) { + try { + flutterEngine.getPlugins()?.add(new IntegrationTestPlugin()); + flutterEngine.getPlugins()?.add(new PackageInfoPlugin()); + } catch (e) { + Log.e( + TAG, + "Tried to register plugins with FlutterEngine (" + + flutterEngine + + ") failed."); + Log.e(TAG, "Received exception while registering", e); + } + } +} diff --git a/packages/package_info_plus/package_info_plus/example/ohos/entry/src/main/module.json5 b/packages/package_info_plus/package_info_plus/example/ohos/entry/src/main/module.json5 new file mode 100644 index 0000000000000000000000000000000000000000..7bbf78b18f39991b1404061c7437538c7d532bb7 --- /dev/null +++ b/packages/package_info_plus/package_info_plus/example/ohos/entry/src/main/module.json5 @@ -0,0 +1,53 @@ +/* +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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", + "type": "entry", + "description": "$string:module_desc", + "mainElement": "EntryAbility", + "deviceTypes": [ + "phone" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "EntryAbility", + "srcEntry": "./ets/entryability/EntryAbility.ets", + "description": "$string:EntryAbility_desc", + "icon": "$media:icon", + "label": "$string:EntryAbility_label", + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:start_window_background", + "exported": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + } + ], + "requestPermissions": [ + {"name" : "ohos.permission.INTERNET"}, + ] + } +} \ No newline at end of file diff --git a/packages/package_info_plus/package_info_plus/example/ohos/entry/src/main/resources/base/element/color.json b/packages/package_info_plus/package_info_plus/example/ohos/entry/src/main/resources/base/element/color.json new file mode 100644 index 0000000000000000000000000000000000000000..3c712962da3c2751c2b9ddb53559afcbd2b54a02 --- /dev/null +++ b/packages/package_info_plus/package_info_plus/example/ohos/entry/src/main/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/packages/package_info_plus/package_info_plus/example/ohos/entry/src/main/resources/base/element/string.json b/packages/package_info_plus/package_info_plus/example/ohos/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..67e0f4ff4ac762d1714f6e215c6636a4ad3d620e --- /dev/null +++ b/packages/package_info_plus/package_info_plus/example/ohos/entry/src/main/resources/base/element/string.json @@ -0,0 +1,16 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "EntryAbility_desc", + "value": "description" + }, + { + "name": "EntryAbility_label", + "value": "example" + } + ] +} \ No newline at end of file diff --git a/packages/package_info_plus/package_info_plus/example/ohos/entry/src/main/resources/base/media/icon.png b/packages/package_info_plus/package_info_plus/example/ohos/entry/src/main/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/packages/package_info_plus/package_info_plus/example/ohos/entry/src/main/resources/base/media/icon.png differ diff --git a/packages/package_info_plus/package_info_plus/example/ohos/entry/src/main/resources/base/profile/main_pages.json b/packages/package_info_plus/package_info_plus/example/ohos/entry/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000000000000000000000000000000000..1898d94f58d6128ab712be2c68acc7c98e9ab9ce --- /dev/null +++ b/packages/package_info_plus/package_info_plus/example/ohos/entry/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "pages/Index" + ] +} diff --git a/packages/package_info_plus/package_info_plus/example/ohos/entry/src/main/resources/en_US/element/string.json b/packages/package_info_plus/package_info_plus/example/ohos/entry/src/main/resources/en_US/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..67e0f4ff4ac762d1714f6e215c6636a4ad3d620e --- /dev/null +++ b/packages/package_info_plus/package_info_plus/example/ohos/entry/src/main/resources/en_US/element/string.json @@ -0,0 +1,16 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "EntryAbility_desc", + "value": "description" + }, + { + "name": "EntryAbility_label", + "value": "example" + } + ] +} \ No newline at end of file diff --git a/packages/package_info_plus/package_info_plus/example/ohos/entry/src/main/resources/zh_CN/element/string.json b/packages/package_info_plus/package_info_plus/example/ohos/entry/src/main/resources/zh_CN/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..601e2b5a1c273aa04920b126e3ab715a4450e58f --- /dev/null +++ b/packages/package_info_plus/package_info_plus/example/ohos/entry/src/main/resources/zh_CN/element/string.json @@ -0,0 +1,16 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "模块描述" + }, + { + "name": "EntryAbility_desc", + "value": "description" + }, + { + "name": "EntryAbility_label", + "value": "example" + } + ] +} \ No newline at end of file diff --git a/packages/package_info_plus/package_info_plus/example/ohos/entry/src/ohosTest/ets/test/Ability.test.ets b/packages/package_info_plus/package_info_plus/example/ohos/entry/src/ohosTest/ets/test/Ability.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..25d4c71ff3cd584f5d64f6f8c0ac864928c234c4 --- /dev/null +++ b/packages/package_info_plus/package_info_plus/example/ohos/entry/src/ohosTest/ets/test/Ability.test.ets @@ -0,0 +1,50 @@ +/* +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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.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/packages/package_info_plus/package_info_plus/example/ohos/entry/src/ohosTest/ets/test/List.test.ets b/packages/package_info_plus/package_info_plus/example/ohos/entry/src/ohosTest/ets/test/List.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..f4140030e65d20df6af30a6bf51e464dea8f8aa6 --- /dev/null +++ b/packages/package_info_plus/package_info_plus/example/ohos/entry/src/ohosTest/ets/test/List.test.ets @@ -0,0 +1,20 @@ +/* +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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/packages/package_info_plus/package_info_plus/example/ohos/entry/src/ohosTest/ets/testability/TestAbility.ets b/packages/package_info_plus/package_info_plus/example/ohos/entry/src/ohosTest/ets/testability/TestAbility.ets new file mode 100644 index 0000000000000000000000000000000000000000..4ca645e6013cfce8e7dbb728313cb8840c4da660 --- /dev/null +++ b/packages/package_info_plus/package_info_plus/example/ohos/entry/src/ohosTest/ets/testability/TestAbility.ets @@ -0,0 +1,63 @@ +/* +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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 AbilityDelegatorRegistry from '@ohos.app.ability.abilityDelegatorRegistry'; +import hilog from '@ohos.hilog'; +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.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.info(0x0000, 'testTag', '%{public}s', 'start run testcase!!!'); + Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite) + } + + onDestroy() { + hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage) { + hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onWindowStageCreate'); + windowStage.loadContent('testability/pages/Index', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', + JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy() { + hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onWindowStageDestroy'); + } + + onForeground() { + hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onForeground'); + } + + onBackground() { + hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onBackground'); + } +} \ No newline at end of file diff --git a/packages/package_info_plus/package_info_plus/example/ohos/entry/src/ohosTest/ets/testability/pages/Index.ets b/packages/package_info_plus/package_info_plus/example/ohos/entry/src/ohosTest/ets/testability/pages/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..cef0447cd2f137ef82d223ead2e156808878ab90 --- /dev/null +++ b/packages/package_info_plus/package_info_plus/example/ohos/entry/src/ohosTest/ets/testability/pages/Index.ets @@ -0,0 +1,49 @@ +/* +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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.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/packages/package_info_plus/package_info_plus/example/ohos/entry/src/ohosTest/ets/testrunner/OpenHarmonyTestRunner.ts b/packages/package_info_plus/package_info_plus/example/ohos/entry/src/ohosTest/ets/testrunner/OpenHarmonyTestRunner.ts new file mode 100644 index 0000000000000000000000000000000000000000..1def08f2e9dcbfa3454a07b7a3b82b173bb90d02 --- /dev/null +++ b/packages/package_info_plus/package_info_plus/example/ohos/entry/src/ohosTest/ets/testrunner/OpenHarmonyTestRunner.ts @@ -0,0 +1,64 @@ +/* +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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.app.ability.abilityDelegatorRegistry'; + +var abilityDelegator = undefined +var abilityDelegatorArguments = undefined + +async function onAbilityCreateCallback() { + hilog.info(0x0000, 'testTag', '%{public}s', 'onAbilityCreateCallback'); +} + +async function addAbilityMonitorCallback(err: any) { + hilog.info(0x0000, 'testTag', 'addAbilityMonitorCallback : %{public}s', JSON.stringify(err) ?? ''); +} + +export default class OpenHarmonyTestRunner implements TestRunner { + constructor() { + } + + onPrepare() { + hilog.info(0x0000, 'testTag', '%{public}s', 'OpenHarmonyTestRunner OnPrepare '); + } + + async onRun() { + 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 + var debug = abilityDelegatorArguments.parameters['-D'] + if (debug == 'true') + { + cmd += ' -D' + } + hilog.info(0x0000, 'testTag', 'cmd : %{public}s', cmd); + abilityDelegator.executeShellCommand(cmd, + (err: any, d: any) => { + 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/packages/package_info_plus/package_info_plus/example/ohos/entry/src/ohosTest/module.json5 b/packages/package_info_plus/package_info_plus/example/ohos/entry/src/ohosTest/module.json5 new file mode 100644 index 0000000000000000000000000000000000000000..fab77ce2e0c61e3ad010bab5b27ccbd15f9a8c96 --- /dev/null +++ b/packages/package_info_plus/package_info_plus/example/ohos/entry/src/ohosTest/module.json5 @@ -0,0 +1,51 @@ +/* +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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": [ + "phone" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:test_pages", + "abilities": [ + { + "name": "TestAbility", + "srcEntry": "./ets/testability/TestAbility.ets", + "description": "$string:TestAbility_desc", + "icon": "$media:icon", + "label": "$string:TestAbility_label", + "exported": true, + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:start_window_background", + "skills": [ + { + "actions": [ + "action.system.home" + ], + "entities": [ + "entity.system.home" + ] + } + ] + } + ] + } +} diff --git a/packages/package_info_plus/package_info_plus/example/ohos/entry/src/ohosTest/resources/base/element/color.json b/packages/package_info_plus/package_info_plus/example/ohos/entry/src/ohosTest/resources/base/element/color.json new file mode 100644 index 0000000000000000000000000000000000000000..3c712962da3c2751c2b9ddb53559afcbd2b54a02 --- /dev/null +++ b/packages/package_info_plus/package_info_plus/example/ohos/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/packages/package_info_plus/package_info_plus/example/ohos/entry/src/ohosTest/resources/base/element/string.json b/packages/package_info_plus/package_info_plus/example/ohos/entry/src/ohosTest/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..65d8fa5a7cf54aa3943dcd0214f58d1771bc1f6c --- /dev/null +++ b/packages/package_info_plus/package_info_plus/example/ohos/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/packages/package_info_plus/package_info_plus/example/ohos/entry/src/ohosTest/resources/base/media/icon.png b/packages/package_info_plus/package_info_plus/example/ohos/entry/src/ohosTest/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/packages/package_info_plus/package_info_plus/example/ohos/entry/src/ohosTest/resources/base/media/icon.png differ diff --git a/packages/package_info_plus/package_info_plus/example/ohos/entry/src/ohosTest/resources/base/profile/test_pages.json b/packages/package_info_plus/package_info_plus/example/ohos/entry/src/ohosTest/resources/base/profile/test_pages.json new file mode 100644 index 0000000000000000000000000000000000000000..b7e7343cacb32ce982a45e76daad86e435e054fe --- /dev/null +++ b/packages/package_info_plus/package_info_plus/example/ohos/entry/src/ohosTest/resources/base/profile/test_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "testability/pages/Index" + ] +} diff --git a/packages/package_info_plus/package_info_plus/example/ohos/har/flutter.har b/packages/package_info_plus/package_info_plus/example/ohos/har/flutter.har new file mode 100644 index 0000000000000000000000000000000000000000..c6ecbede6c1ac09a848c4a97b6546ac92e007854 Binary files /dev/null and b/packages/package_info_plus/package_info_plus/example/ohos/har/flutter.har differ diff --git a/packages/package_info_plus/package_info_plus/example/ohos/har/integration_test.har b/packages/package_info_plus/package_info_plus/example/ohos/har/integration_test.har new file mode 100644 index 0000000000000000000000000000000000000000..9f298e853ea9d0d941e44cdb87fef729d677c5a3 Binary files /dev/null and b/packages/package_info_plus/package_info_plus/example/ohos/har/integration_test.har differ diff --git a/packages/package_info_plus/package_info_plus/example/ohos/har/package_info_plus.har b/packages/package_info_plus/package_info_plus/example/ohos/har/package_info_plus.har new file mode 100644 index 0000000000000000000000000000000000000000..297e54957c8ea40492a1626c0580e4b5d826c7d6 Binary files /dev/null and b/packages/package_info_plus/package_info_plus/example/ohos/har/package_info_plus.har differ diff --git a/packages/package_info_plus/package_info_plus/example/ohos/hvigor/hvigor-config.json5 b/packages/package_info_plus/package_info_plus/example/ohos/hvigor/hvigor-config.json5 new file mode 100644 index 0000000000000000000000000000000000000000..898c353ada0cf4f01739ead437b3180cda8b54c8 --- /dev/null +++ b/packages/package_info_plus/package_info_plus/example/ohos/hvigor/hvigor-config.json5 @@ -0,0 +1,8 @@ +{ + "modelVersion": "5.0.0", + "dependencies": { + }, + "properties": { + "ohos.nativeResolver": false + } +} diff --git a/packages/package_info_plus/package_info_plus/example/ohos/hvigorfile.ts b/packages/package_info_plus/package_info_plus/example/ohos/hvigorfile.ts new file mode 100644 index 0000000000000000000000000000000000000000..5a172b770e3b15f67c12152d00f38f2084d3915b --- /dev/null +++ b/packages/package_info_plus/package_info_plus/example/ohos/hvigorfile.ts @@ -0,0 +1,17 @@ +/* +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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. +*/ + +// Script for compiling build behavior. It is built in the build plug-in and cannot be modified currently. +export { appTasks } from '@ohos/hvigor-ohos-plugin'; \ No newline at end of file diff --git a/packages/package_info_plus/package_info_plus/example/ohos/oh-package.json5 b/packages/package_info_plus/package_info_plus/example/ohos/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..1ea2f4d0437f3d7d95b7fe98799f16b4194f9d04 --- /dev/null +++ b/packages/package_info_plus/package_info_plus/example/ohos/oh-package.json5 @@ -0,0 +1,21 @@ +{ + "modelVersion": "5.0.0", + "name": "apptemplate", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": { + "@ohos/flutter_ohos": "file:./har/flutter.har" + }, + "devDependencies": { + "@ohos/hypium": "1.0.6" + }, + "overrides": { + "@ohos/flutter_ohos": "file:./har/flutter.har", + "package_info_plus": "file:./har/package_info_plus.har", + "integration_test": "file:./har/integration_test.har", + "@ohos/flutter_module": "file:./entry" + } +} \ No newline at end of file diff --git a/packages/package_info_plus/package_info_plus/example/pubspec.yaml b/packages/package_info_plus/package_info_plus/example/pubspec.yaml index cbe2869f6f262a3575cd9de31780e44d31de5a0e..f6d8775f5720edb01ff9d657544962d417ada350 100644 --- a/packages/package_info_plus/package_info_plus/example/pubspec.yaml +++ b/packages/package_info_plus/package_info_plus/example/pubspec.yaml @@ -11,7 +11,8 @@ dependencies: flutter: sdk: flutter http: ">=0.13.5 <2.0.0" - package_info_plus: ^8.1.0 + package_info_plus: + path: ../ dev_dependencies: build_runner: ^2.3.3 @@ -20,7 +21,7 @@ dev_dependencies: sdk: flutter flutter_driver: sdk: flutter - flutter_lints: ^5.0.0 + flutter_lints: ^4.0.0 flutter_test: sdk: flutter mockito: ^5.4.0 diff --git a/packages/package_info_plus/package_info_plus/ohos/.gitignore b/packages/package_info_plus/package_info_plus/ohos/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..6f7b4f89c49a6abadc383d9665d3b4c171d466bc --- /dev/null +++ b/packages/package_info_plus/package_info_plus/ohos/.gitignore @@ -0,0 +1,17 @@ +/node_modules +/oh_modules +/local.properties +/.idea +**/build +/.hvigor +.cxx +/.clangd +/.clang-format +/.clang-tidy +**/.test + +/entry/libs/arm64-v8a/libflutter.so +/entry/src/main/resources/rawfile/flutter_assets +**.har +**/oh-package-lock.json5 +BuildProfile.ets diff --git a/packages/package_info_plus/package_info_plus/ohos/build-profile.json5 b/packages/package_info_plus/package_info_plus/ohos/build-profile.json5 new file mode 100644 index 0000000000000000000000000000000000000000..afe4b6619c102a381c5c535258b912e9a7917022 --- /dev/null +++ b/packages/package_info_plus/package_info_plus/ohos/build-profile.json5 @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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. + */ +{ + "apiType": "stageMode", + "buildOption": { + "arkOptions": { + // "apPath": "./modules.ap" /* Profile used for profile-guided optimization (PGO), a compiler optimization technique to improve app runtime performance. */ + } + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": true, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] +} \ No newline at end of file diff --git a/packages/package_info_plus/package_info_plus/ohos/hvigorfile.ts b/packages/package_info_plus/package_info_plus/ohos/hvigorfile.ts new file mode 100644 index 0000000000000000000000000000000000000000..d13d36380b4131e863f787e793a684a1e156273a --- /dev/null +++ b/packages/package_info_plus/package_info_plus/ohos/hvigorfile.ts @@ -0,0 +1,15 @@ +/* + * Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +export { harTasks } from '@ohos/hvigor-ohos-plugin'; \ No newline at end of file diff --git a/packages/package_info_plus/package_info_plus/ohos/index.ets b/packages/package_info_plus/package_info_plus/ohos/index.ets new file mode 100644 index 0000000000000000000000000000000000000000..3bc3dedd7335f049b47d982cb1aa34ae2b7c2ad8 --- /dev/null +++ b/packages/package_info_plus/package_info_plus/ohos/index.ets @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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 {PackageInfoPlugin} from './src/main/ets/dev/fluttercommunity/plus/packageinfo/PackageInfoPlugin'; +export default PackageInfoPlugin; \ No newline at end of file diff --git a/packages/package_info_plus/package_info_plus/ohos/obfuscation-rules.txt b/packages/package_info_plus/package_info_plus/ohos/obfuscation-rules.txt new file mode 100644 index 0000000000000000000000000000000000000000..985b2aeb7658286b17bd26eab8f217c3fe75ea8b --- /dev/null +++ b/packages/package_info_plus/package_info_plus/ohos/obfuscation-rules.txt @@ -0,0 +1,18 @@ +# Define project specific obfuscation rules here. +# You can include the obfuscation configuration files in the current module's build-profile.json5. +# +# For more details, see +# https://gitee.com/openharmony/arkcompiler_ets_frontend/blob/master/arkguard/README.md + +# Obfuscation options: +# -disable-obfuscation: disable all obfuscations +# -enable-property-obfuscation: obfuscate the property names +# -enable-toplevel-obfuscation: obfuscate the names in the global scope +# -compact: remove unnecessary blank spaces and all line feeds +# -remove-log: remove all console.* statements +# -print-namecache: print the name cache that contains the mapping from the old names to new names +# -apply-namecache: reuse the given cache file + +# Keep options: +# -keep-property-name: specifies property names that you want to keep +# -keep-global-name: specifies names that you want to keep in the global scope \ No newline at end of file diff --git a/packages/package_info_plus/package_info_plus/ohos/oh-package.json5 b/packages/package_info_plus/package_info_plus/ohos/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..905423805a79743ee28d1a80bac08d44324276af --- /dev/null +++ b/packages/package_info_plus/package_info_plus/ohos/oh-package.json5 @@ -0,0 +1,11 @@ +{ + "name": "package_info_plus", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "index.ets", + "author": "", + "license": "Apache-2.0", + "dependencies": { + "@ohos/flutter_ohos": "file:./libs/flutter.har" + } +} \ No newline at end of file diff --git a/packages/package_info_plus/package_info_plus/ohos/src/main/ets/dev/fluttercommunity/plus/packageinfo/PackageInfoPlugin.ets b/packages/package_info_plus/package_info_plus/ohos/src/main/ets/dev/fluttercommunity/plus/packageinfo/PackageInfoPlugin.ets new file mode 100644 index 0000000000000000000000000000000000000000..aad2c0f1c4bd57ec2a008c50bb28579656baf897 --- /dev/null +++ b/packages/package_info_plus/package_info_plus/ohos/src/main/ets/dev/fluttercommunity/plus/packageinfo/PackageInfoPlugin.ets @@ -0,0 +1,93 @@ +/* + * Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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 AbilityAware from '@ohos/flutter_ohos/src/main/ets/embedding/engine/plugins/ability/AbilityAware'; +import { AbilityPluginBinding } from '@ohos/flutter_ohos/src/main/ets/embedding/engine/plugins/ability/AbilityPluginBinding'; +import { FlutterPlugin, FlutterPluginBinding } from '@ohos/flutter_ohos/src/main/ets/embedding/engine/plugins/FlutterPlugin'; +import { MethodCallHandler, MethodResult } from '@ohos/flutter_ohos/src/main/ets/plugin/common/MethodChannel'; +import MethodChannel from '@ohos/flutter_ohos/src/main/ets/plugin/common/MethodChannel'; +import MethodCall from '@ohos/flutter_ohos/src/main/ets/plugin/common/MethodCall'; +import Log from '@ohos/flutter_ohos/src/main/ets/util/Log'; +import HashMap from '@ohos.util.HashMap'; + + +import bundleManager from '@ohos.bundle.bundleManager' +let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_APPLICATION | bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_SIGNATURE_INFO + +const TAG:string ="PackageInfoPlugin" + +const CHANNEL_NAME = "dev.fluttercommunity.plus/package_info"; +export class PackageInfoPlugin implements FlutterPlugin,MethodCallHandler{ + + + getUniqueClassName(): string { + return "PackageInfoPlugin"; + } + + + private methodChannel: MethodChannel | null = null; + + private applicationContext: Context | null = null; + + onAttachedToEngine(binding: FlutterPluginBinding): void { + Log.d(TAG,'onAttachedToEngine packageInfo plugin') + this.applicationContext =binding.getApplicationContext(); + this.methodChannel = new MethodChannel(binding.getBinaryMessenger(), CHANNEL_NAME); + this.methodChannel.setMethodCallHandler(this); + + } + + onDetachedFromEngine(binding: FlutterPluginBinding): void { + Log.d(TAG,'onDetachedFromEngine packageInfo plugin') + this.applicationContext = null; + this.methodChannel?.setMethodCallHandler(null); + this.methodChannel = null; + } + + onMethodCall(call: MethodCall, result: MethodResult): void { + Log.d(TAG,'onMethodCall packageInfo plugin1') + try { + if (call.method == "getAll") { + + const bundleManage = bundleManager.getBundleInfoForSelfSync(bundleFlags); + const appInfo = bundleManage.appInfo; + + const infoMap = new Map(); + const buildSignature = bundleManage.signatureInfo.fingerprint; + const appName = this.applicationContext?.resourceManager.getStringSync(appInfo.labelId) ?? ''; + infoMap.set("appName", appName); + Log.d(TAG,'onMethodCall packageInfo plugin appName '+ appName); + infoMap.set("packageName",bundleManage.name); + Log.d(TAG,'onMethodCall packageInfo plugin packageName '+bundleManage.name) + infoMap.set("version",bundleManage.versionName); + Log.d(TAG,'onMethodCall packageInfo plugin version '+bundleManage.versionName) + infoMap.set("buildNumber",bundleManage.versionCode.toString()); + Log.d(TAG,'onMethodCall packageInfo plugin buildNumber '+bundleManage.versionCode.toString()) + if (buildSignature != null){ + infoMap.set("buildSignature",buildSignature); + Log.d(TAG,'onMethodCall packageInfo plugin buildSignature '+buildSignature) + } + infoMap.set("installerStore",""); + + result.success(infoMap); + } else { + result.notImplemented() + } + } catch(err){ + result.error("Name not found", err.message, null) + } + } + +} diff --git a/packages/package_info_plus/package_info_plus/ohos/src/main/module.json5 b/packages/package_info_plus/package_info_plus/ohos/src/main/module.json5 new file mode 100644 index 0000000000000000000000000000000000000000..f77d97604ab5fe1efd4588dc76d79b93328b8ed0 --- /dev/null +++ b/packages/package_info_plus/package_info_plus/ohos/src/main/module.json5 @@ -0,0 +1,9 @@ +{ + "module": { + "name": "package_info_plus", + "type": "har", + "deviceTypes": [ + "default", + ] + } +} \ No newline at end of file diff --git a/packages/package_info_plus/package_info_plus/ohos/src/main/resources/base/element/string.json b/packages/package_info_plus/package_info_plus/ohos/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..1e76de0c66777cfe83568615c5c2e68c61d23fed --- /dev/null +++ b/packages/package_info_plus/package_info_plus/ohos/src/main/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "page_show", + "value": "page from npm package" + } + ] +} diff --git a/packages/package_info_plus/package_info_plus/ohos/src/main/resources/en_US/element/string.json b/packages/package_info_plus/package_info_plus/ohos/src/main/resources/en_US/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..1e76de0c66777cfe83568615c5c2e68c61d23fed --- /dev/null +++ b/packages/package_info_plus/package_info_plus/ohos/src/main/resources/en_US/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "page_show", + "value": "page from npm package" + } + ] +} diff --git a/packages/package_info_plus/package_info_plus/ohos/src/main/resources/zh_CN/element/string.json b/packages/package_info_plus/package_info_plus/ohos/src/main/resources/zh_CN/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..1e76de0c66777cfe83568615c5c2e68c61d23fed --- /dev/null +++ b/packages/package_info_plus/package_info_plus/ohos/src/main/resources/zh_CN/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "page_show", + "value": "page from npm package" + } + ] +} diff --git a/packages/package_info_plus/package_info_plus/pubspec.yaml b/packages/package_info_plus/package_info_plus/pubspec.yaml index e745d00b77ca045915f65e3ed6254e3375dc7105..42701ecddde38d415fd7390446e19f9576c97982 100644 --- a/packages/package_info_plus/package_info_plus/pubspec.yaml +++ b/packages/package_info_plus/package_info_plus/pubspec.yaml @@ -26,6 +26,9 @@ flutter: fileName: src/package_info_plus_web.dart windows: dartPluginClass: PackageInfoPlusWindowsPlugin + ohos: + package: dev.fluttercommunity.plus.packageinfo + pluginClass: PackageInfoPlugin dependencies: ffi: ^2.0.1