File tree Expand file tree Collapse file tree 2 files changed +21
-11
lines changed Expand file tree Collapse file tree 2 files changed +21
-11
lines changed Original file line number Diff line number Diff line change @@ -6,21 +6,16 @@ import java
66private import semmle.code.xml.AndroidManifest
77
88/**
9- * There is an android manifest file which defines an activity, service or
10- * content provider (so it corresponds to an android application rather than a
11- * library), and `file` is in a subfolder of the folder that contains it .
9+ * Holds if in `file`'s directory or some parent directory there is an `AndroidManifestXmlFile`
10+ * that defines at least one activity, service or contest provider, suggesting this file is
11+ * part of an android application .
1212 */
1313predicate inAndroidApplication ( File file ) {
1414 file .isSourceFile ( ) and
15- exists ( AndroidComponentXmlElement acxe , AndroidManifestXmlFile amxf |
16- amxf .getManifestElement ( ) .getApplicationElement ( ) .getAComponentElement ( ) = acxe and
17- (
18- acxe instanceof AndroidActivityXmlElement or
19- acxe instanceof AndroidServiceXmlElement or
20- acxe instanceof AndroidProviderXmlElement
21- )
15+ exists ( AndroidManifestXmlFile amxf , Folder amxfDir |
16+ amxf .definesAndroidApplication ( ) and amxfDir = amxf .getParentContainer ( )
2217 |
23- file .getParentContainer + ( ) = amxf . getParentContainer ( )
18+ file .getParentContainer + ( ) = amxfDir
2419 )
2520}
2621
Original file line number Diff line number Diff line change @@ -23,6 +23,21 @@ class AndroidManifestXmlFile extends XmlFile {
2323 * Holds if this Android manifest file is located in a build directory.
2424 */
2525 predicate isInBuildDirectory ( ) { this .getFile ( ) .getRelativePath ( ) .matches ( "%build%" ) }
26+
27+ /**
28+ * Holds if `amxf` defines at least one activity, service or contest provider,
29+ * and so it corresponds to an android application rather than a library.
30+ */
31+ predicate definesAndroidApplication ( ) {
32+ exists ( AndroidComponentXmlElement acxe |
33+ this .getManifestElement ( ) .getApplicationElement ( ) .getAComponentElement ( ) = acxe and
34+ (
35+ acxe instanceof AndroidActivityXmlElement or
36+ acxe instanceof AndroidServiceXmlElement or
37+ acxe instanceof AndroidProviderXmlElement
38+ )
39+ )
40+ }
2641}
2742
2843/**
You can’t perform that action at this time.
0 commit comments