From 298228236935397e953463e25f52d8dcb0e151b8 Mon Sep 17 00:00:00 2001 From: Camille Simon Date: Tue, 19 Nov 2024 06:24:16 -0800 Subject: [PATCH 01/10] Add base changes --- ci/licenses_golden/licenses_flutter | 2 + shell/platform/android/BUILD.gn | 2 + .../embedding/android/FlutterActivity.java | 8 +- .../FlutterActivityAndFragmentDelegate.java | 15 ++++ .../embedding/android/FlutterFragment.java | 13 +++- .../embedding/engine/FlutterEngine.java | 7 ++ .../SensitiveContentChannel.java | 76 +++++++++++++++++++ .../plugin/view/SensitiveContentPlugin.java | 47 ++++++++++++ 8 files changed, 168 insertions(+), 2 deletions(-) create mode 100644 shell/platform/android/io/flutter/embedding/engine/systemchannels/SensitiveContentChannel.java create mode 100644 shell/platform/android/io/flutter/plugin/view/SensitiveContentPlugin.java diff --git a/ci/licenses_golden/licenses_flutter b/ci/licenses_golden/licenses_flutter index c8b2aeae37e3e..553f95e51d0fb 100644 --- a/ci/licenses_golden/licenses_flutter +++ b/ci/licenses_golden/licenses_flutter @@ -44291,6 +44291,7 @@ ORIGIN: ../../../flutter/shell/platform/android/io/flutter/embedding/engine/syst ORIGIN: ../../../flutter/shell/platform/android/io/flutter/embedding/engine/systemchannels/ProcessTextChannel.java + ../../../flutter/LICENSE ORIGIN: ../../../flutter/shell/platform/android/io/flutter/embedding/engine/systemchannels/RestorationChannel.java + ../../../flutter/LICENSE ORIGIN: ../../../flutter/shell/platform/android/io/flutter/embedding/engine/systemchannels/ScribeChannel.java + ../../../flutter/LICENSE +ORIGIN: ../../../flutter/shell/platform/android/io/flutter/embedding/engine/systemchannels/SensitiveContentChannel.java + ../../../flutter/LICENSE ORIGIN: ../../../flutter/shell/platform/android/io/flutter/embedding/engine/systemchannels/SpellCheckChannel.java + ../../../flutter/LICENSE ORIGIN: ../../../flutter/shell/platform/android/io/flutter/embedding/engine/systemchannels/SystemChannel.java + ../../../flutter/LICENSE ORIGIN: ../../../flutter/shell/platform/android/io/flutter/plugin/common/ActivityLifecycleListener.java + ../../../flutter/LICENSE @@ -44315,6 +44316,7 @@ ORIGIN: ../../../flutter/shell/platform/android/io/flutter/plugin/editing/ImeSyn ORIGIN: ../../../flutter/shell/platform/android/io/flutter/plugin/editing/InputConnectionAdaptor.java + ../../../flutter/LICENSE ORIGIN: ../../../flutter/shell/platform/android/io/flutter/plugin/editing/ListenableEditingState.java + ../../../flutter/LICENSE ORIGIN: ../../../flutter/shell/platform/android/io/flutter/plugin/editing/ScribePlugin.java + ../../../flutter/LICENSE +ORIGIN: ../../../flutter/shell/platform/android/io/flutter/plugin/view/SensitiveContentPlugin.java + ../../../flutter/LICENSE ORIGIN: ../../../flutter/shell/platform/android/io/flutter/plugin/editing/SpellCheckPlugin.java + ../../../flutter/LICENSE ORIGIN: ../../../flutter/shell/platform/android/io/flutter/plugin/editing/TextEditingDelta.java + ../../../flutter/LICENSE ORIGIN: ../../../flutter/shell/platform/android/io/flutter/plugin/editing/TextInputPlugin.java + ../../../flutter/LICENSE diff --git a/shell/platform/android/BUILD.gn b/shell/platform/android/BUILD.gn index 4b6ea453c09ed..6435269d3a8c3 100644 --- a/shell/platform/android/BUILD.gn +++ b/shell/platform/android/BUILD.gn @@ -287,6 +287,7 @@ android_java_sources = [ "io/flutter/embedding/engine/systemchannels/RestorationChannel.java", "io/flutter/embedding/engine/systemchannels/ScribeChannel.java", "io/flutter/embedding/engine/systemchannels/SettingsChannel.java", + "io/flutter/embedding/engine/systemchannels/SensitiveContentChannel.java", "io/flutter/embedding/engine/systemchannels/SpellCheckChannel.java", "io/flutter/embedding/engine/systemchannels/SystemChannel.java", "io/flutter/embedding/engine/systemchannels/TextInputChannel.java", @@ -313,6 +314,7 @@ android_java_sources = [ "io/flutter/plugin/editing/InputConnectionAdaptor.java", "io/flutter/plugin/editing/ListenableEditingState.java", "io/flutter/plugin/editing/ScribePlugin.java", + "io/flutter/plugin/view/SensitiveContentPlugin.java", "io/flutter/plugin/editing/SpellCheckPlugin.java", "io/flutter/plugin/editing/TextEditingDelta.java", "io/flutter/plugin/editing/TextInputPlugin.java", diff --git a/shell/platform/android/io/flutter/embedding/android/FlutterActivity.java b/shell/platform/android/io/flutter/embedding/android/FlutterActivity.java index f5794335b74f4..d7dae20963d05 100644 --- a/shell/platform/android/io/flutter/embedding/android/FlutterActivity.java +++ b/shell/platform/android/io/flutter/embedding/android/FlutterActivity.java @@ -220,7 +220,7 @@ public class FlutterActivity extends Activity *

This ID can be used to lookup {@code FlutterView} in the Android view hierarchy. For more, * see {@link android.view.View#findViewById}. */ - public static final int FLUTTER_VIEW_ID = View.generateViewId(); + public static final int FLUTTER_VIEW_ID = 0; /** * Creates an {@link Intent} that launches a {@code FlutterActivity}, which creates a {@link @@ -1312,6 +1312,12 @@ public PlatformPlugin providePlatformPlugin( return new PlatformPlugin(getActivity(), flutterEngine.getPlatformChannel(), this); } + @Nullable + @Override + public SensitiveContentPlugin provideSensitiveContentPlugin(@Nullable Activity, @NonNull FlutterEngine flutterEngine) { + return new SensitiveContentPlugin(getActivity(), flutterEngine.getSensitiveContentChannel()); + } + /** * Hook for subclasses to easily configure a {@code FlutterEngine}. * diff --git a/shell/platform/android/io/flutter/embedding/android/FlutterActivityAndFragmentDelegate.java b/shell/platform/android/io/flutter/embedding/android/FlutterActivityAndFragmentDelegate.java index c576eacda8c0c..549fbfd29a850 100644 --- a/shell/platform/android/io/flutter/embedding/android/FlutterActivityAndFragmentDelegate.java +++ b/shell/platform/android/io/flutter/embedding/android/FlutterActivityAndFragmentDelegate.java @@ -89,6 +89,7 @@ public interface DelegateFactory { @Nullable private FlutterEngine flutterEngine; @VisibleForTesting @Nullable FlutterView flutterView; @Nullable private PlatformPlugin platformPlugin; + @Nullable private SensitiveContentPlugin sensitiveContentPlugin; @VisibleForTesting @Nullable OnPreDrawListener activePreDrawListener; private boolean isFlutterEngineFromHost; private boolean isFlutterUiDisplayed; @@ -140,6 +141,7 @@ void release() { this.flutterEngine = null; this.flutterView = null; this.platformPlugin = null; + this.sensitiveContentPlugin = null; } /** @@ -215,6 +217,7 @@ void onAttach(@NonNull Context context) { // control of the entire window. This is unacceptable for non-fullscreen // use-cases. platformPlugin = host.providePlatformPlugin(host.getActivity(), flutterEngine); + sensitiveContentPlugin = host.provideSensitiveContentPlugin(host.getActivity()); host.configureFlutterEngine(flutterEngine); isAttached = true; @@ -756,6 +759,11 @@ void onDetach() { platformPlugin = null; } + if(sensitiveContentPlugin != null) { + sensitiveContentPlugin.destroy(); + sensitiveContentPlugin = null; + } + if (host.shouldDispatchAppLifecycleState() && flutterEngine != null) { flutterEngine.getLifecycleChannel().appIsDetached(); } @@ -1184,6 +1192,13 @@ private void ensureAlive() { PlatformPlugin providePlatformPlugin( @Nullable Activity activity, @NonNull FlutterEngine flutterEngine); + /** + * Hook for host to create/provide a {@link SensitiveContentPlugin} if the associated Flutter + * experience should set content sensitivity. + */ + @Nullable + SensitiveContentPlugin provideSensitiveContentPlugin(@Nullable Activity, @NonNull FlutterEngine flutterEngine); + /** * Hook for the host to configure the {@link io.flutter.embedding.engine.FlutterEngine} as * desired. diff --git a/shell/platform/android/io/flutter/embedding/android/FlutterFragment.java b/shell/platform/android/io/flutter/embedding/android/FlutterFragment.java index e26d13e80f74a..7ae5eb35dc105 100644 --- a/shell/platform/android/io/flutter/embedding/android/FlutterFragment.java +++ b/shell/platform/android/io/flutter/embedding/android/FlutterFragment.java @@ -104,7 +104,8 @@ public class FlutterFragment extends Fragment *

This ID can be used to lookup {@code FlutterView} in the Android view hierarchy. For more, * see {@link android.view.View#findViewById}. */ - public static final int FLUTTER_VIEW_ID = View.generateViewId(); + // TODO(camsim99): Determine if we should involve FlutterFragment. + public static final int FLUTTER_VIEW_ID = 1; private static final String TAG = "FlutterFragment"; @@ -1501,6 +1502,16 @@ public PlatformPlugin providePlatformPlugin( } } + @Nullable + @Override + public SensitiveContentPlugin provideSensitiveContentPlugin(@Nullable Activity, @NonNull FlutterEngine flutterEngine) { + if (activity != null) { + return new SensitiveContentPlugin(getActivity(), flutterEngine.getSensitiveContentChannel()); + } else { + return null; + } + } + /** * Configures a {@link io.flutter.embedding.engine.FlutterEngine} after its creation. * diff --git a/shell/platform/android/io/flutter/embedding/engine/FlutterEngine.java b/shell/platform/android/io/flutter/embedding/engine/FlutterEngine.java index 683dfeace7937..b77b1385760fb 100644 --- a/shell/platform/android/io/flutter/embedding/engine/FlutterEngine.java +++ b/shell/platform/android/io/flutter/embedding/engine/FlutterEngine.java @@ -102,6 +102,7 @@ public class FlutterEngine implements ViewUtils.DisplayUpdater { @NonNull private final PlatformChannel platformChannel; @NonNull private final ProcessTextChannel processTextChannel; @NonNull private final ScribeChannel scribeChannel; + @NonNull private final SensitiveContent sensitiveContentChannel; @NonNull private final SettingsChannel settingsChannel; @NonNull private final SpellCheckChannel spellCheckChannel; @NonNull private final SystemChannel systemChannel; @@ -619,6 +620,12 @@ public ScribeChannel getScribeChannel() { return scribeChannel; } + /** System channel that handles setting content sensitivity. */ + @NonNull + public SensitiveContentChannel getSensitiveContentChannel() { + return SensitiveContentChannel; + } + /** System channel that sends and receives spell check requests and results. */ @NonNull public SpellCheckChannel getSpellCheckChannel() { diff --git a/shell/platform/android/io/flutter/embedding/engine/systemchannels/SensitiveContentChannel.java b/shell/platform/android/io/flutter/embedding/engine/systemchannels/SensitiveContentChannel.java new file mode 100644 index 0000000000000..6f84178c3ba21 --- /dev/null +++ b/shell/platform/android/io/flutter/embedding/engine/systemchannels/SensitiveContentChannel.java @@ -0,0 +1,76 @@ +// Copyright 2013 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. + +package io.flutter.embedding.engine.systemchannels; + +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import io.flutter.Log; +import io.flutter.embedding.engine.dart.DartExecutor; +import io.flutter.plugin.common.MethodCall; +import io.flutter.plugin.common.MethodChannel; +import io.flutter.plugin.common.StandardMethodCodec; +import java.util.ArrayList; + +/** + * {@link SensitiveContentChannel} is a platform channel that is used by the framework to set + * the content sensitivity of native Flutter Android {@code View}s. + **/ +public class SensitiveContentChannel { + private static final String TAG = "SensitiveContentChannel"; + + public final MethodChannel channel; + private SensitiveContentMethodHandler sensitiveContentMethodHandler; + + @NonNull + public final MethodChannel.MethodCallHandler parsingMethodHandler = + new MethodChannel.MethodCallHandler() { + @Override + public void onMethodCall(@NonNull MethodCall call, @NonNull MethodChannel.Result result) { + if (sensitiveContentMethodHandler == null) { + Log.v( + TAG, + "No SensitiveContentChannel registered, call not forwarded to sensitive content API."); + return; + } + String method = call.method; + Object args = call.arguments; + Log.v(TAG, "Received '" + method + "' message."); + switch (method) { + case "SensitiveContent.setContentSensitivity": + final int flutterViewId = argumentList.get(0); + final int contentSensitivityLevel = argumentList.get(1); + // TODO(camsim99): Add error handling if required. + sensitiveContentMethodHandler.setContentSensitivity(flutterViewId, contentSensitivityLevel); + break; + default: + result.notImplemented(); + break; + } + } + }; + + public SensitiveContentChannel(@NonNull DartExecutor dartExecutor) { + channel = new MethodChannel(dartExecutor, "flutter/sensitivecontent", StandardMethodCodec.INSTANCE); + channel.setMethodCallHandler(parsingMethodHandler); + } + + /** + * Sets the {@link SensitiveContentMethodHandler} which receives all requests to set a + * particular content sensitivty level sent through this channel. + */ + public void setSensitiveContentMethodHandler( + @Nullable SensitiveContentMethodHandler sensitiveContentMethodHandler) { + this.sensitiveContentMethodHandler = sensitiveContentMethodHandler; + } + + public interface SensitiveContentMethodHandler { + /** + * Requests that content being marked with the requested {@code contentSensitivity} mode for the native + * Flutter Android {@code View} whose ID matches {@Long flutterViewId}. + */ + void setContentSensitivity( + @NonNull int flutterViewId, @NonNull int contentSensitivity, @NonNull MethodChannel.Result result); + } +} diff --git a/shell/platform/android/io/flutter/plugin/view/SensitiveContentPlugin.java b/shell/platform/android/io/flutter/plugin/view/SensitiveContentPlugin.java new file mode 100644 index 0000000000000..6b61adc95b11e --- /dev/null +++ b/shell/platform/android/io/flutter/plugin/view/SensitiveContentPlugin.java @@ -0,0 +1,47 @@ +// Copyright 2013 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. + +package io.flutter.plugin.editing; + +import androidx.annotation.NonNull; +import androidx.annotation.VisibleForTesting; +import io.flutter.embedding.engine.systemchannels.SensitiveContentChannel; +import io.flutter.plugin.common.MethodChannel; +import io.flutter.plugin.localization.LocalizationPlugin; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Locale; + +/** + * {@link SensitiveContentPlugin} is the implementation of all functionality needed to + * set content sensitive on a native Flutter Android {@code View}. + * + *

The plugin handles requests for setting content sensitivity sent by the {@link + * io.flutter.embedding.engine.systemchannels.SensitiveContentChannel} via making a call to + * the relevant {@code View}. + */ +public class SensitiveContentPlugin implements SensitiveContentChannel.SensitiveContentMethodHandler { + + private final SensitiveContentChannel mSensitiveContentChannel; + + public SensitiveContentPlugin(@NonNull Activity flutterActivity, @NonNull SensitiveContentChannel sensitiveContentChannel) { + mSensitiveContentChannel = sensitiveContentChannel; + mSensitiveContentChannel.setSensitiveContentMethodHandler(this); + } + + /** + * Sets content sensitivity level of the Android {@code View} with the specified {@code flutterViewId} + * to the level specified by {@contentSensitivity}. + */ + @Override + public void setContentSensitivity(@NonNull int flutterViewId, @NonNull int contentSensitivity, @NonNull MethodChannel.Result result) { + final View flutterView = activity.findViewById(viewId); + if (flutterView == null) { + result.error("error", "Requested Flutter View to set content sensitivty of not found."); + } + + flutterView.setContentSensitivity(contentSensitivity); + result.success(); + } +} \ No newline at end of file From 382ce417ee1ce2c55555dcbd0e214c49a99e6936 Mon Sep 17 00:00:00 2001 From: Camille Simon Date: Tue, 19 Nov 2024 06:25:09 -0800 Subject: [PATCH 02/10] formatting --- shell/platform/android/BUILD.gn | 4 +- .../SensitiveContentChannel.java | 25 +++++---- .../plugin/view/SensitiveContentPlugin.java | 56 +++++++++---------- 3 files changed, 44 insertions(+), 41 deletions(-) diff --git a/shell/platform/android/BUILD.gn b/shell/platform/android/BUILD.gn index 6435269d3a8c3..d6fb9c4208dfd 100644 --- a/shell/platform/android/BUILD.gn +++ b/shell/platform/android/BUILD.gn @@ -286,8 +286,8 @@ android_java_sources = [ "io/flutter/embedding/engine/systemchannels/ProcessTextChannel.java", "io/flutter/embedding/engine/systemchannels/RestorationChannel.java", "io/flutter/embedding/engine/systemchannels/ScribeChannel.java", - "io/flutter/embedding/engine/systemchannels/SettingsChannel.java", "io/flutter/embedding/engine/systemchannels/SensitiveContentChannel.java", + "io/flutter/embedding/engine/systemchannels/SettingsChannel.java", "io/flutter/embedding/engine/systemchannels/SpellCheckChannel.java", "io/flutter/embedding/engine/systemchannels/SystemChannel.java", "io/flutter/embedding/engine/systemchannels/TextInputChannel.java", @@ -314,7 +314,6 @@ android_java_sources = [ "io/flutter/plugin/editing/InputConnectionAdaptor.java", "io/flutter/plugin/editing/ListenableEditingState.java", "io/flutter/plugin/editing/ScribePlugin.java", - "io/flutter/plugin/view/SensitiveContentPlugin.java", "io/flutter/plugin/editing/SpellCheckPlugin.java", "io/flutter/plugin/editing/TextEditingDelta.java", "io/flutter/plugin/editing/TextInputPlugin.java", @@ -340,6 +339,7 @@ android_java_sources = [ "io/flutter/plugin/platform/VirtualDisplayController.java", "io/flutter/plugin/platform/WindowManagerHandler.java", "io/flutter/plugin/text/ProcessTextPlugin.java", + "io/flutter/plugin/view/SensitiveContentPlugin.java", "io/flutter/util/HandlerCompat.java", "io/flutter/util/PathUtils.java", "io/flutter/util/Preconditions.java", diff --git a/shell/platform/android/io/flutter/embedding/engine/systemchannels/SensitiveContentChannel.java b/shell/platform/android/io/flutter/embedding/engine/systemchannels/SensitiveContentChannel.java index 6f84178c3ba21..6580fcdb471d6 100644 --- a/shell/platform/android/io/flutter/embedding/engine/systemchannels/SensitiveContentChannel.java +++ b/shell/platform/android/io/flutter/embedding/engine/systemchannels/SensitiveContentChannel.java @@ -11,12 +11,11 @@ import io.flutter.plugin.common.MethodCall; import io.flutter.plugin.common.MethodChannel; import io.flutter.plugin.common.StandardMethodCodec; -import java.util.ArrayList; /** - * {@link SensitiveContentChannel} is a platform channel that is used by the framework to set - * the content sensitivity of native Flutter Android {@code View}s. - **/ + * {@link SensitiveContentChannel} is a platform channel that is used by the framework to set the + * content sensitivity of native Flutter Android {@code View}s. + */ public class SensitiveContentChannel { private static final String TAG = "SensitiveContentChannel"; @@ -42,7 +41,8 @@ public void onMethodCall(@NonNull MethodCall call, @NonNull MethodChannel.Result final int flutterViewId = argumentList.get(0); final int contentSensitivityLevel = argumentList.get(1); // TODO(camsim99): Add error handling if required. - sensitiveContentMethodHandler.setContentSensitivity(flutterViewId, contentSensitivityLevel); + sensitiveContentMethodHandler.setContentSensitivity( + flutterViewId, contentSensitivityLevel); break; default: result.notImplemented(); @@ -52,13 +52,14 @@ public void onMethodCall(@NonNull MethodCall call, @NonNull MethodChannel.Result }; public SensitiveContentChannel(@NonNull DartExecutor dartExecutor) { - channel = new MethodChannel(dartExecutor, "flutter/sensitivecontent", StandardMethodCodec.INSTANCE); + channel = + new MethodChannel(dartExecutor, "flutter/sensitivecontent", StandardMethodCodec.INSTANCE); channel.setMethodCallHandler(parsingMethodHandler); } /** - * Sets the {@link SensitiveContentMethodHandler} which receives all requests to set a - * particular content sensitivty level sent through this channel. + * Sets the {@link SensitiveContentMethodHandler} which receives all requests to set a particular + * content sensitivty level sent through this channel. */ public void setSensitiveContentMethodHandler( @Nullable SensitiveContentMethodHandler sensitiveContentMethodHandler) { @@ -67,10 +68,12 @@ public void setSensitiveContentMethodHandler( public interface SensitiveContentMethodHandler { /** - * Requests that content being marked with the requested {@code contentSensitivity} mode for the native - * Flutter Android {@code View} whose ID matches {@Long flutterViewId}. + * Requests that content being marked with the requested {@code contentSensitivity} mode for the + * native Flutter Android {@code View} whose ID matches {@Long flutterViewId}. */ void setContentSensitivity( - @NonNull int flutterViewId, @NonNull int contentSensitivity, @NonNull MethodChannel.Result result); + @NonNull int flutterViewId, + @NonNull int contentSensitivity, + @NonNull MethodChannel.Result result); } } diff --git a/shell/platform/android/io/flutter/plugin/view/SensitiveContentPlugin.java b/shell/platform/android/io/flutter/plugin/view/SensitiveContentPlugin.java index 6b61adc95b11e..8622c08a6ba18 100644 --- a/shell/platform/android/io/flutter/plugin/view/SensitiveContentPlugin.java +++ b/shell/platform/android/io/flutter/plugin/view/SensitiveContentPlugin.java @@ -5,43 +5,43 @@ package io.flutter.plugin.editing; import androidx.annotation.NonNull; -import androidx.annotation.VisibleForTesting; import io.flutter.embedding.engine.systemchannels.SensitiveContentChannel; import io.flutter.plugin.common.MethodChannel; -import io.flutter.plugin.localization.LocalizationPlugin; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Locale; /** - * {@link SensitiveContentPlugin} is the implementation of all functionality needed to - * set content sensitive on a native Flutter Android {@code View}. + * {@link SensitiveContentPlugin} is the implementation of all functionality needed to set content + * sensitive on a native Flutter Android {@code View}. * *

The plugin handles requests for setting content sensitivity sent by the {@link - * io.flutter.embedding.engine.systemchannels.SensitiveContentChannel} via making a call to - * the relevant {@code View}. + * io.flutter.embedding.engine.systemchannels.SensitiveContentChannel} via making a call to the + * relevant {@code View}. */ -public class SensitiveContentPlugin implements SensitiveContentChannel.SensitiveContentMethodHandler { +public class SensitiveContentPlugin + implements SensitiveContentChannel.SensitiveContentMethodHandler { - private final SensitiveContentChannel mSensitiveContentChannel; + private final SensitiveContentChannel mSensitiveContentChannel; - public SensitiveContentPlugin(@NonNull Activity flutterActivity, @NonNull SensitiveContentChannel sensitiveContentChannel) { - mSensitiveContentChannel = sensitiveContentChannel; - mSensitiveContentChannel.setSensitiveContentMethodHandler(this); - } - - /** - * Sets content sensitivity level of the Android {@code View} with the specified {@code flutterViewId} - * to the level specified by {@contentSensitivity}. - */ - @Override - public void setContentSensitivity(@NonNull int flutterViewId, @NonNull int contentSensitivity, @NonNull MethodChannel.Result result) { - final View flutterView = activity.findViewById(viewId); - if (flutterView == null) { - result.error("error", "Requested Flutter View to set content sensitivty of not found."); - } + public SensitiveContentPlugin( + @NonNull Activity flutterActivity, @NonNull SensitiveContentChannel sensitiveContentChannel) { + mSensitiveContentChannel = sensitiveContentChannel; + mSensitiveContentChannel.setSensitiveContentMethodHandler(this); + } - flutterView.setContentSensitivity(contentSensitivity); - result.success(); + /** + * Sets content sensitivity level of the Android {@code View} with the specified {@code + * flutterViewId} to the level specified by {@contentSensitivity}. + */ + @Override + public void setContentSensitivity( + @NonNull int flutterViewId, + @NonNull int contentSensitivity, + @NonNull MethodChannel.Result result) { + final View flutterView = activity.findViewById(viewId); + if (flutterView == null) { + result.error("error", "Requested Flutter View to set content sensitivty of not found."); } + + flutterView.setContentSensitivity(contentSensitivity); + result.success(); + } } \ No newline at end of file From 90d54f2085b98c0c19648233aa3fff7ddafe3ac8 Mon Sep 17 00:00:00 2001 From: Camille Simon Date: Tue, 19 Nov 2024 06:27:51 -0800 Subject: [PATCH 03/10] formatting --- .../io/flutter/embedding/android/FlutterActivity.java | 3 ++- .../android/FlutterActivityAndFragmentDelegate.java | 5 +++-- .../io/flutter/embedding/android/FlutterFragment.java | 3 ++- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/shell/platform/android/io/flutter/embedding/android/FlutterActivity.java b/shell/platform/android/io/flutter/embedding/android/FlutterActivity.java index d7dae20963d05..0ed15515a5fd7 100644 --- a/shell/platform/android/io/flutter/embedding/android/FlutterActivity.java +++ b/shell/platform/android/io/flutter/embedding/android/FlutterActivity.java @@ -1314,7 +1314,8 @@ public PlatformPlugin providePlatformPlugin( @Nullable @Override - public SensitiveContentPlugin provideSensitiveContentPlugin(@Nullable Activity, @NonNull FlutterEngine flutterEngine) { + public SensitiveContentPlugin provideSensitiveContentPlugin( + @Nullable Activity activity, @NonNull FlutterEngine flutterEngine) { return new SensitiveContentPlugin(getActivity(), flutterEngine.getSensitiveContentChannel()); } diff --git a/shell/platform/android/io/flutter/embedding/android/FlutterActivityAndFragmentDelegate.java b/shell/platform/android/io/flutter/embedding/android/FlutterActivityAndFragmentDelegate.java index 549fbfd29a850..02e751803aaa3 100644 --- a/shell/platform/android/io/flutter/embedding/android/FlutterActivityAndFragmentDelegate.java +++ b/shell/platform/android/io/flutter/embedding/android/FlutterActivityAndFragmentDelegate.java @@ -759,7 +759,7 @@ void onDetach() { platformPlugin = null; } - if(sensitiveContentPlugin != null) { + if (sensitiveContentPlugin != null) { sensitiveContentPlugin.destroy(); sensitiveContentPlugin = null; } @@ -1197,7 +1197,8 @@ PlatformPlugin providePlatformPlugin( * experience should set content sensitivity. */ @Nullable - SensitiveContentPlugin provideSensitiveContentPlugin(@Nullable Activity, @NonNull FlutterEngine flutterEngine); + SensitiveContentPlugin provideSensitiveContentPlugin( + @Nullable Activity activity, @NonNull FlutterEngine flutterEngine); /** * Hook for the host to configure the {@link io.flutter.embedding.engine.FlutterEngine} as diff --git a/shell/platform/android/io/flutter/embedding/android/FlutterFragment.java b/shell/platform/android/io/flutter/embedding/android/FlutterFragment.java index 7ae5eb35dc105..35c78801f58eb 100644 --- a/shell/platform/android/io/flutter/embedding/android/FlutterFragment.java +++ b/shell/platform/android/io/flutter/embedding/android/FlutterFragment.java @@ -1504,7 +1504,8 @@ public PlatformPlugin providePlatformPlugin( @Nullable @Override - public SensitiveContentPlugin provideSensitiveContentPlugin(@Nullable Activity, @NonNull FlutterEngine flutterEngine) { + public SensitiveContentPlugin provideSensitiveContentPlugin( + @Nullable Activity activity, @NonNull FlutterEngine flutterEngine) { if (activity != null) { return new SensitiveContentPlugin(getActivity(), flutterEngine.getSensitiveContentChannel()); } else { From f1baad9ac7ef52ef83099cad925c7247e7b537e8 Mon Sep 17 00:00:00 2001 From: Camille Simon Date: Wed, 20 Nov 2024 07:32:46 -0800 Subject: [PATCH 04/10] Get it compiling --- .../flutter/embedding/android/FlutterActivity.java | 1 + .../android/FlutterActivityAndFragmentDelegate.java | 3 ++- .../flutter/embedding/android/FlutterFragment.java | 1 + .../io/flutter/embedding/engine/FlutterEngine.java | 3 ++- .../systemchannels/SensitiveContentChannel.java | 10 +++++++--- .../flutter/plugin/view/SensitiveContentPlugin.java | 13 +++++++++---- 6 files changed, 22 insertions(+), 9 deletions(-) diff --git a/shell/platform/android/io/flutter/embedding/android/FlutterActivity.java b/shell/platform/android/io/flutter/embedding/android/FlutterActivity.java index 0ed15515a5fd7..f406a3374a7cd 100644 --- a/shell/platform/android/io/flutter/embedding/android/FlutterActivity.java +++ b/shell/platform/android/io/flutter/embedding/android/FlutterActivity.java @@ -54,6 +54,7 @@ import io.flutter.embedding.engine.plugins.activity.ActivityControlSurface; import io.flutter.embedding.engine.plugins.util.GeneratedPluginRegister; import io.flutter.plugin.platform.PlatformPlugin; +import io.flutter.plugin.view.SensitiveContentPlugin; import java.util.ArrayList; import java.util.List; diff --git a/shell/platform/android/io/flutter/embedding/android/FlutterActivityAndFragmentDelegate.java b/shell/platform/android/io/flutter/embedding/android/FlutterActivityAndFragmentDelegate.java index 02e751803aaa3..5dec91176c540 100644 --- a/shell/platform/android/io/flutter/embedding/android/FlutterActivityAndFragmentDelegate.java +++ b/shell/platform/android/io/flutter/embedding/android/FlutterActivityAndFragmentDelegate.java @@ -36,6 +36,7 @@ import io.flutter.embedding.engine.dart.DartExecutor; import io.flutter.embedding.engine.renderer.FlutterUiDisplayListener; import io.flutter.plugin.platform.PlatformPlugin; +import io.flutter.plugin.view.SensitiveContentPlugin; import java.util.Arrays; import java.util.List; @@ -217,7 +218,7 @@ void onAttach(@NonNull Context context) { // control of the entire window. This is unacceptable for non-fullscreen // use-cases. platformPlugin = host.providePlatformPlugin(host.getActivity(), flutterEngine); - sensitiveContentPlugin = host.provideSensitiveContentPlugin(host.getActivity()); + sensitiveContentPlugin = host.provideSensitiveContentPlugin(host.getActivity(), flutterEngine); host.configureFlutterEngine(flutterEngine); isAttached = true; diff --git a/shell/platform/android/io/flutter/embedding/android/FlutterFragment.java b/shell/platform/android/io/flutter/embedding/android/FlutterFragment.java index 35c78801f58eb..5976ba22bd79b 100644 --- a/shell/platform/android/io/flutter/embedding/android/FlutterFragment.java +++ b/shell/platform/android/io/flutter/embedding/android/FlutterFragment.java @@ -25,6 +25,7 @@ import io.flutter.embedding.engine.FlutterShellArgs; import io.flutter.embedding.engine.renderer.FlutterUiDisplayListener; import io.flutter.plugin.platform.PlatformPlugin; +import io.flutter.plugin.view.SensitiveContentPlugin; import java.util.ArrayList; import java.util.List; diff --git a/shell/platform/android/io/flutter/embedding/engine/FlutterEngine.java b/shell/platform/android/io/flutter/embedding/engine/FlutterEngine.java index b77b1385760fb..b4cdcbfff3a33 100644 --- a/shell/platform/android/io/flutter/embedding/engine/FlutterEngine.java +++ b/shell/platform/android/io/flutter/embedding/engine/FlutterEngine.java @@ -35,6 +35,7 @@ import io.flutter.embedding.engine.systemchannels.ProcessTextChannel; import io.flutter.embedding.engine.systemchannels.RestorationChannel; import io.flutter.embedding.engine.systemchannels.ScribeChannel; +import io.flutter.embedding.engine.systemchannels.SensitiveContentChannel; import io.flutter.embedding.engine.systemchannels.SettingsChannel; import io.flutter.embedding.engine.systemchannels.SpellCheckChannel; import io.flutter.embedding.engine.systemchannels.SystemChannel; @@ -102,7 +103,7 @@ public class FlutterEngine implements ViewUtils.DisplayUpdater { @NonNull private final PlatformChannel platformChannel; @NonNull private final ProcessTextChannel processTextChannel; @NonNull private final ScribeChannel scribeChannel; - @NonNull private final SensitiveContent sensitiveContentChannel; + @NonNull private final SensitiveContentChannel sensitiveContentChannel; @NonNull private final SettingsChannel settingsChannel; @NonNull private final SpellCheckChannel spellCheckChannel; @NonNull private final SystemChannel systemChannel; diff --git a/shell/platform/android/io/flutter/embedding/engine/systemchannels/SensitiveContentChannel.java b/shell/platform/android/io/flutter/embedding/engine/systemchannels/SensitiveContentChannel.java index 6580fcdb471d6..5caab0a912741 100644 --- a/shell/platform/android/io/flutter/embedding/engine/systemchannels/SensitiveContentChannel.java +++ b/shell/platform/android/io/flutter/embedding/engine/systemchannels/SensitiveContentChannel.java @@ -38,11 +38,15 @@ public void onMethodCall(@NonNull MethodCall call, @NonNull MethodChannel.Result Log.v(TAG, "Received '" + method + "' message."); switch (method) { case "SensitiveContent.setContentSensitivity": + final ArrayList argumentList = (ArrayList) args; final int flutterViewId = argumentList.get(0); final int contentSensitivityLevel = argumentList.get(1); - // TODO(camsim99): Add error handling if required. - sensitiveContentMethodHandler.setContentSensitivity( - flutterViewId, contentSensitivityLevel); + try { + sensitiveContentMethodHandler.setContentSensitivity( + flutterViewId, contentSensitivityLevel, result); + } catch (IllegalStateException exception) { + result.error("error", exception.getMessage(), null); + } break; default: result.notImplemented(); diff --git a/shell/platform/android/io/flutter/plugin/view/SensitiveContentPlugin.java b/shell/platform/android/io/flutter/plugin/view/SensitiveContentPlugin.java index 8622c08a6ba18..54547e342baaa 100644 --- a/shell/platform/android/io/flutter/plugin/view/SensitiveContentPlugin.java +++ b/shell/platform/android/io/flutter/plugin/view/SensitiveContentPlugin.java @@ -2,8 +2,10 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -package io.flutter.plugin.editing; +package io.flutter.plugin.view; +import android.app.Activity; +import android.view.View; import androidx.annotation.NonNull; import io.flutter.embedding.engine.systemchannels.SensitiveContentChannel; import io.flutter.plugin.common.MethodChannel; @@ -19,11 +21,14 @@ public class SensitiveContentPlugin implements SensitiveContentChannel.SensitiveContentMethodHandler { + private final Activity mflutterActivity; private final SensitiveContentChannel mSensitiveContentChannel; public SensitiveContentPlugin( @NonNull Activity flutterActivity, @NonNull SensitiveContentChannel sensitiveContentChannel) { + mflutterActivity = flutterActivity; mSensitiveContentChannel = sensitiveContentChannel; + mSensitiveContentChannel.setSensitiveContentMethodHandler(this); } @@ -36,12 +41,12 @@ public void setContentSensitivity( @NonNull int flutterViewId, @NonNull int contentSensitivity, @NonNull MethodChannel.Result result) { - final View flutterView = activity.findViewById(viewId); + final View flutterView = mflutterActivity.findViewById(flutterViewId); if (flutterView == null) { result.error("error", "Requested Flutter View to set content sensitivty of not found."); } flutterView.setContentSensitivity(contentSensitivity); - result.success(); + result.success(null); } -} \ No newline at end of file +} From 7d9492e0e95b3925dc1c07041515db179f14893f Mon Sep 17 00:00:00 2001 From: Camille Simon Date: Wed, 4 Dec 2024 09:31:34 -0800 Subject: [PATCH 05/10] working state with multiview --- .../io/flutter/embedding/engine/FlutterEngine.java | 3 ++- .../systemchannels/SensitiveContentChannel.java | 9 +++++---- .../flutter/plugin/view/SensitiveContentPlugin.java | 11 ++++++++++- 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/shell/platform/android/io/flutter/embedding/engine/FlutterEngine.java b/shell/platform/android/io/flutter/embedding/engine/FlutterEngine.java index b4cdcbfff3a33..43916b46c6a7b 100644 --- a/shell/platform/android/io/flutter/embedding/engine/FlutterEngine.java +++ b/shell/platform/android/io/flutter/embedding/engine/FlutterEngine.java @@ -342,6 +342,7 @@ public FlutterEngine( processTextChannel = new ProcessTextChannel(dartExecutor, context.getPackageManager()); restorationChannel = new RestorationChannel(dartExecutor, waitForRestorationData); scribeChannel = new ScribeChannel(dartExecutor); + sensitiveContentChannel = new SensitiveContentChannel(dartExecutor); settingsChannel = new SettingsChannel(dartExecutor); spellCheckChannel = new SpellCheckChannel(dartExecutor); systemChannel = new SystemChannel(dartExecutor); @@ -624,7 +625,7 @@ public ScribeChannel getScribeChannel() { /** System channel that handles setting content sensitivity. */ @NonNull public SensitiveContentChannel getSensitiveContentChannel() { - return SensitiveContentChannel; + return sensitiveContentChannel; } /** System channel that sends and receives spell check requests and results. */ diff --git a/shell/platform/android/io/flutter/embedding/engine/systemchannels/SensitiveContentChannel.java b/shell/platform/android/io/flutter/embedding/engine/systemchannels/SensitiveContentChannel.java index 5caab0a912741..63a07adde3899 100644 --- a/shell/platform/android/io/flutter/embedding/engine/systemchannels/SensitiveContentChannel.java +++ b/shell/platform/android/io/flutter/embedding/engine/systemchannels/SensitiveContentChannel.java @@ -11,6 +11,7 @@ import io.flutter.plugin.common.MethodCall; import io.flutter.plugin.common.MethodChannel; import io.flutter.plugin.common.StandardMethodCodec; +import java.util.ArrayList; /** * {@link SensitiveContentChannel} is a platform channel that is used by the framework to set the @@ -38,9 +39,9 @@ public void onMethodCall(@NonNull MethodCall call, @NonNull MethodChannel.Result Log.v(TAG, "Received '" + method + "' message."); switch (method) { case "SensitiveContent.setContentSensitivity": - final ArrayList argumentList = (ArrayList) args; - final int flutterViewId = argumentList.get(0); - final int contentSensitivityLevel = argumentList.get(1); + final ArrayList argumentList = (ArrayList) args; + final int flutterViewId = (int) argumentList.get(0); + final int contentSensitivityLevel = (int) argumentList.get(1); try { sensitiveContentMethodHandler.setContentSensitivity( flutterViewId, contentSensitivityLevel, result); @@ -73,7 +74,7 @@ public void setSensitiveContentMethodHandler( public interface SensitiveContentMethodHandler { /** * Requests that content being marked with the requested {@code contentSensitivity} mode for the - * native Flutter Android {@code View} whose ID matches {@Long flutterViewId}. + * native Flutter Android {@code View} whose ID matches {@code flutterViewId}. */ void setContentSensitivity( @NonNull int flutterViewId, diff --git a/shell/platform/android/io/flutter/plugin/view/SensitiveContentPlugin.java b/shell/platform/android/io/flutter/plugin/view/SensitiveContentPlugin.java index 54547e342baaa..2bc7e1d3365cc 100644 --- a/shell/platform/android/io/flutter/plugin/view/SensitiveContentPlugin.java +++ b/shell/platform/android/io/flutter/plugin/view/SensitiveContentPlugin.java @@ -43,10 +43,19 @@ public void setContentSensitivity( @NonNull MethodChannel.Result result) { final View flutterView = mflutterActivity.findViewById(flutterViewId); if (flutterView == null) { - result.error("error", "Requested Flutter View to set content sensitivty of not found."); + result.error("error", "Requested Flutter View to set content sensitivty of not found.", null); } flutterView.setContentSensitivity(contentSensitivity); result.success(null); } + + /** + * Releases all resources held by this {@code SensitiveContentPlugin}. + * + *

Do not invoke any methods on a {@code SensitiveContentPlugin} after invoking this method. + */ + public void destroy() { + this.mSensitiveContentChannel.setSensitiveContentMethodHandler(null); + } } From c11426417d58e8a85932c5c11f61339e2c847367 Mon Sep 17 00:00:00 2001 From: Camille Simon Date: Tue, 10 Dec 2024 14:46:42 -0800 Subject: [PATCH 06/10] Debugging logs --- .../io/flutter/plugin/view/SensitiveContentPlugin.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/shell/platform/android/io/flutter/plugin/view/SensitiveContentPlugin.java b/shell/platform/android/io/flutter/plugin/view/SensitiveContentPlugin.java index 2bc7e1d3365cc..24aa361397959 100644 --- a/shell/platform/android/io/flutter/plugin/view/SensitiveContentPlugin.java +++ b/shell/platform/android/io/flutter/plugin/view/SensitiveContentPlugin.java @@ -10,6 +10,8 @@ import io.flutter.embedding.engine.systemchannels.SensitiveContentChannel; import io.flutter.plugin.common.MethodChannel; +import io.flutter.Log; + /** * {@link SensitiveContentPlugin} is the implementation of all functionality needed to set content * sensitive on a native Flutter Android {@code View}. @@ -42,11 +44,13 @@ public void setContentSensitivity( @NonNull int contentSensitivity, @NonNull MethodChannel.Result result) { final View flutterView = mflutterActivity.findViewById(flutterViewId); + Log.e("CAMILLE", "flutter view ID: " + Integer.toString(flutterViewId)); if (flutterView == null) { result.error("error", "Requested Flutter View to set content sensitivty of not found.", null); } flutterView.setContentSensitivity(contentSensitivity); + Log.e("CAMILLE", "set content sensitivity to: " + Integer.toString(contentSensitivity)); result.success(null); } From 2d6e25b9c50796071beeb7cb8da98aca65e4ead6 Mon Sep 17 00:00:00 2001 From: Camille Simon Date: Mon, 16 Dec 2024 15:47:17 -0800 Subject: [PATCH 07/10] logs --- .../plugin/view/SensitiveContentPlugin.java | 26 +++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/shell/platform/android/io/flutter/plugin/view/SensitiveContentPlugin.java b/shell/platform/android/io/flutter/plugin/view/SensitiveContentPlugin.java index 24aa361397959..8384c4ad9b713 100644 --- a/shell/platform/android/io/flutter/plugin/view/SensitiveContentPlugin.java +++ b/shell/platform/android/io/flutter/plugin/view/SensitiveContentPlugin.java @@ -11,6 +11,9 @@ import io.flutter.plugin.common.MethodChannel; import io.flutter.Log; +import android.os.IBinder; +import android.view.Window; +import android.view.WindowId; /** * {@link SensitiveContentPlugin} is the implementation of all functionality needed to set content @@ -34,6 +37,7 @@ public SensitiveContentPlugin( mSensitiveContentChannel.setSensitiveContentMethodHandler(this); } + int i = 0; /** * Sets content sensitivity level of the Android {@code View} with the specified {@code * flutterViewId} to the level specified by {@contentSensitivity}. @@ -44,14 +48,32 @@ public void setContentSensitivity( @NonNull int contentSensitivity, @NonNull MethodChannel.Result result) { final View flutterView = mflutterActivity.findViewById(flutterViewId); - Log.e("CAMILLE", "flutter view ID: " + Integer.toString(flutterViewId)); + // final Window flutterViewWindow = flutterView.getWindow(); + WindowId flutterWindowId = flutterView.getWindowId(); + IBinder windowId = flutterView.getWindowToken(); + + Log.e("CAMILLE", Integer.toString(i) + ": flutter view ID: " + Integer.toString(flutterViewId)); + Log.e("CAMILLE", Integer.toString(i) + ": flutter view: " + flutterView.toString()); + Log.e("CAMILLE", Integer.toString(i) + ": flutter view is visible: " + Integer.toString(flutterView.getVisibility())); + Log.e("CAMILLE", Integer.toString(i) + ": flutter window ID : " + flutterWindowId); + Log.e("CAMILLE", Integer.toString(i) + ": flutter view window token: " + windowId); + + if (flutterView == null) { result.error("error", "Requested Flutter View to set content sensitivty of not found.", null); } + + int currentSensitivity = flutterView.getContentSensitivity(); + Log.e("CAMILLE", Integer.toString(i) + ": current content sensitivity is: " + Integer.toString(currentSensitivity)); + flutterView.setContentSensitivity(contentSensitivity); - Log.e("CAMILLE", "set content sensitivity to: " + Integer.toString(contentSensitivity)); + int newSensitivity = flutterView.getContentSensitivity(); + + Log.e("CAMILLE", Integer.toString(i) + ": set content sensitivity to: " + Integer.toString(contentSensitivity)); + Log.e("CAMILLE", Integer.toString(i) + ": acutal new content sensitivity is: " + Integer.toString(newSensitivity)); result.success(null); + i++; } /** From 61dbaf2853709144e9ad503a03e55767775678c6 Mon Sep 17 00:00:00 2001 From: Camille Simon Date: Wed, 18 Dec 2024 14:30:02 -0800 Subject: [PATCH 08/10] My fix --- .../plugin/view/SensitiveContentPlugin.java | 25 +++++-------------- 1 file changed, 6 insertions(+), 19 deletions(-) diff --git a/shell/platform/android/io/flutter/plugin/view/SensitiveContentPlugin.java b/shell/platform/android/io/flutter/plugin/view/SensitiveContentPlugin.java index 8384c4ad9b713..ed433334b87d1 100644 --- a/shell/platform/android/io/flutter/plugin/view/SensitiveContentPlugin.java +++ b/shell/platform/android/io/flutter/plugin/view/SensitiveContentPlugin.java @@ -48,32 +48,19 @@ public void setContentSensitivity( @NonNull int contentSensitivity, @NonNull MethodChannel.Result result) { final View flutterView = mflutterActivity.findViewById(flutterViewId); - // final Window flutterViewWindow = flutterView.getWindow(); - WindowId flutterWindowId = flutterView.getWindowId(); - IBinder windowId = flutterView.getWindowToken(); - - Log.e("CAMILLE", Integer.toString(i) + ": flutter view ID: " + Integer.toString(flutterViewId)); - Log.e("CAMILLE", Integer.toString(i) + ": flutter view: " + flutterView.toString()); - Log.e("CAMILLE", Integer.toString(i) + ": flutter view is visible: " + Integer.toString(flutterView.getVisibility())); - Log.e("CAMILLE", Integer.toString(i) + ": flutter window ID : " + flutterWindowId); - Log.e("CAMILLE", Integer.toString(i) + ": flutter view window token: " + windowId); - - if (flutterView == null) { result.error("error", "Requested Flutter View to set content sensitivty of not found.", null); } - - int currentSensitivity = flutterView.getContentSensitivity(); - Log.e("CAMILLE", Integer.toString(i) + ": current content sensitivity is: " + Integer.toString(currentSensitivity)); - + final int currentContentSensitivity = flutterView.getContentSensitivity(); flutterView.setContentSensitivity(contentSensitivity); - int newSensitivity = flutterView.getContentSensitivity(); - Log.e("CAMILLE", Integer.toString(i) + ": set content sensitivity to: " + Integer.toString(contentSensitivity)); - Log.e("CAMILLE", Integer.toString(i) + ": acutal new content sensitivity is: " + Integer.toString(newSensitivity)); + final boolean shouldInvalidateView = currentContentSensitivity == View...sensitive && contentSensitivity != View...sensitive; + if (shouldInvalidateView) { + flutterView.invalidate(); + } + result.success(null); - i++; } /** From 144f522ba6d8a4dae6d5438d88ada62854477311 Mon Sep 17 00:00:00 2001 From: Camille Simon Date: Thu, 26 Dec 2024 13:18:53 -0800 Subject: [PATCH 09/10] Finsh invalidate logic --- .../android/io/flutter/plugin/view/SensitiveContentPlugin.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shell/platform/android/io/flutter/plugin/view/SensitiveContentPlugin.java b/shell/platform/android/io/flutter/plugin/view/SensitiveContentPlugin.java index ed433334b87d1..000d831702e18 100644 --- a/shell/platform/android/io/flutter/plugin/view/SensitiveContentPlugin.java +++ b/shell/platform/android/io/flutter/plugin/view/SensitiveContentPlugin.java @@ -55,7 +55,7 @@ public void setContentSensitivity( final int currentContentSensitivity = flutterView.getContentSensitivity(); flutterView.setContentSensitivity(contentSensitivity); - final boolean shouldInvalidateView = currentContentSensitivity == View...sensitive && contentSensitivity != View...sensitive; + final boolean shouldInvalidateView = currentContentSensitivity == View.CONTENT_SENSITIVITY_SENSITIVE && contentSensitivity != View.CONTENT_SENSITIVITY_SENSITIVE; if (shouldInvalidateView) { flutterView.invalidate(); } From 0269e03bfa07f57e64467f4390c665ee27a6a0bd Mon Sep 17 00:00:00 2001 From: Camille Simon Date: Thu, 26 Dec 2024 13:20:22 -0800 Subject: [PATCH 10/10] format --- .../io/flutter/plugin/view/SensitiveContentPlugin.java | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/shell/platform/android/io/flutter/plugin/view/SensitiveContentPlugin.java b/shell/platform/android/io/flutter/plugin/view/SensitiveContentPlugin.java index 000d831702e18..d8ad768360a55 100644 --- a/shell/platform/android/io/flutter/plugin/view/SensitiveContentPlugin.java +++ b/shell/platform/android/io/flutter/plugin/view/SensitiveContentPlugin.java @@ -10,11 +10,6 @@ import io.flutter.embedding.engine.systemchannels.SensitiveContentChannel; import io.flutter.plugin.common.MethodChannel; -import io.flutter.Log; -import android.os.IBinder; -import android.view.Window; -import android.view.WindowId; - /** * {@link SensitiveContentPlugin} is the implementation of all functionality needed to set content * sensitive on a native Flutter Android {@code View}. @@ -55,7 +50,9 @@ public void setContentSensitivity( final int currentContentSensitivity = flutterView.getContentSensitivity(); flutterView.setContentSensitivity(contentSensitivity); - final boolean shouldInvalidateView = currentContentSensitivity == View.CONTENT_SENSITIVITY_SENSITIVE && contentSensitivity != View.CONTENT_SENSITIVITY_SENSITIVE; + final boolean shouldInvalidateView = + currentContentSensitivity == View.CONTENT_SENSITIVITY_SENSITIVE + && contentSensitivity != View.CONTENT_SENSITIVITY_SENSITIVE; if (shouldInvalidateView) { flutterView.invalidate(); }