* [android] External textures must be rescaled to fill the canvas
- After composition, we have a tight box that we need to fill.
- Video decoders typically operate using output buffers that are a whole
number of blocks (vertically and horizontally). This fixes
https://github.com/flutter/flutter/issues/34641 where the decoded
dimensions are rounded up.
- The cropping information for the current frame arrives in the form of
`SurfaceTexture.getTransformMatrix`. When we apply this transform we
need to account for the fact that we have already composited. This
means that in cases where the scaleX, scaleY are less than 1, we need
to rescale the image. We do this while preserving the aspect ratio.
* Remove deprecated runBundle APIs
* Remove code related to dynamic patching (including support for multiple
bundle paths)
* Change FlutterRunArugments.bundlePath to be the Android AssetManager path
where the app's assets are located
The previous logic allowed proxying for any view that belonged to one of the platform views' virtual displays which may lead to us allowing proxying for a view that the platform view isn't allowing proxying for, previous logic also didn't account for unattached views.
This change instead delegates the decision to the platform view.
We use the fact that each virtual display has its unique context to associate any view with its relevant virtual display.
A nice side effect of calling the platform view's checkInputConnectionProxy for webviews is that the plugin now has a way to get a handle to the ThreadedInputConnectionProxyView, which may be useful for getting keyboard working on webview's prior to Android N.
Add views that are added directly to a platform view's window as siblings to the platform view's container view, rather than as children of a full screen container.
This prevents a false-negative for a visibility check from a specific ads SDK (Teads), which [reported the following warning](https://github.com/flutter/flutter/issues/12114#issuecomment-500906158):
```
W/teads#Visibility(17978): The Teads AdView is visible at 0%, hidded by 1 View(s):
W/teads#Visibility(17978): - View of class io.flutter.plugin.platform.SingleViewPresentation$FakeWindowViewGroup, with id: -1, with contentDescription: null, with a size of: [width: 1050, height: 875] is hidding 100% of the ad
```
FlutterMain and the DartServiceIsolate callback list are both globals, and the
callback list state may have already been destructed when FlutterMain's
destructor runs.
The Android embedder had been using a JNI call to get the observatory URI from
DartServiceIsolate. This call was not thread safe and was redundant with the
server status callback mechanism used on iOS.
Fixes a rare NullPointerException on Huawei devices:
```
Stacktrace:
java.lang.NullPointerException: Attempt to invoke virtual method 'android.view.DisplayAdjustments android.view.Display.getDisplayAdjustments()' on a null object reference
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1793)
...
```
This patch works around Android's limitations on reflection. With it embedded
platform views that use virtual node hierarchy trees should be accessible on all
Android versions to date.
The workarounds in this PR are brittle. Ideally the methods would be made public
in Android instead so we wouldn't need to employ tactics like these to work
around the missing methods.
`AccessibilityNodeInfo#getChildId` is blocked from any type of reflection
access, but the underlying private member that the getter accesses,
`mChildNodeIds`, can still be reflected on. On Android versions where we can't
access the getter, this patch falls back on reflectively accessing the field
instead. Unfortunately this field is a
[`LongArray`](https://android.googlesource.com/platform/frameworks/base/+/master/core/java/android/util/LongArray.java),
a utility data class private to Android. So in this case we're reflecting to
both access the member and actually read data from it, since we need to use
reflection to call `LongArray.get(index)`.
`AccessibilityNodeInfo#getParent()` doesn't have any lucky available underlying
members. However, `AccessibilityNodeInfo` itself is `Parcelable`, and
`mParentNodeId` is one of the pieces of data that's written to a parcel via
`AccessibilityNodeInfo#writeToParcel`. So the fallback for that is to write the
node to a parcel and then read the parcel for the ID in question. This will
break if the implementation details of `AccessibilityNodeInfo#writeToParcel`
ever change. The details have already changed enough in the past to require two
sets of logic for reading from the parcel.
The engine RunBundleAndSnapshotFromLibrary API expects a bundle path directory
containing the application's assets. If the Android embedding is using
AOT ELF library packaging and does not need to extract assets, then create an
empty directory at the bundle path.
Fixes https://github.com/flutter/flutter/issues/34287
Previously AOT compiled Dart code would be packaged as a group of assets
within the APK. This has been replaced by a single ELF library containing
the same data.
#9203 broke the keyboard_resize integration test(see more details in flutter/flutter#34085 (comment)).
This re-lands @9203 and fixes the issue the integration test uncovered by always allowing to hide the keyboard.
The difference from the original change is 07d2598
Generally what this PR is doing is setting up a delegation mechanism
for Android's onCreateInputConnection.
It works by letting the framework know when an embedded view gets loses
focus(within the virtual display), the framework maintains a focus node
for each Android view that is kept in sync with the focus state of the
embedded view.
The TextInputPlugin is extended to allow for 2 type of text clients a
"framework client"(what we had before) and a "platform view client".
When the AndroidView's focus node in the framework is focused the
framework sets a "platform view text client" for the TextInputPlugin,
which will result in the TextInputPlugin delegating
createInputConnection to the platform view.
When a platform view is resized, we are detaching it from a virtual
display and attaching it to a new one, as a side affect a platform view
might lose an active input connection, to workaround that we "lock" the
connection when resizing(by caching it and forcing the cached copy until
the resize is done).
Additional things worth calling out in this PR:
To properly answer which views are allowed for input connection
proxying we compare a candidate view's root view to the set of root
views of all virtual displays.
We also preserve a view's focus state across resizes.
Note that this PR only wires text for the io.flutter.view.FlutterView
For the new Android embedding some additional plumbing is necessary.
Corresponding framework PR: flutter/flutter#33901flutter/flutter#19718
Using it, a Flutter app can monitor missing frames in the release mode, and a custom Flutter runner (e.g., Fuchsia) can add a custom FrameRasterizedCallback.
Related issues:
https://github.com/flutter/flutter/issues/26154https://github.com/flutter/flutter/issues/31444https://github.com/flutter/flutter/issues/32447
Need review as soon as possible so we can merge this before the end of May to catch the milestone.
Tests added:
* NoNeedToReportTimingsByDefault
* NeedsReportTimingsIsSetWithCallback
* ReportTimingsIsCalled
* FrameRasterizedCallbackIsCalled
* FrameTimingSetsAndGetsProperly
* onReportTimings preserves callback zone
* FrameTiming.toString has the correct format
This will need a manual engine roll as the TestWindow defined in the framework needs to implement onReportTimings.
This adds the key event source from Android so that the framework can differentiate between keyboard events and game controller events. Also added vendor and product ids so that Flutter code can decide to do special processing based on the kind of device, if desired.
This regression was introduced in #7847.
The PlatformViewsChannel method call handler was always setting the result to `notImplemented` even after handling a result, this resulted in a "Reply already submitted" exception being thrown.
Note that the method channel code is swallowing this exception and logging an error, so we didn't crash instead we were logging an error(this is why the integration test didn't fail).
Filed https://github.com/flutter/flutter/issues/33863 to make sure tests fail when such exceptions are thrown.
This PR also cleans up an unused `NoSuchPlatformViewException` that was introduced in #7847.
https://github.com/flutter/flutter/issues/33866
FlutterMain.findAppBundlePath is using the presence of the flutter_assets
directory as a signal that the app is initialized. For consistency,
FlutterMain will run the resource extractor at startup and create
flutter_assets even if no resources need to be extracted.