Skip to content

Conversation

@camsim99
Copy link
Contributor

@camsim99 camsim99 commented Feb 4, 2025

Warning

This is a a breaking change. TODO: Investigate policy

Ensures every FlutterView created via a FlutterActivity or FlutterFragment 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 multiple FlutterActivity/FlutterFragment instances).

This was prompted by #158473 which will rely on the Android embedder's ability to differentiate between FlutterViews.

Pre-launch Checklist

@github-actions github-actions bot added a: tests "flutter test", flutter_test, or one of our tests platform-android Android applications specifically framework flutter/packages/flutter repository. See also f: labels. engine flutter/engine related. See also e: labels. f: integration_test The flutter/packages/integration_test plugin labels Feb 4, 2025
@github-actions github-actions bot removed a: tests "flutter test", flutter_test, or one of our tests framework flutter/packages/flutter repository. See also f: labels. f: integration_test The flutter/packages/integration_test plugin labels Feb 10, 2025
@github-actions github-actions bot added a: tests "flutter test", flutter_test, or one of our tests framework flutter/packages/flutter repository. See also f: labels. f: integration_test The flutter/packages/integration_test plugin labels Feb 12, 2025
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
@flutter-dashboard

This comment was marked as outdated.

@camsim99 camsim99 closed this May 13, 2025
romanejaquez pushed a commit to romanejaquez/flutter that referenced this pull request Aug 14, 2025
> [!NOTE]  
> This PR lands flutter#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 flutter#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
flutter#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
flutter#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:
flutter#162685
- Add `SensitiveContent` widget to relevant Flutter widgets:
flutter#167302

#### Long-term follow up tasks
- Convert this PR to use JNIgen:
flutter#160050. Verify no frames are
dropped, revealing sensitive content during media projection:
flutter#164820.

#### Stretch goals
- Make the `SensitiveContent` widget sensitive to the visibility of
child widgets: flutter#160051
- Implement `autoSensitivity` mode:
flutter#160879
- Investigate backwards compatibility for APIs < 35:
flutter#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
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 related. 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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant