@@ -2,16 +2,14 @@ use std::sync::Arc;
22
33use jni:: {
44 JNIEnv ,
5- errors:: Result ,
6- objects:: { JClass , JObject , JValueOwned } ,
5+ objects:: { JClass , JObject } ,
76} ;
87use longbridge:: { Config , content:: ContentContext } ;
98
109use crate :: {
1110 async_util,
1211 error:: jni_result,
13- init:: CONTENT_CONTEXT_CLASS ,
14- types:: { FromJValue , IntoJValue , ObjectArray , set_field} ,
12+ types:: { FromJValue , ObjectArray } ,
1513} ;
1614
1715struct ContextObj {
@@ -23,29 +21,11 @@ pub unsafe extern "system" fn Java_com_longbridge_SdkNative_newContentContext(
2321 mut env : JNIEnv ,
2422 _class : JClass ,
2523 config : i64 ,
26- callback : JObject ,
27- ) {
28- struct ContextObjRef ( i64 ) ;
29-
30- impl IntoJValue for ContextObjRef {
31- fn into_jvalue < ' a > ( self , env : & mut JNIEnv < ' a > ) -> Result < JValueOwned < ' a > > {
32- let ctx_obj = env. new_object ( CONTENT_CONTEXT_CLASS . get ( ) . unwrap ( ) , "()V" , & [ ] ) ?;
33- set_field ( env, & ctx_obj, "raw" , self . 0 ) ?;
34- Ok ( JValueOwned :: from ( ctx_obj) )
35- }
36- }
37-
38- jni_result ( & mut env, ( ) , |env| {
24+ ) -> i64 {
25+ jni_result ( & mut env, 0i64 , |_env| {
3926 let config = Arc :: new ( ( * ( config as * const Config ) ) . clone ( ) ) ;
40-
41- async_util:: execute ( env, callback, async move {
42- let ctx = ContentContext :: try_new ( config) ?;
43- Ok ( ContextObjRef (
44- Box :: into_raw ( Box :: new ( ContextObj { ctx } ) ) as i64
45- ) )
46- } ) ?;
47-
48- Ok ( ( ) )
27+ let ctx = ContentContext :: new ( config) ;
28+ Ok ( Box :: into_raw ( Box :: new ( ContextObj { ctx } ) ) as i64 )
4929 } )
5030}
5131
0 commit comments