@@ -6,19 +6,29 @@ import java
66import semmle.code.java.dataflow.ExternalFlow
77import semmle.code.xml.AndroidManifest
88
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+
921/**
1022 * An Android component. That is, either an activity, a service,
1123 * a broadcast receiver, or a content provider.
1224 */
1325class AndroidComponent extends Class {
1426 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" )
2232 }
2333
2434 /** The XML element corresponding to this Android component. */
@@ -52,25 +62,25 @@ class ExportableAndroidComponent extends AndroidComponent {
5262
5363/** An Android activity. */
5464class AndroidActivity extends ExportableAndroidComponent {
55- AndroidActivity ( ) { this . getASupertype * ( ) .hasQualifiedName ( "android.app" , "Activity" ) }
65+ AndroidActivity ( ) { getASuperTypeStar ( this ) .hasQualifiedName ( "android.app" , "Activity" ) }
5666}
5767
5868/** An Android service. */
5969class AndroidService extends ExportableAndroidComponent {
60- AndroidService ( ) { this . getASupertype * ( ) .hasQualifiedName ( "android.app" , "Service" ) }
70+ AndroidService ( ) { getASuperTypeStar ( this ) .hasQualifiedName ( "android.app" , "Service" ) }
6171}
6272
6373/** An Android broadcast receiver. */
6474class AndroidBroadcastReceiver extends ExportableAndroidComponent {
6575 AndroidBroadcastReceiver ( ) {
66- this . getASupertype * ( ) .hasQualifiedName ( "android.content" , "BroadcastReceiver" )
76+ getASuperTypeStar ( this ) .hasQualifiedName ( "android.content" , "BroadcastReceiver" )
6777 }
6878}
6979
7080/** An Android content provider. */
7181class AndroidContentProvider extends ExportableAndroidComponent {
7282 AndroidContentProvider ( ) {
73- this . getASupertype * ( ) .hasQualifiedName ( "android.content" , "ContentProvider" )
83+ getASuperTypeStar ( this ) .hasQualifiedName ( "android.content" , "ContentProvider" )
7484 }
7585
7686 /**
@@ -85,7 +95,7 @@ class AndroidContentProvider extends ExportableAndroidComponent {
8595/** An Android content resolver. */
8696class AndroidContentResolver extends AndroidComponent {
8797 AndroidContentResolver ( ) {
88- this . getASupertype * ( ) .hasQualifiedName ( "android.content" , "ContentResolver" )
98+ getASuperTypeStar ( this ) .hasQualifiedName ( "android.content" , "ContentResolver" )
8999 }
90100}
91101
0 commit comments