@@ -41,14 +41,15 @@ public class AndroidEntryPointUtils {
4141 private SootClass osClassContentProvider ;
4242 private SootClass osClassGCMBaseIntentService ;
4343 private SootClass osClassGCMListenerService ;
44+ private SootClass osClassHostApduService ;
4445 private SootClass osInterfaceServiceConnection ;
4546
4647 /**
4748 * Array containing all types of components supported in Android lifecycles
4849 */
4950 public enum ComponentType {
5051 Application , Activity , Service , Fragment , BroadcastReceiver , ContentProvider , GCMBaseIntentService ,
51- GCMListenerService , ServiceConnection , Plain
52+ GCMListenerService , HostApduService , ServiceConnection , Plain
5253 }
5354
5455 /**
@@ -68,6 +69,7 @@ public AndroidEntryPointUtils() {
6869 osClassGCMBaseIntentService = Scene .v ()
6970 .getSootClassUnsafe (AndroidEntryPointConstants .GCMBASEINTENTSERVICECLASS );
7071 osClassGCMListenerService = Scene .v ().getSootClassUnsafe (AndroidEntryPointConstants .GCMLISTENERSERVICECLASS );
72+ osClassHostApduService = Scene .v ().getSootClassUnsafe (AndroidEntryPointConstants .HOSTAPDUSERVICECLASS );
7173 osInterfaceServiceConnection = Scene .v ()
7274 .getSootClassUnsafe (AndroidEntryPointConstants .SERVICECONNECTIONINTERFACE );
7375 osClassMapActivity = Scene .v ().getSootClassUnsafe (AndroidEntryPointConstants .MAPACTIVITYCLASS );
@@ -88,17 +90,10 @@ public ComponentType getComponentType(SootClass currentClass) {
8890 FastHierarchy fh = Scene .v ().getOrMakeFastHierarchy ();
8991
9092 if (fh != null ) {
91- // (1) android.app.Application
92- if (osClassApplication != null && fh .canStoreType (currentClass .getType (), osClassApplication .getType ()))
93- ctype = ComponentType .Application ;
94- // (2) android.app.Activity
95- else if (osClassActivity != null && fh .canStoreType (currentClass .getType (), osClassActivity .getType ()))
96- ctype = ComponentType .Activity ;
97- // (3) android.app.Service
98- else if (osClassService != null && fh .canStoreType (currentClass .getType (), osClassService .getType ()))
99- ctype = ComponentType .Service ;
100- // (4) android.app.BroadcastReceiver
101- else if (osClassFragment != null && Scene .v ().getOrMakeFastHierarchy ().canStoreType (currentClass .getType (),
93+ // We first look for the specialized types
94+
95+ // (a1) android.app.Fragment
96+ if (osClassFragment != null && Scene .v ().getOrMakeFastHierarchy ().canStoreType (currentClass .getType (),
10297 osClassFragment .getType ()))
10398 ctype = ComponentType .Fragment ;
10499 else if (osClassSupportFragment != null
@@ -107,30 +102,47 @@ else if (osClassSupportFragment != null
107102 else if (osClassAndroidXFragment != null
108103 && fh .canStoreType (currentClass .getType (), osClassAndroidXFragment .getType ()))
109104 ctype = ComponentType .Fragment ;
110- // (5) android.app.BroadcastReceiver
111- else if (osClassBroadcastReceiver != null
112- && fh .canStoreType (currentClass .getType (), osClassBroadcastReceiver .getType ()))
113- ctype = ComponentType .BroadcastReceiver ;
114- // (6) android.app.ContentProvider
115- else if (osClassContentProvider != null
116- && fh .canStoreType (currentClass .getType (), osClassContentProvider .getType ()))
117- ctype = ComponentType .ContentProvider ;
118- // (7) com.google.android.gcm.GCMBaseIntentService
105+ // (a2) com.google.android.gcm.GCMBaseIntentService
119106 else if (osClassGCMBaseIntentService != null
120107 && fh .canStoreType (currentClass .getType (), osClassGCMBaseIntentService .getType ()))
121108 ctype = ComponentType .GCMBaseIntentService ;
122- // (8 ) com.google.android.gms.gcm.GcmListenerService
109+ // (a3 ) com.google.android.gms.gcm.GcmListenerService
123110 else if (osClassGCMListenerService != null
124111 && fh .canStoreType (currentClass .getType (), osClassGCMListenerService .getType ()))
125112 ctype = ComponentType .GCMListenerService ;
126- // (9) android.content.ServiceConnection
113+ // (a4) android.nfc.cardemulation.HostApduService
114+ else if (osClassHostApduService != null
115+ && fh .canStoreType (currentClass .getType (), osClassHostApduService .getType ()))
116+ ctype = ComponentType .HostApduService ;
117+ // (a5) android.content.ServiceConnection
127118 else if (osInterfaceServiceConnection != null
128119 && fh .canStoreType (currentClass .getType (), osInterfaceServiceConnection .getType ()))
129120 ctype = ComponentType .ServiceConnection ;
130- // (10 ) com.google.android.maps.MapActivity
121+ // (a6 ) com.google.android.maps.MapActivity
131122 else if (osClassMapActivity != null
132123 && fh .canStoreType (currentClass .getType (), osClassMapActivity .getType ()))
133124 ctype = ComponentType .Activity ;
125+
126+ // If the given class is not a specific type of component, we look upwards in
127+ // the hierarchy to see if we have something more generic
128+ // (b1) android.app.Application
129+ else if (osClassApplication != null
130+ && fh .canStoreType (currentClass .getType (), osClassApplication .getType ()))
131+ ctype = ComponentType .Application ;
132+ // (b2) android.app.Service
133+ else if (osClassService != null && fh .canStoreType (currentClass .getType (), osClassService .getType ()))
134+ ctype = ComponentType .Service ;
135+ // (b3) android.app.Activity
136+ else if (osClassActivity != null && fh .canStoreType (currentClass .getType (), osClassActivity .getType ()))
137+ ctype = ComponentType .Activity ;
138+ // (b4) android.app.BroadcastReceiver
139+ else if (osClassBroadcastReceiver != null
140+ && fh .canStoreType (currentClass .getType (), osClassBroadcastReceiver .getType ()))
141+ ctype = ComponentType .BroadcastReceiver ;
142+ // (b5) android.app.ContentProvider
143+ else if (osClassContentProvider != null
144+ && fh .canStoreType (currentClass .getType (), osClassContentProvider .getType ()))
145+ ctype = ComponentType .ContentProvider ;
134146 } else
135147 logger .warn (String .format ("No FastHierarchy, assuming %s is a plain class" , currentClass .getName ()));
136148
0 commit comments