Skip to content

Commit 72c2040

Browse files
authored
Merge pull request #10115 from atorralba/atorralba/fragment-fix
Java: Add support for androidx.fragment.app.Fragment
2 parents 4c8926d + 3314b56 commit 72c2040

29 files changed

+742
-338
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
category: minorAnalysis
3+
---
4+
* The class `AndroidFragment` now also models the Android Jetpack version of the `Fragment` class (`androidx.fragment.app.Fragment`).

java/ql/lib/semmle/code/java/frameworks/android/Fragment.qll

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ import java
44

55
/** The class `android.app.Fragment`. */
66
class AndroidFragment extends Class {
7-
AndroidFragment() { this.getAnAncestor().hasQualifiedName("android.app", "Fragment") }
7+
AndroidFragment() {
8+
this.getAnAncestor().hasQualifiedName(["android.app", "androidx.fragment.app"], "Fragment")
9+
}
810
}
911

1012
/** The method `instantiate` of the class `android.app.Fragment`. */
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import androidx.fragment.app.Fragment;
2+
3+
public class TestFragment extends Fragment {
4+
class SecondFragment extends android.app.Fragment {
5+
}
6+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
//semmle-extractor-options: --javac-args -cp ${testdir}/../../../../stubs/google-android-9.0.0
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
| TestFragment.java:3:14:3:25 | TestFragment |
2+
| TestFragment.java:4:11:4:24 | SecondFragment |
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import java
2+
import semmle.code.java.frameworks.android.Fragment
3+
4+
from AndroidFragment f
5+
where f.getFile().getBaseName() = "TestFragment.java"
6+
select f

java/ql/test/library-tests/frameworks/android/sources/TestActivityAndFragment.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import android.app.Activity;
2-
import android.app.Fragment;
32
import android.content.Intent;
43
import android.os.Bundle;
4+
import androidx.fragment.app.Fragment;
55
import androidx.fragment.app.FragmentTransaction;
66

77
public class TestActivityAndFragment extends Activity {

java/ql/test/query-tests/security/CWE-470/MainActivity.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
11
package com.example.myapp;
22

3-
import android.app.Fragment;
43
import android.os.Bundle;
5-
import android.view.LayoutInflater;
6-
import android.view.View;
7-
import android.view.ViewGroup;
8-
import android.widget.Button;
4+
import androidx.fragment.app.Fragment;
95
import androidx.fragment.app.FragmentActivity;
106
import androidx.fragment.app.FragmentTransaction;
117

java/ql/test/stubs/google-android-9.0.0/androidx/core/app/ActivityCompat.java

Lines changed: 49 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

java/ql/test/stubs/google-android-9.0.0/androidx/core/app/SharedElementCallback.java

Lines changed: 27 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy