You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 38e799a
Browse filesBrowse the repository at this point in the historyBrowse files
[Android] Refactor Intent-driven engine flags into a variant-specific module (flutter#191924)
Configures the Android embedding to ignore engine configuration flags
set via `Intent` in release mode. All flag parsing from `Intent`s is
also stripped from release engine binaries as an additional security
measure. Also adds an integration test to ensure flags set via `Intent`
are ignored for apps running in release mode.
As part of this implementation, deprecates the internal interface method
`FlutterActivityAndFragmentDelegate.Host.getFlutterShellArgs` which is
to be replaced
by`FlutterActivityAndFragmentDelegate.Host.getFlutterEngineFlags`. After
a stable release, `getFlutterShellArgs` will be removed:
flutter#193256. **This is not a
breaking change; developers cannot override this interface.** They can
only subclass `FlutterActivity` and `FlutterFragment` and call
`getFlutterShellArgs` which will still work as intended with a
deprecation notice.
Fixesflutter#190461.
Related issue: While working on this, I thought it would be good to
track adding the ability to negate all flags because currently,
presence-only boolean flags (like `--trace-startup`) cannot have their
setting in the manifest negated by the command line, which is
counter-intuitive: flutter#193354
Related PR: Made some updates to the breaking change page for this
project for flutter/website#13931 (directly
related to my `Flutter-Android-Engine-Flags.md` updates)
(@camsim99 authored description)
## Pre-launch Checklist
- [x] I read the [Contributor Guide] and followed the process outlined
there for submitting PRs.
- [x] I read the [AI contribution guidelines] and understand my
responsibilities, or I am not using AI tools.
- [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.
---------
Co-authored-by: Camille Simon <[email protected]>
Co-authored-by: Camille Simon <[email protected]>
for the list of flags that can be set for the Android shell, and see
13
+
`src/flutter/shell/common/switch_defs.h` for the list of all supported flags.
14
14
15
15
For flags that can be set on the command line and via the manifest,
16
16
see below to determine which method to use.
@@ -28,16 +28,54 @@ Use the manifest when:
28
28
`src/release/AndroidManifest.xml` (or per-flavor manifests) to tailor flags
29
29
per variant.
30
30
31
+
See [below](#how-to-set-engine-flags-in-the-manifest) for how to set flags via the manifest.
32
+
31
33
Use the command line when:
32
34
33
35
- You want to quickly experiment with a flag for a single run of your app.
34
-
- You need to override a flag that is already set in the manifest temporarily for debugging
35
-
or testing purposes.
36
+
- You need to override a value or toggle flag that is already set in the manifest temporarily
37
+
for debugging or testing purposes.
38
+
39
+
See [below](#how-to-set-engine-flags-from-the-command-line) for how to set flags via the command line.
40
+
41
+
Use Android `Intent` extras when:
42
+
43
+
- You want to pass flags during manual debugging or automated testing in debug and profile modes (e.g., via `adb shell am start` or programmatically from host Android code). Note that `Intent` flags are disabled in release mode for security reasons.
44
+
45
+
See [below](#how-to-set-engine-flags-via-android-intents) for how to set flags via `Intent`s.
36
46
37
-
**Note: If a flag is specified both on the command line and in the manifest,
38
-
the command-line value takes precedence at runtime.**
47
+
**Note on precedence:**
48
+
49
+
-**Flags that take values or toggles** (e.g., `--enable-impeller=true|false` or `--trace-to-file=<path>`):
50
+
Command-line values and `Intent` extras take precedence over the manifest value at runtime.
tracks adding the ability to negate flags from the command line and `Intent` extras so manifest settings can be overridden.
57
+
58
+
## Release-mode restrictions
59
+
60
+
For security purposes, release builds impose several restrictions on how engine
61
+
flags can be delivered and which flags are permitted:
62
+
63
+
-**Intent flags are disabled in release mode:** For security purposes, the
64
+
Android embedding ignores all engine flags passed via Android `Intent`
65
+
extras in release builds. Setting engine flags via `Intent` is only
66
+
supported in debug and profile modes. For more background on this security restriction
67
+
and how to migrate, see [Restrict command-line flags on prebuilt Android release binaries](https://docs.flutter.dev/release/breaking-changes/restrict-android-engine-flags-release-mode).
68
+
-**Allowed flags in release mode:** Only specific security-reviewed flags are
69
+
allowed in release mode. The Android embedding enforces this policy (see
0 commit comments