From 17047063da3ba5fb6b484932929759d5ba7a19b0 Mon Sep 17 00:00:00 2001 From: zjutyujf Date: Wed, 22 Nov 2017 19:29:33 +0800 Subject: [PATCH] =?UTF-8?q?[atlas-core]host=20=E5=AE=9E=E7=8E=B0=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../taobao/atlas/remote/HostTransactor.java | 16 ++++++++-------- .../taobao/atlas/remote/IRemoteContext.java | 4 ++-- .../taobao/atlas/remote/IRemoteTransactor.java | 2 +- .../atlas/remote/fragment/RemoteFragment.java | 10 +++++----- .../remote/transactor/RemoteTransactor.java | 10 +++++----- .../taobao/atlas/remote/view/RemoteView.java | 10 +++++----- .../atlas/runtime/InstrumentationHook.java | 13 +++++++++++++ 7 files changed, 39 insertions(+), 26 deletions(-) diff --git a/atlas-core/src/main/java/android/taobao/atlas/remote/HostTransactor.java b/atlas-core/src/main/java/android/taobao/atlas/remote/HostTransactor.java index e107ffdc4..f4fa53e1e 100644 --- a/atlas-core/src/main/java/android/taobao/atlas/remote/HostTransactor.java +++ b/atlas-core/src/main/java/android/taobao/atlas/remote/HostTransactor.java @@ -38,18 +38,18 @@ public static HostTransactor get(IRemote remoteItem){ - private final IRemoteTransactor hostTransactor; + private final IRemote host; private final Activity embeddedActivity; - private HostTransactor(IRemoteTransactor transactor,Activity activity){ - hostTransactor = transactor; + private HostTransactor(IRemote remote,Activity activity){ + host = remote; embeddedActivity = activity; } @Override public Bundle call(String commandName, Bundle args, IResponse callback) { - if(hostTransactor!=null) { - return hostTransactor.call(commandName, args, callback); + if(host!=null) { + return host.call(commandName, args, callback); }else{ Log.e("HostTransactor","no real transactor"); return null; @@ -57,9 +57,9 @@ public Bundle call(String commandName, Bundle args, IResponse callback) { } @Override - public T getRemoteInterface(Class interfaceClass) { - if(hostTransactor!=null) { - return hostTransactor.getRemoteInterface(interfaceClass); + public T getRemoteInterface(Class interfaceClass,Bundle args) { + if(host!=null) { + return host.getRemoteInterface(interfaceClass,args); }else{ Log.e("HostTransactor","no real transactor"); return null; diff --git a/atlas-core/src/main/java/android/taobao/atlas/remote/IRemoteContext.java b/atlas-core/src/main/java/android/taobao/atlas/remote/IRemoteContext.java index 4cf21e6b8..b76eecf7f 100644 --- a/atlas-core/src/main/java/android/taobao/atlas/remote/IRemoteContext.java +++ b/atlas-core/src/main/java/android/taobao/atlas/remote/IRemoteContext.java @@ -5,8 +5,8 @@ */ public interface IRemoteContext { - void registerHostTransactor(IRemoteTransactor transactor); + void registerHostTransactor(IRemote transactor); String getTargetBundle(); IRemote getRemoteTarget(); - IRemoteTransactor getHostTransactor(); + IRemote getHostTransactor(); } diff --git a/atlas-core/src/main/java/android/taobao/atlas/remote/IRemoteTransactor.java b/atlas-core/src/main/java/android/taobao/atlas/remote/IRemoteTransactor.java index 9445a1a2b..7c2f9ff9e 100644 --- a/atlas-core/src/main/java/android/taobao/atlas/remote/IRemoteTransactor.java +++ b/atlas-core/src/main/java/android/taobao/atlas/remote/IRemoteTransactor.java @@ -10,7 +10,7 @@ public interface IRemoteTransactor { Bundle call(String commandName, Bundle args, IResponse callback); - T getRemoteInterface(Class interfaceClass); + T getRemoteInterface(Class interfaceClass,Bundle args); interface IResponse{ void OnResponse(Bundle bundle); diff --git a/atlas-core/src/main/java/android/taobao/atlas/remote/fragment/RemoteFragment.java b/atlas-core/src/main/java/android/taobao/atlas/remote/fragment/RemoteFragment.java index ae1a25968..56474a258 100644 --- a/atlas-core/src/main/java/android/taobao/atlas/remote/fragment/RemoteFragment.java +++ b/atlas-core/src/main/java/android/taobao/atlas/remote/fragment/RemoteFragment.java @@ -57,7 +57,7 @@ public static RemoteFragment createRemoteFragment(Activity activity, String key, private Fragment targetFragment; private String targetBundleName; private Activity remoteActivity; - private IRemoteTransactor hostTransactor; + private IRemote hostTransactor; private Field mCalled ; @@ -72,12 +72,12 @@ public IRemote getRemoteTarget() { } @Override - public IRemoteTransactor getHostTransactor() { + public IRemote getHostTransactor() { return hostTransactor; } @Override - public void registerHostTransactor(IRemoteTransactor transactor) { + public void registerHostTransactor(IRemote transactor) { hostTransactor = transactor; } @@ -87,8 +87,8 @@ public Bundle call(String commandName, Bundle args, IResponse callback) { } @Override - public T getRemoteInterface(Class interfaceClass) { - return ((IRemote)targetFragment).getRemoteInterface(interfaceClass); + public T getRemoteInterface(Class interfaceClass,Bundle args) { + return ((IRemote)targetFragment).getRemoteInterface(interfaceClass,args); } private FragmentHostCallback getFragmentHostCallback(FragmentHostCallback callback){ diff --git a/atlas-core/src/main/java/android/taobao/atlas/remote/transactor/RemoteTransactor.java b/atlas-core/src/main/java/android/taobao/atlas/remote/transactor/RemoteTransactor.java index ab783b809..723fbeecb 100644 --- a/atlas-core/src/main/java/android/taobao/atlas/remote/transactor/RemoteTransactor.java +++ b/atlas-core/src/main/java/android/taobao/atlas/remote/transactor/RemoteTransactor.java @@ -31,11 +31,11 @@ public static RemoteTransactor crateRemoteTransactor(Activity activity,String ke private String targetBundleName; private Activity remoteActivity; - private IRemoteTransactor hostTransactor; + private IRemote hostTransactor; private IRemote targetTransactor; @Override - public void registerHostTransactor(IRemoteTransactor transactor) { + public void registerHostTransactor(IRemote transactor) { hostTransactor = transactor; } @@ -50,7 +50,7 @@ public IRemote getRemoteTarget() { } @Override - public IRemoteTransactor getHostTransactor() { + public IRemote getHostTransactor() { return hostTransactor; } @@ -60,7 +60,7 @@ public Bundle call(String commandName, Bundle args, IResponse callback) { } @Override - public T getRemoteInterface(Class interfaceClass) { - return targetTransactor.getRemoteInterface(interfaceClass); + public T getRemoteInterface(Class interfaceClass,Bundle args) { + return targetTransactor.getRemoteInterface(interfaceClass,args); } } diff --git a/atlas-core/src/main/java/android/taobao/atlas/remote/view/RemoteView.java b/atlas-core/src/main/java/android/taobao/atlas/remote/view/RemoteView.java index b63c8cbb3..801d92528 100644 --- a/atlas-core/src/main/java/android/taobao/atlas/remote/view/RemoteView.java +++ b/atlas-core/src/main/java/android/taobao/atlas/remote/view/RemoteView.java @@ -37,7 +37,7 @@ public static RemoteView createRemoteView(Activity activity,String remoteViewKey private IRemote targetView; private String targetBundleName; private Activity remoteActivity; - private IRemoteTransactor hostTransactor; + private IRemote hostTransactor; @Override public Bundle call(String commandName, Bundle args, IResponse callback) { @@ -49,16 +49,16 @@ public Bundle call(String commandName, Bundle args, IResponse callback) { } @Override - public T getRemoteInterface(Class interfaceClass) { + public T getRemoteInterface(Class interfaceClass,Bundle args) { if(!(targetView instanceof IRemote)){ throw new IllegalAccessError("targetView is not an implementation of : RemoteTransactor"); }else { - return ((IRemote)targetView).getRemoteInterface(interfaceClass); + return ((IRemote)targetView).getRemoteInterface(interfaceClass,args); } } @Override - public void registerHostTransactor(IRemoteTransactor transactor) { + public void registerHostTransactor(IRemote transactor) { hostTransactor = transactor; } @@ -73,7 +73,7 @@ public IRemote getRemoteTarget() { } @Override - public IRemoteTransactor getHostTransactor() { + public IRemote getHostTransactor() { return hostTransactor; } diff --git a/atlas-core/src/main/java/android/taobao/atlas/runtime/InstrumentationHook.java b/atlas-core/src/main/java/android/taobao/atlas/runtime/InstrumentationHook.java index 5f329219d..b454264a5 100644 --- a/atlas-core/src/main/java/android/taobao/atlas/runtime/InstrumentationHook.java +++ b/atlas-core/src/main/java/android/taobao/atlas/runtime/InstrumentationHook.java @@ -239,6 +239,7 @@ import android.taobao.atlas.framework.BundleImpl; import android.taobao.atlas.framework.Framework; import android.taobao.atlas.hack.AtlasHacks; +import android.taobao.atlas.hack.Hack; import android.taobao.atlas.runtime.newcomponent.activity.ActivityBridge; import android.taobao.atlas.util.FileUtils; import android.taobao.atlas.util.StringUtils; @@ -248,6 +249,7 @@ import android.view.MotionEvent; import android.content.BroadcastReceiver; import java.lang.reflect.Field; +import java.lang.reflect.Method; import java.util.ArrayList; import java.util.List; import java.util.Set; @@ -1065,6 +1067,17 @@ public void callApplicationOnCreate(Application app) { @Override public void callActivityOnDestroy(Activity activity) { mBase.callActivityOnDestroy(activity); + if(activity!=null && activity.getBaseContext() instanceof ContextImplHook){ + try { + Hack.HackedMethod scheduleFinalCleanup = AtlasHacks.ContextImpl.method("scheduleFinalCleanup",String.class,String.class); + if(scheduleFinalCleanup.getMethod()!=null){ + scheduleFinalCleanup.invoke(((ContextImplHook)activity.getBaseContext()).getBaseContext(), + activity.getClass().getName(),"Activity"); + } + } catch (Throwable e) { + e.printStackTrace(); + } + } } @Override