diff --git a/CHANGELOG.md b/CHANGELOG.md
index f84ec6c..aeaf140 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,136 +1,180 @@
-# 4.0.0
+## 4.0.1
+
+* 新增对 OpenHarmony 的支持
+
+## 4.0.0
+
* iOS中的AliPay SDK升级到15.8.18
* iOS的支付功能需要添加universal link
-# 3.3.2
+## 3.3.2
+
* Merge #155: 增加iOS privacy manifest
-# 3.3.1
+## 3.3.1
+
* Android 增加namespace
-# 3.3.0
+## 3.3.0
+
* AliPay SDK升级到15.8.17
-# 3.2.2
+## 3.2.2
+
* Fix #151
-# 3.2.1
+## 3.2.1
+
* iOS新增ignore_security选项,详见#576
-# 3.2.0
+## 3.2.0
+
* AliPay SDK升级到15.8.15
* iOS切换至xcframework
-# 3.1.3
+## 3.1.3
+
* 修复Flutter module编译问题
* 降级SDK约束以支持dart 2.
-# 3.1.2
+## 3.1.2
+
* 支持检查AliPay HongKong是否安装
-# 3.1.1
+## 3.1.1
+
* 优化iOS yaml读取.
-# 3.1.0
+## 3.1.0
+
* iOS支持在pubspec.yaml中设置是否使用no_utdid.
-# 3.0.0
+## 3.0.0
+
* 重构Flutter端
* 现在可以在pubspec.yaml里直接配置url_schme
* 自动在iOS添加Queries
## 2.4.2
-* compileSdkVersion -> compileSdk
+
+* compileSdkVersion -> compileSdk
## 2.4.1+1
+
* Kotlin 1.7.10
* AGP 7.4.1
## 2.4.1
+
* 更新原生SDK
* 升级Kotlin
## 2.4.0+2
+
* 更新文档
## 2.4.0+1
+
* 修复iOS编译问题
## 2.4.0
+
* 升级SDK到15.8.08
## 2.3.0
+
* Update Android configurations
## 2.2.0
+
* Update AlipaySDK to 15.8.06
## 2.1.2+1
+
* Update compileSdk version to 30
## 2.1.2
+
* Use Android no-uuid sdk
## 2.1.1
+
* Merge #99
* Update Android SDK to 15.08.03
## 2.1.0
+
* NullSafety
## 2.0.0-nullsafety.3
+
* Fix #82
## 2.0.0-nullsafety.2
+
* Update dependency
## 2.0.0-nullsafety.1
+
* Support NullSafety
## 1.7.1+3
+
* Fix #82
## 1.7.1+2
+
* Update libs.
## 1.7.1+1
+
* Fix #57
## 1.7.1
+
* Fix #55
## 1.7.0
+
* 支付SDK升级至15.7.9
* 兼容Flutter 1.20
* Android 依赖升级
## 1.6.1+1
+
* 删除不必要的权限
* Android的支付宝SDK升级到15.7.6
## 1.6.1
+
* Android的支付宝SDK升级到15.7.5
* iOS的支付宝SDK升级到15.7.4
* Kotlin->1.3.72
## 1.6.0+1
+
* 升级
## 1.6.0
+
* Fix #41
* 升级kotlin coroutine
## 1.5.0
+
* 改进Android代码
## 1.4.0
+
* 修复1.3.0的问题
## 1.3.0
+
* 删除过时方法
* 升级Android plugin以兼容新API
## 1.2.3
+
* Android的支付宝SDK升级到15.7.3
## 1.2.2
@@ -152,12 +196,15 @@
* 修复ios获取版本的bug。
## 1.1.0+1
+
* 兼容swift
## 1.1.0
+
* 升级sdk,同时ios源换成官方源
## 1.0.0+1
+
* 按照pub意见进行修改
## 1.0.0
@@ -165,58 +212,73 @@
* ios不必重写AppDelegate
## 0.1.6+2
+
* 按照pub意见进行修改
## 0.1.6+1
+
* 按照pub意见进行修改
## 0.1.6
+
* 支付宝SDK升级到15.6.4
* 升级Kotlin
## 0.1.5
+
* 支持检查客户端是否安装了支付宝App。
## 0.1.4
+
* Fix #18
## 0.1.3
-* Android支持沙箱了
+* Android支持沙箱了
## 0.1.2
+
* 修复在ios上调用登录报错的问题
## 0.1.1
+
* 修复ios上通过webview登录无回调的问题
## 0.1.0
+
* 支持支付宝登录了。
## 0.0.8
+
* kotlin升级至1.3.21
* kotlinx-coroutines升级至1.1.1
* AliPaySDK升级至15.6.0
## 0.0.7
+
* android构建工具升级
* AliPaySDK升级至15.5.9
## 0.0.6
+
* android构建工具升级
* AliPaySDK升级至15.5.7
## 0.0.5
+
* *build.gradle*升级到了*3.2.0*
* *kotlin*升级到了*1.2.71*
## 0.0.4
+
* 修复iOS无回调问题
## 0.0.3
+
* 删除AliPayModel
## 0.0.2
+
* 修复iOS支付bug
## 0.0.1
diff --git a/README.md b/README.md
index 66f0767..e389d93 100644
--- a/README.md
+++ b/README.md
@@ -1,5 +1,12 @@

