8000
Skip to content

[FragmentStrictMode] Detect calls to Fragment#setTargetFragment - #139

Closed
simonschiller wants to merge 2 commits into
androidx:androidx-mainfrom
simonschiller:feature/set-target-fragment
Closed

[FragmentStrictMode] Detect calls to Fragment#setTargetFragment#139
simonschiller wants to merge 2 commits into
androidx:androidx-mainfrom
simonschiller:feature/set-target-fragment

Conversation

@simonschiller
Copy link
Copy Markdown
Contributor

Proposed Changes

  • Detect calls to Fragment#setTargetFragment

Testing

Test: See FragmentStrictModeTest#detectSetTargetFragment

Issues Fixed

Fixes: 153737745

@google-cla google-cla Bot added the cla: yes label Mar 12, 2021
@simonschiller
Copy link
Copy Markdown
Contributor Author

Right now, this check only detects calls to Fragment#setTargetFragment. We could also extend it to detect calls to Fragment#getTargetFragment and Fragment#getTargetRequestCode, as those methods belong to the same category. What do you think?

@jbw0033
jbw0033 commented Mar 15, 2021
Copy link
Copy Markdown

We should do all of the methods.

The long term goal for strict mode is to remove any APIs that cause violations. So if you have strict mode on and your app has no problems, then when you upgrade to say Fragment 2.0 where all the APIs that cause violations have been removed, it should be like a no-op. So although, calling the getters without the setter is not very useful, we should make sure we are actually catching those calls and reporting them as violations.

@simonschiller
Copy link
Copy Markdown
Contributor Author

Makes sense, I adapted the PR (as well as #140).

@simonschiller
simonschiller force-pushed the feature/set-target-fragment branch from 5d2d215 to 89c830c Compare March 22, 2021 08:26
@simonschiller
simonschiller deleted the feature/set-target-fragment branch March 23, 2021 15:56
harryzz pushed a commit to harryzz/compose-multiplatform-core that referenced this pull request Jul 28, 2026
## Proposed Changes

  - Detect calls to `Fragment#setTargetFragment`

## Testing

Test: See `FragmentStrictModeTest#detectSetTargetFragment`

## Issues Fixed

Fixes: 153737745

This is an imported pull request from androidx#139.

Resolves JetBrains#139
Github-Pr-Head-Sha: 89c830c
GitOrigin-RevId: e73f51c
Change-Id: I3066e87ed7cfa2bda19089979c722f1efe4103cf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

4738

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

0