diff --git a/flutter_service/flutter_test_background_service/flutter_background_service_ohos/.gitignore b/flutter_service/flutter_test_background_service/flutter_background_service_ohos/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..ac5aa9893e489c2ce51135893f258c60a475bb7a --- /dev/null +++ b/flutter_service/flutter_test_background_service/flutter_background_service_ohos/.gitignore @@ -0,0 +1,29 @@ +# Miscellaneous +*.class +*.log +*.pyc +*.swp +.DS_Store +.atom/ +.buildlog/ +.history +.svn/ +migrate_working_dir/ + +# IntelliJ related +*.iml +*.ipr +*.iws +.idea/ + +# The .vscode folder contains launch configuration and tasks you configure in +# VS Code which you may wish to be included in version control, so this line +# is commented out by default. +#.vscode/ + +# Flutter/Dart/Pub related +# Libraries should not include pubspec.lock, per https://dart.dev/guides/libraries/private-files#pubspeclock. +/pubspec.lock +**/doc/api/ +.dart_tool/ +build/ diff --git a/flutter_service/flutter_test_background_service/flutter_background_service_ohos/.metadata b/flutter_service/flutter_test_background_service/flutter_background_service_ohos/.metadata new file mode 100644 index 0000000000000000000000000000000000000000..159321c46c9cb5ef1f6ffd2d97bc0c9cb51b6661 --- /dev/null +++ b/flutter_service/flutter_test_background_service/flutter_background_service_ohos/.metadata @@ -0,0 +1,30 @@ +# This file tracks properties of this Flutter project. +# Used by Flutter tool to assess capabilities and perform upgrades etc. +# +# This file should be version controlled and should not be manually edited. + +version: + revision: "c4a66f77d0e5047ddf5a1bd353fd3ee9cbfeafcd" + channel: "[user-branch]" + +project_type: plugin + +# Tracks metadata for the flutter migrate command +migration: + platforms: + - platform: root + create_revision: c4a66f77d0e5047ddf5a1bd353fd3ee9cbfeafcd + base_revision: c4a66f77d0e5047ddf5a1bd353fd3ee9cbfeafcd + - platform: ohos + create_revision: c4a66f77d0e5047ddf5a1bd353fd3ee9cbfeafcd + base_revision: c4a66f77d0e5047ddf5a1bd353fd3ee9cbfeafcd + + # User provided section + + # List of Local paths (relative to this file) that should be + # ignored by the migrate tool. + # + # Files that are not part of the templates will be ignored by default. + unmanaged_files: + - 'lib/main.dart' + - 'ios/Runner.xcodeproj/project.pbxproj' diff --git a/flutter_service/flutter_test_background_service/flutter_background_service_ohos/CHANGELOG.md b/flutter_service/flutter_test_background_service/flutter_background_service_ohos/CHANGELOG.md new file mode 100644 index 0000000000000000000000000000000000000000..41cc7d8192ecf7f46ac85be44be7fcb99c8b54c6 --- /dev/null +++ b/flutter_service/flutter_test_background_service/flutter_background_service_ohos/CHANGELOG.md @@ -0,0 +1,3 @@ +## 0.0.1 + +* TODO: Describe initial release. diff --git a/flutter_service/flutter_test_background_service/flutter_background_service_ohos/LICENSE b/flutter_service/flutter_test_background_service/flutter_background_service_ohos/LICENSE new file mode 100644 index 0000000000000000000000000000000000000000..ba75c69f7f2175380928fff6693b797e2373e603 --- /dev/null +++ b/flutter_service/flutter_test_background_service/flutter_background_service_ohos/LICENSE @@ -0,0 +1 @@ +TODO: Add your license here. diff --git a/flutter_service/flutter_test_background_service/flutter_background_service_ohos/README.md b/flutter_service/flutter_test_background_service/flutter_background_service_ohos/README.md new file mode 100644 index 0000000000000000000000000000000000000000..25c89e1d892ea02d7686cf7e4ace1d1c538c464f --- /dev/null +++ b/flutter_service/flutter_test_background_service/flutter_background_service_ohos/README.md @@ -0,0 +1,15 @@ +# flutter_background_service_ohos + +A new Flutter plugin project. + +## Getting Started + +This project is a starting point for a Flutter +[plug-in package](https://flutter.dev/developing-packages/), +a specialized package that includes platform-specific implementation code for +Android and/or iOS. + +For help getting started with Flutter development, view the +[online documentation](https://flutter.dev/docs), which offers tutorials, +samples, guidance on mobile development, and a full API reference. + diff --git a/flutter_service/flutter_test_background_service/flutter_background_service_ohos/analysis_options.yaml b/flutter_service/flutter_test_background_service/flutter_background_service_ohos/analysis_options.yaml new file mode 100644 index 0000000000000000000000000000000000000000..a5744c1cfbe77ae2daba29c74156c617b5f09b77 --- /dev/null +++ b/flutter_service/flutter_test_background_service/flutter_background_service_ohos/analysis_options.yaml @@ -0,0 +1,4 @@ +include: package:flutter_lints/flutter.yaml + +# Additional information about this file can be found at +# https://dart.dev/guides/language/analysis-options diff --git a/flutter_service/flutter_test_background_service/flutter_background_service_ohos/example/.gitignore b/flutter_service/flutter_test_background_service/flutter_background_service_ohos/example/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..29a3a5017f048d6d8e6a450eef64435ddee44fb7 --- /dev/null +++ b/flutter_service/flutter_test_background_service/flutter_background_service_ohos/example/.gitignore @@ -0,0 +1,43 @@ +# Miscellaneous +*.class +*.log +*.pyc +*.swp +.DS_Store +.atom/ +.buildlog/ +.history +.svn/ +migrate_working_dir/ + +# IntelliJ related +*.iml +*.ipr +*.iws +.idea/ + +# The .vscode folder contains launch configuration and tasks you configure in +# VS Code which you may wish to be included in version control, so this line +# is commented out by default. +#.vscode/ + +# Flutter/Dart/Pub related +**/doc/api/ +**/ios/Flutter/.last_build_id +.dart_tool/ +.flutter-plugins +.flutter-plugins-dependencies +.pub-cache/ +.pub/ +/build/ + +# Symbolication related +app.*.symbols + +# Obfuscation related +app.*.map.json + +# Android Studio will place build artifacts here +/android/app/debug +/android/app/profile +/android/app/release diff --git a/flutter_service/flutter_test_background_service/flutter_background_service_ohos/example/.metadata b/flutter_service/flutter_test_background_service/flutter_background_service_ohos/example/.metadata new file mode 100644 index 0000000000000000000000000000000000000000..76fd1d08531fa60215e624ca9b532881aa143af3 --- /dev/null +++ b/flutter_service/flutter_test_background_service/flutter_background_service_ohos/example/.metadata @@ -0,0 +1,30 @@ +# This file tracks properties of this Flutter project. +# Used by Flutter tool to assess capabilities and perform upgrades etc. +# +# This file should be version controlled and should not be manually edited. + +version: + revision: "05db9689081f091050f01aed79f04dce0c750154" + channel: "stable" + +project_type: app + +# Tracks metadata for the flutter migrate command +migration: + platforms: + - platform: root + create_revision: 05db9689081f091050f01aed79f04dce0c750154 + base_revision: 05db9689081f091050f01aed79f04dce0c750154 + - platform: android + create_revision: 05db9689081f091050f01aed79f04dce0c750154 + base_revision: 05db9689081f091050f01aed79f04dce0c750154 + + # User provided section + + # List of Local paths (relative to this file) that should be + # ignored by the migrate tool. + # + # Files that are not part of the templates will be ignored by default. + unmanaged_files: + - 'lib/main.dart' + - 'ios/Runner.xcodeproj/project.pbxproj' diff --git a/flutter_service/flutter_test_background_service/flutter_background_service_ohos/example/README.md b/flutter_service/flutter_test_background_service/flutter_background_service_ohos/example/README.md new file mode 100644 index 0000000000000000000000000000000000000000..2aec92615f6772c059588d6b23b02750d1f3c739 --- /dev/null +++ b/flutter_service/flutter_test_background_service/flutter_background_service_ohos/example/README.md @@ -0,0 +1,16 @@ +# flutter_background_service_ohos_example + +Demonstrates how to use the flutter_background_service_ohos plugin. + +## Getting Started + +This project is a starting point for a Flutter application. + +A few resources to get you started if this is your first Flutter project: + +- [Lab: Write your first Flutter app](https://docs.flutter.dev/get-started/codelab) +- [Cookbook: Useful Flutter samples](https://docs.flutter.dev/cookbook) + +For help getting started with Flutter development, view the +[online documentation](https://docs.flutter.dev/), which offers tutorials, +samples, guidance on mobile development, and a full API reference. diff --git a/flutter_service/flutter_test_background_service/flutter_background_service_ohos/example/analysis_options.yaml b/flutter_service/flutter_test_background_service/flutter_background_service_ohos/example/analysis_options.yaml new file mode 100644 index 0000000000000000000000000000000000000000..0d2902135caece481a035652d88970c80e29cc7e --- /dev/null +++ b/flutter_service/flutter_test_background_service/flutter_background_service_ohos/example/analysis_options.yaml @@ -0,0 +1,28 @@ +# This file configures the analyzer, which statically analyzes Dart code to +# check for errors, warnings, and lints. +# +# The issues identified by the analyzer are surfaced in the UI of Dart-enabled +# IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be +# invoked from the command line by running `flutter analyze`. + +# The following line activates a set of recommended lints for Flutter apps, +# packages, and plugins designed to encourage good coding practices. +include: package:flutter_lints/flutter.yaml + +linter: + # The lint rules applied to this project can be customized in the + # section below to disable rules from the `package:flutter_lints/flutter.yaml` + # included above or to enable additional rules. A list of all available lints + # and their documentation is published at https://dart.dev/lints. + # + # Instead of disabling a lint rule for the entire project in the + # section below, it can also be suppressed for a single line of code + # or a specific dart file by using the `// ignore: name_of_lint` and + # `// ignore_for_file: name_of_lint` syntax on the line or in the file + # producing the lint. + rules: + # avoid_print: false # Uncomment to disable the `avoid_print` rule + # prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule + +# Additional information about this file can be found at +# https://dart.dev/guides/language/analysis-options diff --git a/flutter_service/flutter_test_background_service/flutter_background_service_ohos/example/android/.gitignore b/flutter_service/flutter_test_background_service/flutter_background_service_ohos/example/android/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..be3943c96d8eed92e2a329ce8327616d5e7dc440 --- /dev/null +++ b/flutter_service/flutter_test_background_service/flutter_background_service_ohos/example/android/.gitignore @@ -0,0 +1,14 @@ +gradle-wrapper.jar +/.gradle +/captures/ +/gradlew +/gradlew.bat +/local.properties +GeneratedPluginRegistrant.java +.cxx/ + +# Remember to never publicly share your keystore. +# See https://flutter.dev/to/reference-keystore +key.properties +**/*.keystore +**/*.jks diff --git a/flutter_service/flutter_test_background_service/flutter_background_service_ohos/example/android/app/build.gradle.kts b/flutter_service/flutter_test_background_service/flutter_background_service_ohos/example/android/app/build.gradle.kts new file mode 100644 index 0000000000000000000000000000000000000000..8f369452f21b86918c61fbf2c779268246f51161 --- /dev/null +++ b/flutter_service/flutter_test_background_service/flutter_background_service_ohos/example/android/app/build.gradle.kts @@ -0,0 +1,44 @@ +plugins { + id("com.android.application") + id("kotlin-android") + // The Flutter Gradle Plugin must be applied after the Android and Kotlin Gradle plugins. + id("dev.flutter.flutter-gradle-plugin") +} + +android { + namespace = "com.example.flutter_background_service_ohos_example" + compileSdk = flutter.compileSdkVersion + ndkVersion = flutter.ndkVersion + + compileOptions { + sourceCompatibility = JavaVersion.VERSION_11 + targetCompatibility = JavaVersion.VERSION_11 + } + + kotlinOptions { + jvmTarget = JavaVersion.VERSION_11.toString() + } + + defaultConfig { + // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). + applicationId = "com.example.flutter_background_service_ohos_example" + // You can update the following values to match your application needs. + // For more information, see: https://flutter.dev/to/review-gradle-config. + minSdk = flutter.minSdkVersion + targetSdk = flutter.targetSdkVersion + versionCode = flutter.versionCode + versionName = flutter.versionName + } + + buildTypes { + release { + // TODO: Add your own signing config for the release build. + // Signing with the debug keys for now, so `flutter run --release` works. + signingConfig = signingConfigs.getByName("debug") + } + } +} + +flutter { + source = "../.." +} diff --git a/flutter_service/flutter_test_background_service/flutter_background_service_ohos/example/android/app/src/debug/AndroidManifest.xml b/flutter_service/flutter_test_background_service/flutter_background_service_ohos/example/android/app/src/debug/AndroidManifest.xml new file mode 100644 index 0000000000000000000000000000000000000000..399f6981d5d35475eb18e6068ae67cdd7c731978 --- /dev/null +++ b/flutter_service/flutter_test_background_service/flutter_background_service_ohos/example/android/app/src/debug/AndroidManifest.xml @@ -0,0 +1,7 @@ + + + + diff --git a/flutter_service/flutter_test_background_service/flutter_background_service_ohos/example/android/app/src/main/AndroidManifest.xml b/flutter_service/flutter_test_background_service/flutter_background_service_ohos/example/android/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000000000000000000000000000000000000..213df12180bd336ddfe6962be0d383078ff59b3f --- /dev/null +++ b/flutter_service/flutter_test_background_service/flutter_background_service_ohos/example/android/app/src/main/AndroidManifest.xml @@ -0,0 +1,45 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/flutter_service/flutter_test_background_service/flutter_background_service_ohos/example/android/app/src/main/kotlin/com/example/flutter_background_service_ohos_example/MainActivity.kt b/flutter_service/flutter_test_background_service/flutter_background_service_ohos/example/android/app/src/main/kotlin/com/example/flutter_background_service_ohos_example/MainActivity.kt new file mode 100644 index 0000000000000000000000000000000000000000..2ed46484c1fb07c81afb3b36d2de0ba62cc8c6bb --- /dev/null +++ b/flutter_service/flutter_test_background_service/flutter_background_service_ohos/example/android/app/src/main/kotlin/com/example/flutter_background_service_ohos_example/MainActivity.kt @@ -0,0 +1,5 @@ +package com.example.flutter_background_service_ohos_example + +import io.flutter.embedding.android.FlutterActivity + +class MainActivity : FlutterActivity() diff --git a/flutter_service/flutter_test_background_service/flutter_background_service_ohos/example/android/app/src/main/res/drawable-v21/launch_background.xml b/flutter_service/flutter_test_background_service/flutter_background_service_ohos/example/android/app/src/main/res/drawable-v21/launch_background.xml new file mode 100644 index 0000000000000000000000000000000000000000..f74085f3f6a2b995f8ad1f9ff7b2c46dc118a9e0 --- /dev/null +++ b/flutter_service/flutter_test_background_service/flutter_background_service_ohos/example/android/app/src/main/res/drawable-v21/launch_background.xml @@ -0,0 +1,12 @@ + + + + + + + + diff --git a/flutter_service/flutter_test_background_service/flutter_background_service_ohos/example/android/app/src/main/res/drawable/launch_background.xml b/flutter_service/flutter_test_background_service/flutter_background_service_ohos/example/android/app/src/main/res/drawable/launch_background.xml new file mode 100644 index 0000000000000000000000000000000000000000..304732f8842013497e14bd02f67a55f2614fb8f7 --- /dev/null +++ b/flutter_service/flutter_test_background_service/flutter_background_service_ohos/example/android/app/src/main/res/drawable/launch_background.xml @@ -0,0 +1,12 @@ + + + + + + + + diff --git a/flutter_service/flutter_test_background_service/flutter_background_service_ohos/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png b/flutter_service/flutter_test_background_service/flutter_background_service_ohos/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png new file mode 100644 index 0000000000000000000000000000000000000000..db77bb4b7b0906d62b1847e87f15cdcacf6a4f29 Binary files /dev/null and b/flutter_service/flutter_test_background_service/flutter_background_service_ohos/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png differ diff --git a/flutter_service/flutter_test_background_service/flutter_background_service_ohos/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png b/flutter_service/flutter_test_background_service/flutter_background_service_ohos/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png new file mode 100644 index 0000000000000000000000000000000000000000..17987b79bb8a35cc66c3c1fd44f5a5526c1b78be Binary files /dev/null and b/flutter_service/flutter_test_background_service/flutter_background_service_ohos/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png differ diff --git a/flutter_service/flutter_test_background_service/flutter_background_service_ohos/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png b/flutter_service/flutter_test_background_service/flutter_background_service_ohos/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png new file mode 100644 index 0000000000000000000000000000000000000000..09d4391482be68e9e4a07fab769b5de337d16eb1 Binary files /dev/null and b/flutter_service/flutter_test_background_service/flutter_background_service_ohos/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png differ diff --git a/flutter_service/flutter_test_background_service/flutter_background_service_ohos/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/flutter_service/flutter_test_background_service/flutter_background_service_ohos/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png new file mode 100644 index 0000000000000000000000000000000000000000..d5f1c8d34e7a88e3f88bea192c3a370d44689c3c Binary files /dev/null and b/flutter_service/flutter_test_background_service/flutter_background_service_ohos/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png differ diff --git a/flutter_service/flutter_test_background_service/flutter_background_service_ohos/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/flutter_service/flutter_test_background_service/flutter_background_service_ohos/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png new file mode 100644 index 0000000000000000000000000000000000000000..4d6372eebdb28e45604e46eeda8dd24651419bc0 Binary files /dev/null and b/flutter_service/flutter_test_background_service/flutter_background_service_ohos/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png differ diff --git a/flutter_service/flutter_test_background_service/flutter_background_service_ohos/example/android/app/src/main/res/values-night/styles.xml b/flutter_service/flutter_test_background_service/flutter_background_service_ohos/example/android/app/src/main/res/values-night/styles.xml new file mode 100644 index 0000000000000000000000000000000000000000..06952be745f9fa6fa75196e830d9578eb2ee631d --- /dev/null +++ b/flutter_service/flutter_test_background_service/flutter_background_service_ohos/example/android/app/src/main/res/values-night/styles.xml @@ -0,0 +1,18 @@ + + + + + + + diff --git a/flutter_service/flutter_test_background_service/flutter_background_service_ohos/example/android/app/src/main/res/values/styles.xml b/flutter_service/flutter_test_background_service/flutter_background_service_ohos/example/android/app/src/main/res/values/styles.xml new file mode 100644 index 0000000000000000000000000000000000000000..cb1ef88056edd1caf99a935e434e7ff6943a0ef6 --- /dev/null +++ b/flutter_service/flutter_test_background_service/flutter_background_service_ohos/example/android/app/src/main/res/values/styles.xml @@ -0,0 +1,18 @@ + + + + + + + diff --git a/flutter_service/flutter_test_background_service/flutter_background_service_ohos/example/android/app/src/profile/AndroidManifest.xml b/flutter_service/flutter_test_background_service/flutter_background_service_ohos/example/android/app/src/profile/AndroidManifest.xml new file mode 100644 index 0000000000000000000000000000000000000000..399f6981d5d35475eb18e6068ae67cdd7c731978 --- /dev/null +++ b/flutter_service/flutter_test_background_service/flutter_background_service_ohos/example/android/app/src/profile/AndroidManifest.xml @@ -0,0 +1,7 @@ + + + + diff --git a/flutter_service/flutter_test_background_service/flutter_background_service_ohos/example/android/build.gradle.kts b/flutter_service/flutter_test_background_service/flutter_background_service_ohos/example/android/build.gradle.kts new file mode 100644 index 0000000000000000000000000000000000000000..dbee657bb5b9158516486b3a1b47ef8b6fc72a2a --- /dev/null +++ b/flutter_service/flutter_test_background_service/flutter_background_service_ohos/example/android/build.gradle.kts @@ -0,0 +1,24 @@ +allprojects { + repositories { + google() + mavenCentral() + } +} + +val newBuildDir: Directory = + rootProject.layout.buildDirectory + .dir("../../build") + .get() +rootProject.layout.buildDirectory.value(newBuildDir) + +subprojects { + val newSubprojectBuildDir: Directory = newBuildDir.dir(project.name) + project.layout.buildDirectory.value(newSubprojectBuildDir) +} +subprojects { + project.evaluationDependsOn(":app") +} + +tasks.register("clean") { + delete(rootProject.layout.buildDirectory) +} diff --git a/flutter_service/flutter_test_background_service/flutter_background_service_ohos/example/android/gradle.properties b/flutter_service/flutter_test_background_service/flutter_background_service_ohos/example/android/gradle.properties new file mode 100644 index 0000000000000000000000000000000000000000..f018a61817f55e78bb92ce8df2dda423ec570a4a --- /dev/null +++ b/flutter_service/flutter_test_background_service/flutter_background_service_ohos/example/android/gradle.properties @@ -0,0 +1,3 @@ +org.gradle.jvmargs=-Xmx8G -XX:MaxMetaspaceSize=4G -XX:ReservedCodeCacheSize=512m -XX:+HeapDumpOnOutOfMemoryError +android.useAndroidX=true +android.enableJetifier=true diff --git a/flutter_service/flutter_test_background_service/flutter_background_service_ohos/example/android/gradle/wrapper/gradle-wrapper.properties b/flutter_service/flutter_test_background_service/flutter_background_service_ohos/example/android/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000000000000000000000000000000000000..ac3b47926ee56b0efc39cbff3c532918abbf953f --- /dev/null +++ b/flutter_service/flutter_test_background_service/flutter_background_service_ohos/example/android/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,5 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-8.12-all.zip diff --git a/flutter_service/flutter_test_background_service/flutter_background_service_ohos/example/android/settings.gradle.kts b/flutter_service/flutter_test_background_service/flutter_background_service_ohos/example/android/settings.gradle.kts new file mode 100644 index 0000000000000000000000000000000000000000..fb605bc840f7bb713a721358bd422dd94c0755c2 --- /dev/null +++ b/flutter_service/flutter_test_background_service/flutter_background_service_ohos/example/android/settings.gradle.kts @@ -0,0 +1,26 @@ +pluginManagement { + val flutterSdkPath = + run { + val properties = java.util.Properties() + file("local.properties").inputStream().use { properties.load(it) } + val flutterSdkPath = properties.getProperty("flutter.sdk") + require(flutterSdkPath != null) { "flutter.sdk not set in local.properties" } + flutterSdkPath + } + + includeBuild("$flutterSdkPath/packages/flutter_tools/gradle") + + repositories { + google() + mavenCentral() + gradlePluginPortal() + } +} + +plugins { + id("dev.flutter.flutter-plugin-loader") version "1.0.0" + id("com.android.application") version "8.9.1" apply false + id("org.jetbrains.kotlin.android") version "2.1.0" apply false +} + +include(":app") diff --git a/flutter_service/flutter_test_background_service/flutter_background_service_ohos/example/integration_test/plugin_integration_test.dart b/flutter_service/flutter_test_background_service/flutter_background_service_ohos/example/integration_test/plugin_integration_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..95e2e1b5ca4168e21773cd64c357a1b105806319 --- /dev/null +++ b/flutter_service/flutter_test_background_service/flutter_background_service_ohos/example/integration_test/plugin_integration_test.dart @@ -0,0 +1,25 @@ +// This is a basic Flutter integration test. +// +// Since integration tests run in a full Flutter application, they can interact +// with the host side of a plugin implementation, unlike Dart unit tests. +// +// For more information about Flutter integration tests, please see +// https://docs.flutter.dev/cookbook/testing/integration/introduction + + +import 'package:flutter_test/flutter_test.dart'; +import 'package:integration_test/integration_test.dart'; + +import 'package:flutter_background_service_ohos/flutter_background_service_ohos.dart'; + +void main() { + IntegrationTestWidgetsFlutterBinding.ensureInitialized(); + + testWidgets('getPlatformVersion test', (WidgetTester tester) async { + final FlutterBackgroundServiceOhos plugin = FlutterBackgroundServiceOhos(); + final String? version = await plugin.getPlatformVersion(); + // The version string depends on the host platform running the test, so + // just assert that some non-empty string is returned. + expect(version?.isNotEmpty, true); + }); +} diff --git a/flutter_service/flutter_test_background_service/flutter_background_service_ohos/example/lib/main.dart b/flutter_service/flutter_test_background_service/flutter_background_service_ohos/example/lib/main.dart new file mode 100644 index 0000000000000000000000000000000000000000..cfa0b13bd858d5a283abb4a3bddb2ffae677c5a1 --- /dev/null +++ b/flutter_service/flutter_test_background_service/flutter_background_service_ohos/example/lib/main.dart @@ -0,0 +1,63 @@ +import 'package:flutter/material.dart'; +import 'dart:async'; + +import 'package:flutter/services.dart'; +import 'package:flutter_background_service_ohos/flutter_background_service_ohos.dart'; + +void main() { + runApp(const MyApp()); +} + +class MyApp extends StatefulWidget { + const MyApp({super.key}); + + @override + State createState() => _MyAppState(); +} + +class _MyAppState extends State { + String _platformVersion = 'Unknown'; + final _flutterBackgroundServiceOhosPlugin = FlutterBackgroundServiceOhos(); + + @override + void initState() { + super.initState(); + initPlatformState(); + } + + // Platform messages are asynchronous, so we initialize in an async method. + Future initPlatformState() async { + String platformVersion; + // Platform messages may fail, so we use a try/catch PlatformException. + // We also handle the message potentially returning null. + try { + platformVersion = + await _flutterBackgroundServiceOhosPlugin.getPlatformVersion() ?? 'Unknown platform version'; + } on PlatformException { + platformVersion = 'Failed to get platform version.'; + } + + // If the widget was removed from the tree while the asynchronous platform + // message was in flight, we want to discard the reply rather than calling + // setState to update our non-existent appearance. + if (!mounted) return; + + setState(() { + _platformVersion = platformVersion; + }); + } + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + appBar: AppBar( + title: const Text('Plugin example app'), + ), + body: Center( + child: Text('Running on: $_platformVersion\n'), + ), + ), + ); + } +} diff --git a/flutter_service/flutter_test_background_service/flutter_background_service_ohos/example/ohos/.gitignore b/flutter_service/flutter_test_background_service/flutter_background_service_ohos/example/ohos/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..e32649140581211002e81e849a2a04c93b605ebb --- /dev/null +++ b/flutter_service/flutter_test_background_service/flutter_background_service_ohos/example/ohos/.gitignore @@ -0,0 +1,20 @@ +/node_modules +/oh_modules +/local.properties +/.idea +**/build +/.hvigor +.cxx +/.clangd +/.clang-format +/.clang-tidy +**/.test +**/BuildProfile.ets +**/oh-package-lock.json5 +/package.json +/package-lock.json + +**/src/main/resources/rawfile/flutter_assets/ +**/libs/**/libapp.so +**/libs/**/libflutter.so +**/libs/**/libvmservice_snapshot.so diff --git a/flutter_service/flutter_test_background_service/flutter_background_service_ohos/example/ohos/AppScope/app.json5 b/flutter_service/flutter_test_background_service/flutter_background_service_ohos/example/ohos/AppScope/app.json5 new file mode 100644 index 0000000000000000000000000000000000000000..c81d8b8256e731429f101053a217867db3a89949 --- /dev/null +++ b/flutter_service/flutter_test_background_service/flutter_background_service_ohos/example/ohos/AppScope/app.json5 @@ -0,0 +1,10 @@ +{ + "app": { + "bundleName": "com.example.flutter_background_service_ohos_example", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name" + } +} diff --git a/flutter_service/flutter_test_background_service/flutter_background_service_ohos/example/ohos/AppScope/resources/base/element/string.json b/flutter_service/flutter_test_background_service/flutter_background_service_ohos/example/ohos/AppScope/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..c842b5ef46d4d1aad02ad78096cdfa9eb414a2a2 --- /dev/null +++ b/flutter_service/flutter_test_background_service/flutter_background_service_ohos/example/ohos/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "flutter_background_service_ohos_example" + } + ] +} diff --git a/flutter_service/flutter_test_background_service/flutter_background_service_ohos/example/ohos/AppScope/resources/base/media/app_icon.png b/flutter_service/flutter_test_background_service/flutter_background_service_ohos/example/ohos/AppScope/resources/base/media/app_icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/flutter_service/flutter_test_background_service/flutter_background_service_ohos/example/ohos/AppScope/resources/base/media/app_icon.png differ diff --git a/flutter_service/flutter_test_background_service/flutter_background_service_ohos/example/ohos/build-profile.json5 b/flutter_service/flutter_test_background_service/flutter_background_service_ohos/example/ohos/build-profile.json5 new file mode 100644 index 0000000000000000000000000000000000000000..1c112b1a1be6ba7c138b690f189bccbd427c9e64 --- /dev/null +++ b/flutter_service/flutter_test_background_service/flutter_background_service_ohos/example/ohos/build-profile.json5 @@ -0,0 +1,39 @@ + +{ + "app": { + "signingConfigs": [], + "products": [ + { + "name": "default", + "signingConfig": "default", + "compatibleSdkVersion": "5.1.0(18)", + "runtimeOS": "HarmonyOS", + } + ], + "buildModeSet": [ + { + "name": "debug" + }, + { + "name": "profile" + }, + { + "name": "release" + } + ] + }, + "modules": [ + { + "name": "entry", + "srcPath": "./entry", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/flutter_service/flutter_test_background_service/flutter_background_service_ohos/example/ohos/entry/.gitignore b/flutter_service/flutter_test_background_service/flutter_background_service_ohos/example/ohos/entry/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..5254b880d9bc9c95f2c95e46a958845bdc3ab470 --- /dev/null +++ b/flutter_service/flutter_test_background_service/flutter_background_service_ohos/example/ohos/entry/.gitignore @@ -0,0 +1,7 @@ +/node_modules +/oh_modules +/.preview +/build +/.cxx +/.test +GeneratedPluginRegistrant.ets \ No newline at end of file diff --git a/flutter_service/flutter_test_background_service/flutter_background_service_ohos/example/ohos/entry/build-profile.json5 b/flutter_service/flutter_test_background_service/flutter_background_service_ohos/example/ohos/entry/build-profile.json5 new file mode 100644 index 0000000000000000000000000000000000000000..6de31ee2243926392c90c572c00a052f7c3fa9e9 --- /dev/null +++ b/flutter_service/flutter_test_background_service/flutter_background_service_ohos/example/ohos/entry/build-profile.json5 @@ -0,0 +1,15 @@ + +{ + "apiType": 'stageMode', + "buildOption": { + }, + "targets": [ + { + "name": "default", + "runtimeOS": "HarmonyOS" + }, + { + "name": "ohosTest", + } + ] +} \ No newline at end of file diff --git a/flutter_service/flutter_test_background_service/flutter_background_service_ohos/example/ohos/entry/hvigorfile.ts b/flutter_service/flutter_test_background_service/flutter_background_service_ohos/example/ohos/entry/hvigorfile.ts new file mode 100644 index 0000000000000000000000000000000000000000..ff3bfe082b896f58e6c5001262ef90ae7fe90093 --- /dev/null +++ b/flutter_service/flutter_test_background_service/flutter_background_service_ohos/example/ohos/entry/hvigorfile.ts @@ -0,0 +1,7 @@ + +// Script for compiling build behavior. It is built in the build plug-in and cannot be modified currently. +import { hapTasks } from '@ohos/hvigor-ohos-plugin'; +export default { + system: hapTasks, /* Built-in plugin of Hvigor. It cannot be modified. */ + plugins: [] /* Custom plugin to extend the functionality of Hvigor. */ +} diff --git a/flutter_service/flutter_test_background_service/flutter_background_service_ohos/example/ohos/entry/oh-package.json5 b/flutter_service/flutter_test_background_service/flutter_background_service_ohos/example/ohos/entry/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..854eec208da5f8dccfe8c2ff41b1d9d856059f97 --- /dev/null +++ b/flutter_service/flutter_test_background_service/flutter_background_service_ohos/example/ohos/entry/oh-package.json5 @@ -0,0 +1,11 @@ + +{ + "name": "entry", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": {}, +} + diff --git a/flutter_service/flutter_test_background_service/flutter_background_service_ohos/example/ohos/entry/src/main/ets/entryability/EntryAbility.ets b/flutter_service/flutter_test_background_service/flutter_background_service_ohos/example/ohos/entry/src/main/ets/entryability/EntryAbility.ets new file mode 100644 index 0000000000000000000000000000000000000000..f85a65508a6140721404097998b77be622c93d5d --- /dev/null +++ b/flutter_service/flutter_test_background_service/flutter_background_service_ohos/example/ohos/entry/src/main/ets/entryability/EntryAbility.ets @@ -0,0 +1,10 @@ + +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/flutter_service/flutter_test_background_service/flutter_background_service_ohos/example/ohos/entry/src/main/ets/pages/Index.ets b/flutter_service/flutter_test_background_service/flutter_background_service_ohos/example/ohos/entry/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..7bb6543fe7ad7539f0167c4fbf56113e101662a1 --- /dev/null +++ b/flutter_service/flutter_test_background_service/flutter_background_service_ohos/example/ohos/entry/src/main/ets/pages/Index.ets @@ -0,0 +1,24 @@ + +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/flutter_service/flutter_test_background_service/flutter_background_service_ohos/example/ohos/entry/src/main/module.json5 b/flutter_service/flutter_test_background_service/flutter_background_service_ohos/example/ohos/entry/src/main/module.json5 new file mode 100644 index 0000000000000000000000000000000000000000..5bd7950ba5343abd89b475921bca8bbbacd3629c --- /dev/null +++ b/flutter_service/flutter_test_background_service/flutter_background_service_ohos/example/ohos/entry/src/main/module.json5 @@ -0,0 +1,40 @@ + +{ + "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/flutter_service/flutter_test_background_service/flutter_background_service_ohos/example/ohos/entry/src/main/resources/base/element/color.json b/flutter_service/flutter_test_background_service/flutter_background_service_ohos/example/ohos/entry/src/main/resources/base/element/color.json new file mode 100644 index 0000000000000000000000000000000000000000..3c712962da3c2751c2b9ddb53559afcbd2b54a02 --- /dev/null +++ b/flutter_service/flutter_test_background_service/flutter_background_service_ohos/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/flutter_service/flutter_test_background_service/flutter_background_service_ohos/example/ohos/entry/src/main/resources/base/element/string.json b/flutter_service/flutter_test_background_service/flutter_background_service_ohos/example/ohos/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..be3d280cdaa53d5b04423f1ae5e95d8563d25810 --- /dev/null +++ b/flutter_service/flutter_test_background_service/flutter_background_service_ohos/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": "flutter_background_service_ohos_example" + } + ] +} \ No newline at end of file diff --git a/flutter_service/flutter_test_background_service/flutter_background_service_ohos/example/ohos/entry/src/main/resources/base/media/icon.png b/flutter_service/flutter_test_background_service/flutter_background_service_ohos/example/ohos/entry/src/main/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/flutter_service/flutter_test_background_service/flutter_background_service_ohos/example/ohos/entry/src/main/resources/base/media/icon.png differ diff --git a/flutter_service/flutter_test_background_service/flutter_background_service_ohos/example/ohos/entry/src/main/resources/base/profile/buildinfo.json5 b/flutter_service/flutter_test_background_service/flutter_background_service_ohos/example/ohos/entry/src/main/resources/base/profile/buildinfo.json5 new file mode 100644 index 0000000000000000000000000000000000000000..6125c99c00f88253e2c22ea2e8f45bbadbd56675 --- /dev/null +++ b/flutter_service/flutter_test_background_service/flutter_background_service_ohos/example/ohos/entry/src/main/resources/base/profile/buildinfo.json5 @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "enable_impeller", + "value": "true" + } + ] +} \ No newline at end of file diff --git a/flutter_service/flutter_test_background_service/flutter_background_service_ohos/example/ohos/entry/src/main/resources/base/profile/main_pages.json b/flutter_service/flutter_test_background_service/flutter_background_service_ohos/example/ohos/entry/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000000000000000000000000000000000..1898d94f58d6128ab712be2c68acc7c98e9ab9ce --- /dev/null +++ b/flutter_service/flutter_test_background_service/flutter_background_service_ohos/example/ohos/entry/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "pages/Index" + ] +} diff --git a/flutter_service/flutter_test_background_service/flutter_background_service_ohos/example/ohos/entry/src/main/resources/en_US/element/string.json b/flutter_service/flutter_test_background_service/flutter_background_service_ohos/example/ohos/entry/src/main/resources/en_US/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..be3d280cdaa53d5b04423f1ae5e95d8563d25810 --- /dev/null +++ b/flutter_service/flutter_test_background_service/flutter_background_service_ohos/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": "flutter_background_service_ohos_example" + } + ] +} \ No newline at end of file diff --git a/flutter_service/flutter_test_background_service/flutter_background_service_ohos/example/ohos/entry/src/main/resources/zh_CN/element/string.json b/flutter_service/flutter_test_background_service/flutter_background_service_ohos/example/ohos/entry/src/main/resources/zh_CN/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..ea5d0e7c28f246225c9833f0e3b0f9034f4c083d --- /dev/null +++ b/flutter_service/flutter_test_background_service/flutter_background_service_ohos/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": "flutter_background_service_ohos_example" + } + ] +} \ No newline at end of file diff --git a/flutter_service/flutter_test_background_service/flutter_background_service_ohos/example/ohos/entry/src/ohosTest/ets/test/Ability.test.ets b/flutter_service/flutter_test_background_service/flutter_background_service_ohos/example/ohos/entry/src/ohosTest/ets/test/Ability.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..8abf7f2f44c0e56110df8c09b2524a4ca37bc993 --- /dev/null +++ b/flutter_service/flutter_test_background_service/flutter_background_service_ohos/example/ohos/entry/src/ohosTest/ets/test/Ability.test.ets @@ -0,0 +1,35 @@ +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/flutter_service/flutter_test_background_service/flutter_background_service_ohos/example/ohos/entry/src/ohosTest/ets/test/List.test.ets b/flutter_service/flutter_test_background_service/flutter_background_service_ohos/example/ohos/entry/src/ohosTest/ets/test/List.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..d766fe249dfc3ada636f27e64d9b64451ce32c93 --- /dev/null +++ b/flutter_service/flutter_test_background_service/flutter_background_service_ohos/example/ohos/entry/src/ohosTest/ets/test/List.test.ets @@ -0,0 +1,5 @@ +import abilityTest from './Ability.test' + +export default function testsuite() { + abilityTest() +} \ No newline at end of file diff --git a/flutter_service/flutter_test_background_service/flutter_background_service_ohos/example/ohos/entry/src/ohosTest/ets/testability/TestAbility.ets b/flutter_service/flutter_test_background_service/flutter_background_service_ohos/example/ohos/entry/src/ohosTest/ets/testability/TestAbility.ets new file mode 100644 index 0000000000000000000000000000000000000000..e3f6e911d3fffba1e1795c60ed1ee4db15b386fd --- /dev/null +++ b/flutter_service/flutter_test_background_service/flutter_background_service_ohos/example/ohos/entry/src/ohosTest/ets/testability/TestAbility.ets @@ -0,0 +1,48 @@ +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/flutter_service/flutter_test_background_service/flutter_background_service_ohos/example/ohos/entry/src/ohosTest/ets/testability/pages/Index.ets b/flutter_service/flutter_test_background_service/flutter_background_service_ohos/example/ohos/entry/src/ohosTest/ets/testability/pages/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..545843d3949e383b7bdd6ebbf5681d28c3e6ef71 --- /dev/null +++ b/flutter_service/flutter_test_background_service/flutter_background_service_ohos/example/ohos/entry/src/ohosTest/ets/testability/pages/Index.ets @@ -0,0 +1,36 @@ + + +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/flutter_service/flutter_test_background_service/flutter_background_service_ohos/example/ohos/entry/src/ohosTest/ets/testrunner/OpenHarmonyTestRunner.ts b/flutter_service/flutter_test_background_service/flutter_background_service_ohos/example/ohos/entry/src/ohosTest/ets/testrunner/OpenHarmonyTestRunner.ts new file mode 100644 index 0000000000000000000000000000000000000000..47fc89b4f05bf2efc6e863b8c2569705a4c56fd9 --- /dev/null +++ b/flutter_service/flutter_test_background_service/flutter_background_service_ohos/example/ohos/entry/src/ohosTest/ets/testrunner/OpenHarmonyTestRunner.ts @@ -0,0 +1,50 @@ + +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/flutter_service/flutter_test_background_service/flutter_background_service_ohos/example/ohos/entry/src/ohosTest/module.json5 b/flutter_service/flutter_test_background_service/flutter_background_service_ohos/example/ohos/entry/src/ohosTest/module.json5 new file mode 100644 index 0000000000000000000000000000000000000000..3b02a75a22d44e7ed129f102197a3050a8f922be --- /dev/null +++ b/flutter_service/flutter_test_background_service/flutter_background_service_ohos/example/ohos/entry/src/ohosTest/module.json5 @@ -0,0 +1,37 @@ + +{ + "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/flutter_service/flutter_test_background_service/flutter_background_service_ohos/example/ohos/entry/src/ohosTest/resources/base/element/color.json b/flutter_service/flutter_test_background_service/flutter_background_service_ohos/example/ohos/entry/src/ohosTest/resources/base/element/color.json new file mode 100644 index 0000000000000000000000000000000000000000..3c712962da3c2751c2b9ddb53559afcbd2b54a02 --- /dev/null +++ b/flutter_service/flutter_test_background_service/flutter_background_service_ohos/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/flutter_service/flutter_test_background_service/flutter_background_service_ohos/example/ohos/entry/src/ohosTest/resources/base/element/string.json b/flutter_service/flutter_test_background_service/flutter_background_service_ohos/example/ohos/entry/src/ohosTest/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..65d8fa5a7cf54aa3943dcd0214f58d1771bc1f6c --- /dev/null +++ b/flutter_service/flutter_test_background_service/flutter_background_service_ohos/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/flutter_service/flutter_test_background_service/flutter_background_service_ohos/example/ohos/entry/src/ohosTest/resources/base/media/icon.png b/flutter_service/flutter_test_background_service/flutter_background_service_ohos/example/ohos/entry/src/ohosTest/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/flutter_service/flutter_test_background_service/flutter_background_service_ohos/example/ohos/entry/src/ohosTest/resources/base/media/icon.png differ diff --git a/flutter_service/flutter_test_background_service/flutter_background_service_ohos/example/ohos/entry/src/ohosTest/resources/base/profile/test_pages.json b/flutter_service/flutter_test_background_service/flutter_background_service_ohos/example/ohos/entry/src/ohosTest/resources/base/profile/test_pages.json new file mode 100644 index 0000000000000000000000000000000000000000..b7e7343cacb32ce982a45e76daad86e435e054fe --- /dev/null +++ b/flutter_service/flutter_test_background_service/flutter_background_service_ohos/example/ohos/entry/src/ohosTest/resources/base/profile/test_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "testability/pages/Index" + ] +} diff --git a/flutter_service/flutter_test_background_service/flutter_background_service_ohos/example/ohos/hvigor/hvigor-config.json5 b/flutter_service/flutter_test_background_service/flutter_background_service_ohos/example/ohos/hvigor/hvigor-config.json5 new file mode 100644 index 0000000000000000000000000000000000000000..ad3ecab4a02b30749e4ead70ed4970c7d237a9d6 --- /dev/null +++ b/flutter_service/flutter_test_background_service/flutter_background_service_ohos/example/ohos/hvigor/hvigor-config.json5 @@ -0,0 +1,6 @@ + +{ + "modelVersion": "5.1.0", + "dependencies": { + } +} \ No newline at end of file diff --git a/flutter_service/flutter_test_background_service/flutter_background_service_ohos/example/ohos/hvigorconfig.ts b/flutter_service/flutter_test_background_service/flutter_background_service_ohos/example/ohos/hvigorconfig.ts new file mode 100644 index 0000000000000000000000000000000000000000..fc2b208637340e3f7956671c0bf108ae4deb43d1 --- /dev/null +++ b/flutter_service/flutter_test_background_service/flutter_background_service_ohos/example/ohos/hvigorconfig.ts @@ -0,0 +1,4 @@ +import path from 'path' +import { injectNativeModules } from 'flutter-hvigor-plugin'; + +injectNativeModules(__dirname, path.dirname(__dirname)) \ No newline at end of file diff --git a/flutter_service/flutter_test_background_service/flutter_background_service_ohos/example/ohos/hvigorfile.ts b/flutter_service/flutter_test_background_service/flutter_background_service_ohos/example/ohos/hvigorfile.ts new file mode 100644 index 0000000000000000000000000000000000000000..a64db460c843b13700bd56d79a4f2e208350d22a --- /dev/null +++ b/flutter_service/flutter_test_background_service/flutter_background_service_ohos/example/ohos/hvigorfile.ts @@ -0,0 +1,8 @@ +import path from 'path' +import { appTasks } from '@ohos/hvigor-ohos-plugin'; +import { flutterHvigorPlugin } from 'flutter-hvigor-plugin'; + +export default { + system: appTasks, /* Built-in plugin of Hvigor. It cannot be modified. */ + plugins:[flutterHvigorPlugin(path.dirname(__dirname))] /* Custom plugin to extend the functionality of Hvigor. */ +} \ No newline at end of file diff --git a/flutter_service/flutter_test_background_service/flutter_background_service_ohos/example/ohos/oh-package.json5 b/flutter_service/flutter_test_background_service/flutter_background_service_ohos/example/ohos/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..53733fa9766445a6d6195a2a8f9c5afc880666df --- /dev/null +++ b/flutter_service/flutter_test_background_service/flutter_background_service_ohos/example/ohos/oh-package.json5 @@ -0,0 +1,13 @@ +{ + "modelVersion": "5.1.0", + "name": "flutter_background_service_ohos_example", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": {}, + "devDependencies": { + "@ohos/hypium": "1.0.6" + } +} diff --git a/flutter_service/flutter_test_background_service/flutter_background_service_ohos/example/pubspec.lock b/flutter_service/flutter_test_background_service/flutter_background_service_ohos/example/pubspec.lock new file mode 100644 index 0000000000000000000000000000000000000000..9a42f5f3ad8ca2a46e7130f414a18b373517e28f --- /dev/null +++ b/flutter_service/flutter_test_background_service/flutter_background_service_ohos/example/pubspec.lock @@ -0,0 +1,283 @@ +# Generated by pub +# See https://dart.dev/tools/pub/glossary#lockfile +packages: + async: + dependency: transitive + description: + name: async + sha256: "947bfcf187f74dbc5e146c9eb9c0f10c9f8b30743e341481c1e2ed3ecc18c20c" + url: "https://pub.flutter-io.cn" + source: hosted + version: "2.11.0" + boolean_selector: + dependency: transitive + description: + name: boolean_selector + sha256: "6cfb5af12253eaf2b368f07bacc5a80d1301a071c73360d746b7f2e32d762c66" + url: "https://pub.flutter-io.cn" + source: hosted + version: "2.1.1" + characters: + dependency: transitive + description: + name: characters + sha256: f71061c654a3380576a52b451dd5532377954cf9dbd272a78fc8479606670803 + url: "https://pub.flutter-io.cn" + source: hosted + version: "1.4.0" + clock: + dependency: transitive + description: + name: clock + sha256: fddb70d9b5277016c77a80201021d40a2247104d9f4aa7bab7157b7e3f05b84b + url: "https://pub.flutter-io.cn" + source: hosted + version: "1.1.2" + collection: + dependency: transitive + description: + name: collection + sha256: "2f5709ae4d3d59dd8f7cd309b4e023046b57d8a6c82130785d2b0e5868084e76" + url: "https://pub.flutter-io.cn" + source: hosted + version: "1.19.1" + cupertino_icons: + dependency: "direct main" + description: + name: cupertino_icons + sha256: ba631d1c7f7bef6b729a622b7b752645a2d076dba9976925b8f25725a30e1ee6 + url: "https://pub.flutter-io.cn" + source: hosted + version: "1.0.8" + fake_async: + dependency: transitive + description: + name: fake_async + sha256: "5368f224a74523e8d2e7399ea1638b37aecfca824a3cc4dfdf77bf1fa905ac44" + url: "https://pub.flutter-io.cn" + source: hosted + version: "1.3.3" + file: + dependency: transitive + description: + name: file + sha256: "5fc22d7c25582e38ad9a8515372cd9a93834027aacf1801cf01164dac0ffa08c" + url: "https://pub.flutter-io.cn" + source: hosted + version: "7.0.0" + flutter: + dependency: "direct main" + description: flutter + source: sdk + version: "0.0.0" + flutter_background_service_ohos: + dependency: "direct main" + description: + path: ".." + relative: true + source: path + version: "0.0.1" + flutter_driver: + dependency: transitive + description: flutter + source: sdk + version: "0.0.0" + flutter_lints: + dependency: "direct dev" + description: + name: flutter_lints + sha256: "9e8c3858111da373efc5aa341de011d9bd23e2c5c5e0c62bccf32438e192d7b1" + url: "https://pub.flutter-io.cn" + source: hosted + version: "3.0.2" + flutter_test: + dependency: "direct dev" + description: flutter + source: sdk + version: "0.0.0" + fuchsia_remote_debug_protocol: + dependency: transitive + description: flutter + source: sdk + version: "0.0.0" + integration_test: + dependency: "direct dev" + description: flutter + source: sdk + version: "0.0.0" + leak_tracker: + dependency: transitive + description: + name: leak_tracker + sha256: "8dcda04c3fc16c14f48a7bb586d4be1f0d1572731b6d81d51772ef47c02081e0" + url: "https://pub.flutter-io.cn" + source: hosted + version: "11.0.1" + leak_tracker_flutter_testing: + dependency: transitive + description: + name: leak_tracker_flutter_testing + sha256: "1dbc140bb5a23c75ea9c4811222756104fbcd1a27173f0c34ca01e16bea473c1" + url: "https://pub.flutter-io.cn" + source: hosted + version: "3.0.10" + leak_tracker_testing: + dependency: transitive + description: + name: leak_tracker_testing + sha256: "8d5a2d49f4a66b49744b23b018848400d23e54caf9463f4eb20df3eb8acb2eb1" + url: "https://pub.flutter-io.cn" + source: hosted + version: "3.0.2" + lints: + dependency: transitive + description: + name: lints + sha256: cbf8d4b858bb0134ef3ef87841abdf8d63bfc255c266b7bf6b39daa1085c4290 + url: "https://pub.flutter-io.cn" + source: hosted + version: "3.0.0" + matcher: + dependency: transitive + description: + name: matcher + sha256: dc58c723c3c24bf8d3e2d3ad3f2f9d7bd9cf43ec6feaa64181775e60190153f2 + url: "https://pub.flutter-io.cn" + source: hosted + version: "0.12.17" + material_color_utilities: + dependency: transitive + description: + name: material_color_utilities + sha256: f7142bb1154231d7ea5f96bc7bde4bda2a0945d2806bb11670e30b850d56bdec + url: "https://pub.flutter-io.cn" + source: hosted + version: "0.11.1" + meta: + dependency: transitive + description: + name: meta + sha256: e3641ec5d63ebf0d9b41bd43201a66e3fc79a65db5f61fc181f04cd27aab950c + url: "https://pub.flutter-io.cn" + source: hosted + version: "1.16.0" + path: + dependency: transitive + description: + name: path + sha256: "75cca69d1490965be98c73ceaea117e8a04dd21217b37b292c9ddbec0d955bc5" + url: "https://pub.flutter-io.cn" + source: hosted + version: "1.9.1" + platform: + dependency: transitive + description: + name: platform + sha256: "12220bb4b65720483f8fa9450b4332347737cf8213dd2840d8b2c823e47243ec" + url: "https://pub.flutter-io.cn" + source: hosted + version: "3.1.4" + plugin_platform_interface: + dependency: transitive + description: + name: plugin_platform_interface + sha256: "4820fbfdb9478b1ebae27888254d445073732dae3d6ea81f0b7e06d5dedc3f02" + url: "https://pub.flutter-io.cn" + source: hosted + version: "2.1.8" + process: + dependency: transitive + description: + name: process + sha256: "21e54fd2faf1b5bdd5102afd25012184a6793927648ea81eea80552ac9405b32" + url: "https://pub.flutter-io.cn" + source: hosted + version: "5.0.2" + sky_engine: + dependency: transitive + description: flutter + source: sdk + version: "0.0.0" + source_span: + dependency: transitive + description: + name: source_span + sha256: "53e943d4206a5e30df338fd4c6e7a077e02254531b138a15aec3bd143c1a8b3c" + url: "https://pub.flutter-io.cn" + source: hosted + version: "1.10.0" + stack_trace: + dependency: transitive + description: + name: stack_trace + sha256: "8b27215b45d22309b5cddda1aa2b19bdfec9df0e765f2de506401c071d38d1b1" + url: "https://pub.flutter-io.cn" + source: hosted + version: "1.12.1" + stream_channel: + dependency: transitive + description: + name: stream_channel + sha256: "969e04c80b8bcdf826f8f16579c7b14d780458bd97f56d107d3950fdbeef059d" + url: "https://pub.flutter-io.cn" + source: hosted + version: "2.1.4" + string_scanner: + dependency: transitive + description: + name: string_scanner + sha256: "556692adab6cfa87322a115640c11f13cb77b3f076ddcc5d6ae3c20242bedcde" + url: "https://pub.flutter-io.cn" + source: hosted + version: "1.2.0" + sync_http: + dependency: transitive + description: + name: sync_http + sha256: "7f0cd72eca000d2e026bcd6f990b81d0ca06022ef4e32fb257b30d3d1014a961" + url: "https://pub.flutter-io.cn" + source: hosted + version: "0.3.1" + term_glyph: + dependency: transitive + description: + name: term_glyph + sha256: a29248a84fbb7c79282b40b8c72a1209db169a2e0542bce341da992fe1bc7e84 + url: "https://pub.flutter-io.cn" + source: hosted + version: "1.2.1" + test_api: + dependency: transitive + description: + name: test_api + sha256: "522f00f556e73044315fa4585ec3270f1808a4b186c936e612cab0b565ff1e00" + url: "https://pub.flutter-io.cn" + source: hosted + version: "0.7.6" + vector_math: + dependency: transitive + description: + name: vector_math + sha256: d530bd74fea330e6e364cda7a85019c434070188383e1cd8d9777ee586914c5b + url: "https://pub.flutter-io.cn" + source: hosted + version: "2.2.0" + vm_service: + dependency: transitive + description: + name: vm_service + sha256: "3923c89304b715fb1eb6423f017651664a03bf5f4b29983627c4da791f74a4ec" + url: "https://pub.flutter-io.cn" + source: hosted + version: "14.2.1" + webdriver: + dependency: transitive + description: + name: webdriver + sha256: "003d7da9519e1e5f329422b36c4dcdf18d7d2978d1ba099ea4e45ba490ed845e" + url: "https://pub.flutter-io.cn" + source: hosted + version: "3.0.3" +sdks: + dart: ">=3.8.0-0 <4.0.0" + flutter: ">=3.18.0-18.0.pre.54" diff --git a/flutter_service/flutter_test_background_service/flutter_background_service_ohos/example/pubspec.yaml b/flutter_service/flutter_test_background_service/flutter_background_service_ohos/example/pubspec.yaml new file mode 100644 index 0000000000000000000000000000000000000000..beaf2c0679a81c1c69858143f69e3820825d8979 --- /dev/null +++ b/flutter_service/flutter_test_background_service/flutter_background_service_ohos/example/pubspec.yaml @@ -0,0 +1,32 @@ +name: flutter_background_service_ohos_example +description: "Demonstrates how to use the flutter_background_service_ohos plugin." +# The following line prevents the package from being accidentally published to +# pub.dev using `flutter pub publish`. This is preferred for private packages. +publish_to: 'none' # Remove this line if you wish to publish to pub.dev + +environment: + sdk: '>=3.4.0 <4.0.0' + +# Dependencies specify other packages that your package needs in order to work. +# To automatically upgrade your package dependencies to the latest versions +# consider running `flutter pub upgrade --major-versions`. Alternatively, +# dependencies can be manually updated by changing the version numbers below to +# the latest version available on pub.dev. To see which dependencies have newer +# versions available, run `flutter pub outdated`. +dependencies: + flutter: + sdk: flutter + + cupertino_icons: ^1.0.6 + flutter_background_service_ohos: + path: '../' + +dev_dependencies: + integration_test: + sdk: flutter + flutter_test: + sdk: flutter + flutter_lints: ^3.0.0 + +flutter: + uses-material-design: true \ No newline at end of file diff --git a/flutter_service/flutter_test_background_service/flutter_background_service_ohos/example/test/widget_test.dart b/flutter_service/flutter_test_background_service/flutter_background_service_ohos/example/test/widget_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..954a23b49b26f9ca76c962ad8cd111d67dff0d93 --- /dev/null +++ b/flutter_service/flutter_test_background_service/flutter_background_service_ohos/example/test/widget_test.dart @@ -0,0 +1,27 @@ +// This is a basic Flutter widget test. +// +// To perform an interaction with a widget in your test, use the WidgetTester +// utility in the flutter_test package. For example, you can send tap and scroll +// gestures. You can also use WidgetTester to find child widgets in the widget +// tree, read text, and verify that the values of widget properties are correct. + +import 'package:flutter/material.dart'; +import 'package:flutter_test/flutter_test.dart'; + +import 'package:flutter_background_service_ohos_example/main.dart'; + +void main() { + testWidgets('Verify Platform version', (WidgetTester tester) async { + // Build our app and trigger a frame. + await tester.pumpWidget(const MyApp()); + + // Verify that platform version is retrieved. + expect( + find.byWidgetPredicate( + (Widget widget) => widget is Text && + widget.data!.startsWith('Running on:'), + ), + findsOneWidget, + ); + }); +} diff --git a/flutter_service/flutter_test_background_service/flutter_background_service_ohos/example/web/favicon.png b/flutter_service/flutter_test_background_service/flutter_background_service_ohos/example/web/favicon.png new file mode 100644 index 0000000000000000000000000000000000000000..8aaa46ac1ae21512746f852a42ba87e4165dfdd1 Binary files /dev/null and b/flutter_service/flutter_test_background_service/flutter_background_service_ohos/example/web/favicon.png differ diff --git a/flutter_service/flutter_test_background_service/flutter_background_service_ohos/example/web/icons/Icon-192.png b/flutter_service/flutter_test_background_service/flutter_background_service_ohos/example/web/icons/Icon-192.png new file mode 100644 index 0000000000000000000000000000000000000000..b749bfef07473333cf1dd31e9eed89862a5d52aa Binary files /dev/null and b/flutter_service/flutter_test_background_service/flutter_background_service_ohos/example/web/icons/Icon-192.png differ diff --git a/flutter_service/flutter_test_background_service/flutter_background_service_ohos/example/web/icons/Icon-512.png b/flutter_service/flutter_test_background_service/flutter_background_service_ohos/example/web/icons/Icon-512.png new file mode 100644 index 0000000000000000000000000000000000000000..88cfd48dff1169879ba46840804b412fe02fefd6 Binary files /dev/null and b/flutter_service/flutter_test_background_service/flutter_background_service_ohos/example/web/icons/Icon-512.png differ diff --git a/flutter_service/flutter_test_background_service/flutter_background_service_ohos/example/web/icons/Icon-maskable-192.png b/flutter_service/flutter_test_background_service/flutter_background_service_ohos/example/web/icons/Icon-maskable-192.png new file mode 100644 index 0000000000000000000000000000000000000000..eb9b4d76e525556d5d89141648c724331630325d Binary files /dev/null and b/flutter_service/flutter_test_background_service/flutter_background_service_ohos/example/web/icons/Icon-maskable-192.png differ diff --git a/flutter_service/flutter_test_background_service/flutter_background_service_ohos/example/web/icons/Icon-maskable-512.png b/flutter_service/flutter_test_background_service/flutter_background_service_ohos/example/web/icons/Icon-maskable-512.png new file mode 100644 index 0000000000000000000000000000000000000000..d69c56691fbdb0b7efa65097c7cc1edac12a6d3e Binary files /dev/null and b/flutter_service/flutter_test_background_service/flutter_background_service_ohos/example/web/icons/Icon-maskable-512.png differ diff --git a/flutter_service/flutter_test_background_service/flutter_background_service_ohos/example/web/index.html b/flutter_service/flutter_test_background_service/flutter_background_service_ohos/example/web/index.html new file mode 100644 index 0000000000000000000000000000000000000000..75da839d05c088a089c481f85701c02a87e55f43 --- /dev/null +++ b/flutter_service/flutter_test_background_service/flutter_background_service_ohos/example/web/index.html @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + + + + + + flutter_background_service_ohos_example + + + + + + diff --git a/flutter_service/flutter_test_background_service/flutter_background_service_ohos/example/web/manifest.json b/flutter_service/flutter_test_background_service/flutter_background_service_ohos/example/web/manifest.json new file mode 100644 index 0000000000000000000000000000000000000000..7a3c7ac99d7551ec7dd436412d9da738a1e0752d --- /dev/null +++ b/flutter_service/flutter_test_background_service/flutter_background_service_ohos/example/web/manifest.json @@ -0,0 +1,35 @@ +{ + "name": "flutter_background_service_ohos_example", + "short_name": "flutter_background_service_ohos_example", + "start_url": ".", + "display": "standalone", + "background_color": "#0175C2", + "theme_color": "#0175C2", + "description": "A new Flutter project.", + "orientation": "portrait-primary", + "prefer_related_applications": false, + "icons": [ + { + "src": "icons/Icon-192.png", + "sizes": "192x192", + "type": "image/png" + }, + { + "src": "icons/Icon-512.png", + "sizes": "512x512", + "type": "image/png" + }, + { + "src": "icons/Icon-maskable-192.png", + "sizes": "192x192", + "type": "image/png", + "purpose": "maskable" + }, + { + "src": "icons/Icon-maskable-512.png", + "sizes": "512x512", + "type": "image/png", + "purpose": "maskable" + } + ] +} diff --git a/flutter_service/flutter_test_background_service/flutter_background_service_ohos/lib/flutter_background_service_ohos.dart b/flutter_service/flutter_test_background_service/flutter_background_service_ohos/lib/flutter_background_service_ohos.dart new file mode 100644 index 0000000000000000000000000000000000000000..b124c8f36cc0b8d4df9235791ed5f3ac787e28bd --- /dev/null +++ b/flutter_service/flutter_test_background_service/flutter_background_service_ohos/lib/flutter_background_service_ohos.dart @@ -0,0 +1,8 @@ + +import 'flutter_background_service_ohos_platform_interface.dart'; + +class FlutterBackgroundServiceOhos { + Future getPlatformVersion() { + return FlutterBackgroundServiceOhosPlatform.instance.getPlatformVersion(); + } +} diff --git a/flutter_service/flutter_test_background_service/flutter_background_service_ohos/lib/flutter_background_service_ohos_method_channel.dart b/flutter_service/flutter_test_background_service/flutter_background_service_ohos/lib/flutter_background_service_ohos_method_channel.dart new file mode 100644 index 0000000000000000000000000000000000000000..64dcdf55cd203f547005c683dc7697a8d446ee9a --- /dev/null +++ b/flutter_service/flutter_test_background_service/flutter_background_service_ohos/lib/flutter_background_service_ohos_method_channel.dart @@ -0,0 +1,19 @@ +import 'package:flutter/foundation.dart'; +import 'package:flutter/services.dart'; + +import 'flutter_background_service_ohos_platform_interface.dart'; + +/// An implementation of [FlutterBackgroundServiceOhosPlatform] that uses method channels. +class MethodChannelFlutterBackgroundServiceOhos + extends FlutterBackgroundServiceOhosPlatform { + /// The method channel used to interact with the native platform. + @visibleForTesting + final methodChannel = const MethodChannel('flutter_background_service_ohos'); + + @override + Future getPlatformVersion() async { + final version = + await methodChannel.invokeMethod('getPlatformVersion'); + return version; + } +} diff --git a/flutter_service/flutter_test_background_service/flutter_background_service_ohos/lib/flutter_background_service_ohos_platform_interface.dart b/flutter_service/flutter_test_background_service/flutter_background_service_ohos/lib/flutter_background_service_ohos_platform_interface.dart new file mode 100644 index 0000000000000000000000000000000000000000..7ac92f14f78b7f4f17a8b6bb1f820f87c629a770 --- /dev/null +++ b/flutter_service/flutter_test_background_service/flutter_background_service_ohos/lib/flutter_background_service_ohos_platform_interface.dart @@ -0,0 +1,29 @@ +import 'package:plugin_platform_interface/plugin_platform_interface.dart'; + +import 'flutter_background_service_ohos_method_channel.dart'; + +abstract class FlutterBackgroundServiceOhosPlatform extends PlatformInterface { + /// Constructs a FlutterBackgroundServiceOhosPlatform. + FlutterBackgroundServiceOhosPlatform() : super(token: _token); + + static final Object _token = Object(); + + static FlutterBackgroundServiceOhosPlatform _instance = MethodChannelFlutterBackgroundServiceOhos(); + + /// The default instance of [FlutterBackgroundServiceOhosPlatform] to use. + /// + /// Defaults to [MethodChannelFlutterBackgroundServiceOhos]. + static FlutterBackgroundServiceOhosPlatform get instance => _instance; + + /// Platform-specific implementations should set this with their own + /// platform-specific class that extends [FlutterBackgroundServiceOhosPlatform] when + /// they register themselves. + static set instance(FlutterBackgroundServiceOhosPlatform instance) { + PlatformInterface.verifyToken(instance, _token); + _instance = instance; + } + + Future getPlatformVersion() { + throw UnimplementedError('platformVersion() has not been implemented.'); + } +} diff --git a/flutter_service/flutter_test_background_service/flutter_background_service_ohos/ohos/.gitignore b/flutter_service/flutter_test_background_service/flutter_background_service_ohos/ohos/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..a653a701c05d6e0c7be0f29d6232bb55d72ea742 --- /dev/null +++ b/flutter_service/flutter_test_background_service/flutter_background_service_ohos/ohos/.gitignore @@ -0,0 +1,10 @@ +/node_modules +/oh_modules +/local.properties +/.preview +/.idea +/build +/.cxx +/.test +/BuildProfile.ets +/oh-package-lock.json5 diff --git a/flutter_service/flutter_test_background_service/flutter_background_service_ohos/ohos/build-profile.json5 b/flutter_service/flutter_test_background_service/flutter_background_service_ohos/ohos/build-profile.json5 new file mode 100644 index 0000000000000000000000000000000000000000..79961f96a6fe0507354b7952a378c3be2ae4bfab --- /dev/null +++ b/flutter_service/flutter_test_background_service/flutter_background_service_ohos/ohos/build-profile.json5 @@ -0,0 +1,10 @@ +{ + "apiType": "stageMode", + "buildOption": { + }, + "targets": [ + { + "name": "default" + } + ] +} diff --git a/flutter_service/flutter_test_background_service/flutter_background_service_ohos/ohos/hvigorfile.ts b/flutter_service/flutter_test_background_service/flutter_background_service_ohos/ohos/hvigorfile.ts new file mode 100644 index 0000000000000000000000000000000000000000..c50b28d4b7e8864696585ae770a08bcae24329ed --- /dev/null +++ b/flutter_service/flutter_test_background_service/flutter_background_service_ohos/ohos/hvigorfile.ts @@ -0,0 +1,7 @@ +// Script for compiling build behavior. It is built in the build plug-in and cannot be modified currently. +import { harTasks } from '@ohos/hvigor-ohos-plugin'; + +export default { + system: harTasks, /* 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/flutter_service/flutter_test_background_service/flutter_background_service_ohos/ohos/index.ets b/flutter_service/flutter_test_background_service/flutter_background_service_ohos/ohos/index.ets new file mode 100644 index 0000000000000000000000000000000000000000..2bb4508a0185738ea27b555185482226a1f4e211 --- /dev/null +++ b/flutter_service/flutter_test_background_service/flutter_background_service_ohos/ohos/index.ets @@ -0,0 +1,4 @@ + + +import FlutterBackgroundServiceOhosPlugin from './src/main/ets/components/plugin/FlutterBackgroundServiceOhosPlugin'; +export default FlutterBackgroundServiceOhosPlugin; diff --git a/flutter_service/flutter_test_background_service/flutter_background_service_ohos/ohos/oh-package.json5 b/flutter_service/flutter_test_background_service/flutter_background_service_ohos/ohos/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..1ece644bb5822f1281815f413ebec3dfd5cb7668 --- /dev/null +++ b/flutter_service/flutter_test_background_service/flutter_background_service_ohos/ohos/oh-package.json5 @@ -0,0 +1,9 @@ +{ + "name": "flutter_background_service_ohos", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "index.ets", + "author": "", + "license": "Apache-2.0", + "dependencies": {} +} diff --git a/flutter_service/flutter_test_background_service/flutter_background_service_ohos/ohos/src/main/ets/components/plugin/FlutterBackgroundServiceOhosPlugin.ets b/flutter_service/flutter_test_background_service/flutter_background_service_ohos/ohos/src/main/ets/components/plugin/FlutterBackgroundServiceOhosPlugin.ets new file mode 100644 index 0000000000000000000000000000000000000000..80387555bcf770980198408bfa96be8b2b22b5c1 --- /dev/null +++ b/flutter_service/flutter_test_background_service/flutter_background_service_ohos/ohos/src/main/ets/components/plugin/FlutterBackgroundServiceOhosPlugin.ets @@ -0,0 +1,39 @@ +import { + FlutterPlugin, + FlutterPluginBinding, + MethodCall, + MethodCallHandler, + MethodChannel, + MethodResult, +} from '@ohos/flutter_ohos'; + +/** FlutterBackgroundServiceOhosPlugin **/ +export default class FlutterBackgroundServiceOhosPlugin implements FlutterPlugin, MethodCallHandler { + private channel: MethodChannel | null = null; + + constructor() { + } + + getUniqueClassName(): string { + return "FlutterBackgroundServiceOhosPlugin" + } + + onAttachedToEngine(binding: FlutterPluginBinding): void { + this.channel = new MethodChannel(binding.getBinaryMessenger(), "flutter_background_service_ohos"); + this.channel.setMethodCallHandler(this) + } + + onDetachedFromEngine(binding: FlutterPluginBinding): void { + if (this.channel != null) { + this.channel.setMethodCallHandler(null) + } + } + + onMethodCall(call: MethodCall, result: MethodResult): void { + if (call.method == "getPlatformVersion") { + result.success("OpenHarmony ^ ^ ") + } else { + result.notImplemented() + } + } +} \ No newline at end of file diff --git a/flutter_service/flutter_test_background_service/flutter_background_service_ohos/ohos/src/main/module.json5 b/flutter_service/flutter_test_background_service/flutter_background_service_ohos/ohos/src/main/module.json5 new file mode 100644 index 0000000000000000000000000000000000000000..e95ccf47118f9c195b76dd7a76764fe18dbed0e2 --- /dev/null +++ b/flutter_service/flutter_test_background_service/flutter_background_service_ohos/ohos/src/main/module.json5 @@ -0,0 +1,10 @@ +{ + "module": { + "name": "flutter_background_service_ohos", + "type": "har", + "deviceTypes": [ + "default", + "tablet" + ] + } +} diff --git a/flutter_service/flutter_test_background_service/flutter_background_service_ohos/pubspec.yaml b/flutter_service/flutter_test_background_service/flutter_background_service_ohos/pubspec.yaml new file mode 100644 index 0000000000000000000000000000000000000000..32470ef333c2125e2a805356dc9183c601703144 --- /dev/null +++ b/flutter_service/flutter_test_background_service/flutter_background_service_ohos/pubspec.yaml @@ -0,0 +1,69 @@ +name: flutter_background_service_ohos +description: "A new Flutter plugin project." +version: 0.0.1 +homepage: + +environment: + sdk: '>=3.4.0 <4.0.0' + flutter: '>=3.3.0' + +dependencies: + flutter: + sdk: flutter + plugin_platform_interface: ^2.0.2 + +dev_dependencies: + flutter_test: + sdk: flutter + flutter_lints: ^3.0.0 + +# For information on the generic Dart part of this file, see the +# following page: https://dart.dev/tools/pub/pubspec + +# The following section is specific to Flutter packages. +flutter: + # This section identifies this Flutter project as a plugin project. + # The 'pluginClass' specifies the class (in Java, Kotlin, Swift, Objective-C, etc.) + # which should be registered in the plugin registry. This is required for + # using method channels. + # The Android 'package' specifies package in which the registered class is. + # This is required for using method channels on Android. + # The 'ffiPlugin' specifies that native code should be built and bundled. + # This is required for using `dart:ffi`. + # All these are used by the tooling to maintain consistency when + # adding or updating assets for this project. + plugin: + platforms: + ohos: + pluginClass: FlutterBackgroundServiceOhosPlugin + + # To add assets to your plugin package, add an assets section, like this: + # assets: + # - images/a_dot_burr.jpeg + # - images/a_dot_ham.jpeg + # + # For details regarding assets in packages, see + # https://flutter.dev/assets-and-images/#from-packages + # + # An image asset can refer to one or more resolution-specific "variants", see + # https://flutter.dev/assets-and-images/#resolution-aware + + # To add custom fonts to your plugin package, add a fonts section here, + # in this "flutter" section. Each entry in this list should have a + # "family" key with the font family name, and a "fonts" key with a + # list giving the asset and other descriptors for the font. For + # example: + # fonts: + # - family: Schyler + # fonts: + # - asset: fonts/Schyler-Regular.ttf + # - asset: fonts/Schyler-Italic.ttf + # style: italic + # - family: Trajan Pro + # fonts: + # - asset: fonts/TrajanPro.ttf + # - asset: fonts/TrajanPro_Bold.ttf + # weight: 700 + # + # For details regarding fonts in packages, see + # https://flutter.dev/custom-fonts/#from-packages diff --git a/flutter_service/flutter_test_background_service/flutter_background_service_ohos/test/flutter_background_service_ohos_method_channel_test.dart b/flutter_service/flutter_test_background_service/flutter_background_service_ohos/test/flutter_background_service_ohos_method_channel_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..68a1ba444752fd481c076f808d795718730ace7e --- /dev/null +++ b/flutter_service/flutter_test_background_service/flutter_background_service_ohos/test/flutter_background_service_ohos_method_channel_test.dart @@ -0,0 +1,27 @@ +import 'package:flutter/services.dart'; +import 'package:flutter_test/flutter_test.dart'; +import 'package:flutter_background_service_ohos/flutter_background_service_ohos_method_channel.dart'; + +void main() { + TestWidgetsFlutterBinding.ensureInitialized(); + + MethodChannelFlutterBackgroundServiceOhos platform = MethodChannelFlutterBackgroundServiceOhos(); + const MethodChannel channel = MethodChannel('flutter_background_service_ohos'); + + setUp(() { + TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger.setMockMethodCallHandler( + channel, + (MethodCall methodCall) async { + return '42'; + }, + ); + }); + + tearDown(() { + TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger.setMockMethodCallHandler(channel, null); + }); + + test('getPlatformVersion', () async { + expect(await platform.getPlatformVersion(), '42'); + }); +} diff --git a/flutter_service/flutter_test_background_service/flutter_background_service_ohos/test/flutter_background_service_ohos_test.dart b/flutter_service/flutter_test_background_service/flutter_background_service_ohos/test/flutter_background_service_ohos_test.dart new file mode 100644 index 0000000000000000000000000000000000000000..00671d1524b4a0cb0b53c7cf33f99a5c17091a11 --- /dev/null +++ b/flutter_service/flutter_test_background_service/flutter_background_service_ohos/test/flutter_background_service_ohos_test.dart @@ -0,0 +1,29 @@ +import 'package:flutter_test/flutter_test.dart'; +import 'package:flutter_background_service_ohos/flutter_background_service_ohos.dart'; +import 'package:flutter_background_service_ohos/flutter_background_service_ohos_platform_interface.dart'; +import 'package:flutter_background_service_ohos/flutter_background_service_ohos_method_channel.dart'; +import 'package:plugin_platform_interface/plugin_platform_interface.dart'; + +class MockFlutterBackgroundServiceOhosPlatform + with MockPlatformInterfaceMixin + implements FlutterBackgroundServiceOhosPlatform { + + @override + Future getPlatformVersion() => Future.value('42'); +} + +void main() { + final FlutterBackgroundServiceOhosPlatform initialPlatform = FlutterBackgroundServiceOhosPlatform.instance; + + test('$MethodChannelFlutterBackgroundServiceOhos is the default instance', () { + expect(initialPlatform, isInstanceOf()); + }); + + test('getPlatformVersion', () async { + FlutterBackgroundServiceOhos flutterBackgroundServiceOhosPlugin = FlutterBackgroundServiceOhos(); + MockFlutterBackgroundServiceOhosPlatform fakePlatform = MockFlutterBackgroundServiceOhosPlatform(); + FlutterBackgroundServiceOhosPlatform.instance = fakePlatform; + + expect(await flutterBackgroundServiceOhosPlugin.getPlatformVersion(), '42'); + }); +} diff --git a/flutter_service/flutter_test_background_service/pubspec.yaml b/flutter_service/flutter_test_background_service/pubspec.yaml index c3650d8a48bbcf4d1d94d8d9e96edf764461f191..552130130ca766326fcc868f40115dad4932f588 100644 --- a/flutter_service/flutter_test_background_service/pubspec.yaml +++ b/flutter_service/flutter_test_background_service/pubspec.yaml @@ -1,92 +1,26 @@ name: flutter_test_background_service description: "A new Flutter project." -# The following line prevents the package from being accidentally published to -# pub.dev using `flutter pub publish`. This is preferred for private packages. publish_to: 'none' # Remove this line if you wish to publish to pub.dev -# The following defines the version and build number for your application. -# A version number is three numbers separated by dots, like 1.2.43 -# followed by an optional build number separated by a +. -# Both the version and the builder number may be overridden in flutter -# build by specifying --build-name and --build-number, respectively. -# In Android, build-name is used as versionName while build-number used as versionCode. -# Read more about Android versioning at https://developer.android.com/studio/publish/versioning -# In iOS, build-name is used as CFBundleShortVersionString while build-number is used as CFBundleVersion. -# Read more about iOS versioning at -# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html -# In Windows, build-name is used as the major, minor, and patch parts -# of the product and file versions while build-number is used as the build suffix. version: 1.0.0+1 environment: sdk: ^3.9.0 -# Dependencies specify other packages that your package needs in order to work. -# To automatically upgrade your package dependencies to the latest versions -# consider running `flutter pub upgrade --major-versions`. Alternatively, -# dependencies can be manually updated by changing the version numbers below to -# the latest version available on pub.dev. To see which dependencies have newer -# versions available, run `flutter pub outdated`. dependencies: flutter: sdk: flutter - # The following adds the Cupertino Icons font to your application. - # Use with the CupertinoIcons class for iOS style icons. cupertino_icons: ^1.0.8 flutter_background_service_android: ^6.3.1 flutter_background_service: ^5.1.0 flutter_local_notifications: ^17.2.2 + flutter_background_service_ohos: ../flutter_background_service_ohos dev_dependencies: flutter_test: sdk: flutter - - # The "flutter_lints" package below contains a set of recommended lints to - # encourage good coding practices. The lint set provided by the package is - # activated in the `analysis_options.yaml` file located at the root of your - # package. See that file for information about deactivating specific lint - # rules and activating additional ones. flutter_lints: ^5.0.0 -# For information on the generic Dart part of this file, see the -# following page: https://dart.dev/tools/pub/pubspec - -# The following section is specific to Flutter packages. flutter: - - # The following line ensures that the Material Icons font is - # included with your application, so that you can use the icons in - # the material Icons class. - uses-material-design: true - - # To add assets to your application, add an assets section, like this: - # assets: - # - images/a_dot_burr.jpeg - # - images/a_dot_ham.jpeg - - # An image asset can refer to one or more resolution-specific "variants", see - # https://flutter.dev/to/resolution-aware-images - - # For details regarding adding assets from package dependencies, see - # https://flutter.dev/to/asset-from-package - - # To add custom fonts to your application, add a fonts section here, - # in this "flutter" section. Each entry in this list should have a - # "family" key with the font family name, and a "fonts" key with a - # list giving the asset and other descriptors for the font. For - # example: - # fonts: - # - family: Schyler - # fonts: - # - asset: fonts/Schyler-Regular.ttf - # - asset: fonts/Schyler-Italic.ttf - # style: italic - # - family: Trajan Pro - # fonts: - # - asset: fonts/TrajanPro.ttf - # - asset: fonts/TrajanPro_Bold.ttf - # weight: 700 - # - # For details regarding fonts from package dependencies, - # see https://flutter.dev/to/font-from-package + uses-material-design: true \ No newline at end of file