支持单进程接口

master
kangxuyao 2022-09-28 14:49:41 +08:00
parent 9473a50e65
commit e73f590f04
6 changed files with 85 additions and 47 deletions

View File

@ -91,6 +91,6 @@ kapt {
} }
dependencies { dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs') implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.finogeeks.lib:finapplet:2.38.1' implementation 'com.finogeeks.lib:finapplet:2.38.0-alpha20220927v03'
implementation 'com.finogeeks.mop:plugins:2.38.1' implementation 'com.finogeeks.mop:plugins:2.38.1'
} }

View File

@ -63,23 +63,31 @@ public class AppletModule extends BaseApi {
Integer sequence = (Integer) param.get("sequence"); Integer sequence = (Integer) param.get("sequence");
Map<String, String> params = (Map) param.get("params"); Map<String, String> params = (Map) param.get("params");
String apiServer = (String) param.get("apiServer"); String apiServer = (String) param.get("apiServer");
Boolean isSingleProcess = (Boolean) param.get("isSingleProcess");
// mContextFlutterActivity // mContextFlutterActivity
// Android 6.07.0contextmContext // Android 6.07.0contextmContext
// 使Application Context // 使Application Context
Context context = mContext.getApplicationContext(); Context context = mContext.getApplicationContext();
FinAppInfo.StartParams startParams = params == null ? null : new FinAppInfo.StartParams(params.get("path"), params.get("query"), params.get("scene")); FinAppInfo.StartParams startParams = params == null ? null : new FinAppInfo.StartParams(params.get("path"), params.get("query"), params.get("scene"));
Log.d(TAG, "openApplet:" + appId + "," + param + "," + sequence + "," + apiServer); Log.d(TAG, "openApplet:" + appId + "," + param + "," + sequence + "," + apiServer + ", isSingleProcess:" + isSingleProcess);
if (apiServer != null) { if (apiServer != null) {
FinAppClient.INSTANCE.getAppletApiManager().startApplet(context, FinAppClient.INSTANCE.getAppletApiManager().startApplet(context,
IFinAppletRequest.Companion.fromAppId(apiServer, appId) IFinAppletRequest.Companion.fromAppId(apiServer, appId)
.setStartParams(startParams) .setStartParams(startParams)
.setSequence(sequence), .setSequence(sequence)
.setSingleProcess(Boolean.TRUE.equals(isSingleProcess)),
null null
); );
// FinAppClient.INSTANCE.getAppletApiManager().startApplet(context, apiServer, appId, sequence, startParams,null); // FinAppClient.INSTANCE.getAppletApiManager().startApplet(context, apiServer, appId, sequence, startParams,null);
} else { } else {
FinAppClient.INSTANCE.getAppletApiManager().startApplet(context, appId, sequence, startParams,null); FinAppClient.INSTANCE.getAppletApiManager().startApplet(context,
IFinAppletRequest.Companion.fromAppId(appId)
.setStartParams(startParams)
.setSequence(sequence)
.setSingleProcess(Boolean.TRUE.equals(isSingleProcess)),
null
);
} }
// String apiServer = (String) param.get("apiServer"); // String apiServer = (String) param.get("apiServer");
@ -136,6 +144,8 @@ public class AppletModule extends BaseApi {
String apiServer = (String) param.get("apiServer"); String apiServer = (String) param.get("apiServer");
String offlineMiniprogramZipPath = (String) param.get("offlineMiniprogramZipPath"); String offlineMiniprogramZipPath = (String) param.get("offlineMiniprogramZipPath");
String offlineFrameworkZipPath = (String) param.get("offlineFrameworkZipPath"); String offlineFrameworkZipPath = (String) param.get("offlineFrameworkZipPath");
Boolean isSingleProcess = (Boolean) param.get("isSingleProcess");
Log.d("MopPlugin", "startApplet (appId=" + appId + ", sequence=" + sequence + " apiServer=" + apiServer + ")"); Log.d("MopPlugin", "startApplet (appId=" + appId + ", sequence=" + sequence + " apiServer=" + apiServer + ")");
// mContextFlutterActivity // mContextFlutterActivity
// Android 6.07.0contextmContext // Android 6.07.0contextmContext
@ -149,7 +159,8 @@ public class AppletModule extends BaseApi {
IFinAppletRequest.Companion.fromAppId(apiServer, appId) IFinAppletRequest.Companion.fromAppId(apiServer, appId)
.setSequence(sequence) .setSequence(sequence)
.setStartParams(params) .setStartParams(params)
.setOfflineParams(offlineFrameworkZipPath, offlineMiniprogramZipPath), .setOfflineParams(offlineFrameworkZipPath, offlineMiniprogramZipPath)
.setSingleProcess(Boolean.TRUE.equals(isSingleProcess)),
null); null);
// request // request
// FinAppClient.INSTANCE.getAppletApiManager().startApplet(context, IFinAppletRequest.Companion.fromAppId("apiServer", "appId") // FinAppClient.INSTANCE.getAppletApiManager().startApplet(context, IFinAppletRequest.Companion.fromAppId("apiServer", "appId")
@ -159,14 +170,18 @@ public class AppletModule extends BaseApi {
private void scanOpenApplet(Map param, ICallback callback) { private void scanOpenApplet(Map param, ICallback callback) {
String info = String.valueOf(param.get("info")); String info = String.valueOf(param.get("info"));
FinAppClient.INSTANCE.getAppletApiManager().startApplet(mContext, IFinAppletRequest.Companion.fromDecrypt(info), null); Boolean isSingleProcess = (Boolean) param.get("isSingleProcess");
FinAppClient.INSTANCE.getAppletApiManager().startApplet(mContext, IFinAppletRequest.Companion.fromDecrypt(info)
.setSingleProcess(Boolean.TRUE.equals(isSingleProcess)), null);
// FinAppClient.INSTANCE.getAppletApiManager().startApplet(mContext, new StartAppletDecryptRequest(info),null); // FinAppClient.INSTANCE.getAppletApiManager().startApplet(mContext, new StartAppletDecryptRequest(info),null);
callback.onSuccess(new HashMap()); callback.onSuccess(new HashMap());
} }
private void qrcodeOpenApplet(Map param, ICallback callback){ private void qrcodeOpenApplet(Map param, ICallback callback){
String qrcode = String.valueOf(param.get("qrcode")); String qrcode = String.valueOf(param.get("qrcode"));
FinAppClient.INSTANCE.getAppletApiManager().startApplet(mContext, IFinAppletRequest.Companion.fromQrCode(qrcode), new FinCallback<String>() { Boolean isSingleProcess = (Boolean) param.get("isSingleProcess");
FinAppClient.INSTANCE.getAppletApiManager().startApplet(mContext, IFinAppletRequest.Companion.fromQrCode(qrcode)
.setSingleProcess(Boolean.TRUE.equals(isSingleProcess)), new FinCallback<String>() {
@Override @Override
public void onSuccess(String s) { public void onSuccess(String s) {
callback.onSuccess(new HashMap()); callback.onSuccess(new HashMap());

View File

@ -12,9 +12,11 @@ import com.finogeeks.lib.applet.interfaces.FinCallback;
import com.finogeeks.mop.api.BaseApi; import com.finogeeks.mop.api.BaseApi;
import com.finogeeks.mop.interfaces.ICallback; import com.finogeeks.mop.interfaces.ICallback;
import com.finogeeks.mop.service.MopPluginService; import com.finogeeks.mop.service.MopPluginService;
import com.finogeeks.xlog.XLogLevel;
import com.google.gson.Gson; import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken; import com.google.gson.reflect.TypeToken;
import java.io.File;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -121,7 +123,9 @@ public class BaseModule extends BaseApi {
.setUserId(userId) .setUserId(userId)
.setDebugMode(debug) .setDebugMode(debug)
.setDisableRequestPermissions(disablePermission) .setDisableRequestPermissions(disablePermission)
.setBindAppletWithMainProcess(bindAppletWithMainProcess); .setBindAppletWithMainProcess(bindAppletWithMainProcess)
.setLogLevel(XLogLevel.LEVEL_VERBOSE)
.setXLogDir(new File(getContext().getExternalCacheDir(),"xlog"));
// .setPageCountLimit(pageCountLimit); // .setPageCountLimit(pageCountLimit);
if (customWebViewUserAgent != null) if (customWebViewUserAgent != null)

View File

@ -42,7 +42,7 @@ packages:
name: collection name: collection
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "1.16.0" version: "1.15.0"
cupertino_icons: cupertino_icons:
dependency: "direct main" dependency: "direct main"
description: description:
@ -56,7 +56,7 @@ packages:
name: fake_async name: fake_async
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "1.3.0" version: "1.2.0"
flutter: flutter:
dependency: "direct main" dependency: "direct main"
description: flutter description: flutter
@ -95,13 +95,6 @@ packages:
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "0.12.11" version: "0.12.11"
material_color_utilities:
dependency: transitive
description:
name: material_color_utilities
url: "https://pub.flutter-io.cn"
source: hosted
version: "0.1.4"
meta: meta:
dependency: transitive dependency: transitive
description: description:
@ -115,14 +108,14 @@ packages:
path: ".." path: ".."
relative: true relative: true
source: path source: path
version: "2.37.3" version: "2.37.13"
path: path:
dependency: transitive dependency: transitive
description: description:
name: path name: path
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "1.8.1" version: "1.8.0"
sky_engine: sky_engine:
dependency: transitive dependency: transitive
description: flutter description: flutter
@ -134,7 +127,7 @@ packages:
name: source_span name: source_span
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "1.8.2" version: "1.8.1"
stack_trace: stack_trace:
dependency: transitive dependency: transitive
description: description:
@ -169,14 +162,21 @@ packages:
name: test_api name: test_api
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "0.4.9" version: "0.4.3"
typed_data:
dependency: transitive
description:
name: typed_data
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.3.0"
vector_math: vector_math:
dependency: transitive dependency: transitive
description: description:
name: vector_math name: vector_math
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "2.1.2" version: "2.1.1"
sdks: sdks:
dart: ">=2.17.0-0 <3.0.0" dart: ">=2.14.0 <3.0.0"
flutter: ">=2.2.3" flutter: ">=2.2.3"

View File

@ -225,12 +225,15 @@ class BaseAppletRequest {
Map<String, String>? startParams; Map<String, String>? startParams;
// iOStrue // iOStrue
bool? animated; bool? animated;
// androidfalse
bool isSingleProcess;
BaseAppletRequest({ BaseAppletRequest({
required this.apiServer, required this.apiServer,
required this.appletId, required this.appletId,
this.startParams, this.startParams,
this.animated = true, this.animated = true,
this.isSingleProcess = false,
}); });
Map<String, dynamic> toMap() { Map<String, dynamic> toMap() {
@ -238,7 +241,8 @@ class BaseAppletRequest {
"apiServer": apiServer, "apiServer": apiServer,
"appletId": appletId, "appletId": appletId,
"startParams": startParams, "startParams": startParams,
"animated": animated "animated": animated,
"isSingleProcess": isSingleProcess,
}; };
} }
} }
@ -258,15 +262,18 @@ class RemoteAppletRequest {
String? offlineFrameworkZipPath; String? offlineFrameworkZipPath;
// iOStrue // iOStrue
bool animated; bool animated;
// androidfalse
bool isSingleProcess;
RemoteAppletRequest({ RemoteAppletRequest({
required this.apiServer, required this.apiServer,
required this.appletId, required this.appletId,
this.startParams, this.startParams,
this.sequence, this.sequence,
this.offlineMiniprogramZipPath, this.offlineMiniprogramZipPath,
this.offlineFrameworkZipPath, this.offlineFrameworkZipPath,
this.animated = true, this.animated = true,
this.isSingleProcess = false,
}); });
@override @override
@ -274,7 +281,8 @@ class RemoteAppletRequest {
Map<String, dynamic> result = { Map<String, dynamic> result = {
"apiServer": apiServer, "apiServer": apiServer,
"appletId": appletId, "appletId": appletId,
"animated": animated "animated": animated,
"isSingleProcess": isSingleProcess,
}; };
if (startParams != null) result["startParams"] = startParams; if (startParams != null) result["startParams"] = startParams;
if (offlineMiniprogramZipPath != null) result["offlineMiniprogramZipPath"] = offlineMiniprogramZipPath; if (offlineMiniprogramZipPath != null) result["offlineMiniprogramZipPath"] = offlineMiniprogramZipPath;
@ -290,13 +298,16 @@ class QRCodeAppletRequest {
String qrCode; String qrCode;
// //
bool animated = true; bool animated = true;
// androidfalse
bool isSingleProcess;
QRCodeAppletRequest(this.qrCode); QRCodeAppletRequest(this.qrCode, {this.isSingleProcess = false});
Map<String, dynamic> toMap() { Map<String, dynamic> toMap() {
return { return {
"apiServer": qrCode, "apiServer": qrCode,
"animated": animated "animated": animated,
"isSingleProcess": isSingleProcess,
}; };
} }
} }
@ -447,6 +458,7 @@ class Mop {
final int? sequence, final int? sequence,
final String? apiServer, final String? apiServer,
final String? scene, final String? scene,
final bool isSingleProcess = false,
}) async { }) async {
Map<String, Object> params = {'appId': appId}; Map<String, Object> params = {'appId': appId};
Map param = {}; Map param = {};
@ -456,6 +468,7 @@ class Mop {
if (sequence != null) params["sequence"] = sequence; if (sequence != null) params["sequence"] = sequence;
if (apiServer != null) params["apiServer"] = apiServer; if (apiServer != null) params["apiServer"] = apiServer;
if (scene != null) param["scene"] = scene; if (scene != null) param["scene"] = scene;
params["isSingleProcess"] = isSingleProcess;
final Map ret = await _channel.invokeMethod('openApplet', params); final Map ret = await _channel.invokeMethod('openApplet', params);
return ret; return ret;
} }
@ -524,8 +537,11 @@ class Mop {
/// ///
/// -- /// --
/// ///
Future scanOpenApplet(String info) async { Future scanOpenApplet(String info, {bool isSingleProcess = false}) async {
Map<String, Object> params = {'info': info}; Map<String, Object> params = {
'info': info,
'isSingleProcess': isSingleProcess,
};
return await _channel.invokeMapMethod("scanOpenApplet", params); return await _channel.invokeMapMethod("scanOpenApplet", params);
} }
@ -533,8 +549,11 @@ class Mop {
/// ///
/// [qrcode] /// [qrcode]
/// ///
Future qrcodeOpenApplet(String qrcode) async { Future qrcodeOpenApplet(String qrcode, {bool isSingleProcess = false}) async {
Map<String, Object> params = {'qrcode': qrcode}; Map<String, Object> params = {
'qrcode': qrcode,
'isSingleProcess': isSingleProcess,
};
return await _channel.invokeMapMethod("qrcodeOpenApplet", params); return await _channel.invokeMapMethod("qrcodeOpenApplet", params);
} }

View File

@ -42,14 +42,14 @@ packages:
name: collection name: collection
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "1.16.0" version: "1.15.0"
fake_async: fake_async:
dependency: transitive dependency: transitive
description: description:
name: fake_async name: fake_async
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "1.3.0" version: "1.2.0"
flutter: flutter:
dependency: "direct main" dependency: "direct main"
description: flutter description: flutter
@ -88,13 +88,6 @@ packages:
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "0.12.11" version: "0.12.11"
material_color_utilities:
dependency: transitive
description:
name: material_color_utilities
url: "https://pub.flutter-io.cn"
source: hosted
version: "0.1.4"
meta: meta:
dependency: transitive dependency: transitive
description: description:
@ -108,7 +101,7 @@ packages:
name: path name: path
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "1.8.1" version: "1.8.0"
sky_engine: sky_engine:
dependency: transitive dependency: transitive
description: flutter description: flutter
@ -120,7 +113,7 @@ packages:
name: source_span name: source_span
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "1.8.2" version: "1.8.1"
stack_trace: stack_trace:
dependency: transitive dependency: transitive
description: description:
@ -155,14 +148,21 @@ packages:
name: test_api name: test_api
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "0.4.9" version: "0.4.3"
typed_data:
dependency: transitive
description:
name: typed_data
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.3.0"
vector_math: vector_math:
dependency: transitive dependency: transitive
description: description:
name: vector_math name: vector_math
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "2.1.2" version: "2.1.1"
sdks: sdks:
dart: ">=2.17.0-0 <3.0.0" dart: ">=2.14.0 <3.0.0"
flutter: ">=2.2.3" flutter: ">=2.2.3"