-
Notifications
You must be signed in to change notification settings - Fork 28.5k
[Android] Make FlutterView
IDs instance variables instead of a static one
#162685
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
camsim99
wants to merge
40
commits into
flutter:master
Choose a base branch
from
camsim99:unstatic_fviewid
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 tasks
9 tasks
github-merge-queue bot
pushed a commit
that referenced
this pull request
Apr 29, 2025
> [!NOTE] > This PR lands #158473 (closed due to confusing git-isms). Please see that PR for all comments and discussion on landing this feature. ### Overview Implements setting content sensitivity on Android via a new widget called `SensitiveContent` that currently will only function on Android. ### How it's implemented There are three different content sensitivity levels: [`autoSensitive`](https://developer.android.com/reference/android/view/View#CONTENT_SENSITIVITY_AUTO), [`sensitive`](https://developer.android.com/reference/android/view/View#CONTENT_SENSITIVITY_SENSITIVE), [`notSensitive`](https://developer.android.com/reference/android/view/View#CONTENT_SENSITIVITY_NOT_SENSITIVE). All except `autoSensitive` behave as their Android counterpart level behaves (see links on the levels); for Flutter, `autoSensitive` will behave the same as `notSensitive` though it is implemented as if it works (see #160879 for more details. In any given Flutter view, each `SensitiveContent` widget sets a content sensitivity level and there may be multiple `SensitiveContent` widgets in the widget tree at a time, but only the most severe content sensitivity level in the tree will be maintained in order to ensure secure content remains obscured during screen projection. This means that even widgets that are not visible may still impact the overall content sensitivity of the entire Flutter view (see #160051 for more details). Under the hood, the implementation uses method channels. Theoretically, this could cause a delay in setting the content sensitivity level and a Flutter view being obscured during screen projection on time, so we will investigate using JNIgen in the future (see #160050 for more details). Over the method channel, the framework will send a Flutter view ID and content sensitivity level to the engine to set the expected content sensitivity level for the view. ### Timeline #### Required for feature shipping - Land this PR with the method channel implementation of content sensitivity. #### Short-term follow up tasks - Ensure every `FlutterView` has a unique ID for the native `SensitiveContentPlugin` to identify them by: #162685 - Add `SensitiveContent` widget to relevant Flutter widgets: #167302 #### Long-term follow up tasks - Convert this PR to use JNIgen: #160050. Verify no frames are dropped, revealing sensitive content during media projection: #164820. #### Stretch goals - Make the `SensitiveContent` widget sensitive to the visibility of child widgets: #160051 - Implement `autoSensitivity` mode: #160879 - Investigate backwards compatibility for APIs < 35: #159208 ### Open questions - ~Is it okay to hard-code the `FlutterActivity` and `FlutterFragment` view IDs? Does this impact add-to-app in any way? I assume we would need extenders of those classes to use a different view ID than the hardcoded one.~ Approach not used. - ~Should we expose `autoSensitive` for now? If so, what behavior should it have?~ Exposing `autoSensitive` as if it works. ### One way to test this PR (rough steps) 1. Create a Flutter app that has some number of `SensitiveContent` widgets. 9. Run the app on an emulator/device that runs API 35 and has the Google meets app downloaded. 10. Start a Google meets meeting and screen share (works with full screen and single app mode). 11. Join the Google meets meeting from another device and witness a blacked out screen if content has been marked sensitive. ## Pre-launch Checklist - [x] I read the [Contributor Guide] and followed the process outlined there for submitting PRs. - [x] I read the [Tree Hygiene] wiki page, which explains my responsibilities. - [x] I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement]. - [x] I signed the [CLA]. - [x] I listed at least one issue that this PR fixes in the description above. - [x] I updated/added relevant documentation (doc comments with `///`). - [x] I added new tests to check the change I am making, or this PR is [test-exempt]. - [x] I followed the [breaking change policy] and added [Data Driven Fixes] where supported. - [x] All existing and new tests are passing. If you need help, consider asking for advice on the #hackers-new channel on [Discord]. <!-- Links --> [Contributor Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview [Tree Hygiene]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md [test-exempt]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests [Flutter Style Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md [Features we expect every widget to implement]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement [CLA]: https://cla.developers.google.com/ [flutter/tests]: https://github.com/flutter/tests [breaking change policy]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes [Discord]: https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md [Data Driven Fixes]: https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md
This comment was marked as outdated.
This comment was marked as outdated.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
a: tests
"flutter test", flutter_test, or one of our tests
engine
flutter/engine repository. See also e: labels.
f: integration_test
The flutter/packages/integration_test plugin
framework
flutter/packages/flutter repository. See also f: labels.
platform-android
Android applications specifically
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Warning
This is a a breaking change. TODO: Investigate policy
Ensures every
FlutterView
created via aFlutterActivity
orFlutterFragment
has a unique ID.The current setup (with a final static view ID per
FlutterActivity
/FlutterFragment
) should not work in the case where a Flutter engine is reused between multipleFlutterActivity
/FlutterFragment
instances).This was prompted by #158473 which will rely on the Android embedder's ability to differentiate between
FlutterView
s.Pre-launch Checklist
///
).