Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(core): BroadcastReceiver不再以Wrapper方式支持 #1108

Merged
merged 1 commit into from
Nov 19, 2022

Conversation

shifujun
Copy link
Collaborator

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

Shadow对于BroadcastReceiver所需的处理只涉及onReceive方法传回的参数。
由于插件的BroadcastReceiver是通过正常的Context对象直接注册到系统中的,
所以对于系统来说这些BroadcastReceiver和宿主的其他BroadcastReceiver
没有什么区别。系统回调onReceive方法时传回的Context和Intent也都是宿主的。
其中需要把Context换回ShadowContext,Intent中的ClassLoader换回插件的。

Tencent#865#issuecomment-1134246493指出:系统控件 ViewFlipper
在 onAttachedToWindow() 方法中使用 Contenxt.registerReceiverAsUser
 方法进行广播注册;在 onDetachedFromWindow() 方法中使用
 Context.unregisterReceiver 方法进行取消广播注册。

本地提交改为通过Transform修改插件中的onReceive方法,在BroadcastReceiver
内部进行参数转换。从而避免引入新的类型,同时也不依赖如何注册和反注册Receiver。

fix Tencent#865
close Tencent#1105
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ShadowContext中unregisterReceivery可能有问题
1 participant