Bump androidx.window:window-java (flutter/engine#29897)

This commit is contained in:
Emmanuel Garcia
2021-11-24 11:41:40 -08:00
committed by GitHub
parent 07df843083
commit 93e6dbe5ab
9 changed files with 65 additions and 74 deletions

2
DEPS
View File

@@ -526,7 +526,7 @@ deps = {
'packages': [
{
'package': 'flutter/android/embedding_bundle',
'version': 'last_updated:2021-11-03T10:29:50-0700'
'version': 'last_updated:2021-11-23T12:31:07-0800'
}
],
'condition': 'download_android_deps',

View File

@@ -38,12 +38,12 @@ import androidx.annotation.RequiresApi;
import androidx.annotation.VisibleForTesting;
import androidx.core.content.ContextCompat;
import androidx.core.util.Consumer;
import androidx.window.java.layout.WindowInfoRepositoryCallbackAdapter;
import androidx.window.java.layout.WindowInfoTrackerCallbackAdapter;
import androidx.window.layout.DisplayFeature;
import androidx.window.layout.FoldingFeature;
import androidx.window.layout.FoldingFeature.OcclusionType;
import androidx.window.layout.FoldingFeature.State;
import androidx.window.layout.WindowInfoRepository;
import androidx.window.layout.WindowInfoTracker;
import androidx.window.layout.WindowLayoutInfo;
import io.flutter.Log;
import io.flutter.embedding.engine.FlutterEngine;
@@ -454,8 +454,8 @@ public class FlutterView extends FrameLayout implements MouseCursorPlugin.MouseC
protected WindowInfoRepositoryCallbackAdapterWrapper createWindowInfoRepo() {
try {
return new WindowInfoRepositoryCallbackAdapterWrapper(
new WindowInfoRepositoryCallbackAdapter(
WindowInfoRepository.getOrCreate((Activity) getContext())));
new WindowInfoTrackerCallbackAdapter(
WindowInfoTracker.getOrCreate((Activity) getContext())));
} catch (NoClassDefFoundError noClassDefFoundError) {
// Testing environment uses gn/javac, which does not work with aar files. This is why aar
// are converted to jar files, losing resources and other android-specific files.
@@ -470,7 +470,7 @@ public class FlutterView extends FrameLayout implements MouseCursorPlugin.MouseC
/**
* Invoked when this is attached to the window.
*
* <p>We register for {@link androidx.window.layout.WindowInfoRepository} updates.
* <p>We register for {@link androidx.window.layout.WindowInfoTracker} updates.
*/
@Override
protected void onAttachedToWindow() {
@@ -478,14 +478,14 @@ public class FlutterView extends FrameLayout implements MouseCursorPlugin.MouseC
this.windowInfoRepo = createWindowInfoRepo();
if (windowInfoRepo != null) {
windowInfoRepo.addWindowLayoutInfoListener(
ContextCompat.getMainExecutor(getContext()), windowInfoListener);
(Activity) getContext(), ContextCompat.getMainExecutor(getContext()), windowInfoListener);
}
}
/**
* Invoked when this is detached from the window.
*
* <p>We unregister from {@link androidx.window.layout.WindowInfoRepository} updates.
* <p>We unregister from {@link androidx.window.layout.WindowInfoTracker} updates.
*/
@Override
protected void onDetachedFromWindow() {
@@ -497,20 +497,20 @@ public class FlutterView extends FrameLayout implements MouseCursorPlugin.MouseC
}
/**
* Refresh {@link androidx.window.layout.WindowInfoRepository} and {@link
* android.view.DisplayCutout} display features. Fold, hinge and cutout areas are populated here.
* Refresh {@link androidx.window.layout.WindowInfoTracker} and {@link android.view.DisplayCutout}
* display features. Fold, hinge and cutout areas are populated here.
*/
@TargetApi(28)
protected void setWindowInfoListenerDisplayFeatures(WindowLayoutInfo layoutInfo) {
List<DisplayFeature> displayFeatures = layoutInfo.getDisplayFeatures();
List<FlutterRenderer.DisplayFeature> result = new ArrayList<>();
// Data from WindowInfoRepository display features. Fold and hinge areas are
// Data from WindowInfoTracker display features. Fold and hinge areas are
// populated here.
for (DisplayFeature displayFeature : displayFeatures) {
Log.v(
TAG,
"WindowInfoRepository Display Feature reported with bounds = "
"WindowInfoTracker Display Feature reported with bounds = "
+ displayFeature.getBounds().toString()
+ " and type = "
+ displayFeature.getClass().getSimpleName());

View File

@@ -4,27 +4,31 @@
package io.flutter.embedding.android;
import android.app.Activity;
import androidx.annotation.NonNull;
import androidx.core.util.Consumer;
import androidx.window.java.layout.WindowInfoRepositoryCallbackAdapter;
import androidx.window.java.layout.WindowInfoTrackerCallbackAdapter;
import androidx.window.layout.WindowLayoutInfo;
import java.util.concurrent.Executor;
/**
* Wraps {@link WindowInfoRepositoryCallbackAdapter} in order to be able to mock it during testing.
*/
/** Wraps {@link WindowInfoTrackerCallbackAdapter} in order to be able to mock it during testing. */
public class WindowInfoRepositoryCallbackAdapterWrapper {
final WindowInfoRepositoryCallbackAdapter adapter;
@NonNull final WindowInfoTrackerCallbackAdapter adapter;
public WindowInfoRepositoryCallbackAdapterWrapper(WindowInfoRepositoryCallbackAdapter adapter) {
public WindowInfoRepositoryCallbackAdapterWrapper(
@NonNull WindowInfoTrackerCallbackAdapter adapter) {
this.adapter = adapter;
}
public void addWindowLayoutInfoListener(Executor executor, Consumer<WindowLayoutInfo> consumer) {
adapter.addWindowLayoutInfoListener(executor, consumer);
public void addWindowLayoutInfoListener(
@NonNull Activity activity,
@NonNull Executor executor,
@NonNull Consumer<WindowLayoutInfo> consumer) {
adapter.addWindowLayoutInfoListener(activity, executor, consumer);
}
public void removeWindowLayoutInfoListener(Consumer<WindowLayoutInfo> consumer) {
public void removeWindowLayoutInfoListener(@NonNull Consumer<WindowLayoutInfo> consumer) {
adapter.removeWindowLayoutInfoListener(consumer);
}
}

View File

@@ -652,7 +652,7 @@ public class FlutterViewTest {
flutterView.onAttachedToWindow();
// Then the WindowManager callback is registered
verify(windowInfoRepo, times(1)).addWindowLayoutInfoListener(any(), any());
verify(windowInfoRepo, times(1)).addWindowLayoutInfoListener(any(), any(), any());
// When the FlutterView is detached from the window
flutterView.onDetachedFromWindow();
@@ -695,7 +695,7 @@ public class FlutterViewTest {
flutterView.onAttachedToWindow();
ArgumentCaptor<Consumer<WindowLayoutInfo>> wmConsumerCaptor =
ArgumentCaptor.forClass((Class) Consumer.class);
verify(windowInfoRepo).addWindowLayoutInfoListener(any(), wmConsumerCaptor.capture());
verify(windowInfoRepo).addWindowLayoutInfoListener(any(), any(), wmConsumerCaptor.capture());
Consumer<WindowLayoutInfo> wmConsumer = wmConsumerCaptor.getValue();
wmConsumer.accept(testWindowLayout);

View File

@@ -43,7 +43,7 @@ android {
testImplementation "androidx.lifecycle:lifecycle-common-java8:2.2.0"
testImplementation "androidx.test:core:1.4.0"
testImplementation "androidx.tracing:tracing:1.0.0"
testImplementation "androidx.window:window-java:1.0.0-beta03"
testImplementation "androidx.window:window-java:1.0.0-beta04"
testImplementation "com.google.android.play:core:1.8.0"
testImplementation "com.ibm.icu:icu4j:69.1"
testImplementation "org.mockito:mockito-core:3.11.2"

View File

@@ -67,9 +67,9 @@
]
},
{
"url": "https://maven.google.com/androidx/window/window-java/1.0.0-beta03/window-java-1.0.0-beta03.aar",
"url": "https://maven.google.com/androidx/window/window-java/1.0.0-beta04/window-java-1.0.0-beta04.aar",
"out_file_name": "androidx_window_java.aar",
"maven_dependency": "androidx.window:window-java:1.0.0-beta03",
"maven_dependency": "androidx.window:window-java:1.0.0-beta04",
"provides": [
"androidx.window.java.layout.WindowInfoRepositoryCallbackAdapter",
"androidx.window.layout.DisplayFeature",

View File

@@ -7,50 +7,8 @@
## Steps
To update the embedding dependencies, just `cd` into this directory,
modify the dependencies in `build.gradle` and run `gradle updateDependencies`.
Once you have updated the dependencies, you can upload a new version by running
`cipd create --pkg-def cipd.yaml`. For more, see the Chromium instructions on ["Updating a CIPD
dependency"](https://chromium.googlesource.com/chromium/src/+/main/docs/cipd_and_3pp.md#Updating-a-CIPD-dependency) for how to upload a package update to CIPD.
On successful upload, you will receive a hash for the upload such as
`cipd: successfully uploaded and verified flutter/android/embedding_bundle:NZvE-rL3E66nHQZb5Vyl9-1Y_1MWEX7KURgOHqX2cYcC`
Let's further annotate the new upload with the current timestamp.
$ cipd set-tag flutter/android/embedding_bundle --version=<new_version_hash> -tag=last_updated:<timestamp>
Example of a last-updated timestamp: 2019-07-29T15:27:42-0700
You can generate the same date format with `date +%Y-%m-%dT%T%z`.
You can run `cipd describe flutter/android/embedding_bundle
--version=<new_version_hash>` to verify. You should see:
```
Package: flutter/android/embedding_bundle
Instance ID: <new_version_hash>
...
Tags:
last_updated:<timestamp>
```
Then update the `DEPS` file (located at /src/flutter/DEPS) to use the new version by pointing to
your new `last_updated_at` tag.
```
'src/third_party/android_embedding_dependencies': {
'packages': [
{
'package': 'flutter/android/embedding_bundle',
'version': 'last_updated:<timestamp>'
}
],
'condition': 'download_android_deps',
'dep_type': 'cipd',
},
```
You can now re-run `gclient sync` to fetch the latest package version.
1. `cd` into this directory.
2. Update the dependency in build.gradle.
3. Update the dependency used in Android unit tests `shell/platform/android/test_runner/build.gradle`
4. Run `./generate.sh`.
5. Update tools/androidx/files.json. (This file includes the Maven dependencies used to build Flutter apps).

View File

@@ -44,7 +44,7 @@ android {
embedding "androidx.core:core:1.6.0"
embedding "androidx.fragment:fragment:1.1.0"
embedding "androidx.tracing:tracing:1.0.0"
embedding "androidx.window:window-java:1.0.0-beta03"
embedding "androidx.window:window-java:1.0.0-beta04"
def lifecycle_version = "2.2.0"
embedding "androidx.lifecycle:lifecycle-runtime:$lifecycle_version"

View File

@@ -0,0 +1,29 @@
#!/bin/bash
#
# 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.
set -e
gradle updateDependencies
version_tag=`date +%Y-%m-%dT%T%z`
cipd create --pkg-def cipd.yaml -tag last_updated:"$version_tag"
echo ""
echo "Update the dependency in the DEPS file:"
echo ""
echo "'src/third_party/android_embedding_dependencies': {"
echo " 'packages': ["
echo " {"
echo " 'package': 'flutter/android/embedding_bundle',"
echo " 'version': 'last_updated:$version_tag'"
echo " }"
echo " ],"
echo " 'condition': 'download_android_deps',"
echo " 'dep_type': 'cipd',"
echo "}"
echo ""
echo "Run gclient sync"