mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
> [!NOTE] > This PR lands https://github.com/flutter/flutter/pull/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 https://github.com/flutter/flutter/issues/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 https://github.com/flutter/flutter/issues/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 https://github.com/flutter/flutter/issues/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: https://github.com/flutter/flutter/pull/162685 - Add `SensitiveContent` widget to relevant Flutter widgets: https://github.com/flutter/flutter/issues/167302 #### Long-term follow up tasks - Convert this PR to use JNIgen: https://github.com/flutter/flutter/issues/160050. Verify no frames are dropped, revealing sensitive content during media projection: https://github.com/flutter/flutter/issues/164820. #### Stretch goals - Make the `SensitiveContent` widget sensitive to the visibility of child widgets: https://github.com/flutter/flutter/issues/160051 - Implement `autoSensitivity` mode: https://github.com/flutter/flutter/issues/160879 - Investigate backwards compatibility for APIs < 35: https://github.com/flutter/flutter/issues/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
63 lines
2.5 KiB
Dart
63 lines
2.5 KiB
Dart
// Copyright 2014 The Flutter Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE file.
|
|
|
|
/// Platform services exposed to Flutter apps.
|
|
///
|
|
/// To use, import `package:flutter/services.dart`.
|
|
///
|
|
/// This library depends only on core Dart libraries and the `foundation`
|
|
/// library.
|
|
library services;
|
|
|
|
export 'src/services/asset_bundle.dart';
|
|
export 'src/services/asset_manifest.dart';
|
|
export 'src/services/autofill.dart';
|
|
export 'src/services/binary_messenger.dart';
|
|
export 'src/services/binding.dart';
|
|
export 'src/services/browser_context_menu.dart';
|
|
export 'src/services/clipboard.dart';
|
|
export 'src/services/debug.dart';
|
|
export 'src/services/deferred_component.dart';
|
|
export 'src/services/flavor.dart';
|
|
export 'src/services/flutter_version.dart';
|
|
export 'src/services/font_loader.dart';
|
|
export 'src/services/haptic_feedback.dart';
|
|
export 'src/services/hardware_keyboard.dart';
|
|
export 'src/services/keyboard_inserted_content.dart';
|
|
export 'src/services/keyboard_key.g.dart';
|
|
export 'src/services/keyboard_maps.g.dart';
|
|
export 'src/services/live_text.dart';
|
|
export 'src/services/message_codec.dart';
|
|
export 'src/services/message_codecs.dart';
|
|
export 'src/services/mouse_cursor.dart';
|
|
export 'src/services/mouse_tracking.dart';
|
|
export 'src/services/platform_channel.dart';
|
|
export 'src/services/platform_views.dart';
|
|
export 'src/services/predictive_back_event.dart';
|
|
export 'src/services/process_text.dart';
|
|
export 'src/services/raw_keyboard.dart';
|
|
export 'src/services/raw_keyboard_android.dart';
|
|
export 'src/services/raw_keyboard_fuchsia.dart';
|
|
export 'src/services/raw_keyboard_ios.dart';
|
|
export 'src/services/raw_keyboard_linux.dart';
|
|
export 'src/services/raw_keyboard_macos.dart';
|
|
export 'src/services/raw_keyboard_web.dart';
|
|
export 'src/services/raw_keyboard_windows.dart';
|
|
export 'src/services/restoration.dart';
|
|
export 'src/services/scribe.dart';
|
|
export 'src/services/sensitive_content.dart';
|
|
export 'src/services/service_extensions.dart';
|
|
export 'src/services/spell_check.dart';
|
|
export 'src/services/system_channels.dart';
|
|
export 'src/services/system_chrome.dart';
|
|
export 'src/services/system_navigator.dart';
|
|
export 'src/services/system_sound.dart';
|
|
export 'src/services/text_boundary.dart';
|
|
export 'src/services/text_editing.dart';
|
|
export 'src/services/text_editing_delta.dart';
|
|
export 'src/services/text_formatter.dart';
|
|
export 'src/services/text_input.dart';
|
|
export 'src/services/text_layout_metrics.dart';
|
|
export 'src/services/undo_manager.dart';
|