Fixed
Status Update
Comments
ap...@google.com <ap...@google.com> #2
Project: platform/frameworks/support
Branch: androidx-main
commit 57ca221882695bd6a52549f4d9ea3b812e6fe87c
Author: Simon Schiller <simonschiller@users.noreply.github.com>
Date: Mon Mar 22 16:09:30 2021
[GH] [FragmentStrictMode] Detect <fragment> tag usage
## Proposed Changes
- Detect `<fragment>` tag usage inside XML layouts
## Testing
Test: See `FragmentStrictModeTest#detectFragmentTagUsage`
## Issues Fixed
Fixes: 153738235
This is an imported pull request fromhttps://github.com/androidx/androidx/pull/141 .
Resolves #141
Github-Pr-Head-Sha: 4ea052596e4341b9f11bcf335e2bc38045a91f19
GitOrigin-RevId: 62e7487aa4874eef6bb556490e193717cf937251
Change-Id: Iae48578e85e4e4897f806d7ade2e2a660adf9479
M fragment/fragment/api/public_plus_experimental_current.txt
M fragment/fragment/api/restricted_current.txt
M fragment/fragment/src/androidTest/java/androidx/fragment/app/strictmode/FragmentStrictModeTest.kt
M fragment/fragment/src/main/java/androidx/fragment/app/FragmentLayoutInflaterFactory.java
M fragment/fragment/src/main/java/androidx/fragment/app/strictmode/FragmentStrictMode.java
A fragment/fragment/src/main/java/androidx/fragment/app/strictmode/FragmentTagUsageViolation.java
https://android-review.googlesource.com/1649748
Branch: androidx-main
commit 57ca221882695bd6a52549f4d9ea3b812e6fe87c
Author: Simon Schiller <simonschiller@users.noreply.github.com>
Date: Mon Mar 22 16:09:30 2021
[GH] [FragmentStrictMode] Detect <fragment> tag usage
## Proposed Changes
- Detect `<fragment>` tag usage inside XML layouts
## Testing
Test: See `FragmentStrictModeTest#detectFragmentTagUsage`
## Issues Fixed
Fixes: 153738235
This is an imported pull request from
Resolves #141
Github-Pr-Head-Sha: 4ea052596e4341b9f11bcf335e2bc38045a91f19
GitOrigin-RevId: 62e7487aa4874eef6bb556490e193717cf937251
Change-Id: Iae48578e85e4e4897f806d7ade2e2a660adf9479
M fragment/fragment/api/public_plus_experimental_current.txt
M fragment/fragment/api/restricted_current.txt
M fragment/fragment/src/androidTest/java/androidx/fragment/app/strictmode/FragmentStrictModeTest.kt
M fragment/fragment/src/main/java/androidx/fragment/app/FragmentLayoutInflaterFactory.java
M fragment/fragment/src/main/java/androidx/fragment/app/strictmode/FragmentStrictMode.java
A fragment/fragment/src/main/java/androidx/fragment/app/strictmode/FragmentTagUsageViolation.java
ap...@google.com <ap...@google.com> #3
Project: platform/frameworks/support
Branch: androidx-main
commit c089c772cb6332c8a8a1f685d3bcf235221176e9
Author: Sanura N'Jaka <sanura@google.com>
Date: Wed May 19 23:54:34 2021
Expand Violation class to contain the Fragment
causing the Violation
Expanding the Violation class and those extending
from it to contain the Fragment that is causing
that Violation. This will be useful for better
error messaging.
RelNote: "The `Violation` class and those extending
from it now contain the `Fragment` that caused the
violation."
Bug: 187871150
Test: ./gradlew updateApi
Change-Id: If5118b1a169e4050620d4aac084d4692393e4e04
M fragment/fragment/api/current.txt
M fragment/fragment/api/public_plus_experimental_current.txt
M fragment/fragment/api/restricted_current.txt
M fragment/fragment/src/androidTest/java/androidx/fragment/app/strictmode/FragmentStrictModeTest.kt
M fragment/fragment/src/main/java/androidx/fragment/app/strictmode/FragmentReuseViolation.java
M fragment/fragment/src/main/java/androidx/fragment/app/strictmode/FragmentStrictMode.java
M fragment/fragment/src/main/java/androidx/fragment/app/strictmode/FragmentTagUsageViolation.java
M fragment/fragment/src/main/java/androidx/fragment/app/strictmode/RetainInstanceUsageViolation.java
M fragment/fragment/src/main/java/androidx/fragment/app/strictmode/SetUserVisibleHintViolation.java
M fragment/fragment/src/main/java/androidx/fragment/app/strictmode/TargetFragmentUsageViolation.java
M fragment/fragment/src/main/java/androidx/fragment/app/strictmode/Violation.java
M fragment/fragment/src/main/java/androidx/fragment/app/strictmode/WrongFragmentContainerViolation.java
https://android-review.googlesource.com/1712557
Branch: androidx-main
commit c089c772cb6332c8a8a1f685d3bcf235221176e9
Author: Sanura N'Jaka <sanura@google.com>
Date: Wed May 19 23:54:34 2021
Expand Violation class to contain the Fragment
causing the Violation
Expanding the Violation class and those extending
from it to contain the Fragment that is causing
that Violation. This will be useful for better
error messaging.
RelNote: "The `Violation` class and those extending
from it now contain the `Fragment` that caused the
violation."
Bug: 187871150
Test: ./gradlew updateApi
Change-Id: If5118b1a169e4050620d4aac084d4692393e4e04
M fragment/fragment/api/current.txt
M fragment/fragment/api/public_plus_experimental_current.txt
M fragment/fragment/api/restricted_current.txt
M fragment/fragment/src/androidTest/java/androidx/fragment/app/strictmode/FragmentStrictModeTest.kt
M fragment/fragment/src/main/java/androidx/fragment/app/strictmode/FragmentReuseViolation.java
M fragment/fragment/src/main/java/androidx/fragment/app/strictmode/FragmentStrictMode.java
M fragment/fragment/src/main/java/androidx/fragment/app/strictmode/FragmentTagUsageViolation.java
M fragment/fragment/src/main/java/androidx/fragment/app/strictmode/RetainInstanceUsageViolation.java
M fragment/fragment/src/main/java/androidx/fragment/app/strictmode/SetUserVisibleHintViolation.java
M fragment/fragment/src/main/java/androidx/fragment/app/strictmode/TargetFragmentUsageViolation.java
M fragment/fragment/src/main/java/androidx/fragment/app/strictmode/Violation.java
M fragment/fragment/src/main/java/androidx/fragment/app/strictmode/WrongFragmentContainerViolation.java
ap...@google.com <ap...@google.com> #4
Project: platform/frameworks/support
Branch: androidx-main
commit 4b311dadfa55ac583c4a591633dc09f9c85926aa
Author: Sanura N'Jaka <sanura@google.com>
Date: Thu May 20 00:26:17 2021
Expand FragmentTagUsageViolation to contain the
parent ViewGroup that the Fragment would have
been added to
Expanding FragmentTagUsageViolation to contain
the parent ViewGroup container that the Fragment
causing the violation would have been added to.
RelNote: "`FragmentTagUsageViolation` now contains
the parent ViewGroup container that the Fragment
causing the violation would have been added to."
Bug: 187871150
Test: ./gradlew checkApi
Change-Id: I5dbbc3bc1e318dca326b2d58ad5e9b421e33b072
M fragment/fragment/api/current.txt
M fragment/fragment/api/public_plus_experimental_current.txt
M fragment/fragment/api/restricted_current.txt
M fragment/fragment/src/main/java/androidx/fragment/app/FragmentLayoutInflaterFactory.java
M fragment/fragment/src/main/java/androidx/fragment/app/strictmode/FragmentStrictMode.java
M fragment/fragment/src/main/java/androidx/fragment/app/strictmode/FragmentTagUsageViolation.java
https://android-review.googlesource.com/1712486
Branch: androidx-main
commit 4b311dadfa55ac583c4a591633dc09f9c85926aa
Author: Sanura N'Jaka <sanura@google.com>
Date: Thu May 20 00:26:17 2021
Expand FragmentTagUsageViolation to contain the
parent ViewGroup that the Fragment would have
been added to
Expanding FragmentTagUsageViolation to contain
the parent ViewGroup container that the Fragment
causing the violation would have been added to.
RelNote: "`FragmentTagUsageViolation` now contains
the parent ViewGroup container that the Fragment
causing the violation would have been added to."
Bug: 187871150
Test: ./gradlew checkApi
Change-Id: I5dbbc3bc1e318dca326b2d58ad5e9b421e33b072
M fragment/fragment/api/current.txt
M fragment/fragment/api/public_plus_experimental_current.txt
M fragment/fragment/api/restricted_current.txt
M fragment/fragment/src/main/java/androidx/fragment/app/FragmentLayoutInflaterFactory.java
M fragment/fragment/src/main/java/androidx/fragment/app/strictmode/FragmentStrictMode.java
M fragment/fragment/src/main/java/androidx/fragment/app/strictmode/FragmentTagUsageViolation.java
ap...@google.com <ap...@google.com> #5
Project: platform/frameworks/support
Branch: androidx-main
commit 547d5a1f7ae587fb7a7548ca39b4708a28edb432
Author: Sanura N'Jaka <sanura@google.com>
Date: Thu May 20 01:18:12 2021
Separate TargetFragmentUsageViolation into 3 subclasses
representing the three cases of the violation
Separating TargetFragmentUsageViolation into 3 subclasses,
SetTargetFragmentUsageViolation, GetTargetFragmentUsageViolation,
and GetTargetFragmentRequestCodeUsageViolation, representing
the three cases of the violation.
RelNote: "`TargetFragmentUsageViolation` is now abstract and
has 3 subclasses, `SetTargetFragmentUsageViolation`,
`GetTargetFragmentUsageViolation`, and
`GetTargetFragmentRequestCodeUsageViolation`, representing
the 3 cases that can cause the violation."
Bug: 187871150
Test: ./gradlew checkApi
Change-Id: I741b4e0b8aff45babe1a453d41149c7972538789
M fragment/fragment/api/current.txt
M fragment/fragment/api/public_plus_experimental_current.txt
M fragment/fragment/api/restricted_current.txt
M fragment/fragment/src/androidTest/java/androidx/fragment/app/strictmode/FragmentStrictModeTest.kt
M fragment/fragment/src/main/java/androidx/fragment/app/Fragment.java
M fragment/fragment/src/main/java/androidx/fragment/app/strictmode/FragmentStrictMode.java
A fragment/fragment/src/main/java/androidx/fragment/app/strictmode/GetTargetFragmentRequestCodeUsageViolation.java
A fragment/fragment/src/main/java/androidx/fragment/app/strictmode/GetTargetFragmentUsageViolation.java
A fragment/fragment/src/main/java/androidx/fragment/app/strictmode/SetTargetFragmentUsageViolation.java
M fragment/fragment/src/main/java/androidx/fragment/app/strictmode/TargetFragmentUsageViolation.java
https://android-review.googlesource.com/1713429
Branch: androidx-main
commit 547d5a1f7ae587fb7a7548ca39b4708a28edb432
Author: Sanura N'Jaka <sanura@google.com>
Date: Thu May 20 01:18:12 2021
Separate TargetFragmentUsageViolation into 3 subclasses
representing the three cases of the violation
Separating TargetFragmentUsageViolation into 3 subclasses,
SetTargetFragmentUsageViolation, GetTargetFragmentUsageViolation,
and GetTargetFragmentRequestCodeUsageViolation, representing
the three cases of the violation.
RelNote: "`TargetFragmentUsageViolation` is now abstract and
has 3 subclasses, `SetTargetFragmentUsageViolation`,
`GetTargetFragmentUsageViolation`, and
`GetTargetFragmentRequestCodeUsageViolation`, representing
the 3 cases that can cause the violation."
Bug: 187871150
Test: ./gradlew checkApi
Change-Id: I741b4e0b8aff45babe1a453d41149c7972538789
M fragment/fragment/api/current.txt
M fragment/fragment/api/public_plus_experimental_current.txt
M fragment/fragment/api/restricted_current.txt
M fragment/fragment/src/androidTest/java/androidx/fragment/app/strictmode/FragmentStrictModeTest.kt
M fragment/fragment/src/main/java/androidx/fragment/app/Fragment.java
M fragment/fragment/src/main/java/androidx/fragment/app/strictmode/FragmentStrictMode.java
A fragment/fragment/src/main/java/androidx/fragment/app/strictmode/GetTargetFragmentRequestCodeUsageViolation.java
A fragment/fragment/src/main/java/androidx/fragment/app/strictmode/GetTargetFragmentUsageViolation.java
A fragment/fragment/src/main/java/androidx/fragment/app/strictmode/SetTargetFragmentUsageViolation.java
M fragment/fragment/src/main/java/androidx/fragment/app/strictmode/TargetFragmentUsageViolation.java
ap...@google.com <ap...@google.com> #6
Project: platform/frameworks/support
Branch: androidx-main
commit 95b7424210db5f4e0d432d23c4d072b7b8022157
Author: Sanura N'Jaka <sanura@google.com>
Date: Thu May 20 01:03:19 2021
Expand SetUserVisibleHintViolation to contain whether
the Fragment was being set isVisibleToUser or not
Expanding SetUserVisibleHintViolation to contain whether
the Fragment causing the violation was being set
isVisibleToUser or not.
RelNote: "`SetUserVisibleHintViolation` now contains
whether the `Fragment` causing the violation was being
set `isVisibleToUser` or not."
Bug: 187871150
Test: ./gradlew checkApi
Change-Id: I0058552a0176f3e964ceda122b1eb2540490d1a5
M fragment/fragment/api/current.txt
M fragment/fragment/api/public_plus_experimental_current.txt
M fragment/fragment/api/restricted_current.txt
M fragment/fragment/src/main/java/androidx/fragment/app/Fragment.java
M fragment/fragment/src/main/java/androidx/fragment/app/strictmode/FragmentStrictMode.java
M fragment/fragment/src/main/java/androidx/fragment/app/strictmode/FragmentTagUsageViolation.java
M fragment/fragment/src/main/java/androidx/fragment/app/strictmode/SetUserVisibleHintViolation.java
https://android-review.googlesource.com/1713428
Branch: androidx-main
commit 95b7424210db5f4e0d432d23c4d072b7b8022157
Author: Sanura N'Jaka <sanura@google.com>
Date: Thu May 20 01:03:19 2021
Expand SetUserVisibleHintViolation to contain whether
the Fragment was being set isVisibleToUser or not
Expanding SetUserVisibleHintViolation to contain whether
the Fragment causing the violation was being set
isVisibleToUser or not.
RelNote: "`SetUserVisibleHintViolation` now contains
whether the `Fragment` causing the violation was being
set `isVisibleToUser` or not."
Bug: 187871150
Test: ./gradlew checkApi
Change-Id: I0058552a0176f3e964ceda122b1eb2540490d1a5
M fragment/fragment/api/current.txt
M fragment/fragment/api/public_plus_experimental_current.txt
M fragment/fragment/api/restricted_current.txt
M fragment/fragment/src/main/java/androidx/fragment/app/Fragment.java
M fragment/fragment/src/main/java/androidx/fragment/app/strictmode/FragmentStrictMode.java
M fragment/fragment/src/main/java/androidx/fragment/app/strictmode/FragmentTagUsageViolation.java
M fragment/fragment/src/main/java/androidx/fragment/app/strictmode/SetUserVisibleHintViolation.java
ap...@google.com <ap...@google.com> #7
Project: platform/frameworks/support
Branch: androidx-main
commit 0ccc9e762bff9aaa2681c327d72dd96114853c20
Author: Sanura N'Jaka <sanura@google.com>
Date: Thu May 20 00:49:23 2021
Separate RetainInstanceUsageViolation into
two subclasses distinguishes the two cases
Separating RetainInstanceUsageViolation into two
subclasses, SetRetainInstanceUsageViolation and
GetRetainInstanceUsageViolation, representing the
two cases for this violation type.
RelNote: "`RetainInstanceUsageViolation` is now
abstract and has two subclasses, `SetRetainInstanceUsageViolation`
and `GetRetainInstanceUsageViolation`, representing the two
cases for the violation type."
Bug: 187871150
Test: ./gradlew checkApi
Change-Id: Ic81e5ce6a552f47137cf9d101bc6ce81a3f61db3
M fragment/fragment/api/current.txt
M fragment/fragment/api/public_plus_experimental_current.txt
M fragment/fragment/api/restricted_current.txt
M fragment/fragment/src/androidTest/java/androidx/fragment/app/strictmode/FragmentStrictModeTest.kt
M fragment/fragment/src/main/java/androidx/fragment/app/Fragment.java
M fragment/fragment/src/main/java/androidx/fragment/app/strictmode/FragmentStrictMode.java
A fragment/fragment/src/main/java/androidx/fragment/app/strictmode/GetRetainInstanceUsageViolation.java
M fragment/fragment/src/main/java/androidx/fragment/app/strictmode/RetainInstanceUsageViolation.java
A fragment/fragment/src/main/java/androidx/fragment/app/strictmode/SetRetainInstanceUsageViolation.java
https://android-review.googlesource.com/1712487
Branch: androidx-main
commit 0ccc9e762bff9aaa2681c327d72dd96114853c20
Author: Sanura N'Jaka <sanura@google.com>
Date: Thu May 20 00:49:23 2021
Separate RetainInstanceUsageViolation into
two subclasses distinguishes the two cases
Separating RetainInstanceUsageViolation into two
subclasses, SetRetainInstanceUsageViolation and
GetRetainInstanceUsageViolation, representing the
two cases for this violation type.
RelNote: "`RetainInstanceUsageViolation` is now
abstract and has two subclasses, `SetRetainInstanceUsageViolation`
and `GetRetainInstanceUsageViolation`, representing the two
cases for the violation type."
Bug: 187871150
Test: ./gradlew checkApi
Change-Id: Ic81e5ce6a552f47137cf9d101bc6ce81a3f61db3
M fragment/fragment/api/current.txt
M fragment/fragment/api/public_plus_experimental_current.txt
M fragment/fragment/api/restricted_current.txt
M fragment/fragment/src/androidTest/java/androidx/fragment/app/strictmode/FragmentStrictModeTest.kt
M fragment/fragment/src/main/java/androidx/fragment/app/Fragment.java
M fragment/fragment/src/main/java/androidx/fragment/app/strictmode/FragmentStrictMode.java
A fragment/fragment/src/main/java/androidx/fragment/app/strictmode/GetRetainInstanceUsageViolation.java
M fragment/fragment/src/main/java/androidx/fragment/app/strictmode/RetainInstanceUsageViolation.java
A fragment/fragment/src/main/java/androidx/fragment/app/strictmode/SetRetainInstanceUsageViolation.java
ap...@google.com <ap...@google.com> #8
Project: platform/frameworks/support
Branch: androidx-main
commit 260563499d2b7f8a5c9e0fd5d4b66eb9f1697609
Author: Sanura N'Jaka <sanura@google.com>
Date: Thu May 20 01:27:28 2021
Expand WrongFragmentContainerViolation to contain
the ViewGroup container that the Fragment was trying
to be added to
Expanding WrongFragmentContainerViolation to contain
the ViewGroup container that the Fragment causing the
violation was trying to be added to. This will be
helpful in error messging.
RelNote: "`WrongFragmentContainerViolation` now contains
the `ViewGroup` container that the `Fragment` causing the
violation was trying to be added to."
Bug: 187871150
Test: ./gradlew checkApi
Change-Id: I83c75a2b30f2defef7868e6d1b1d7ea63e576c57
M fragment/fragment/api/current.txt
M fragment/fragment/api/public_plus_experimental_current.txt
M fragment/fragment/api/restricted_current.txt
M fragment/fragment/src/main/java/androidx/fragment/app/FragmentStateManager.java
M fragment/fragment/src/main/java/androidx/fragment/app/strictmode/FragmentStrictMode.java
M fragment/fragment/src/main/java/androidx/fragment/app/strictmode/WrongFragmentContainerViolation.java
https://android-review.googlesource.com/1713430
Branch: androidx-main
commit 260563499d2b7f8a5c9e0fd5d4b66eb9f1697609
Author: Sanura N'Jaka <sanura@google.com>
Date: Thu May 20 01:27:28 2021
Expand WrongFragmentContainerViolation to contain
the ViewGroup container that the Fragment was trying
to be added to
Expanding WrongFragmentContainerViolation to contain
the ViewGroup container that the Fragment causing the
violation was trying to be added to. This will be
helpful in error messging.
RelNote: "`WrongFragmentContainerViolation` now contains
the `ViewGroup` container that the `Fragment` causing the
violation was trying to be added to."
Bug: 187871150
Test: ./gradlew checkApi
Change-Id: I83c75a2b30f2defef7868e6d1b1d7ea63e576c57
M fragment/fragment/api/current.txt
M fragment/fragment/api/public_plus_experimental_current.txt
M fragment/fragment/api/restricted_current.txt
M fragment/fragment/src/main/java/androidx/fragment/app/FragmentStateManager.java
M fragment/fragment/src/main/java/androidx/fragment/app/strictmode/FragmentStrictMode.java
M fragment/fragment/src/main/java/androidx/fragment/app/strictmode/WrongFragmentContainerViolation.java
jb...@google.com <jb...@google.com> #9
This has been fixed internally and will be available in the Fragment 1.4.0-alpha02
release.
Description
Component used: Fragment Version used: 1.4.0-alpha01
Each instance of
androidx.fragment.strictmode.Violation
tracks a specific type of StrictMode violation. Ideally, each subclass of Violation should have enough structured information (i.e., getters) to allow developers to verify exactly what caused the violation. This could include the Fragment instance itself or violation specific information. This would greatly improve the ability to have custom loggers extract this information and parse it in a useful way.The base
Violation
class should have agetFragment()
method that returns a NonNullFragment
instance that caused the Violation.Examples of information I'd expect to be available:
FragmentReuseViolation
:mRemoved
flag with amPreviousWho
nullable String).FragmentTagUsageViolation
:ViewGroup
that the Fragment would have been added to.RetainInstanceUsageViolation
:RetainInstanceUsageViolation
:SetRetainInstanceUsageViolation
andGetRetainInstanceUsageViolation
to allow distinguishing the two casesSetUserVisibleHintViolation
:boolean
indicating on whether the fragment was being setisVisibleToUser
or notTargetFragmentUsageViolation
TargetFragmentUsageViolation
:SetTargetFragmentUsageViolation
would include the targetFragment
instance and the intrequestCode
GetTargetFragmentUsageViolation
(no additional information)GetTargetFragmentRequestCodeUsageViolation
(no additional information)WrongFragmentContainerViolation
ViewGroup
container that the Fragment was trying to be added to