+
+[](https://pub.dartlang.org/packages/tobias)

+[](https://github.com/OpenFlutter/tobias/stargazers)
+[](https://github.com/OpenFlutter/tobias/network)
+[](https://github.com/OpenFlutter/tobias/blob/master/LICENSE)
+[](https://github.com/OpenFlutter/tobias/issues)
+
[中文移步这里](./README_CN.md)
@@ -9,27 +16,43 @@
## What's Tobias
-Tobias is a flutter plugin for AliPaySDK.
+Tobias is a flutter plugin for AliPaySDK, works on iOS, Android and OpenHarmony
## Getting Started
I highly recommend that you read [the official documents](https://docs.open.alipay.com/204/105051/) before using tobias.
-1. You have to config `url_scheme` in [pubspec.yaml](./example/pubspec.yaml). Url scheme is a unique string to
+1. You have to config `url_scheme` in [pubspec.yaml](./example/pubspec.yaml). Url scheme is a unique string to
resume you app on iOS but please note that `_` is invalid.
+2. for OpenHarmony, you have to add scheme `alipays` to module.json5 in your project like this:
+
+```json5
+{
+ "module": {
+ "querySchemes": [
+ "alipays"
+ ],
+ }
+}
+```
+
## Payment
+
It's simple,pass Tobias your order info from server :
+
```dart
import 'package:tobias/tobias.dart' ;
Tobias tobias = Tobias();
tobias.pay(yourOrder);
```
+
If you're working with iOS, please add and pass universal link. See [how to configure universal link](https://opendocs.alipay.com/open/0b9qzi).
The result is map contains results from AliPay.The result also contains an external filed named `platform` which
means the result is from `iOS` or `android`.
Result sample:
+
```dart
{
result: partner="2088411752388544"&seller_id="etongka123@163.com"&out_trade_no="180926084213001"&subject="test pay"&total_fee="0.01"¬ify_url="http://127.0.0.1/alipay001"&service="mobile.securitypay.pay"&payment_type="1"&_input_charset="utf-8"&it_b_pay="30m"&return_url="m.alipay.com"&success="true"&sign_type="RSA"&sign="nCZ8MDhsNvYNAbrLZJZ2VUy6vydgAp+JCq1aQo6ORDYtI9zwtnja3qNGQNiDJCuktoIj7fSTM487XhjPDqnOreZjIA1GJpxu9D1I3nMXIn1M7DfZ0noDwXcYZ438/jbYac7g8mhpwdKGweLCAni9mO3Y6q3iBFkox8i9PcsGxJY=",
@@ -39,9 +62,9 @@ resultStatus: 9000,
}
```
-
+
> NOTE:Tobias use pay_V2.
-
+
> If you're facing conflicts with `utdid` on iOS, you can set `no_utdid: true` in [pubspec.yaml](./example/pubspec.yaml)
## Auth
@@ -61,10 +84,9 @@ var result = await tobias.isAliPayInstalled;
You can also call `tobias.version` which returns a map contains `version` and `platform`.
-
## Upgrade to 1.0.0
-There's no need to override `AppDelegate` since `tobais 1.0.0`. If you have done that before, please remove
+There's no need to override `AppDelegate` since `tobais 1.0.0`. If you have done that before, please remove
the following code in your `AppDelegate`:
```objective-c
@@ -79,6 +101,7 @@ the following code in your `AppDelegate`:
```
If you have to override these two functions, make sure you have called the `super`:
+
```objective-c
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation {
@@ -92,20 +115,18 @@ If you have to override these two functions, make sure you have called the `supe
}
```
-
-
### Donate
+
Buy me a cup of coffee。
-
### Subscribe Us On WeChat
+

## LICENSE
-
Copyright 2018 OpenFlutter Project
Licensed to the Apache Software Foundation (ASF) under one or more contributor
diff --git a/README_CN.md b/README_CN.md
index 3a1615e..1ed4d1a 100644
--- a/README_CN.md
+++ b/README_CN.md
@@ -1,5 +1,12 @@

+
+[](https://pub.dartlang.org/packages/tobias)

+[](https://github.com/OpenFlutter/tobias/stargazers)
+[](https://github.com/OpenFlutter/tobias/network)
+[](https://github.com/OpenFlutter/tobias/blob/master/LICENSE)
+[](https://github.com/OpenFlutter/tobias/issues)
+
> QQ群: 1003811176
@@ -7,19 +14,31 @@
## Tobias是什么
-Tobias是一个为支付宝支付SDK做的Flutter插件。
+Tobias 是一个为支付宝支付 SDK 做的 Flutter 插件,支持 iOS, Android 和 OpenHarmony
## 开始
在使用前强烈阅读[官方接入指南](https://docs.open.alipay.com/204/105051/)。
-1. 您需要在[pubspec.yaml](./example/pubspec.yaml)中配置`url_scheme`。 Url scheme是一个独特的字符串用来重新启动你的app
+1. 您需要在[pubspec.yaml](./example/pubspec.yaml)中配置`url_scheme`。 Url scheme是一个独特的字符串用来重新启动你的app
但是请注意字符串`_`是不合法的.
+2. 如果在 OpenHarmony, 请在项目中的 `module.json5` 文件中的 `module.querySchemes` 中添加 `alipays`,如下:
+
+```json5
+{
+ "module": {
+ "querySchemes": [
+ "alipays"
+ ],
+ }
+}
+```
## 支付
-Tobias使用起来很简单,只需要把从服务器取得的字符串交给Tobias就行了:
-如果安卓出现Unhandled Exception: MissingPluginException(No implementation found for method pay on channel com.jarvanmo/tobias)错误
-请将[android/build.gradle](https://github.com/OpenFlutter/tobias/blob/master/android/build.gradle#L5)更改为同一版本。
+
+Tobias使用起来很简单,只需要把从服务器取得的字符串交给Tobias就行了:
+如果安卓出现Unhandled Exception: MissingPluginException(No implementation found for method pay on channel com.jarvanmo/tobias)错误
+请将[android/build.gradle](https://github.com/OpenFlutter/tobias/blob/master/android/build.gradle#L5)更改为同一版本。
```dart
import 'package:tobias/tobias.dart' ;
@@ -27,7 +46,7 @@ Tobias tobias = Tobias();
tobias.pay(yourOrder);
```
-在iOS端, 你还需要配置并传入一个universal link. See [how to configure universal link](https://opendocs.alipay.com/open/0b9qzi).
+在iOS端, 你还需要配置并传入一个universal link. See [how to configure universal link](https://opendocs.alipay.com/open/0b9qzi).
返回值是一个包含支付宝支付结果的`map`。其中还包含了一个额外的 `platform`字段,
它的值为 `iOS` 或 `android`。
@@ -35,6 +54,8 @@ tobias.pay(yourOrder);
## 授权登录
+> 当前在 OpenHarmony 上不支持授权登录
+
```
import 'package:tobias/tobias.dart' ;
Tobias tobias = Tobias();
@@ -46,10 +67,11 @@ tobias.auth("your auth str);
```
Tobias tobias = Tobias();
var result = await tobias.isAliPayInstalled;
-```
+```
你可以通过调用 `tobias.version` 来获取对应平上的SDK版本,其返回值是一个包含 `version` 和 `platform`的map。
结果示例:
+
```dart
{
result: partner="2088411752388544"&seller_id="etongka123@163.com"&out_trade_no="180926084213001"&subject="test pay"&total_fee="0.01"¬ify_url="http://127.0.0.1/alipay001"&service="mobile.securitypay.pay"&payment_type="1"&_input_charset="utf-8"&it_b_pay="30m"&return_url="m.alipay.com"&success="true"&sign_type="RSA"&sign="nCZ8MDhsNvYNAbrLZJZ2VUy6vydgAp+JCq1aQo6ORDYtI9zwtnja3qNGQNiDJCuktoIj7fSTM487XhjPDqnOreZjIA1GJpxu9D1I3nMXIn1M7DfZ0noDwXcYZ438/jbYac7g8mhpwdKGweLCAni9mO3Y6q3iBFkox8i9PcsGxJY=",
@@ -62,7 +84,6 @@ resultStatus: 9000,
> 如果你在iOS上遇到了 `utdid`问题, 你可以在[pubspec.yaml](./example/pubspec.yaml)中开启`no_utdid: true`。
-
## 升级到1.0.0
从`tobais 1.0.0`开始开发者不必重写`AppDelegate`了。如果你以前重写了这个方法,请在 `AppDelegate`中删除相应的代码:
@@ -79,6 +100,7 @@ resultStatus: 9000,
```
如果一定要重写这2个方法,请确保你调用了 `super`:
+
```objective-c
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation {
@@ -92,17 +114,16 @@ resultStatus: 9000,
}
```
-## 请作者喝杯咖啡。
+## 请作者喝杯咖啡
### 欢迎关注公众号
-
+
## LICENSE
-
Copyright 2018 OpenFlutter Project
Licensed to the Apache Software Foundation (ASF) under one or more contributor
diff --git a/example/ohos/.gitignore b/example/ohos/.gitignore
new file mode 100644
index 0000000..6ca13b3
--- /dev/null
+++ b/example/ohos/.gitignore
@@ -0,0 +1,19 @@
+/node_modules
+/oh_modules
+/local.properties
+/.idea
+**/build
+/.hvigor
+.cxx
+/.clangd
+/.clang-format
+/.clang-tidy
+**/.test
+*.har
+**/BuildProfile.ets
+**/oh-package-lock.json5
+
+**/src/main/resources/rawfile/flutter_assets/
+**/libs/arm64-v8a/libapp.so
+**/libs/arm64-v8a/libflutter.so
+**/libs/arm64-v8a/libvmservice_snapshot.so
diff --git a/example/ohos/AppScope/app.json5 b/example/ohos/AppScope/app.json5
new file mode 100644
index 0000000..645ea4f
--- /dev/null
+++ b/example/ohos/AppScope/app.json5
@@ -0,0 +1,10 @@
+{
+ "app": {
+ "bundleName": "com.jarvanmo.tobias_example",
+ "vendor": "example",
+ "versionCode": 1000000,
+ "versionName": "1.0.0",
+ "icon": "$media:app_icon",
+ "label": "$string:app_name"
+ }
+}
diff --git a/example/ohos/AppScope/resources/base/element/string.json b/example/ohos/AppScope/resources/base/element/string.json
new file mode 100644
index 0000000..2f95a1e
--- /dev/null
+++ b/example/ohos/AppScope/resources/base/element/string.json
@@ -0,0 +1,8 @@
+{
+ "string": [
+ {
+ "name": "app_name",
+ "value": "tobias_example"
+ }
+ ]
+}
diff --git a/example/ohos/AppScope/resources/base/media/app_icon.png b/example/ohos/AppScope/resources/base/media/app_icon.png
new file mode 100644
index 0000000..ce307a8
Binary files /dev/null and b/example/ohos/AppScope/resources/base/media/app_icon.png differ
diff --git a/example/ohos/build-profile.json5 b/example/ohos/build-profile.json5
new file mode 100644
index 0000000..63a5ec9
--- /dev/null
+++ b/example/ohos/build-profile.json5
@@ -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.
+ */
+
+{
+ app: {
+ signingConfigs: [],
+ products: [
+ {
+ name: "default",
+ signingConfig: "default",
+ compatibleSdkVersion: "5.0.0(12)",
+ runtimeOS: "HarmonyOS",
+ },
+ ],
+ },
+ modules: [
+ {
+ name: "entry",
+ srcPath: "./entry",
+ targets: [
+ {
+ name: "default",
+ applyToProducts: ["default"],
+ },
+ ],
+ },
+ {
+ name: "tobias",
+ srcPath: "../../ohos",
+ targets: [
+ {
+ name: "default",
+ applyToProducts: ["default"],
+ },
+ ],
+ },
+ ],
+}
diff --git a/example/ohos/entry/.gitignore b/example/ohos/entry/.gitignore
new file mode 100644
index 0000000..2795a1c
--- /dev/null
+++ b/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/example/ohos/entry/build-profile.json5 b/example/ohos/entry/build-profile.json5
new file mode 100644
index 0000000..633d360
--- /dev/null
+++ b/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/example/ohos/entry/hvigorfile.ts b/example/ohos/entry/hvigorfile.ts
new file mode 100644
index 0000000..894fc15
--- /dev/null
+++ b/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/example/ohos/entry/oh-package.json5 b/example/ohos/entry/oh-package.json5
new file mode 100644
index 0000000..ea94569
--- /dev/null
+++ b/example/ohos/entry/oh-package.json5
@@ -0,0 +1,27 @@
+/*
+ * 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.
+ */
+
+{
+ name: "entry",
+ version: "1.0.0",
+ description: "Please describe the basic information.",
+ main: "",
+ author: "",
+ license: "",
+ dependencies: {
+ "@ohos/flutter_ohos": "file:../har/flutter.har",
+ "tobias": "../../../ohos",
+ },
+}
diff --git a/example/ohos/entry/src/main/ets/entryability/EntryAbility.ets b/example/ohos/entry/src/main/ets/entryability/EntryAbility.ets
new file mode 100644
index 0000000..8bc48be
--- /dev/null
+++ b/example/ohos/entry/src/main/ets/entryability/EntryAbility.ets
@@ -0,0 +1,24 @@
+/*
+* 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, FlutterEngine } from '@ohos/flutter_ohos';
+import { GeneratedPluginRegistrant } from '../plugins/GeneratedPluginRegistrant';
+
+export default class EntryAbility extends FlutterAbility {
+ configureFlutterEngine(flutterEngine: FlutterEngine) {
+ super.configureFlutterEngine(flutterEngine)
+ GeneratedPluginRegistrant.registerWith(flutterEngine)
+ }
+}
diff --git a/example/ohos/entry/src/main/ets/pages/Index.ets b/example/ohos/entry/src/main/ets/pages/Index.ets
new file mode 100644
index 0000000..1125f9f
--- /dev/null
+++ b/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/example/ohos/entry/src/main/module.json5 b/example/ohos/entry/src/main/module.json5
new file mode 100644
index 0000000..7bbf78b
--- /dev/null
+++ b/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/example/ohos/entry/src/main/resources/base/element/color.json b/example/ohos/entry/src/main/resources/base/element/color.json
new file mode 100644
index 0000000..3c71296
--- /dev/null
+++ b/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/example/ohos/entry/src/main/resources/base/element/string.json b/example/ohos/entry/src/main/resources/base/element/string.json
new file mode 100644
index 0000000..d6c71ea
--- /dev/null
+++ b/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": "tobias_example"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/example/ohos/entry/src/main/resources/base/media/icon.png b/example/ohos/entry/src/main/resources/base/media/icon.png
new file mode 100644
index 0000000..ce307a8
Binary files /dev/null and b/example/ohos/entry/src/main/resources/base/media/icon.png differ
diff --git a/example/ohos/entry/src/main/resources/base/profile/main_pages.json b/example/ohos/entry/src/main/resources/base/profile/main_pages.json
new file mode 100644
index 0000000..1898d94
--- /dev/null
+++ b/example/ohos/entry/src/main/resources/base/profile/main_pages.json
@@ -0,0 +1,5 @@
+{
+ "src": [
+ "pages/Index"
+ ]
+}
diff --git a/example/ohos/entry/src/main/resources/en_US/element/string.json b/example/ohos/entry/src/main/resources/en_US/element/string.json
new file mode 100644
index 0000000..d6c71ea
--- /dev/null
+++ b/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": "tobias_example"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/example/ohos/entry/src/main/resources/zh_CN/element/string.json b/example/ohos/entry/src/main/resources/zh_CN/element/string.json
new file mode 100644
index 0000000..9c1417e
--- /dev/null
+++ b/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": "tobias_example"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/example/ohos/entry/src/ohosTest/ets/test/Ability.test.ets b/example/ohos/entry/src/ohosTest/ets/test/Ability.test.ets
new file mode 100644
index 0000000..25d4c71
--- /dev/null
+++ b/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/example/ohos/entry/src/ohosTest/ets/test/List.test.ets b/example/ohos/entry/src/ohosTest/ets/test/List.test.ets
new file mode 100644
index 0000000..f414003
--- /dev/null
+++ b/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/example/ohos/entry/src/ohosTest/ets/testability/TestAbility.ets b/example/ohos/entry/src/ohosTest/ets/testability/TestAbility.ets
new file mode 100644
index 0000000..4ca645e
--- /dev/null
+++ b/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/example/ohos/entry/src/ohosTest/ets/testability/pages/Index.ets b/example/ohos/entry/src/ohosTest/ets/testability/pages/Index.ets
new file mode 100644
index 0000000..cef0447
--- /dev/null
+++ b/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/example/ohos/entry/src/ohosTest/ets/testrunner/OpenHarmonyTestRunner.ts b/example/ohos/entry/src/ohosTest/ets/testrunner/OpenHarmonyTestRunner.ts
new file mode 100644
index 0000000..1def08f
--- /dev/null
+++ b/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/example/ohos/entry/src/ohosTest/module.json5 b/example/ohos/entry/src/ohosTest/module.json5
new file mode 100644
index 0000000..fab77ce
--- /dev/null
+++ b/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/example/ohos/entry/src/ohosTest/resources/base/element/color.json b/example/ohos/entry/src/ohosTest/resources/base/element/color.json
new file mode 100644
index 0000000..3c71296
--- /dev/null
+++ b/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/example/ohos/entry/src/ohosTest/resources/base/element/string.json b/example/ohos/entry/src/ohosTest/resources/base/element/string.json
new file mode 100644
index 0000000..65d8fa5
--- /dev/null
+++ b/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/example/ohos/entry/src/ohosTest/resources/base/media/icon.png b/example/ohos/entry/src/ohosTest/resources/base/media/icon.png
new file mode 100644
index 0000000..ce307a8
Binary files /dev/null and b/example/ohos/entry/src/ohosTest/resources/base/media/icon.png differ
diff --git a/example/ohos/entry/src/ohosTest/resources/base/profile/test_pages.json b/example/ohos/entry/src/ohosTest/resources/base/profile/test_pages.json
new file mode 100644
index 0000000..b7e7343
--- /dev/null
+++ b/example/ohos/entry/src/ohosTest/resources/base/profile/test_pages.json
@@ -0,0 +1,5 @@
+{
+ "src": [
+ "testability/pages/Index"
+ ]
+}
diff --git a/example/ohos/hvigor/hvigor-config.json5 b/example/ohos/hvigor/hvigor-config.json5
new file mode 100644
index 0000000..541ba35
--- /dev/null
+++ b/example/ohos/hvigor/hvigor-config.json5
@@ -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.
+*/
+
+{
+ "modelVersion": "5.0.0",
+ "dependencies": {
+ }
+}
\ No newline at end of file
diff --git a/example/ohos/hvigorfile.ts b/example/ohos/hvigorfile.ts
new file mode 100644
index 0000000..8f2d2aa
--- /dev/null
+++ b/example/ohos/hvigorfile.ts
@@ -0,0 +1,21 @@
+/*
+* 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 { appTasks } from '@ohos/hvigor-ohos-plugin';
+
+export default {
+ system: appTasks, /* Built-in plugin of Hvigor. It cannot be modified. */
+ plugins:[] /* Custom plugin to extend the functionality of Hvigor. */
+}
\ No newline at end of file
diff --git a/example/ohos/oh-package.json5 b/example/ohos/oh-package.json5
new file mode 100644
index 0000000..638f4d5
--- /dev/null
+++ b/example/ohos/oh-package.json5
@@ -0,0 +1,34 @@
+/*
+* 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.
+*/
+
+{
+ "modelVersion": "5.0.0",
+ "name": "tobias_example",
+ "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",
+ "tobias": "../../ohos"
+ }
+}
diff --git a/ohos/.gitignore b/ohos/.gitignore
new file mode 100644
index 0000000..4bf3c30
--- /dev/null
+++ b/ohos/.gitignore
@@ -0,0 +1,11 @@
+/node_modules
+/oh_modules
+/.preview
+/.idea
+/build
+/.cxx
+/.test
+/BuildProfile.ets
+/oh-package-lock.json5
+/local.properties
+*.har
\ No newline at end of file
diff --git a/ohos/build-profile.json5 b/ohos/build-profile.json5
new file mode 100644
index 0000000..79961f9
--- /dev/null
+++ b/ohos/build-profile.json5
@@ -0,0 +1,10 @@
+{
+ "apiType": "stageMode",
+ "buildOption": {
+ },
+ "targets": [
+ {
+ "name": "default"
+ }
+ ]
+}
diff --git a/ohos/hvigorfile.ts b/ohos/hvigorfile.ts
new file mode 100644
index 0000000..47e6e1f
--- /dev/null
+++ b/ohos/hvigorfile.ts
@@ -0,0 +1,2 @@
+// Script for compiling build behavior. It is built in the build plug-in and cannot be modified currently.
+export { harTasks } from '@ohos/hvigor-ohos-plugin';
\ No newline at end of file
diff --git a/ohos/index.ets b/ohos/index.ets
new file mode 100644
index 0000000..6d3b0f0
--- /dev/null
+++ b/ohos/index.ets
@@ -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.
+*/
+
+import TobiasPlugin from './src/main/ets/components/plugin/TobiasPlugin';
+export default TobiasPlugin;
diff --git a/ohos/oh-package.json5 b/ohos/oh-package.json5
new file mode 100644
index 0000000..3231976
--- /dev/null
+++ b/ohos/oh-package.json5
@@ -0,0 +1,12 @@
+{
+ "name": "tobias",
+ "version": "1.0.0",
+ "description": "Please describe the basic information.",
+ "main": "index.ets",
+ "author": "",
+ "license": "Apache-2.0",
+ "dependencies": {
+ "@ohos/flutter_ohos": "file:./har/flutter.har",
+ "@cashier_alipay/cashiersdk": "^15.8.27"
+ }
+}
diff --git a/ohos/src/main/ets/components/plugin/TobiasPlugin.ets b/ohos/src/main/ets/components/plugin/TobiasPlugin.ets
new file mode 100644
index 0000000..e2669b3
--- /dev/null
+++ b/ohos/src/main/ets/components/plugin/TobiasPlugin.ets
@@ -0,0 +1,94 @@
+import {
+ AbilityAware,
+ AbilityPluginBinding,
+ FlutterPlugin,
+ FlutterPluginBinding,
+ MethodCall,
+ MethodCallHandler,
+ MethodChannel,
+ MethodResult,
+} from '@ohos/flutter_ohos';
+import { bundleManager, common } from '@kit.AbilityKit';
+import * as alipay from "@cashier_alipay/cashiersdk"
+import { BusinessError } from '@kit.BasicServicesKit';
+
+const MESSAGE_CHANNEL_NAME = "com.jarvanmo/tobias";
+
+/** TobiasPlugin **/
+export default class TobiasPlugin implements FlutterPlugin, MethodCallHandler, AbilityAware {
+ private channel: MethodChannel | null = null;
+ private context: common.UIAbilityContext | null = null;
+
+ getUniqueClassName(): string {
+ return "TobiasPlugin"
+ }
+
+ onAttachedToEngine(binding: FlutterPluginBinding): void {
+ this.channel = new MethodChannel(binding.getBinaryMessenger(), MESSAGE_CHANNEL_NAME);
+ this.channel.setMethodCallHandler(this)
+ }
+
+ onDetachedFromEngine(binding: FlutterPluginBinding): void {
+ this.channel?.setMethodCallHandler(null)
+ this.channel = null
+ }
+
+ onAttachedToAbility(binding: AbilityPluginBinding): void {
+ this.context = binding.getAbility().context;
+ }
+
+ onDetachedFromAbility(): void {
+ this.context = null;
+ }
+
+ onMethodCall(call: MethodCall, result: MethodResult): void {
+ switch (call.method) {
+ case "version":
+ this.version(result);
+ break;
+ case "pay":
+ this.pay(call, result);
+ break;
+ case "auth":
+ result.notImplemented();
+ break;
+ case "isAliPayInstalled":
+ this.isAliPayInstalled(result);
+ break;
+ case "isAliPayHKInstalled":
+ this.isAliPayHKInstalled(result);
+ break;
+ default:
+ result.notImplemented();
+ break;
+ }
+ }
+
+ version(result: MethodResult): void {
+ const pay = new alipay.Pay();
+ result.success(pay.getVersion());
+ }
+
+ pay(call: MethodCall, result: MethodResult): void {
+ const order: string = call.argument("order");
+ const isShowLoading: boolean = true;
+ const payment = new alipay.Pay();
+ payment.pay(order, isShowLoading)
+ .then((res: Map) => {
+ result.success(res);
+ })
+ .catch((_: BusinessError) => {
+ const resp: Map = new Map();
+ resp.set("resultStatus", "-1");
+ result.success(resp);
+ });
+ }
+
+ isAliPayInstalled(result: MethodResult): void {
+ result.success(bundleManager.canOpenLink("alipays://"))
+ }
+
+ isAliPayHKInstalled(result: MethodResult): void {
+ result.success(bundleManager.canOpenLink("alipayhk://"))
+ }
+}
\ No newline at end of file
diff --git a/ohos/src/main/module.json5 b/ohos/src/main/module.json5
new file mode 100644
index 0000000..7588d7a
--- /dev/null
+++ b/ohos/src/main/module.json5
@@ -0,0 +1,10 @@
+{
+ "module": {
+ "name": "tobias",
+ "type": "har",
+ "deviceTypes": [
+ "default",
+ "tablet"
+ ]
+ }
+}
diff --git a/pubspec.yaml b/pubspec.yaml
index 8183274..8aff0ac 100644
--- a/pubspec.yaml
+++ b/pubspec.yaml
@@ -1,5 +1,5 @@
name: tobias
-description: A Flutter plugin for allowing users to authenticate or pay with native Android&iOS AliPay SDKs.
+description: A Flutter plugin for allowing users to authenticate or pay with native Android/iOS/OpenHarmony AliPay SDKs.
version: 4.0.0
homepage: https://github.com/OpenFlutter/tobias
@@ -41,6 +41,8 @@ flutter:
pluginClass: TobiasPlugin
ios:
pluginClass: TobiasPlugin
+ ohos:
+ pluginClass: TobiasPlugin
# web:
# pluginClass: TobiasWeb
# fileName: tobias_web.dart