29
29
import android .content .res .Configuration ;
30
30
import android .os .Build ;
31
31
32
- import java .util .Arrays ;
33
32
import java .util .HashMap ;
34
- import java .util .List ;
35
33
import java .util .Map ;
36
34
37
35
/**
@@ -41,7 +39,7 @@ public class ShadowApplication extends ShadowContext {
41
39
42
40
private Application mHostApplication ;
43
41
44
- private Map <String , List < String > > mBroadcasts ;
42
+ private Map <String , String [] > mBroadcasts ;
45
43
46
44
private ShadowAppComponentFactory mAppComponentFactory ;
47
45
@@ -68,16 +66,19 @@ public void onCreate() {
68
66
69
67
isCallOnCreate = true ;
70
68
71
- for (Map .Entry <String , List < String > > entry : mBroadcasts .entrySet ()) {
69
+ for (Map .Entry <String , String [] > entry : mBroadcasts .entrySet ()) {
72
70
try {
73
- Class <?> clazz = mPluginClassLoader .loadClass (entry .getKey ());
71
+ String receiverClassname = entry .getKey ();
72
+ Class <?> clazz = mPluginClassLoader .loadClass (receiverClassname );
74
73
BroadcastReceiver receiver = ((BroadcastReceiver ) clazz .newInstance ());
75
- mAppComponentFactory .instantiateReceiver (mPluginClassLoader , entry . getKey () , null );
74
+ mAppComponentFactory .instantiateReceiver (mPluginClassLoader , receiverClassname , null );
76
75
77
76
IntentFilter intentFilter = new IntentFilter ();
78
- for (String action :entry .getValue ()
79
- ) {
80
- intentFilter .addAction (action );
77
+ String [] receiverActions = entry .getValue ();
78
+ if (receiverActions != null ) {
79
+ for (String action : receiverActions ) {
80
+ intentFilter .addAction (action );
81
+ }
81
82
}
82
83
registerReceiver (receiver , intentFilter );
83
84
} catch (Exception e ) {
@@ -151,10 +152,10 @@ public void setHostApplicationContextAsBase(Context hostAppContext) {
151
152
}
152
153
153
154
public void setBroadcasts (PluginManifest .ReceiverInfo [] receiverInfos ) {
154
- Map <String , List < String > > classNameToActions = new HashMap <>();
155
+ Map <String , String [] > classNameToActions = new HashMap <>();
155
156
if (receiverInfos != null ) {
156
157
for (PluginManifest .ReceiverInfo receiverInfo : receiverInfos ) {
157
- classNameToActions .put (receiverInfo .className , Arrays . asList ( receiverInfo .actions ) );
158
+ classNameToActions .put (receiverInfo .className , receiverInfo .actions );
158
159
}
159
160
}
160
161
mBroadcasts = classNameToActions ;
0 commit comments