Skip to content

Commit 57b88f2

Browse files
committed
Merge branch 'release/0.3.20'
# Conflicts: # dart_native/example/lib/android/unit_test.dart
2 parents 610d1d6 + 28e7798 commit 57b88f2

File tree

80 files changed

+2641
-1183
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

80 files changed

+2641
-1183
lines changed

.travis.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727
- unzip -qq gradle-3.5-bin.zip
2828
- export GRADLE_HOME=$PWD/gradle-3.5
2929
- export PATH=$GRADLE_HOME/bin:$PATH
30-
- git clone https://github.com/flutter/flutter.git -b stable --depth 1
30+
- git clone https://github.com/flutter/flutter.git --depth 1 --branch 1.22.6
3131
- export PATH=./flutter/bin:$PATH
3232
- flutter doctor
3333
- yes | sdkmanager "platforms;android-29"
@@ -44,7 +44,7 @@ jobs:
4444
- brew install libimobiledevice
4545
- brew install ideviceinstaller
4646
- brew install ios-deploy
47-
- git clone https://github.com/flutter/flutter.git -b stable --depth 1
47+
- git clone https://github.com/flutter/flutter.git --depth 1 --branch 1.22.6
4848
- export PATH=./flutter/bin:$PATH
4949
- flutter doctor
5050
script:

dart_native/.vscode/launch.json

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
{
2+
// 使用 IntelliSense 了解相关属性。
3+
// 悬停以查看现有属性的描述。
4+
// 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
5+
"version": "0.2.0",
6+
"configurations": [
7+
{
8+
"name": "dart_native",
9+
"request": "launch",
10+
"type": "dart"
11+
},
12+
{
13+
"name": "dart_native (profile mode)",
14+
"request": "launch",
15+
"type": "dart",
16+
"flutterMode": "profile"
17+
},
18+
{
19+
"name": "example",
20+
"cwd": "example",
21+
"request": "launch",
22+
"type": "dart"
23+
},
24+
{
25+
"name": "example (profile mode)",
26+
"cwd": "example",
27+
"request": "launch",
28+
"type": "dart",
29+
"flutterMode": "profile"
30+
}
31+
]
32+
}

dart_native/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 0.3.20
2+
3+
* [Feature] Support 64 bit on Android.
4+
15
## 0.3.19
26

37
* [Fix] Some crash on Android.

dart_native/android/CMakeLists.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,11 @@ add_library( # Specifies the name of the library.
1818

1919
# Provides a relative path to your source file(s).
2020
src/main/jni/include/dart_api_dl.c
21-
src/main/jni/dart_native.cpp )
21+
src/main/jni/dart_native.cpp
22+
src/main/jni/dn_type_convert.cpp
23+
src/main/jni/dn_method_call.cpp
24+
src/main/jni/dn_signature_helper.cpp
25+
src/main/jni/dn_callback.cpp)
2226

2327
find_library( # Sets the name of the path variable.
2428
log-lib

dart_native/android/src/main/java/com/dartnative/dart_native/ArrayListConverter.java

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44
import java.util.ArrayList;
55
import java.util.Arrays;
66
import java.util.Collections;
7+
import java.util.HashSet;
78
import java.util.List;
9+
import java.util.Set;
810

911
/**
1012
* Created by huizzzhou on 3/26/21.
@@ -80,11 +82,11 @@ public double[] doubleListToArray(List<Double> arguments) {
8082
/************************object type list to array***************************************/
8183

8284
public Object[] objectListToArray(List<Object> arguments) {
83-
Object[] doubleArray = new Object[arguments.size()];
85+
Object[] objectArray = new Object[arguments.size()];
8486
for (int i = 0; i < arguments.size(); i++) {
85-
doubleArray[i] = arguments.get(i);
87+
objectArray[i] = arguments.get(i);
8688
}
87-
return doubleArray;
89+
return objectArray;
8890
}
8991

9092

@@ -138,5 +140,14 @@ public List arrayToList(Object array) {
138140

139141
return arrayList;
140142
}
141-
143+
144+
/************************set to list***************************************/
145+
146+
public List setToList(HashSet<Object> set) {
147+
if (set == null || set.size() == 0) {
148+
return new ArrayList();
149+
}
150+
151+
return new ArrayList<Object>(set);
152+
}
142153
}

dart_native/android/src/main/java/com/dartnative/dart_native/CallbackInvocationHandler.java

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,27 +12,33 @@
1212
public class CallbackInvocationHandler implements InvocationHandler {
1313
private static final String TAG = "CallbackHandler";
1414

15-
private static HashMap<Class<?>, String> sTypeConvert = new HashMap<Class<?>, String>() {{
16-
put(int.class, "I");
17-
put(float.class, "F");
18-
put(double.class, "D");
19-
put(boolean.class, "Z");
20-
put(String.class, "Ljava/lang/String;");
15+
private static final HashMap<String, String> sBasicTypeConvert = new HashMap<String, String>() {{
16+
put("int", "java.lang.Integer");
17+
put("float", "java.lang.Float");
18+
put("double", "java.lang.Double");
19+
put("boolean", "java.lang.Boolean");
20+
put("byte", "java.lang.Byte");
21+
put("short", "java.lang.Short");
22+
put("long", "java.lang.Long");
23+
put("char", "java.lang.Character");
2124
}};
2225

2326
@Override
2427
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
2528
Log.d(TAG, "invoke method: " + method.getName());
26-
Class<?>[] paramTypes = method.getParameterTypes();
27-
String[] params = new String[paramTypes.length];
28-
for (int i = 0; i < paramTypes.length; i++) {
29-
params[i] = sTypeConvert.get(paramTypes[i]);
29+
int argumentLength = args == null ? 0 : args.length;
30+
String[] paramsType = new String[argumentLength];
31+
for (int i = 0; i < argumentLength; i++) {
32+
paramsType[i] = args[i] != null ? args[i].getClass().getName() : null;
3033
}
34+
3135
String funName = method.getName();
32-
String returnType = sTypeConvert.get(method.getReturnType());
33-
long dartObjectAddr = CallbackManager.getInstance().getRegisterDartAddr(proxy);
34-
return hookCallback(dartObjectAddr, funName, paramTypes.length, params, args, returnType);
36+
String returnType = method.getReturnType().getName();
37+
returnType = sBasicTypeConvert.get(returnType) == null ? returnType : sBasicTypeConvert.get(returnType);
38+
long dartObjectAddress = CallbackManager.getInstance().getRegisterDartAddr(proxy);
39+
40+
return hookCallback(dartObjectAddress, funName, argumentLength, paramsType, args, returnType);
3541
}
3642

37-
static native Object hookCallback(long dartObjectAddr, String funName, int argCount, String[] argTypes, Object[] args, String returnType);
43+
static native Object hookCallback(long dartObjectAddress, String funName, int argCount, String[] argTypes, Object[] args, String returnType);
3844
}

0 commit comments

Comments
 (0)