├── .clang-format
├── .clang-tidy
├── .clangd
├── .gitignore
├── AppScope
├── app.json5
└── resources
│ └── base
│ ├── element
│ └── string.json
│ └── media
│ └── app_icon.png
├── CMakeLists.txt
├── README.md
├── build-profile.json5
├── build.gradle
├── cross.podspec
├── example
├── android
│ ├── .gitignore
│ ├── build.gradle
│ └── src
│ │ └── main
│ │ ├── AndroidManifest.xml
│ │ ├── java
│ │ └── com
│ │ │ └── cross
│ │ │ └── example
│ │ │ └── MainActivity.java
│ │ └── res
│ │ ├── layout
│ │ └── activity_main.xml
│ │ ├── mipmap-hdpi
│ │ └── ic_launcher.png
│ │ ├── mipmap-mdpi
│ │ └── ic_launcher.png
│ │ ├── mipmap-xhdpi
│ │ └── ic_launcher.png
│ │ ├── mipmap-xxhdpi
│ │ └── ic_launcher.png
│ │ ├── mipmap-xxxhdpi
│ │ └── ic_launcher.png
│ │ ├── values
│ │ └── styles.xml
│ │ └── xml
│ │ └── backup_descriptor.xml
├── harmony
│ ├── .gitignore
│ ├── build-profile.json5
│ ├── hvigorfile.ts
│ ├── obfuscation-rules.txt
│ ├── oh-package-lock.json5
│ ├── oh-package.json5
│ └── src
│ │ ├── main
│ │ ├── ets
│ │ │ ├── harmonyability
│ │ │ │ └── HarmonyAbility.ets
│ │ │ ├── harmonybackupability
│ │ │ │ └── HarmonyBackupAbility.ets
│ │ │ └── pages
│ │ │ │ └── Index.ets
│ │ ├── module.json5
│ │ └── resources
│ │ │ ├── base
│ │ │ ├── element
│ │ │ │ ├── color.json
│ │ │ │ └── string.json
│ │ │ ├── media
│ │ │ │ ├── background.png
│ │ │ │ ├── foreground.png
│ │ │ │ ├── layered_image.json
│ │ │ │ └── startIcon.png
│ │ │ └── profile
│ │ │ │ ├── backup_config.json
│ │ │ │ └── main_pages.json
│ │ │ ├── en_US
│ │ │ └── element
│ │ │ │ └── string.json
│ │ │ └── zh_CN
│ │ │ └── element
│ │ │ └── string.json
│ │ ├── mock
│ │ └── mock-config.json5
│ │ ├── ohosTest
│ │ ├── ets
│ │ │ └── test
│ │ │ │ ├── Ability.test.ets
│ │ │ │ └── List.test.ets
│ │ └── module.json5
│ │ └── test
│ │ ├── List.test.ets
│ │ └── LocalUnit.test.ets
└── ios
│ ├── .gitignore
│ ├── Podfile
│ ├── Podfile.lock
│ ├── example.xcodeproj
│ ├── project.pbxproj
│ └── project.xcworkspace
│ │ ├── contents.xcworkspacedata
│ │ └── xcshareddata
│ │ └── IDEWorkspaceChecks.plist
│ ├── example.xcworkspace
│ ├── contents.xcworkspacedata
│ └── xcshareddata
│ │ └── IDEWorkspaceChecks.plist
│ └── example
│ ├── AppDelegate.h
│ ├── AppDelegate.m
│ ├── Assets.xcassets
│ ├── AccentColor.colorset
│ │ └── Contents.json
│ ├── AppIcon.appiconset
│ │ └── Contents.json
│ └── Contents.json
│ ├── Base.lproj
│ ├── LaunchScreen.storyboard
│ └── Main.storyboard
│ ├── Info.plist
│ ├── SceneDelegate.h
│ ├── SceneDelegate.m
│ ├── ViewController.h
│ ├── ViewController.m
│ ├── cross.mm
│ └── main.m
├── gradle.properties
├── gradle
└── wrapper
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── hvigor
└── hvigor-config.json5
├── hvigorfile.ts
├── oh-package-lock.json5
├── oh-package.json5
├── platforms
├── android
│ ├── .gitignore
│ ├── build.gradle
│ └── src
│ │ └── main
│ │ ├── AndroidManifest.xml
│ │ ├── cpp
│ │ ├── CMakeLists.txt
│ │ └── cross.cpp
│ │ └── java
│ │ └── com
│ │ └── cross
│ │ └── Cross.java
├── harmony
│ ├── .gitignore
│ ├── BuildProfile.ets
│ ├── Index.ets
│ ├── build-profile.json5
│ ├── hvigorfile.ts
│ ├── obfuscation-rules.txt
│ ├── oh-package-lock.json5
│ ├── oh-package.json5
│ └── src
│ │ ├── main
│ │ ├── cpp
│ │ │ ├── CMakeLists.txt
│ │ │ ├── napi_init.cpp
│ │ │ └── types
│ │ │ │ └── libcross
│ │ │ │ ├── Index.d.ts
│ │ │ │ └── oh-package.json5
│ │ ├── ets
│ │ │ ├── NativeReader.ets
│ │ │ ├── harmonyability
│ │ │ │ └── HarmonyAbility.ets
│ │ │ └── pages
│ │ │ │ └── Index.ets
│ │ ├── module.json5
│ │ └── resources
│ │ │ ├── base
│ │ │ ├── element
│ │ │ │ ├── color.json
│ │ │ │ └── string.json
│ │ │ ├── media
│ │ │ │ ├── background.png
│ │ │ │ ├── foreground.png
│ │ │ │ ├── layered_image.json
│ │ │ │ └── startIcon.png
│ │ │ └── profile
│ │ │ │ └── main_pages.json
│ │ │ ├── en_US
│ │ │ └── element
│ │ │ │ └── string.json
│ │ │ └── zh_CN
│ │ │ └── element
│ │ │ └── string.json
│ │ ├── mock
│ │ ├── Libcross.mock.ets
│ │ └── mock-config.json5
│ │ ├── ohosTest
│ │ ├── ets
│ │ │ └── test
│ │ │ │ ├── Ability.test.ets
│ │ │ │ └── List.test.ets
│ │ └── module.json5
│ │ └── test
│ │ ├── List.test.ets
│ │ └── LocalUnit.test.ets
└── ios
│ ├── .gitignore
│ └── Classes
│ ├── Cross.h
│ └── Cross.mm
├── settings.gradle
├── src
└── url_signature
│ ├── CMakeLists.txt
│ ├── README.md
│ ├── include
│ └── url_signature.h
│ └── url_signature.cpp
├── test
├── CMakeLists.txt
├── gtest
│ ├── CMakeLists.txt
│ ├── include
│ │ └── gtest
│ │ │ ├── gtest-death-test.h
│ │ │ ├── gtest-matchers.h
│ │ │ ├── gtest-message.h
│ │ │ ├── gtest-param-test.h
│ │ │ ├── gtest-printers.h
│ │ │ ├── gtest-spi.h
│ │ │ ├── gtest-test-part.h
│ │ │ ├── gtest-typed-test.h
│ │ │ ├── gtest.h
│ │ │ ├── gtest_pred_impl.h
│ │ │ ├── gtest_prod.h
│ │ │ └── internal
│ │ │ ├── custom
│ │ │ ├── README.md
│ │ │ ├── gtest-port.h
│ │ │ ├── gtest-printers.h
│ │ │ └── gtest.h
│ │ │ ├── gtest-death-test-internal.h
│ │ │ ├── gtest-filepath.h
│ │ │ ├── gtest-internal.h
│ │ │ ├── gtest-param-util.h
│ │ │ ├── gtest-port-arch.h
│ │ │ ├── gtest-port.h
│ │ │ ├── gtest-string.h
│ │ │ └── gtest-type-util.h
│ └── src
│ │ ├── gtest-all.cc
│ │ ├── gtest-death-test.cc
│ │ ├── gtest-filepath.cc
│ │ ├── gtest-internal-inl.h
│ │ ├── gtest-matchers.cc
│ │ ├── gtest-port.cc
│ │ ├── gtest-printers.cc
│ │ ├── gtest-test-part.cc
│ │ ├── gtest-typed-test.cc
│ │ ├── gtest.cc
│ │ └── gtest_main.cc
├── main.cpp
└── test.cpp
└── third_party
├── cxxurl
├── CMakeLists.txt
├── include
│ └── cxxurl
│ │ ├── string.hpp
│ │ └── url.hpp
└── src
│ └── url.cpp
└── hash
├── CMakeLists.txt
├── include
├── crc32.h
├── hash.h
├── hmac.h
├── keccak.h
├── md5.h
├── sha1.h
├── sha256.h
└── sha3.h
└── src
├── crc32.cpp
├── digest.cpp
├── keccak.cpp
├── md5.cpp
├── sha1.cpp
├── sha256.cpp
└── sha3.cpp
/.clang-format:
--------------------------------------------------------------------------------
1 | Language: Cpp
2 | # BasedOnStyle: LLVM
3 | ColumnLimit: 120
4 | SortIncludes: false
5 | TabWidth: 4
6 | IndentWidth: 4
7 | UseTab: Never
8 | AccessModifierOffset: -4
9 | ContinuationIndentWidth: 4
10 | IndentCaseBlocks: false
11 | IndentCaseLabels: false
12 | IndentGotoLabels: true
13 | IndentWrappedFunctionNames: false
14 | SortUsingDeclarations: false
15 | NamespaceIndentation: None
16 | SpaceAfterCStyleCast: false
17 | SpaceAfterLogicalNot: false
18 | SpaceAfterTemplateKeyword: true
19 | SpaceBeforeAssignmentOperators: true
20 | SpaceBeforeCaseColon: false
21 | SpaceBeforeCpp11BracedList: false
22 | SpaceBeforeCtorInitializerColon: true
23 | SpaceBeforeInheritanceColon: true
24 | SpaceBeforeRangeBasedForLoopColon: true
25 | SpaceBeforeSquareBrackets: false
26 | SpaceInEmptyBlock: false
27 | SpaceInEmptyParentheses: false
28 | SpacesInAngles: false
29 | SpacesInCStyleCastParentheses: false
30 | SpacesInConditionalStatement: false
31 | SpacesInParentheses: false
32 | SpacesInSquareBrackets: false
33 | AllowShortCaseLabelsOnASingleLine: false
34 | AllowShortEnumsOnASingleLine: true
35 | AllowShortFunctionsOnASingleLine: All
36 | AllowShortIfStatementsOnASingleLine: Never
37 | AllowShortLambdasOnASingleLine: All
38 | AllowShortLoopsOnASingleLine: false
39 | AlwaysBreakTemplateDeclarations: MultiLine
40 | BinPackArguments: true
41 | BinPackParameters: true
42 | BreakBeforeTernaryOperators: true
43 | BreakConstructorInitializers: BeforeColon
44 | BreakInheritanceList: BeforeColon
45 | BreakStringLiterals: true
46 | InsertBraces: false
47 | IndentExternBlock: NoIndent
48 | BreakBeforeBraces: Custom
49 | BraceWrapping:
50 | AfterCaseLabel: false
51 | AfterClass: false
52 | AfterControlStatement: Never
53 | AfterEnum: false
54 | AfterFunction: false
55 | AfterNamespace: false
56 | AfterStruct: false
57 | AfterUnion: false
58 | AfterExternBlock: false
59 | BeforeCatch: false
60 | BeforeElse: false
61 | ReflowComments: true
62 | MaxEmptyLinesToKeep: 2
--------------------------------------------------------------------------------
/.clang-tidy:
--------------------------------------------------------------------------------
1 | Checks: 'misc-missing-switch-cases,misc-napi-module-name,misc-replace-if-else-with-ternary-operator,misc-unused-local-variable,misc-unused-parameters,modernize-use-auto,readability-system-capabilities'
2 |
--------------------------------------------------------------------------------
/.clangd:
--------------------------------------------------------------------------------
1 | CompileFlags:
2 | Add: [-Wunreachable-code-aggressive]
3 | Diagnostics:
4 | ClangTidy:
5 | Add: [misc-missing-switch-cases,misc-napi-module-name,misc-replace-if-else-with-ternary-operator,misc-unused-local-variable,misc-unused-parameters,modernize-use-auto,readability-system-capabilities]
6 | Remove: []
7 | CheckOptions:
8 | misc-unused-parameters.StrictMode: true
9 | misc-unused-parameters.IgnoreVirtual: true
10 | modernize-use-auto.MinTypeNameLength: 0
11 |
12 | UnusedIncludes: Strict
13 | UnusedFunctions: Check
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | local.properties
4 | /.idea/workspace.xml
5 | /.idea/libraries
6 | .DS_Store
7 | build
8 | /captures
9 | .cxx
10 | .idea
11 | cmake-build-debug
12 | gradle-wrapper.jar
13 | .vscode
14 | oh_modules
15 | .hvigor
--------------------------------------------------------------------------------
/AppScope/app.json5:
--------------------------------------------------------------------------------
1 | {
2 | "app": {
3 | "bundleName": "com.taoweiji.harmony.example",
4 | "vendor": "example",
5 | "versionCode": 1000000,
6 | "versionName": "1.0.0",
7 | "icon": "$media:app_icon",
8 | "label": "$string:app_name"
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/AppScope/resources/base/element/string.json:
--------------------------------------------------------------------------------
1 | {
2 | "string": [
3 | {
4 | "name": "app_name",
5 | "value": "MyApplication"
6 | }
7 | ]
8 | }
9 |
--------------------------------------------------------------------------------
/AppScope/resources/base/media/app_icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/taoweiji/cpp-android-ios-example/8647fa5aa89e43fd5705e07e1437b553c2405785/AppScope/resources/base/media/app_icon.png
--------------------------------------------------------------------------------
/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | cmake_minimum_required(VERSION 3.10.2)
2 | project(cpp-android-ios-example)
3 | set(CMAKE_CXX_STANDARD 17)
4 | add_subdirectory(third_party/hash)
5 | add_subdirectory(third_party/cxxurl)
6 | add_subdirectory(src/url_signature)
7 | if (HARMONY)
8 | add_subdirectory(platforms/harmony/src/main/cpp)
9 | elseif (ANDROID)
10 | add_subdirectory(platforms/android/src/main/cpp)
11 | else ()
12 | add_subdirectory(test/gtest)
13 | add_subdirectory(test)
14 | endif ()
--------------------------------------------------------------------------------
/build-profile.json5:
--------------------------------------------------------------------------------
1 | {
2 | "app": {
3 | "signingConfigs": [
4 | {
5 | "name": "default",
6 | "type": "HarmonyOS",
7 | "material": {
8 | "certpath": "/Users/wiki/.ohos/config/default_MyApplication9_yYDzc6FLiNuw8ZxbIN_ppdzLrdax8rQZwyrpPNOvf6k=.cer",
9 | "storePassword": "0000001BAE98E175997B9584358F81F0970FC63B57B3538887D317B4AF396FE143407CC54521F5F579C862",
10 | "keyAlias": "debugKey",
11 | "keyPassword": "0000001BA023D96A0F9E14E97031D369DF17BDD1656DDD049E7C8A1C4510D4B6637844BA5D6DF2B021015B",
12 | "profile": "/Users/wiki/.ohos/config/default_MyApplication9_yYDzc6FLiNuw8ZxbIN_ppdzLrdax8rQZwyrpPNOvf6k=.p7b",
13 | "signAlg": "SHA256withECDSA",
14 | "storeFile": "/Users/wiki/.ohos/config/default_MyApplication9_yYDzc6FLiNuw8ZxbIN_ppdzLrdax8rQZwyrpPNOvf6k=.p12"
15 | }
16 | }
17 | ],
18 | "products": [
19 | {
20 | "name": "default",
21 | "signingConfig": "default",
22 | "compatibleSdkVersion": "5.0.0(12)",
23 | "runtimeOS": "HarmonyOS",
24 | }
25 | ],
26 | "buildModeSet": [
27 | {
28 | "name": "debug",
29 | },
30 | {
31 | "name": "release"
32 | }
33 | ]
34 | },
35 | "modules": [
36 | {
37 | "name": "harmony_example",
38 | "srcPath": "./example/harmony",
39 | "targets": [
40 | {
41 | "name": "default",
42 | "applyToProducts": [
43 | "default"
44 | ]
45 | }
46 | ]
47 | },
48 | {
49 | "name": "harmony",
50 | "srcPath": "./platforms/harmony",
51 | "targets": [
52 | {
53 | "name": "default",
54 | "applyToProducts": [
55 | "default"
56 | ]
57 | }
58 | ]
59 | }
60 | ]
61 | }
--------------------------------------------------------------------------------
/build.gradle:
--------------------------------------------------------------------------------
1 | group 'com.cross'
2 | version '1.0'
3 |
4 | buildscript {
5 | repositories {
6 | google()
7 | jcenter()
8 | }
9 |
10 | dependencies {
11 | classpath "com.android.tools.build:gradle:4.1.2"
12 | }
13 | }
14 |
15 | rootProject.allprojects {
16 | repositories {
17 | google()
18 | jcenter()
19 | }
20 | }
--------------------------------------------------------------------------------
/cross.podspec:
--------------------------------------------------------------------------------
1 | Pod::Spec.new do |s|
2 | s.name = 'cross'
3 | s.version = '0.0.1'
4 | s.summary = 'cross library'
5 | s.description = 'Cross library'
6 | s.homepage = 'http://example.com'
7 | s.license = { :file => '../LICENSE' }
8 | s.author = { 'Your Company' => 'email@example.com' }
9 | s.source = { :path => '.' }
10 | # 设置源文件,切记不要把测试代码包含进来
11 | s.source_files = 'platforms/ios/Classes/**/*','third_party/**/*.{cc,cpp,h}','src/**/*.{cc,cpp,h}'
12 | # 暴露头文件,否则引用该spec的项目无法找到头文件
13 | s.public_header_files = 'platforms/ios/Classes/**/*.h','src/url_signature/include/*.h'
14 | s.platform = :ios, '9.0'
15 | # 必须配置HEADER_SEARCH_PATHS属性,是否会导致项目中C++找不到头文件
16 | s.xcconfig = {
17 | 'HEADER_SEARCH_PATHS' => '"${PODS_TARGET_SRCROOT}/third_party/cxxurl/include/" "${PODS_TARGET_SRCROOT}/third_party/hash/include/" "${PODS_TARGET_SRCROOT}/src/url_signature/include/"'
18 | }
19 | end
20 |
--------------------------------------------------------------------------------
/example/android/.gitignore:
--------------------------------------------------------------------------------
1 | gradle-wrapper.jar
2 | /.gradle
3 | /captures/
4 | /local.properties
--------------------------------------------------------------------------------
/example/android/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 | android {
3 | compileSdkVersion 30
4 |
5 | lintOptions {
6 | disable 'InvalidPackage'
7 | }
8 |
9 | defaultConfig {
10 | applicationId "com.cross.example"
11 | minSdkVersion 16
12 | targetSdkVersion 30
13 | versionCode 1
14 | versionName "1.0"
15 | }
16 |
17 | buildTypes {
18 | release {
19 | signingConfig signingConfigs.debug
20 | }
21 | }
22 | }
23 |
24 | dependencies {
25 | implementation project(path: ':cross')
26 | }
--------------------------------------------------------------------------------
/example/android/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
8 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/example/android/src/main/java/com/cross/example/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.cross.example;
2 |
3 |
4 | import android.app.Activity;
5 | import android.os.Bundle;
6 | import android.widget.TextView;
7 |
8 | import com.cross.Cross;
9 |
10 | public class MainActivity extends Activity {
11 | @Override
12 | protected void onCreate(Bundle savedInstanceState) {
13 | super.onCreate(savedInstanceState);
14 | setContentView(R.layout.activity_main);
15 | TextView textView = findViewById(R.id.textView);
16 | String url = "http://example.com?key2=value2&key3=value3&key1=VALUE1";
17 | String result = Cross.signatureUrl(url);
18 | textView.setText(url + "\n" + result);
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/example/android/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
13 |
--------------------------------------------------------------------------------
/example/android/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/taoweiji/cpp-android-ios-example/8647fa5aa89e43fd5705e07e1437b553c2405785/example/android/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/example/android/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/taoweiji/cpp-android-ios-example/8647fa5aa89e43fd5705e07e1437b553c2405785/example/android/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/example/android/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/taoweiji/cpp-android-ios-example/8647fa5aa89e43fd5705e07e1437b553c2405785/example/android/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/example/android/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/taoweiji/cpp-android-ios-example/8647fa5aa89e43fd5705e07e1437b553c2405785/example/android/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/example/android/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/taoweiji/cpp-android-ios-example/8647fa5aa89e43fd5705e07e1437b553c2405785/example/android/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/example/android/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/example/android/src/main/res/xml/backup_descriptor.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/example/harmony/.gitignore:
--------------------------------------------------------------------------------
1 | /node_modules
2 | /oh_modules
3 | /.preview
4 | /build
5 | /.cxx
6 | /.test
--------------------------------------------------------------------------------
/example/harmony/build-profile.json5:
--------------------------------------------------------------------------------
1 | {
2 | "apiType": "stageMode",
3 | "buildOption": {
4 | },
5 | "buildOptionSet": [
6 | {
7 | "name": "release",
8 | "arkOptions": {
9 | "obfuscation": {
10 | "ruleOptions": {
11 | "enable": true,
12 | "files": [
13 | "./obfuscation-rules.txt"
14 | ]
15 | }
16 | }
17 | }
18 | },
19 | ],
20 | "targets": [
21 | {
22 | "name": "default"
23 | },
24 | {
25 | "name": "ohosTest",
26 | }
27 | ]
28 | }
--------------------------------------------------------------------------------
/example/harmony/hvigorfile.ts:
--------------------------------------------------------------------------------
1 | import { hapTasks } from '@ohos/hvigor-ohos-plugin';
2 |
3 | export default {
4 | system: hapTasks, /* Built-in plugin of Hvigor. It cannot be modified. */
5 | plugins:[] /* Custom plugin to extend the functionality of Hvigor. */
6 | }
7 |
--------------------------------------------------------------------------------
/example/harmony/obfuscation-rules.txt:
--------------------------------------------------------------------------------
1 | # Define project specific obfuscation rules here.
2 | # You can include the obfuscation configuration files in the current module's build-profile.json5.
3 | #
4 | # For more details, see
5 | # https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5
6 |
7 | # Obfuscation options:
8 | # -disable-obfuscation: disable all obfuscations
9 | # -enable-property-obfuscation: obfuscate the property names
10 | # -enable-toplevel-obfuscation: obfuscate the names in the global scope
11 | # -compact: remove unnecessary blank spaces and all line feeds
12 | # -remove-log: remove all console.* statements
13 | # -print-namecache: print the name cache that contains the mapping from the old names to new names
14 | # -apply-namecache: reuse the given cache file
15 |
16 | # Keep options:
17 | # -keep-property-name: specifies property names that you want to keep
18 | # -keep-global-name: specifies names that you want to keep in the global scope
--------------------------------------------------------------------------------
/example/harmony/oh-package-lock.json5:
--------------------------------------------------------------------------------
1 | {
2 | "meta": {
3 | "stableOrder": true
4 | },
5 | "lockfileVersion": 3,
6 | "ATTENTION": "THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.",
7 | "specifiers": {
8 | "harmony@../../platforms/harmony": "harmony@../../platforms/harmony",
9 | "libcross.so@../../platforms/harmony/src/main/cpp/types/libcross": "libcross.so@../../platforms/harmony/src/main/cpp/types/libcross"
10 | },
11 | "packages": {
12 | "harmony@../../platforms/harmony": {
13 | "name": "harmony",
14 | "version": "1.0.0",
15 | "resolved": "../../platforms/harmony",
16 | "registryType": "local",
17 | "dependencies": {
18 | "libcross.so": "file:./src/main/cpp/types/libcross"
19 | }
20 | },
21 | "libcross.so@../../platforms/harmony/src/main/cpp/types/libcross": {
22 | "name": "libcross.so",
23 | "version": "1.0.0",
24 | "resolved": "../../platforms/harmony/src/main/cpp/types/libcross",
25 | "registryType": "local"
26 | }
27 | }
28 | }
--------------------------------------------------------------------------------
/example/harmony/oh-package.json5:
--------------------------------------------------------------------------------
1 | {
2 | "name": "harmony_example",
3 | "version": "1.0.0",
4 | "description": "Please describe the basic information.",
5 | "main": "",
6 | "author": "",
7 | "license": "",
8 | "dependencies": {
9 | "harmony": "file:../../platforms/harmony"
10 | }
11 | }
12 |
13 |
--------------------------------------------------------------------------------
/example/harmony/src/main/ets/harmonyability/HarmonyAbility.ets:
--------------------------------------------------------------------------------
1 | import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit';
2 | import { hilog } from '@kit.PerformanceAnalysisKit';
3 | import { window } from '@kit.ArkUI';
4 |
5 | export default class HarmonyAbility extends UIAbility {
6 | onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void {
7 | hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate');
8 | }
9 |
10 | onDestroy(): void {
11 | hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy');
12 | }
13 |
14 | onWindowStageCreate(windowStage: window.WindowStage): void {
15 | // Main window is created, set main page for this ability
16 | hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate');
17 |
18 | windowStage.loadContent('pages/Index', (err) => {
19 | if (err.code) {
20 | hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? '');
21 | return;
22 | }
23 | hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.');
24 | });
25 | }
26 |
27 | onWindowStageDestroy(): void {
28 | // Main window is destroyed, release UI related resources
29 | hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy');
30 | }
31 |
32 | onForeground(): void {
33 | // Ability has brought to foreground
34 | hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground');
35 | }
36 |
37 | onBackground(): void {
38 | // Ability has back to background
39 | hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground');
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/example/harmony/src/main/ets/harmonybackupability/HarmonyBackupAbility.ets:
--------------------------------------------------------------------------------
1 | import { hilog } from '@kit.PerformanceAnalysisKit';
2 | import { BackupExtensionAbility, BundleVersion } from '@kit.CoreFileKit';
3 |
4 | export default class HarmonyBackupAbility extends BackupExtensionAbility {
5 | async onBackup() {
6 | hilog.info(0x0000, 'testTag', 'onBackup ok');
7 | }
8 |
9 | async onRestore(bundleVersion: BundleVersion) {
10 | hilog.info(0x0000, 'testTag', 'onRestore ok %{public}s', JSON.stringify(bundleVersion));
11 | }
12 | }
--------------------------------------------------------------------------------
/example/harmony/src/main/ets/pages/Index.ets:
--------------------------------------------------------------------------------
1 | import { NativeReader } from 'harmony'
2 |
3 | @Entry
4 | @Component
5 | struct Index {
6 | @State message: string = 'Hello World';
7 |
8 | build() {
9 | RelativeContainer() {
10 | Text('1 + 10 = ' + new NativeReader().add(1, 10))
11 | .fontSize(12)
12 | .fontWeight(FontWeight.Bold)
13 | .alignRules({
14 | center: { anchor: '__container__', align: VerticalAlign.Center },
15 | middle: { anchor: '__container__', align: HorizontalAlign.Center }
16 | })
17 | Text(new NativeReader().signatureUrl("http://example.com?key2=value2&key3=value3&key1=VALUE1"))
18 | .fontSize(12)
19 | .margin({ top: 100 })
20 | .fontWeight(FontWeight.Bold)
21 | .alignRules({
22 | center: { anchor: '__container__', align: VerticalAlign.Center },
23 | middle: { anchor: '__container__', align: HorizontalAlign.Center }
24 | })
25 |
26 | }
27 | .height('100%')
28 | .width('100%')
29 | }
30 | }
--------------------------------------------------------------------------------
/example/harmony/src/main/module.json5:
--------------------------------------------------------------------------------
1 | {
2 | "module": {
3 | "name": "harmony_example",
4 | "type": "entry",
5 | "description": "$string:module_desc",
6 | "mainElement": "HarmonyAbility",
7 | "deviceTypes": [
8 | "phone",
9 | "tablet",
10 | "2in1"
11 | ],
12 | "deliveryWithInstall": true,
13 | "installationFree": false,
14 | "pages": "$profile:main_pages",
15 | "abilities": [
16 | {
17 | "name": "HarmonyAbility",
18 | "srcEntry": "./ets/harmonyability/HarmonyAbility.ets",
19 | "description": "$string:HarmonyAbility_desc",
20 | "icon": "$media:layered_image",
21 | "label": "$string:HarmonyAbility_label",
22 | "startWindowIcon": "$media:startIcon",
23 | "startWindowBackground": "$color:start_window_background",
24 | "exported": true,
25 | "skills": [
26 | {
27 | "entities": [
28 | "entity.system.home"
29 | ],
30 | "actions": [
31 | "action.system.home"
32 | ]
33 | }
34 | ]
35 | }
36 | ],
37 | "extensionAbilities": [
38 | {
39 | "name": "HarmonyBackupAbility",
40 | "srcEntry": "./ets/harmonybackupability/HarmonyBackupAbility.ets",
41 | "type": "backup",
42 | "exported": false,
43 | "metadata": [
44 | {
45 | "name": "ohos.extension.backup",
46 | "resource": "$profile:backup_config"
47 | }
48 | ]
49 | }
50 | ]
51 | }
52 | }
--------------------------------------------------------------------------------
/example/harmony/src/main/resources/base/element/color.json:
--------------------------------------------------------------------------------
1 | {
2 | "color": [
3 | {
4 | "name": "start_window_background",
5 | "value": "#FFFFFF"
6 | }
7 | ]
8 | }
--------------------------------------------------------------------------------
/example/harmony/src/main/resources/base/element/string.json:
--------------------------------------------------------------------------------
1 | {
2 | "string": [
3 | {
4 | "name": "module_desc",
5 | "value": "module description"
6 | },
7 | {
8 | "name": "HarmonyAbility_desc",
9 | "value": "description"
10 | },
11 | {
12 | "name": "HarmonyAbility_label",
13 | "value": "label"
14 | }
15 | ]
16 | }
--------------------------------------------------------------------------------
/example/harmony/src/main/resources/base/media/background.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/taoweiji/cpp-android-ios-example/8647fa5aa89e43fd5705e07e1437b553c2405785/example/harmony/src/main/resources/base/media/background.png
--------------------------------------------------------------------------------
/example/harmony/src/main/resources/base/media/foreground.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/taoweiji/cpp-android-ios-example/8647fa5aa89e43fd5705e07e1437b553c2405785/example/harmony/src/main/resources/base/media/foreground.png
--------------------------------------------------------------------------------
/example/harmony/src/main/resources/base/media/layered_image.json:
--------------------------------------------------------------------------------
1 | {
2 | "layered-image":
3 | {
4 | "background" : "$media:background",
5 | "foreground" : "$media:foreground"
6 | }
7 | }
--------------------------------------------------------------------------------
/example/harmony/src/main/resources/base/media/startIcon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/taoweiji/cpp-android-ios-example/8647fa5aa89e43fd5705e07e1437b553c2405785/example/harmony/src/main/resources/base/media/startIcon.png
--------------------------------------------------------------------------------
/example/harmony/src/main/resources/base/profile/backup_config.json:
--------------------------------------------------------------------------------
1 | {
2 | "allowToBackupRestore": true
3 | }
--------------------------------------------------------------------------------
/example/harmony/src/main/resources/base/profile/main_pages.json:
--------------------------------------------------------------------------------
1 | {
2 | "src": [
3 | "pages/Index"
4 | ]
5 | }
6 |
--------------------------------------------------------------------------------
/example/harmony/src/main/resources/en_US/element/string.json:
--------------------------------------------------------------------------------
1 | {
2 | "string": [
3 | {
4 | "name": "module_desc",
5 | "value": "module description"
6 | },
7 | {
8 | "name": "HarmonyAbility_desc",
9 | "value": "description"
10 | },
11 | {
12 | "name": "HarmonyAbility_label",
13 | "value": "label"
14 | }
15 | ]
16 | }
--------------------------------------------------------------------------------
/example/harmony/src/main/resources/zh_CN/element/string.json:
--------------------------------------------------------------------------------
1 | {
2 | "string": [
3 | {
4 | "name": "module_desc",
5 | "value": "模块描述"
6 | },
7 | {
8 | "name": "HarmonyAbility_desc",
9 | "value": "description"
10 | },
11 | {
12 | "name": "HarmonyAbility_label",
13 | "value": "label"
14 | }
15 | ]
16 | }
--------------------------------------------------------------------------------
/example/harmony/src/mock/mock-config.json5:
--------------------------------------------------------------------------------
1 | {
2 | }
--------------------------------------------------------------------------------
/example/harmony/src/ohosTest/ets/test/Ability.test.ets:
--------------------------------------------------------------------------------
1 | import { hilog } from '@kit.PerformanceAnalysisKit';
2 | import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium';
3 |
4 | export default function abilityTest() {
5 | describe('ActsAbilityTest', () => {
6 | // Defines a test suite. Two parameters are supported: test suite name and test suite function.
7 | beforeAll(() => {
8 | // Presets an action, which is performed only once before all test cases of the test suite start.
9 | // This API supports only one parameter: preset action function.
10 | })
11 | beforeEach(() => {
12 | // Presets an action, which is performed before each unit test case starts.
13 | // The number of execution times is the same as the number of test cases defined by **it**.
14 | // This API supports only one parameter: preset action function.
15 | })
16 | afterEach(() => {
17 | // Presets a clear action, which is performed after each unit test case ends.
18 | // The number of execution times is the same as the number of test cases defined by **it**.
19 | // This API supports only one parameter: clear action function.
20 | })
21 | afterAll(() => {
22 | // Presets a clear action, which is performed after all test cases of the test suite end.
23 | // This API supports only one parameter: clear action function.
24 | })
25 | it('assertContain', 0, () => {
26 | // Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function.
27 | hilog.info(0x0000, 'testTag', '%{public}s', 'it begin');
28 | let a = 'abc';
29 | let b = 'b';
30 | // Defines a variety of assertion methods, which are used to declare expected boolean conditions.
31 | expect(a).assertContain(b);
32 | expect(a).assertEqual(a);
33 | })
34 | })
35 | }
--------------------------------------------------------------------------------
/example/harmony/src/ohosTest/ets/test/List.test.ets:
--------------------------------------------------------------------------------
1 | import abilityTest from './Ability.test';
2 |
3 | export default function testsuite() {
4 | abilityTest();
5 | }
--------------------------------------------------------------------------------
/example/harmony/src/ohosTest/module.json5:
--------------------------------------------------------------------------------
1 | {
2 | "module": {
3 | "name": "harmony_test",
4 | "type": "feature",
5 | "deviceTypes": [
6 | "phone",
7 | "tablet",
8 | "2in1"
9 | ],
10 | "deliveryWithInstall": true,
11 | "installationFree": false
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/example/harmony/src/test/List.test.ets:
--------------------------------------------------------------------------------
1 | import localUnitTest from './LocalUnit.test';
2 |
3 | export default function testsuite() {
4 | localUnitTest();
5 | }
--------------------------------------------------------------------------------
/example/harmony/src/test/LocalUnit.test.ets:
--------------------------------------------------------------------------------
1 | import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium';
2 |
3 | export default function localUnitTest() {
4 | describe('localUnitTest', () => {
5 | // Defines a test suite. Two parameters are supported: test suite name and test suite function.
6 | beforeAll(() => {
7 | // Presets an action, which is performed only once before all test cases of the test suite start.
8 | // This API supports only one parameter: preset action function.
9 | });
10 | beforeEach(() => {
11 | // Presets an action, which is performed before each unit test case starts.
12 | // The number of execution times is the same as the number of test cases defined by **it**.
13 | // This API supports only one parameter: preset action function.
14 | });
15 | afterEach(() => {
16 | // Presets a clear action, which is performed after each unit test case ends.
17 | // The number of execution times is the same as the number of test cases defined by **it**.
18 | // This API supports only one parameter: clear action function.
19 | });
20 | afterAll(() => {
21 | // Presets a clear action, which is performed after all test cases of the test suite end.
22 | // This API supports only one parameter: clear action function.
23 | });
24 | it('assertContain', 0, () => {
25 | // Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function.
26 | let a = 'abc';
27 | let b = 'b';
28 | // Defines a variety of assertion methods, which are used to declare expected boolean conditions.
29 | expect(a).assertContain(b);
30 | expect(a).assertEqual(a);
31 | });
32 | });
33 | }
--------------------------------------------------------------------------------
/example/ios/.gitignore:
--------------------------------------------------------------------------------
1 | *.mode1v3
2 | *.mode2v3
3 | *.moved-aside
4 | *.pbxuser
5 | *.perspectivev3
6 | **/*sync/
7 | .sconsign.dblite
8 | .tags*
9 | **/.vagrant/
10 | **/DerivedData/
11 | Icon?
12 | **/Pods/
13 | **/.symlinks/
14 | profile
15 | xcuserdata
16 | **/.generated/
17 | Flutter/App.framework
18 | Flutter/Flutter.framework
19 | Flutter/Flutter.podspec
20 | Flutter/Generated.xcconfig
21 | Flutter/app.flx
22 | Flutter/app.zip
23 | Flutter/flutter_assets/
24 | Flutter/flutter_export_environment.sh
25 | ServiceDefinitions.json
26 | Runner/GeneratedPluginRegistrant.*
27 |
28 | # Exceptions to above rules.
29 | !default.mode1v3
30 | !default.mode2v3
31 | !default.pbxuser
32 | !default.perspectivev3
33 |
--------------------------------------------------------------------------------
/example/ios/Podfile:
--------------------------------------------------------------------------------
1 | platform :ios, '9.0'
2 | use_frameworks!
3 |
4 | target 'example' do
5 | pod 'cross', :path => '../../'
6 | end
7 |
--------------------------------------------------------------------------------
/example/ios/Podfile.lock:
--------------------------------------------------------------------------------
1 | PODS:
2 | - cross (0.0.1)
3 |
4 | DEPENDENCIES:
5 | - cross (from `../../`)
6 |
7 | EXTERNAL SOURCES:
8 | cross:
9 | :path: "../../"
10 |
11 | SPEC CHECKSUMS:
12 | cross: df12eb640eb57547c4501973fbe9581eaa3ac21a
13 |
14 | PODFILE CHECKSUM: 802d9961bd6aa896e109ea6e40b6aa7a2939a1d2
15 |
16 | COCOAPODS: 1.15.2
17 |
--------------------------------------------------------------------------------
/example/ios/example.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/example/ios/example.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | IDEDidComputeMac32BitWarning
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/example/ios/example.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/example/ios/example.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | IDEDidComputeMac32BitWarning
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/example/ios/example/AppDelegate.h:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.h
3 | // example
4 | //
5 | // Created by Wiki on 2021/2/19.
6 | //
7 |
8 | #import
9 |
10 | @interface AppDelegate : UIResponder
11 |
12 |
13 | @end
14 |
15 |
--------------------------------------------------------------------------------
/example/ios/example/AppDelegate.m:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.m
3 | // example
4 | //
5 | // Created by Wiki on 2021/2/19.
6 | //
7 |
8 | #import "AppDelegate.h"
9 |
10 |
11 | @interface AppDelegate ()
12 |
13 | @end
14 |
15 | @implementation AppDelegate
16 |
17 |
18 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
19 | // Override point for customization after application launch.
20 |
21 | return YES;
22 | }
23 |
24 |
25 | #pragma mark - UISceneSession lifecycle
26 |
27 |
28 | - (UISceneConfiguration *)application:(UIApplication *)application configurationForConnectingSceneSession:(UISceneSession *)connectingSceneSession options:(UISceneConnectionOptions *)options {
29 | // Called when a new scene session is being created.
30 | // Use this method to select a configuration to create the new scene with.
31 | return [[UISceneConfiguration alloc] initWithName:@"Default Configuration" sessionRole:connectingSceneSession.role];
32 | }
33 |
34 |
35 | - (void)application:(UIApplication *)application didDiscardSceneSessions:(NSSet *)sceneSessions {
36 | // Called when the user discards a scene session.
37 | // If any sessions were discarded while the application was not running, this will be called shortly after application:didFinishLaunchingWithOptions.
38 | // Use this method to release any resources that were specific to the discarded scenes, as they will not return.
39 | }
40 |
41 |
42 | @end
43 |
--------------------------------------------------------------------------------
/example/ios/example/Assets.xcassets/AccentColor.colorset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "colors" : [
3 | {
4 | "idiom" : "universal"
5 | }
6 | ],
7 | "info" : {
8 | "author" : "xcode",
9 | "version" : 1
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/example/ios/example/Assets.xcassets/AppIcon.appiconset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "iphone",
5 | "scale" : "2x",
6 | "size" : "20x20"
7 | },
8 | {
9 | "idiom" : "iphone",
10 | "scale" : "3x",
11 | "size" : "20x20"
12 | },
13 | {
14 | "idiom" : "iphone",
15 | "scale" : "2x",
16 | "size" : "29x29"
17 | },
18 | {
19 | "idiom" : "iphone",
20 | "scale" : "3x",
21 | "size" : "29x29"
22 | },
23 | {
24 | "idiom" : "iphone",
25 | "scale" : "2x",
26 | "size" : "40x40"
27 | },
28 | {
29 | "idiom" : "iphone",
30 | "scale" : "3x",
31 | "size" : "40x40"
32 | },
33 | {
34 | "idiom" : "iphone",
35 | "scale" : "2x",
36 | "size" : "60x60"
37 | },
38 | {
39 | "idiom" : "iphone",
40 | "scale" : "3x",
41 | "size" : "60x60"
42 | },
43 | {
44 | "idiom" : "ipad",
45 | "scale" : "1x",
46 | "size" : "20x20"
47 | },
48 | {
49 | "idiom" : "ipad",
50 | "scale" : "2x",
51 | "size" : "20x20"
52 | },
53 | {
54 | "idiom" : "ipad",
55 | "scale" : "1x",
56 | "size" : "29x29"
57 | },
58 | {
59 | "idiom" : "ipad",
60 | "scale" : "2x",
61 | "size" : "29x29"
62 | },
63 | {
64 | "idiom" : "ipad",
65 | "scale" : "1x",
66 | "size" : "40x40"
67 | },
68 | {
69 | "idiom" : "ipad",
70 | "scale" : "2x",
71 | "size" : "40x40"
72 | },
73 | {
74 | "idiom" : "ipad",
75 | "scale" : "1x",
76 | "size" : "76x76"
77 | },
78 | {
79 | "idiom" : "ipad",
80 | "scale" : "2x",
81 | "size" : "76x76"
82 | },
83 | {
84 | "idiom" : "ipad",
85 | "scale" : "2x",
86 | "size" : "83.5x83.5"
87 | },
88 | {
89 | "idiom" : "ios-marketing",
90 | "scale" : "1x",
91 | "size" : "1024x1024"
92 | }
93 | ],
94 | "info" : {
95 | "author" : "xcode",
96 | "version" : 1
97 | }
98 | }
99 |
--------------------------------------------------------------------------------
/example/ios/example/Assets.xcassets/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "info" : {
3 | "author" : "xcode",
4 | "version" : 1
5 | }
6 | }
7 |
--------------------------------------------------------------------------------
/example/ios/example/Base.lproj/LaunchScreen.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/example/ios/example/Base.lproj/Main.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/example/ios/example/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | $(DEVELOPMENT_LANGUAGE)
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | $(PRODUCT_BUNDLE_IDENTIFIER)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | $(PRODUCT_NAME)
15 | CFBundlePackageType
16 | $(PRODUCT_BUNDLE_PACKAGE_TYPE)
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleVersion
20 | 1
21 | LSRequiresIPhoneOS
22 |
23 | UIApplicationSceneManifest
24 |
25 | UIApplicationSupportsMultipleScenes
26 |
27 | UISceneConfigurations
28 |
29 | UIWindowSceneSessionRoleApplication
30 |
31 |
32 | UISceneConfigurationName
33 | Default Configuration
34 | UISceneDelegateClassName
35 | SceneDelegate
36 | UISceneStoryboardFile
37 | Main
38 |
39 |
40 |
41 |
42 | UIApplicationSupportsIndirectInputEvents
43 |
44 | UILaunchStoryboardName
45 | LaunchScreen
46 | UIMainStoryboardFile
47 | Main
48 | UIRequiredDeviceCapabilities
49 |
50 | armv7
51 |
52 | UISupportedInterfaceOrientations
53 |
54 | UIInterfaceOrientationPortrait
55 | UIInterfaceOrientationLandscapeLeft
56 | UIInterfaceOrientationLandscapeRight
57 |
58 | UISupportedInterfaceOrientations~ipad
59 |
60 | UIInterfaceOrientationPortrait
61 | UIInterfaceOrientationPortraitUpsideDown
62 | UIInterfaceOrientationLandscapeLeft
63 | UIInterfaceOrientationLandscapeRight
64 |
65 |
66 |
67 |
--------------------------------------------------------------------------------
/example/ios/example/SceneDelegate.h:
--------------------------------------------------------------------------------
1 | //
2 | // SceneDelegate.h
3 | // example
4 | //
5 | // Created by Wiki on 2021/2/19.
6 | //
7 |
8 | #import
9 |
10 | @interface SceneDelegate : UIResponder
11 |
12 | @property (strong, nonatomic) UIWindow * window;
13 |
14 | @end
15 |
16 |
--------------------------------------------------------------------------------
/example/ios/example/SceneDelegate.m:
--------------------------------------------------------------------------------
1 | //
2 | // SceneDelegate.m
3 | // example
4 | //
5 | // Created by Wiki on 2021/2/19.
6 | //
7 |
8 | #import "SceneDelegate.h"
9 |
10 | @interface SceneDelegate ()
11 |
12 | @end
13 |
14 | @implementation SceneDelegate
15 |
16 |
17 | - (void)scene:(UIScene *)scene willConnectToSession:(UISceneSession *)session options:(UISceneConnectionOptions *)connectionOptions {
18 | // Use this method to optionally configure and attach the UIWindow `window` to the provided UIWindowScene `scene`.
19 | // If using a storyboard, the `window` property will automatically be initialized and attached to the scene.
20 | // This delegate does not imply the connecting scene or session are new (see `application:configurationForConnectingSceneSession` instead).
21 | }
22 |
23 |
24 | - (void)sceneDidDisconnect:(UIScene *)scene {
25 | // Called as the scene is being released by the system.
26 | // This occurs shortly after the scene enters the background, or when its session is discarded.
27 | // Release any resources associated with this scene that can be re-created the next time the scene connects.
28 | // The scene may re-connect later, as its session was not necessarily discarded (see `application:didDiscardSceneSessions` instead).
29 | }
30 |
31 |
32 | - (void)sceneDidBecomeActive:(UIScene *)scene {
33 | // Called when the scene has moved from an inactive state to an active state.
34 | // Use this method to restart any tasks that were paused (or not yet started) when the scene was inactive.
35 | }
36 |
37 |
38 | - (void)sceneWillResignActive:(UIScene *)scene {
39 | // Called when the scene will move from an active state to an inactive state.
40 | // This may occur due to temporary interruptions (ex. an incoming phone call).
41 | }
42 |
43 |
44 | - (void)sceneWillEnterForeground:(UIScene *)scene {
45 | // Called as the scene transitions from the background to the foreground.
46 | // Use this method to undo the changes made on entering the background.
47 | }
48 |
49 |
50 | - (void)sceneDidEnterBackground:(UIScene *)scene {
51 | // Called as the scene transitions from the foreground to the background.
52 | // Use this method to save data, release shared resources, and store enough scene-specific state information
53 | // to restore the scene back to its current state.
54 | }
55 |
56 |
57 | @end
58 |
--------------------------------------------------------------------------------
/example/ios/example/ViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // ViewController.h
3 | // example
4 | //
5 | // Created by Wiki on 2021/2/19.
6 | //
7 |
8 | #import
9 |
10 | @interface ViewController : UIViewController
11 |
12 |
13 | @end
14 |
15 |
--------------------------------------------------------------------------------
/example/ios/example/ViewController.m:
--------------------------------------------------------------------------------
1 | //
2 | // ViewController.m
3 | // example
4 | //
5 | // Created by Wiki on 2021/2/19.
6 | //
7 |
8 | #import "ViewController.h"
9 | #import "Cross.h"
10 |
11 | @interface ViewController ()
12 |
13 | @end
14 |
15 | @implementation ViewController
16 |
17 | - (void)viewDidLoad {
18 | [super viewDidLoad];
19 | NSString* url = @"http://example.com?key2=value2&key3=value3&key1=VALUE1";
20 | Cross *cross = [[Cross alloc] init];
21 | NSString*newUrl = [cross signatureUrl:url];
22 | NSLog(url);
23 | NSLog(newUrl);
24 | // Do any additional setup after loading the view.
25 | }
26 | @end
27 |
--------------------------------------------------------------------------------
/example/ios/example/cross.mm:
--------------------------------------------------------------------------------
1 | //
2 | // cross.h
3 | // example
4 | //
5 | // Created by Wiki on 2021/2/19.
6 | //
7 |
8 | #i
9 |
--------------------------------------------------------------------------------
/example/ios/example/main.m:
--------------------------------------------------------------------------------
1 | //
2 | // main.m
3 | // example
4 | //
5 | // Created by Wiki on 2021/2/19.
6 | //
7 |
8 | #import
9 | #import "AppDelegate.h"
10 |
11 | int main(int argc, char * argv[]) {
12 | NSString * appDelegateClassName;
13 | @autoreleasepool {
14 | // Setup code that might create autoreleased objects goes here.
15 | appDelegateClassName = NSStringFromClass([AppDelegate class]);
16 | }
17 | return UIApplicationMain(argc, argv, nil, appDelegateClassName);
18 | }
19 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | org.gradle.jvmargs=-Xmx1536M
2 | android.useAndroidX=true
3 | android.enableJetifier=true
4 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Tue Oct 18 14:48:41 CST 2022
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://mirrors.aliyun.com/macports/distfiles/gradle/gradle-6.5-all.zip
7 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
10 | DEFAULT_JVM_OPTS=""
11 |
12 | APP_NAME="Gradle"
13 | APP_BASE_NAME=`basename "$0"`
14 |
15 | # Use the maximum available, or set MAX_FD != -1 to use that value.
16 | MAX_FD="maximum"
17 |
18 | warn ( ) {
19 | echo "$*"
20 | }
21 |
22 | die ( ) {
23 | echo
24 | echo "$*"
25 | echo
26 | exit 1
27 | }
28 |
29 | # OS specific support (must be 'true' or 'false').
30 | cygwin=false
31 | msys=false
32 | darwin=false
33 | case "`uname`" in
34 | CYGWIN* )
35 | cygwin=true
36 | ;;
37 | Darwin* )
38 | darwin=true
39 | ;;
40 | MINGW* )
41 | msys=true
42 | ;;
43 | esac
44 |
45 | # Attempt to set APP_HOME
46 | # Resolve links: $0 may be a link
47 | PRG="$0"
48 | # Need this for relative symlinks.
49 | while [ -h "$PRG" ] ; do
50 | ls=`ls -ld "$PRG"`
51 | link=`expr "$ls" : '.*-> \(.*\)$'`
52 | if expr "$link" : '/.*' > /dev/null; then
53 | PRG="$link"
54 | else
55 | PRG=`dirname "$PRG"`"/$link"
56 | fi
57 | done
58 | SAVED="`pwd`"
59 | cd "`dirname \"$PRG\"`/" >/dev/null
60 | APP_HOME="`pwd -P`"
61 | cd "$SAVED" >/dev/null
62 |
63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
64 |
65 | # Determine the Java command to use to start the JVM.
66 | if [ -n "$JAVA_HOME" ] ; then
67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
68 | # IBM's JDK on AIX uses strange locations for the executables
69 | JAVACMD="$JAVA_HOME/jre/sh/java"
70 | else
71 | JAVACMD="$JAVA_HOME/bin/java"
72 | fi
73 | if [ ! -x "$JAVACMD" ] ; then
74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
75 |
76 | Please set the JAVA_HOME variable in your environment to match the
77 | location of your Java installation."
78 | fi
79 | else
80 | JAVACMD="java"
81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
82 |
83 | Please set the JAVA_HOME variable in your environment to match the
84 | location of your Java installation."
85 | fi
86 |
87 | # Increase the maximum file descriptors if we can.
88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
89 | MAX_FD_LIMIT=`ulimit -H -n`
90 | if [ $? -eq 0 ] ; then
91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
92 | MAX_FD="$MAX_FD_LIMIT"
93 | fi
94 | ulimit -n $MAX_FD
95 | if [ $? -ne 0 ] ; then
96 | warn "Could not set maximum file descriptor limit: $MAX_FD"
97 | fi
98 | else
99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
100 | fi
101 | fi
102 |
103 | # For Darwin, add options to specify how the application appears in the dock
104 | if $darwin; then
105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
106 | fi
107 |
108 | # For Cygwin, switch paths to Windows format before running java
109 | if $cygwin ; then
110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
112 | JAVACMD=`cygpath --unix "$JAVACMD"`
113 |
114 | # We build the pattern for arguments to be converted via cygpath
115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
116 | SEP=""
117 | for dir in $ROOTDIRSRAW ; do
118 | ROOTDIRS="$ROOTDIRS$SEP$dir"
119 | SEP="|"
120 | done
121 | OURCYGPATTERN="(^($ROOTDIRS))"
122 | # Add a user-defined pattern to the cygpath arguments
123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
125 | fi
126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
127 | i=0
128 | for arg in "$@" ; do
129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
131 |
132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
134 | else
135 | eval `echo args$i`="\"$arg\""
136 | fi
137 | i=$((i+1))
138 | done
139 | case $i in
140 | (0) set -- ;;
141 | (1) set -- "$args0" ;;
142 | (2) set -- "$args0" "$args1" ;;
143 | (3) set -- "$args0" "$args1" "$args2" ;;
144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
150 | esac
151 | fi
152 |
153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
154 | function splitJvmOpts() {
155 | JVM_OPTS=("$@")
156 | }
157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
159 |
160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
161 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12 | set DEFAULT_JVM_OPTS=
13 |
14 | set DIRNAME=%~dp0
15 | if "%DIRNAME%" == "" set DIRNAME=.
16 | set APP_BASE_NAME=%~n0
17 | set APP_HOME=%DIRNAME%
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windowz variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 | if "%@eval[2+2]" == "4" goto 4NT_args
53 |
54 | :win9xME_args
55 | @rem Slurp the command line arguments.
56 | set CMD_LINE_ARGS=
57 | set _SKIP=2
58 |
59 | :win9xME_args_slurp
60 | if "x%~1" == "x" goto execute
61 |
62 | set CMD_LINE_ARGS=%*
63 | goto execute
64 |
65 | :4NT_args
66 | @rem Get arguments from the 4NT Shell from JP Software
67 | set CMD_LINE_ARGS=%$
68 |
69 | :execute
70 | @rem Setup the command line
71 |
72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if "%ERRORLEVEL%"=="0" goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85 | exit /b 1
86 |
87 | :mainEnd
88 | if "%OS%"=="Windows_NT" endlocal
89 |
90 | :omega
91 |
--------------------------------------------------------------------------------
/hvigor/hvigor-config.json5:
--------------------------------------------------------------------------------
1 | {
2 | "modelVersion": "5.0.0",
3 | "dependencies": {
4 | },
5 | "execution": {
6 | // "analyze": "normal", /* Define the build analyze mode. Value: [ "normal" | "advanced" | false ]. Default: "normal" */
7 | // "daemon": true, /* Enable daemon compilation. Value: [ true | false ]. Default: true */
8 | // "incremental": true, /* Enable incremental compilation. Value: [ true | false ]. Default: true */
9 | // "parallel": true, /* Enable parallel compilation. Value: [ true | false ]. Default: true */
10 | // "typeCheck": false, /* Enable typeCheck. Value: [ true | false ]. Default: false */
11 | },
12 | "logging": {
13 | // "level": "info" /* Define the log level. Value: [ "debug" | "info" | "warn" | "error" ]. Default: "info" */
14 | },
15 | "debugging": {
16 | // "stacktrace": false /* Disable stacktrace compilation. Value: [ true | false ]. Default: false */
17 | },
18 | "nodeOptions": {
19 | // "maxOldSpaceSize": 8192 /* Enable nodeOptions maxOldSpaceSize compilation. Unit M. Used for the daemon process. Default: 8192*/
20 | // "exposeGC": true /* Enable to trigger garbage collection explicitly. Default: true*/
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/hvigorfile.ts:
--------------------------------------------------------------------------------
1 | import { appTasks } from '@ohos/hvigor-ohos-plugin';
2 |
3 | export default {
4 | system: appTasks, /* Built-in plugin of Hvigor. It cannot be modified. */
5 | plugins:[] /* Custom plugin to extend the functionality of Hvigor. */
6 | }
7 |
--------------------------------------------------------------------------------
/oh-package-lock.json5:
--------------------------------------------------------------------------------
1 | {
2 | "meta": {
3 | "stableOrder": true
4 | },
5 | "lockfileVersion": 3,
6 | "ATTENTION": "THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.",
7 | "specifiers": {
8 | "@ohos/hamock@1.0.0": "@ohos/hamock@1.0.0",
9 | "@ohos/hypium@1.0.18": "@ohos/hypium@1.0.18"
10 | },
11 | "packages": {
12 | "@ohos/hamock@1.0.0": {
13 | "name": "@ohos/hamock",
14 | "version": "1.0.0",
15 | "integrity": "sha512-K6lDPYc6VkKe6ZBNQa9aoG+ZZMiwqfcR/7yAVFSUGIuOAhPvCJAo9+t1fZnpe0dBRBPxj2bxPPbKh69VuyAtDg==",
16 | "resolved": "https://repo.harmonyos.com/ohpm/@ohos/hamock/-/hamock-1.0.0.har",
17 | "registryType": "ohpm"
18 | },
19 | "@ohos/hypium@1.0.18": {
20 | "name": "@ohos/hypium",
21 | "version": "1.0.18",
22 | "integrity": "sha512-RGe/iLGdeywdQilMWZsHKUoiE9OJ+9QxQsorF92R2ImLNVHVhbpSePNITGpW7TnvLgOIP/jscOqfIOhk6X7XRQ==",
23 | "resolved": "https://repo.harmonyos.com/ohpm/@ohos/hypium/-/hypium-1.0.18.har",
24 | "registryType": "ohpm"
25 | }
26 | }
27 | }
--------------------------------------------------------------------------------
/oh-package.json5:
--------------------------------------------------------------------------------
1 | {
2 | "modelVersion": "5.0.0",
3 | "description": "Please describe the basic information.",
4 | "dependencies": {
5 | },
6 | "devDependencies": {
7 | "@ohos/hypium": "1.0.18",
8 | "@ohos/hamock": "1.0.0"
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/platforms/android/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea/workspace.xml
5 | /.idea/libraries
6 | .DS_Store
7 | /build
8 | /captures
9 | .cxx
10 | .idea
--------------------------------------------------------------------------------
/platforms/android/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 |
3 | android {
4 | compileSdkVersion 30
5 | buildToolsVersion "30.0.2"
6 |
7 | defaultConfig {
8 | minSdkVersion 16
9 | targetSdkVersion 30
10 |
11 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
12 | consumerProguardFiles "consumer-rules.pro"
13 | externalNativeBuild {
14 | cmake {
15 | cppFlags ""
16 | }
17 | }
18 | }
19 |
20 | buildTypes {
21 | release {
22 | minifyEnabled false
23 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
24 | }
25 | }
26 | compileOptions {
27 | sourceCompatibility JavaVersion.VERSION_1_8
28 | targetCompatibility JavaVersion.VERSION_1_8
29 | }
30 | externalNativeBuild {
31 | cmake {
32 | // 这里需要指向项目根目录的 CMakeLists.txt 文件
33 | path "../../CMakeLists.txt"
34 | version "3.10.2"
35 | }
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/platforms/android/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/platforms/android/src/main/cpp/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | cmake_minimum_required(VERSION 3.10.2)
2 | project("cross")
3 | include_directories(export_include)
4 | add_library(${PROJECT_NAME} SHARED cross.cpp)
5 | find_library(log-lib log)
6 | target_link_libraries(${PROJECT_NAME} ${log-lib} url_signature)
--------------------------------------------------------------------------------
/platforms/android/src/main/cpp/cross.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include "url_signature.h"
4 |
5 | JavaVM *jvm = nullptr;
6 |
7 | JNIEXPORT jint JNI_OnLoad(JavaVM *vm, void *reserved) {
8 | JNIEnv *env = nullptr;
9 | if (vm->GetEnv((void **) &env, JNI_VERSION_1_6) != JNI_OK) {
10 | return JNI_ERR;
11 | }
12 | jvm = vm;
13 | return JNI_VERSION_1_6;
14 | }
15 |
16 | void GetJNIEnv(JNIEnv *&env) {
17 | int status = jvm->GetEnv((void **) &env, JNI_VERSION_1_6);
18 | // 获取当前native线程是否有没有被附加到jvm环境中
19 | if (status == JNI_EDETACHED) {
20 | // 如果没有, 主动附加到jvm环境中,获取到env
21 | if (jvm->AttachCurrentThread(&env, nullptr) != JNI_OK) {
22 | // Failed to attach
23 | }
24 | } else if (status == JNI_OK) {
25 | // success
26 | } else if (status == JNI_EVERSION) {
27 | // GetEnv: version not supported
28 | }
29 | }
30 |
31 | void test() {
32 | JNIEnv *env;
33 | GetJNIEnv(env);
34 | jstring jstr = env->NewStringUTF("hello world");
35 | }
36 |
37 |
38 | extern "C"
39 | JNIEXPORT jstring JNICALL
40 | Java_com_cross_Cross_signatureUrl(JNIEnv *env, jclass clazz, jstring j_url) {
41 | const char *url = env->GetStringUTFChars(j_url, JNI_FALSE);
42 | auto result = env->NewStringUTF(SignatureUrl(url).c_str());
43 | env->ReleaseStringUTFChars(j_url, url);
44 | return result;
45 | }
--------------------------------------------------------------------------------
/platforms/android/src/main/java/com/cross/Cross.java:
--------------------------------------------------------------------------------
1 | package com.cross;
2 |
3 | public class Cross {
4 | static {
5 | System.loadLibrary("cross");
6 | }
7 | public static native String signatureUrl(String url);
8 | }
9 |
--------------------------------------------------------------------------------
/platforms/harmony/.gitignore:
--------------------------------------------------------------------------------
1 | /node_modules
2 | /oh_modules
3 | /.preview
4 | /build
5 | /.cxx
6 | /.test
--------------------------------------------------------------------------------
/platforms/harmony/BuildProfile.ets:
--------------------------------------------------------------------------------
1 | /**
2 | * Use these variables when you tailor your ArkTS code. They must be of the const type.
3 | */
4 | export const HAR_VERSION = '1.0.0';
5 | export const BUILD_MODE_NAME = 'debug';
6 | export const DEBUG = true;
7 | export const TARGET_NAME = 'default';
8 |
9 | /**
10 | * BuildProfile Class is used only for compatibility purposes.
11 | */
12 | export default class BuildProfile {
13 | static readonly HAR_VERSION = HAR_VERSION;
14 | static readonly BUILD_MODE_NAME = BUILD_MODE_NAME;
15 | static readonly DEBUG = DEBUG;
16 | static readonly TARGET_NAME = TARGET_NAME;
17 | }
--------------------------------------------------------------------------------
/platforms/harmony/Index.ets:
--------------------------------------------------------------------------------
1 | export { NativeReader } from './src/main/ets/NativeReader'
2 |
--------------------------------------------------------------------------------
/platforms/harmony/build-profile.json5:
--------------------------------------------------------------------------------
1 | {
2 | "apiType": "stageMode",
3 | "buildOption": {
4 | "externalNativeOptions": {
5 | "path": "../../CMakeLists.txt",
6 | "arguments": "-DHARMONY=TRUE",
7 | "cppFlags": ""
8 | }
9 | },
10 | "buildOptionSet": [
11 | {
12 | "name": "release",
13 | "arkOptions": {
14 | "obfuscation": {
15 | "ruleOptions": {
16 | "enable": true,
17 | "files": [
18 | "./obfuscation-rules.txt"
19 | ]
20 | }
21 | }
22 | },
23 | "nativeLib": {
24 | "debugSymbol": {
25 | "strip": true,
26 | "exclude": []
27 | }
28 | }
29 | },
30 | ],
31 | "targets": [
32 | {
33 | "name": "default"
34 | },
35 | {
36 | "name": "ohosTest",
37 | }
38 | ]
39 | }
--------------------------------------------------------------------------------
/platforms/harmony/hvigorfile.ts:
--------------------------------------------------------------------------------
1 | import { harTasks } from '@ohos/hvigor-ohos-plugin';
2 |
3 | export default {
4 | system: harTasks, /* Built-in plugin of Hvigor. It cannot be modified. */
5 | plugins:[] /* Custom plugin to extend the functionality of Hvigor. */
6 | }
7 |
--------------------------------------------------------------------------------
/platforms/harmony/obfuscation-rules.txt:
--------------------------------------------------------------------------------
1 | # Define project specific obfuscation rules here.
2 | # You can include the obfuscation configuration files in the current module's build-profile.json5.
3 | #
4 | # For more details, see
5 | # https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5
6 |
7 | # Obfuscation options:
8 | # -disable-obfuscation: disable all obfuscations
9 | # -enable-property-obfuscation: obfuscate the property names
10 | # -enable-toplevel-obfuscation: obfuscate the names in the global scope
11 | # -compact: remove unnecessary blank spaces and all line feeds
12 | # -remove-log: remove all console.* statements
13 | # -print-namecache: print the name cache that contains the mapping from the old names to new names
14 | # -apply-namecache: reuse the given cache file
15 |
16 | # Keep options:
17 | # -keep-property-name: specifies property names that you want to keep
18 | # -keep-global-name: specifies names that you want to keep in the global scope
--------------------------------------------------------------------------------
/platforms/harmony/oh-package-lock.json5:
--------------------------------------------------------------------------------
1 | {
2 | "meta": {
3 | "stableOrder": true
4 | },
5 | "lockfileVersion": 3,
6 | "ATTENTION": "THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.",
7 | "specifiers": {
8 | "libcross.so@src/main/cpp/types/libcross": "libcross.so@src/main/cpp/types/libcross"
9 | },
10 | "packages": {
11 | "libcross.so@src/main/cpp/types/libcross": {
12 | "name": "libcross.so",
13 | "version": "1.0.0",
14 | "resolved": "src/main/cpp/types/libcross",
15 | "registryType": "local"
16 | }
17 | }
18 | }
--------------------------------------------------------------------------------
/platforms/harmony/oh-package.json5:
--------------------------------------------------------------------------------
1 | {
2 | "name": "harmony",
3 | "version": "1.0.0",
4 | "description": "Please describe the basic information.",
5 | "main": "Index.ets",
6 | "author": "",
7 | "license": "",
8 | "dependencies": {
9 | "libcross.so": "file:./src/main/cpp/types/libcross"
10 | }
11 | }
--------------------------------------------------------------------------------
/platforms/harmony/src/main/cpp/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | # the minimum version of CMake.
2 | cmake_minimum_required(VERSION 3.4.1)
3 | project("cross")
4 | include_directories(export_include)
5 | set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR})
6 |
7 | if(DEFINED PACKAGE_FIND_FILE)
8 | include(${PACKAGE_FIND_FILE})
9 | endif()
10 |
11 | include_directories(${NATIVERENDER_ROOT_PATH}
12 | ${NATIVERENDER_ROOT_PATH}/include)
13 |
14 | add_library(${PROJECT_NAME} SHARED napi_init.cpp)
15 | target_link_libraries(${PROJECT_NAME} PUBLIC libace_napi.z.so url_signature)
16 | #target_link_libraries(${PROJECT_NAME} url_signature)
17 |
18 |
19 | #cmake_minimum_required(VERSION 3.10.2)
20 | #project("cross")
21 | #include_directories(export_include)
22 | #add_library(${PROJECT_NAME} SHARED cross.cpp)
23 | #find_library(log-lib log)
24 | #target_link_libraries(${PROJECT_NAME} ${log-lib} url_signature)
--------------------------------------------------------------------------------
/platforms/harmony/src/main/cpp/napi_init.cpp:
--------------------------------------------------------------------------------
1 | #include "napi/native_api.h"
2 | #include "url_signature.h"
3 |
4 | static napi_value Add(napi_env env, napi_callback_info info) {
5 | size_t argc = 2;
6 | napi_value args[2] = {nullptr};
7 |
8 | napi_get_cb_info(env, info, &argc, args, nullptr, nullptr);
9 |
10 | napi_valuetype valuetype0;
11 | napi_typeof(env, args[0], &valuetype0);
12 |
13 | napi_valuetype valuetype1;
14 | napi_typeof(env, args[1], &valuetype1);
15 |
16 | double value0;
17 | napi_get_value_double(env, args[0], &value0);
18 |
19 | double value1;
20 | napi_get_value_double(env, args[1], &value1);
21 |
22 | napi_value sum;
23 | napi_create_double(env, value0 + value1, &sum);
24 |
25 | std::string str = SignatureUrl("");
26 |
27 | return sum;
28 | }
29 |
30 | static std::string value2String(napi_env env, napi_value value) {
31 | size_t stringSize = 0;
32 | napi_get_value_string_utf8(env, value, nullptr, 0, &stringSize); // 获取字符串长度
33 | char buff[stringSize + 1];
34 | napi_get_value_string_utf8(env, value, buff, stringSize + 1, &stringSize); // 根据长度传换成字符串
35 | return buff;
36 | }
37 |
38 | static napi_value SignatureUrl(napi_env env, napi_callback_info info) {
39 | size_t argc = 1;
40 | napi_value args[1] = {nullptr};
41 | napi_get_cb_info(env, info, &argc, args, nullptr, nullptr);
42 | napi_value str = args[0]; // args[0]->string
43 | std::string stringValue = value2String(env, str); // 将 str 转换成 string 类型
44 | std::string result = SignatureUrl(stringValue);
45 | napi_value sum;
46 | napi_create_string_utf8(env, result.c_str(), result.length(), &sum);
47 | return sum;
48 | }
49 |
50 |
51 | EXTERN_C_START
52 | static napi_value Init(napi_env env, napi_value exports) {
53 | napi_property_descriptor desc[] = {
54 | {"add", nullptr, Add, nullptr, nullptr, nullptr, napi_default, nullptr},
55 | {"signatureUrl", nullptr, SignatureUrl, nullptr, nullptr, nullptr, napi_default, nullptr}};
56 | napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc);
57 | return exports;
58 | }
59 | EXTERN_C_END
60 |
61 | static napi_module demoModule = {
62 | .nm_version = 1,
63 | .nm_flags = 0,
64 | .nm_filename = nullptr,
65 | .nm_register_func = Init,
66 | .nm_modname = "cross",
67 | .nm_priv = ((void *)0),
68 | .reserved = {0},
69 | };
70 |
71 | extern "C" __attribute__((constructor)) void RegisterHarmonyModule(void) { napi_module_register(&demoModule); }
72 |
--------------------------------------------------------------------------------
/platforms/harmony/src/main/cpp/types/libcross/Index.d.ts:
--------------------------------------------------------------------------------
1 | export const add: (a: number, b: number) => number;
2 | export const signatureUrl: (url: string) => string;
--------------------------------------------------------------------------------
/platforms/harmony/src/main/cpp/types/libcross/oh-package.json5:
--------------------------------------------------------------------------------
1 | {
2 | "name": "libcross.so",
3 | "types": "./Index.d.ts",
4 | "version": "1.0.0",
5 | "description": "Please describe the basic information."
6 | }
--------------------------------------------------------------------------------
/platforms/harmony/src/main/ets/NativeReader.ets:
--------------------------------------------------------------------------------
1 | import testNapi from 'libcross.so';
2 |
3 | export class NativeReader {
4 | add(a: number, b: number): number {
5 | return testNapi.add(a, b);
6 | }
7 | signatureUrl(url: string): string {
8 | return testNapi.signatureUrl(url);
9 | }
10 |
11 | }
--------------------------------------------------------------------------------
/platforms/harmony/src/main/ets/harmonyability/HarmonyAbility.ets:
--------------------------------------------------------------------------------
1 | import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit';
2 | import { hilog } from '@kit.PerformanceAnalysisKit';
3 | import { window } from '@kit.ArkUI';
4 |
5 | export default class HarmonyAbility extends UIAbility {
6 | onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void {
7 | hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate');
8 | }
9 |
10 | onDestroy(): void {
11 | hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy');
12 | }
13 |
14 | onWindowStageCreate(windowStage: window.WindowStage): void {
15 | // Main window is created, set main page for this ability
16 | hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate');
17 |
18 | windowStage.loadContent('pages/Index', (err) => {
19 | if (err.code) {
20 | hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? '');
21 | return;
22 | }
23 | hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.');
24 | });
25 | }
26 |
27 | onWindowStageDestroy(): void {
28 | // Main window is destroyed, release UI related resources
29 | hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy');
30 | }
31 |
32 | onForeground(): void {
33 | // Ability has brought to foreground
34 | hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground');
35 | }
36 |
37 | onBackground(): void {
38 | // Ability has back to background
39 | hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground');
40 | }
41 | };
42 |
--------------------------------------------------------------------------------
/platforms/harmony/src/main/ets/pages/Index.ets:
--------------------------------------------------------------------------------
1 | import { hilog } from '@kit.PerformanceAnalysisKit';
2 | import testNapi from 'libcross.so';
3 |
4 | @Entry
5 | @Component
6 | struct Index {
7 | @State message: string = 'Hello World';
8 |
9 | build() {
10 | Row() {
11 | Column() {
12 | Text(this.message)
13 | .fontSize(50)
14 | .fontWeight(FontWeight.Bold)
15 | .onClick(() => {
16 | hilog.info(0x0000, 'testTag', 'Test NAPI 2 + 3 = %{public}d', testNapi.add(2, 3));
17 | })
18 | }
19 | .width('100%')
20 | }
21 | .height('100%')
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/platforms/harmony/src/main/module.json5:
--------------------------------------------------------------------------------
1 | {
2 | "module": {
3 | "name": "harmony",
4 | "type": "har",
5 | "deviceTypes": [
6 | "phone",
7 | "tablet",
8 | "2in1"
9 | ],
10 | "abilities": [
11 | ]
12 | }
13 | }
--------------------------------------------------------------------------------
/platforms/harmony/src/main/resources/base/element/color.json:
--------------------------------------------------------------------------------
1 | {
2 | "color": [
3 | {
4 | "name": "start_window_background",
5 | "value": "#FFFFFF"
6 | }
7 | ]
8 | }
--------------------------------------------------------------------------------
/platforms/harmony/src/main/resources/base/element/string.json:
--------------------------------------------------------------------------------
1 | {
2 | "string": [
3 | {
4 | "name": "module_desc",
5 | "value": "module description"
6 | },
7 | {
8 | "name": "HarmonyAbility_desc",
9 | "value": "description"
10 | },
11 | {
12 | "name": "HarmonyAbility_label",
13 | "value": "label"
14 | }
15 | ]
16 | }
--------------------------------------------------------------------------------
/platforms/harmony/src/main/resources/base/media/background.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/taoweiji/cpp-android-ios-example/8647fa5aa89e43fd5705e07e1437b553c2405785/platforms/harmony/src/main/resources/base/media/background.png
--------------------------------------------------------------------------------
/platforms/harmony/src/main/resources/base/media/foreground.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/taoweiji/cpp-android-ios-example/8647fa5aa89e43fd5705e07e1437b553c2405785/platforms/harmony/src/main/resources/base/media/foreground.png
--------------------------------------------------------------------------------
/platforms/harmony/src/main/resources/base/media/layered_image.json:
--------------------------------------------------------------------------------
1 | {
2 | "layered-image":
3 | {
4 | "background" : "$media:background",
5 | "foreground" : "$media:foreground"
6 | }
7 | }
--------------------------------------------------------------------------------
/platforms/harmony/src/main/resources/base/media/startIcon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/taoweiji/cpp-android-ios-example/8647fa5aa89e43fd5705e07e1437b553c2405785/platforms/harmony/src/main/resources/base/media/startIcon.png
--------------------------------------------------------------------------------
/platforms/harmony/src/main/resources/base/profile/main_pages.json:
--------------------------------------------------------------------------------
1 | {
2 | "src": [
3 | "pages/Index"
4 | ]
5 | }
6 |
--------------------------------------------------------------------------------
/platforms/harmony/src/main/resources/en_US/element/string.json:
--------------------------------------------------------------------------------
1 | {
2 | "string": [
3 | {
4 | "name": "module_desc",
5 | "value": "module description"
6 | },
7 | {
8 | "name": "HarmonyAbility_desc",
9 | "value": "description"
10 | },
11 | {
12 | "name": "HarmonyAbility_label",
13 | "value": "label"
14 | }
15 | ]
16 | }
--------------------------------------------------------------------------------
/platforms/harmony/src/main/resources/zh_CN/element/string.json:
--------------------------------------------------------------------------------
1 | {
2 | "string": [
3 | {
4 | "name": "module_desc",
5 | "value": "模块描述"
6 | },
7 | {
8 | "name": "HarmonyAbility_desc",
9 | "value": "description"
10 | },
11 | {
12 | "name": "HarmonyAbility_label",
13 | "value": "label"
14 | }
15 | ]
16 | }
--------------------------------------------------------------------------------
/platforms/harmony/src/mock/Libcross.mock.ets:
--------------------------------------------------------------------------------
1 | const NativeMock: Record = {
2 | 'add': (a: number, b: number) => {
3 | return a + b;
4 | },
5 | };
6 |
7 | export default NativeMock;
--------------------------------------------------------------------------------
/platforms/harmony/src/mock/mock-config.json5:
--------------------------------------------------------------------------------
1 | {
2 | "libcross.so": {
3 | "source": "src/mock/Libcross.mock.ets"
4 | }
5 | }
--------------------------------------------------------------------------------
/platforms/harmony/src/ohosTest/ets/test/Ability.test.ets:
--------------------------------------------------------------------------------
1 | import { hilog } from '@kit.PerformanceAnalysisKit';
2 | import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium';
3 |
4 | export default function abilityTest() {
5 | describe('ActsAbilityTest', () => {
6 | // Defines a test suite. Two parameters are supported: test suite name and test suite function.
7 | beforeAll(() => {
8 | // Presets an action, which is performed only once before all test cases of the test suite start.
9 | // This API supports only one parameter: preset action function.
10 | })
11 | beforeEach(() => {
12 | // Presets an action, which is performed before each unit test case starts.
13 | // The number of execution times is the same as the number of test cases defined by **it**.
14 | // This API supports only one parameter: preset action function.
15 | })
16 | afterEach(() => {
17 | // Presets a clear action, which is performed after each unit test case ends.
18 | // The number of execution times is the same as the number of test cases defined by **it**.
19 | // This API supports only one parameter: clear action function.
20 | })
21 | afterAll(() => {
22 | // Presets a clear action, which is performed after all test cases of the test suite end.
23 | // This API supports only one parameter: clear action function.
24 | })
25 | it('assertContain', 0, () => {
26 | // Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function.
27 | hilog.info(0x0000, 'testTag', '%{public}s', 'it begin');
28 | let a = 'abc';
29 | let b = 'b';
30 | // Defines a variety of assertion methods, which are used to declare expected boolean conditions.
31 | expect(a).assertContain(b);
32 | expect(a).assertEqual(a);
33 | })
34 | })
35 | }
--------------------------------------------------------------------------------
/platforms/harmony/src/ohosTest/ets/test/List.test.ets:
--------------------------------------------------------------------------------
1 | import abilityTest from './Ability.test';
2 |
3 | export default function testsuite() {
4 | abilityTest();
5 | }
--------------------------------------------------------------------------------
/platforms/harmony/src/ohosTest/module.json5:
--------------------------------------------------------------------------------
1 | {
2 | "module": {
3 | "name": "harmony_test",
4 | "type": "har",
5 | "deviceTypes": [
6 | "phone",
7 | "tablet",
8 | "2in1"
9 | ],
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/platforms/harmony/src/test/List.test.ets:
--------------------------------------------------------------------------------
1 | import localUnitTest from './LocalUnit.test';
2 |
3 | export default function testsuite() {
4 | localUnitTest();
5 | }
--------------------------------------------------------------------------------
/platforms/harmony/src/test/LocalUnit.test.ets:
--------------------------------------------------------------------------------
1 | import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium';
2 |
3 | export default function localUnitTest() {
4 | describe('localUnitTest', () => {
5 | // Defines a test suite. Two parameters are supported: test suite name and test suite function.
6 | beforeAll(() => {
7 | // Presets an action, which is performed only once before all test cases of the test suite start.
8 | // This API supports only one parameter: preset action function.
9 | });
10 | beforeEach(() => {
11 | // Presets an action, which is performed before each unit test case starts.
12 | // The number of execution times is the same as the number of test cases defined by **it**.
13 | // This API supports only one parameter: preset action function.
14 | });
15 | afterEach(() => {
16 | // Presets a clear action, which is performed after each unit test case ends.
17 | // The number of execution times is the same as the number of test cases defined by **it**.
18 | // This API supports only one parameter: clear action function.
19 | });
20 | afterAll(() => {
21 | // Presets a clear action, which is performed after all test cases of the test suite end.
22 | // This API supports only one parameter: clear action function.
23 | });
24 | it('assertContain', 0, () => {
25 | // Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function.
26 | let a = 'abc';
27 | let b = 'b';
28 | // Defines a variety of assertion methods, which are used to declare expected boolean conditions.
29 | expect(a).assertContain(b);
30 | expect(a).assertEqual(a);
31 | });
32 | });
33 | }
--------------------------------------------------------------------------------
/platforms/ios/.gitignore:
--------------------------------------------------------------------------------
1 | .idea/
2 | .vagrant/
3 | .sconsign.dblite
4 | .svn/
5 |
6 | .DS_Store
7 | *.swp
8 | profile
9 |
10 | DerivedData/
11 | build/
12 | GeneratedPluginRegistrant.h
13 | GeneratedPluginRegistrant.m
14 |
15 | .generated/
16 |
17 | *.pbxuser
18 | *.mode1v3
19 | *.mode2v3
20 | *.perspectivev3
21 |
22 | !default.pbxuser
23 | !default.mode1v3
24 | !default.mode2v3
25 | !default.perspectivev3
26 |
27 | xcuserdata
28 |
29 | *.moved-aside
30 |
31 | *.pyc
32 | *sync/
33 | Icon?
34 | .tags*
35 |
36 | /Flutter/Generated.xcconfig
37 | /Flutter/flutter_export_environment.sh
--------------------------------------------------------------------------------
/platforms/ios/Classes/Cross.h:
--------------------------------------------------------------------------------
1 |
2 | @interface Cross : NSObject
3 | - (NSString*)signatureUrl:(NSString *)url;
4 | @end
5 |
--------------------------------------------------------------------------------
/platforms/ios/Classes/Cross.mm:
--------------------------------------------------------------------------------
1 | #import "Cross.h"
2 | #include
3 | #include
4 |
5 | @implementation Cross
6 | - (NSString*)signatureUrl:(NSString *)url{
7 | std::string str = [url UTF8String];
8 | std::string result = SignatureUrl(str);
9 | NSString *newUrl = [NSString stringWithUTF8String:result.c_str()];
10 | return newUrl;
11 | }
12 | @end
13 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | rootProject.name = 'cpp-android-ios-example'
2 | include ":cross"
3 | project(":cross").projectDir = new File("platforms/android")
4 | include ":example"
5 | project(":example").projectDir = new File("example/android")
--------------------------------------------------------------------------------
/src/url_signature/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | cmake_minimum_required(VERSION 3.10.2)
2 | set(CMAKE_CXX_STANDARD 14)
3 | project(url_signature)
4 | add_library(${PROJECT_NAME} url_signature.cpp)
5 | target_include_directories(${PROJECT_NAME} PUBLIC ${PROJECT_SOURCE_DIR}/include)
6 | target_link_libraries(${PROJECT_NAME} cxxurl hash)
--------------------------------------------------------------------------------
/src/url_signature/README.md:
--------------------------------------------------------------------------------
1 | # URL签名
2 | 1. 约定密钥:1bc29b36f623ba82aaf6724fd3b16718
3 | 2. http://example.com?key1=VALUE1&key2=value2&key3=value3
4 | 3. 对参数的name进行排序后拼接获得 key1VALUE1key2value2key3value3
5 | 4. 拼接后的参数+特定的私钥组合成 key1VALUE1key2value2key3value31bc29b36f623ba82aaf6724fd3b16718
6 | 5. 对拼接后的参数转换成小写key1value1key2value2key3value31bc29b36f623ba82aaf6724fd3b16718
7 | 6. 然后执行md5,得到签名字符串 5779f1cd4693e8b3c5981d37d20aa331
8 | 7. 这个签名字符串也需要放到参数后一起请求服务端,http://example.com?key1=VALUE1&key2=value2&key3=value3&sign=5779f1cd4693e8b3c5981d37d20aa331
9 |
10 | > 这个是标准URL签名方式,密钥放在服务端和C++代码中,这个密钥不能让外部人员知晓
--------------------------------------------------------------------------------
/src/url_signature/include/url_signature.h:
--------------------------------------------------------------------------------
1 | //
2 | // Created by Wiki on 2021/2/18.
3 | //
4 |
5 | #ifndef CPP_ANDROID_IOS_MULTI_PLATFORM_URL_SIGNATURE_H
6 | #define CPP_ANDROID_IOS_MULTI_PLATFORM_URL_SIGNATURE_H
7 | #include
8 | std::string SignatureUrl(const std::string &url);
9 |
10 | #endif //CPP_ANDROID_IOS_MULTI_PLATFORM_URL_SIGNATURE_H
11 |
--------------------------------------------------------------------------------
/src/url_signature/url_signature.cpp:
--------------------------------------------------------------------------------
1 | //
2 | // Created by Wiki on 2021/2/18.
3 | //
4 |
5 | #include "url_signature.h"
6 | #include
7 | #include
8 | #include
9 | #include