fix(core): BroadcastReceiver不再以Wrapper方式支持 #1108
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Shadow对于BroadcastReceiver所需的处理只涉及onReceive方法传回的参数。 由于插件的BroadcastReceiver是通过正常的Context对象直接注册到系统中的,
所以对于系统来说这些BroadcastReceiver和宿主的其他BroadcastReceiver 没有什么区别。系统回调onReceive方法时传回的Context和Intent也都是宿主的。
其中需要把Context换回ShadowContext,Intent中的ClassLoader换回插件的。
#865#issuecomment-1134246493指出:系统控件 ViewFlipper
在 onAttachedToWindow() 方法中使用 Contenxt.registerReceiverAsUser
方法进行广播注册;在 onDetachedFromWindow() 方法中使用
Context.unregisterReceiver 方法进行取消广播注册。
本地提交改为通过Transform修改插件中的onReceive方法,在BroadcastReceiver 内部进行参数转换。从而避免引入新的类型,同时也不依赖如何注册和反注册Receiver。
fix #865
close #1105