@@ -6,19 +6,29 @@ import java
6
6
import semmle.code.java.dataflow.ExternalFlow
7
7
import semmle.code.xml.AndroidManifest
8
8
9
+ /**
10
+ * Gets a transitive superType avoiding magic optimisation
11
+ */
12
+ pragma [ nomagic]
13
+ private RefType getASuperTypePlus ( RefType t ) { result = t .getASupertype + ( ) }
14
+
15
+ /**
16
+ * Gets a reflexive/transitive superType avoiding magic optimisation
17
+ */
18
+ pragma [ inline]
19
+ private RefType getASuperTypeStar ( RefType t ) { result = getASuperTypePlus ( t ) or result = t }
20
+
9
21
/**
10
22
* An Android component. That is, either an activity, a service,
11
23
* a broadcast receiver, or a content provider.
12
24
*/
13
25
class AndroidComponent extends Class {
14
26
AndroidComponent ( ) {
15
- // The casts here are due to misoptimisation if they are missing
16
- // but are not needed semantically.
17
- this .( Class ) .getASupertype * ( ) .hasQualifiedName ( "android.app" , "Activity" ) or
18
- this .( Class ) .getASupertype * ( ) .hasQualifiedName ( "android.app" , "Service" ) or
19
- this .( Class ) .getASupertype * ( ) .hasQualifiedName ( "android.content" , "BroadcastReceiver" ) or
20
- this .( Class ) .getASupertype * ( ) .hasQualifiedName ( "android.content" , "ContentProvider" ) or
21
- this .( Class ) .getASupertype * ( ) .hasQualifiedName ( "android.content" , "ContentResolver" )
27
+ getASuperTypeStar ( this ) .hasQualifiedName ( "android.app" , "Activity" ) or
28
+ getASuperTypeStar ( this ) .hasQualifiedName ( "android.app" , "Service" ) or
29
+ getASuperTypeStar ( this ) .hasQualifiedName ( "android.content" , "BroadcastReceiver" ) or
30
+ getASuperTypeStar ( this ) .hasQualifiedName ( "android.content" , "ContentProvider" ) or
31
+ getASuperTypeStar ( this ) .hasQualifiedName ( "android.content" , "ContentResolver" )
22
32
}
23
33
24
34
/** The XML element corresponding to this Android component. */
@@ -52,25 +62,25 @@ class ExportableAndroidComponent extends AndroidComponent {
52
62
53
63
/** An Android activity. */
54
64
class AndroidActivity extends ExportableAndroidComponent {
55
- AndroidActivity ( ) { this . getASupertype * ( ) .hasQualifiedName ( "android.app" , "Activity" ) }
65
+ AndroidActivity ( ) { getASuperTypeStar ( this ) .hasQualifiedName ( "android.app" , "Activity" ) }
56
66
}
57
67
58
68
/** An Android service. */
59
69
class AndroidService extends ExportableAndroidComponent {
60
- AndroidService ( ) { this . getASupertype * ( ) .hasQualifiedName ( "android.app" , "Service" ) }
70
+ AndroidService ( ) { getASuperTypeStar ( this ) .hasQualifiedName ( "android.app" , "Service" ) }
61
71
}
62
72
63
73
/** An Android broadcast receiver. */
64
74
class AndroidBroadcastReceiver extends ExportableAndroidComponent {
65
75
AndroidBroadcastReceiver ( ) {
66
- this . getASupertype * ( ) .hasQualifiedName ( "android.content" , "BroadcastReceiver" )
76
+ getASuperTypeStar ( this ) .hasQualifiedName ( "android.content" , "BroadcastReceiver" )
67
77
}
68
78
}
69
79
70
80
/** An Android content provider. */
71
81
class AndroidContentProvider extends ExportableAndroidComponent {
72
82
AndroidContentProvider ( ) {
73
- this . getASupertype * ( ) .hasQualifiedName ( "android.content" , "ContentProvider" )
83
+ getASuperTypeStar ( this ) .hasQualifiedName ( "android.content" , "ContentProvider" )
74
84
}
75
85
76
86
/**
@@ -85,7 +95,7 @@ class AndroidContentProvider extends ExportableAndroidComponent {
85
95
/** An Android content resolver. */
86
96
class AndroidContentResolver extends AndroidComponent {
87
97
AndroidContentResolver ( ) {
88
- this . getASupertype * ( ) .hasQualifiedName ( "android.content" , "ContentResolver" )
98
+ getASuperTypeStar ( this ) .hasQualifiedName ( "android.content" , "ContentResolver" )
89
99
}
90
100
}
91
101
0 commit comments