Fixed
Status Update
Comments
vi...@google.com <vi...@google.com>
ra...@google.com <ra...@google.com>
il...@google.com <il...@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 45e2dd162009cdc2823264ee9554c148849c6021
Author: Jeremy Woods <jbwoods@google.com>
Date: Wed Jan 12 16:29:58 2022
Allow negative view ids in fragmentContainerView
When inflating views from xml, FragmentContainerView incorrectly
required that the view ID be a positive int value.
The proper check is just that the view has an id.
RelNote: "`FragmentContainerView` no longer throws an illegal state
exception when view ids generated from xml have negative values."
Test: tested in sample app
Bug: 213086140
Change-Id: Ic185b1efe5b48b616881e51b7b892c0f3bfc8e92
M fragment/fragment/src/main/java/androidx/fragment/app/FragmentContainerView.kt
https://android-review.googlesource.com/1947066
Branch: androidx-main
commit 45e2dd162009cdc2823264ee9554c148849c6021
Author: Jeremy Woods <jbwoods@google.com>
Date: Wed Jan 12 16:29:58 2022
Allow negative view ids in fragmentContainerView
When inflating views from xml, FragmentContainerView incorrectly
required that the view ID be a positive int value.
The proper check is just that the view has an id.
RelNote: "`FragmentContainerView` no longer throws an illegal state
exception when view ids generated from xml have negative values."
Test: tested in sample app
Bug: 213086140
Change-Id: Ic185b1efe5b48b616881e51b7b892c0f3bfc8e92
M fragment/fragment/src/main/java/androidx/fragment/app/FragmentContainerView.kt
jb...@google.com <jb...@google.com> #4
This has been fixed internally and will be available in the Fragment 1.4.1
release.
Description
1. Create a boilerplate app project
2. Add a dynamic feature module to the project
3. Add a FragmentContainerView to the XML layout for an Activity in the dynamic feature module
4. Ensure the FragmentContainerView has an android:id attribute specified
5. Have the base app module use SplitInstallManager to request the dynamic feature module
6. Once the dynamic feature is installed, launch the dynamic feature module's Activity containing a FragmentContainerView
7. Generate an app bundle from the above configuration and use bundletool to perform a local test installation of the apk set per
8. Once the user launches the base app and performs any action necessary to start the dynamic feature installation and launch of the dynamic feature module's Activity, the app will crash with "java.lang.IllegalStateException: FragmentContainerView must have an android:id to add Fragment ..."
-- Minimal reproduce project:
- What happened.
-- FragmentContainerView causes an IllegalStateException on inflation from a dynamic feature module because its android:id generated by AAPT is too large to fit in a signed 32 bit integer. This causes View.getId() to return a negative value that overflows past the signed integer max of 2^31 - 1, which FragmentContainerView's construcotr considers invalid. FragmentContainerView's constructor then throws the IllegalStateException claiming its XML source didn't have an android:id attribute.
-- Presumably dynamic feature modules bump up the resource IDs significantly, as I'm seeing starting values in R.txt at 0x80000000 which is already beyond the 32 bit signed integer max of 2^31 - 1. The R.txt values in the base module seem to start around 0x7f000000, which leaves much more room before overflow. Given that, the dynamic feature module aspect of this issue is likely incidental and the FragmentContainerView constructor logic is the root cause.
-- Full discussion is detailed in
- What you think the correct behavior should be.
-- The View ID validity check should allow negative values; it should simply be 'id != 0'.
- Context Details:
-- Android Version: 11
-- Test Device: Samsung Galaxy S20 Ultra 5G (SM-G988U)
-- ADB Bugreport Output: