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 6b225808fdf7cf51701ed40efda90eedc6d898e7
Author: Sanura N'Jaka <sanura@google.com>
Date: Mon May 24 21:05:01 2021
Add detailed error message to FragmentReuseViolation
Added more detailed error message to FragmentReuseViolation
that includes the previous id of the fragment.
RelNote: "`FragmentReuseViolation` now has more
detailed error message that includes the previous
id of the fragment."
Bug: 187871638
Test: ./gradlew checkApi
Change-Id: I28ce254ddb61dc3bf4daddfc8cc7eb6985b8b611
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/FragmentReuseViolation.java
https://android-review.googlesource.com/1717072
Branch: androidx-main
commit 6b225808fdf7cf51701ed40efda90eedc6d898e7
Author: Sanura N'Jaka <sanura@google.com>
Date: Mon May 24 21:05:01 2021
Add detailed error message to FragmentReuseViolation
Added more detailed error message to FragmentReuseViolation
that includes the previous id of the fragment.
RelNote: "`FragmentReuseViolation` now has more
detailed error message that includes the previous
id of the fragment."
Bug: 187871638
Test: ./gradlew checkApi
Change-Id: I28ce254ddb61dc3bf4daddfc8cc7eb6985b8b611
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/FragmentReuseViolation.java
ap...@google.com <ap...@google.com> #4
Project: platform/frameworks/support
Branch: androidx-main
commit 996da0dc46ce7ee4199b56b21c024ce2dc5c1411
Author: Sanura N'Jaka <sanura@google.com>
Date: Tue May 25 22:42:20 2021
Add detailed error messages to the RetainInstanceUsageViolation classes
Added more detailed error messages to the
RetainInstanceUsageViolation classes to
include the fragment causing the violation.
RelNote: "The classes extending `RetainInstanceUsageViolation`
now have more detailed error messages that include the fragment
causing the violation."
Bug: 187871638
Test: ./gradlew checkApi
Change-Id: I6bd559d35f8b4f9aa340efa3f36cb4aab782bc22
M fragment/fragment/src/androidTest/java/androidx/fragment/app/strictmode/FragmentStrictModeTest.kt
M fragment/fragment/src/main/java/androidx/fragment/app/strictmode/GetRetainInstanceUsageViolation.java
M fragment/fragment/src/main/java/androidx/fragment/app/strictmode/SetRetainInstanceUsageViolation.java
https://android-review.googlesource.com/1718631
Branch: androidx-main
commit 996da0dc46ce7ee4199b56b21c024ce2dc5c1411
Author: Sanura N'Jaka <sanura@google.com>
Date: Tue May 25 22:42:20 2021
Add detailed error messages to the RetainInstanceUsageViolation classes
Added more detailed error messages to the
RetainInstanceUsageViolation classes to
include the fragment causing the violation.
RelNote: "The classes extending `RetainInstanceUsageViolation`
now have more detailed error messages that include the fragment
causing the violation."
Bug: 187871638
Test: ./gradlew checkApi
Change-Id: I6bd559d35f8b4f9aa340efa3f36cb4aab782bc22
M fragment/fragment/src/androidTest/java/androidx/fragment/app/strictmode/FragmentStrictModeTest.kt
M fragment/fragment/src/main/java/androidx/fragment/app/strictmode/GetRetainInstanceUsageViolation.java
M fragment/fragment/src/main/java/androidx/fragment/app/strictmode/SetRetainInstanceUsageViolation.java
ap...@google.com <ap...@google.com> #5
Project: platform/frameworks/support
Branch: androidx-main
commit d2d0bb6647a1331c02b95e7fe27abd19963435bb
Author: Sanura N'Jaka <sanura@google.com>
Date: Mon May 24 21:40:10 2021
Add detailed error message to FragmentTagUsageViolation
Added more detailed error message to FragmentTagUsageViolation
that includes the parent container that the fragment would
have been added to.
RelNote: "`FragmentTagUsageViolation` now contains more
detailed error message that container the parent container
that the fragment would have been added to."
Bug: 187871638
Test: ./gradlew checkApi
Change-Id: Ic33a7bfc836a8640b04af915268f5bc9e027bde3
M fragment/fragment/src/androidTest/java/androidx/fragment/app/strictmode/FragmentStrictModeTest.kt
M fragment/fragment/src/androidTest/res/layout/activity_inflated_fragment.xml
M fragment/fragment/src/main/java/androidx/fragment/app/strictmode/FragmentTagUsageViolation.java
https://android-review.googlesource.com/1717074
Branch: androidx-main
commit d2d0bb6647a1331c02b95e7fe27abd19963435bb
Author: Sanura N'Jaka <sanura@google.com>
Date: Mon May 24 21:40:10 2021
Add detailed error message to FragmentTagUsageViolation
Added more detailed error message to FragmentTagUsageViolation
that includes the parent container that the fragment would
have been added to.
RelNote: "`FragmentTagUsageViolation` now contains more
detailed error message that container the parent container
that the fragment would have been added to."
Bug: 187871638
Test: ./gradlew checkApi
Change-Id: Ic33a7bfc836a8640b04af915268f5bc9e027bde3
M fragment/fragment/src/androidTest/java/androidx/fragment/app/strictmode/FragmentStrictModeTest.kt
M fragment/fragment/src/androidTest/res/layout/activity_inflated_fragment.xml
M fragment/fragment/src/main/java/androidx/fragment/app/strictmode/FragmentTagUsageViolation.java
ap...@google.com <ap...@google.com> #6
Project: platform/frameworks/support
Branch: androidx-main
commit aebee10e6c24c82a5701a56caf483cbebf39e24f
Author: Sanura N'Jaka <sanura@google.com>
Date: Tue May 25 22:56:47 2021
Add detailed error messages to the TargetFragmentUsageViolation classes
Added more detailed error messages to the classes
extending TargetFragmentUsageViolation to include
the fragment causing the violation and any other
contained information.
RelNote: "The use case classes for `TargetFragmentUsageViolation`
now have more detailed error messages to include the fragment
causing the violation and any other contained information."
Bug: 187871638
Test: ./gradlew checkApi
Change-Id: Icc6aceb7a1fd79894fea1837be43a3090c2af4a6
M fragment/fragment/src/androidTest/java/androidx/fragment/app/strictmode/FragmentStrictModeTest.kt
M fragment/fragment/src/main/java/androidx/fragment/app/strictmode/GetTargetFragmentRequestCodeUsageViolation.java
M fragment/fragment/src/main/java/androidx/fragment/app/strictmode/GetTargetFragmentUsageViolation.java
M fragment/fragment/src/main/java/androidx/fragment/app/strictmode/SetTargetFragmentUsageViolation.java
https://android-review.googlesource.com/1718632
Branch: androidx-main
commit aebee10e6c24c82a5701a56caf483cbebf39e24f
Author: Sanura N'Jaka <sanura@google.com>
Date: Tue May 25 22:56:47 2021
Add detailed error messages to the TargetFragmentUsageViolation classes
Added more detailed error messages to the classes
extending TargetFragmentUsageViolation to include
the fragment causing the violation and any other
contained information.
RelNote: "The use case classes for `TargetFragmentUsageViolation`
now have more detailed error messages to include the fragment
causing the violation and any other contained information."
Bug: 187871638
Test: ./gradlew checkApi
Change-Id: Icc6aceb7a1fd79894fea1837be43a3090c2af4a6
M fragment/fragment/src/androidTest/java/androidx/fragment/app/strictmode/FragmentStrictModeTest.kt
M fragment/fragment/src/main/java/androidx/fragment/app/strictmode/GetTargetFragmentRequestCodeUsageViolation.java
M fragment/fragment/src/main/java/androidx/fragment/app/strictmode/GetTargetFragmentUsageViolation.java
M fragment/fragment/src/main/java/androidx/fragment/app/strictmode/SetTargetFragmentUsageViolation.java
ap...@google.com <ap...@google.com> #7
Project: platform/frameworks/support
Branch: androidx-main
commit 41e606d14226682f62777d89ebdaf17a1e97ed26
Author: Sanura N'Jaka <sanura@google.com>
Date: Tue May 25 23:14:49 2021
Add detailed error message to WrongFragmentContainerViolation
Added more detailed error message to WrongFragmentContainerViolation
that includes the fragment causing the violation and the container
that the fragment was being added to.
RelNote: "`WrongFragmentContainerViolation` now has more
detailed error message that includes the container that
the fragment was being added to."
Bug: 187871638
Test: ./gradlew checkApi
Change-Id: Ib55f8e4c05e8e2ff6c25916df0749d820ade30d3
M fragment/fragment/src/androidTest/java/androidx/fragment/app/strictmode/FragmentStrictModeTest.kt
M fragment/fragment/src/main/java/androidx/fragment/app/strictmode/WrongFragmentContainerViolation.java
https://android-review.googlesource.com/1717941
Branch: androidx-main
commit 41e606d14226682f62777d89ebdaf17a1e97ed26
Author: Sanura N'Jaka <sanura@google.com>
Date: Tue May 25 23:14:49 2021
Add detailed error message to WrongFragmentContainerViolation
Added more detailed error message to WrongFragmentContainerViolation
that includes the fragment causing the violation and the container
that the fragment was being added to.
RelNote: "`WrongFragmentContainerViolation` now has more
detailed error message that includes the container that
the fragment was being added to."
Bug: 187871638
Test: ./gradlew checkApi
Change-Id: Ib55f8e4c05e8e2ff6c25916df0749d820ade30d3
M fragment/fragment/src/androidTest/java/androidx/fragment/app/strictmode/FragmentStrictModeTest.kt
M fragment/fragment/src/main/java/androidx/fragment/app/strictmode/WrongFragmentContainerViolation.java
il...@google.com <il...@google.com> #8
We've improved the error messages of all of the Violations. This will be available in Fragment 1.4.0-alpha03.
Description
Component used: Fragment Version used: 1.4.0-alpha01
The Fragment StrictMode outputs to the log when you use
penaltyLog()
orpenaltyDeath()
. While these print the Violation class name and the stack trace, they don't provide useful structured information that would help developers figure out the cause of the exception from only the log message.Building on top of b/187871150 , each
Violation
should use what structured information it has access to in order to override the exception message with a more useful, pre-formatted log message.We should still keep the currently used 'Policy violation in $fragmentName' message (as the exception message will be included in the output of the violation as the
Exception
parameter to theLog
call.