Skip to content

Commit

Permalink
Migrate embedding to AndroidX (#17075)
Browse files Browse the repository at this point in the history
  • Loading branch information
Emmanuel Garcia authored Mar 14, 2020
1 parent cedddb7 commit 025e2d8
Show file tree
Hide file tree
Showing 106 changed files with 454 additions and 551 deletions.
15 changes: 3 additions & 12 deletions DEPS
Original file line number Diff line number Diff line change
Expand Up @@ -497,11 +497,11 @@ deps = {
'dep_type': 'cipd',
},

'src/third_party/robolectric': {
'src/third_party/android_embedding_dependencies': {
'packages': [
{
'package': 'flutter/android/robolectric_bundle',
'version': 'last_updated:2019-09-09T16:47:38-0700'
'package': 'flutter/android/embedding_bundle',
'version': 'last_updated:2020-03-13T15:42:26-0700'
}
],
'condition': 'download_android_deps',
Expand Down Expand Up @@ -593,15 +593,6 @@ hooks = [
'pattern': '.',
'action': ['python', 'src/build/vs_toolchain.py', 'update'],
},
{
'name': 'download_android_support',
'pattern': '.',
'condition': 'download_android_deps',
'action': [
'python',
'src/flutter/tools/android_support/download_android_support.py',
],
},
{
'name': 'generate_package_files',
'pattern': '.',
Expand Down
290 changes: 145 additions & 145 deletions ci/licenses_golden/licenses_fuchsia

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion ci/licenses_golden/tool_signature
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
Signature: 9ad4afaa43bd81d0e6a011688ca40377
Signature: c182c713338fa4bfd82bfab82778038b

52 changes: 18 additions & 34 deletions shell/platform/android/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -228,15 +228,14 @@ android_java_sources = [
"io/flutter/view/VsyncWaiter.java",
]

android_support_jars = [
"//third_party/android_support/android_support_compat.jar",
"//third_party/android_support/android_support_annotations.jar",
"//third_party/android_support/android_support_fragment.jar",
"//third_party/android_support/android_arch_lifecycle_common.jar",
"//third_party/android_support/android_arch_lifecycle_common_java8.jar",
"//third_party/android_support/android_arch_lifecycle_runtime.jar",
"//third_party/android_support/android_arch_lifecycle_viewmodel.jar",
]
list_script = rebase_path("//build/ls.py", ".", "//")
embedding_dependencies_jars =
exec_script(list_script,
[
"--target-directory",
rebase_path("//third_party/android_embedding_dependencies"),
],
"list lines")

action("flutter_shell_java") {
script = "//build/android/gyp/javac.py"
Expand All @@ -256,18 +255,15 @@ action("flutter_shell_java") {
source_jar_path,
source_jar_path + ".md5.stamp",
]
inputs = [
android_sdk_jar,
]
inputs += android_support_jars
inputs = [ android_sdk_jar ] + embedding_dependencies_jars

_rebased_current_path = rebase_path(".")
_rebased_jar_path = rebase_path(jar_path, root_build_dir)
_rebased_source_jar_path = rebase_path(source_jar_path, root_build_dir)
_rebased_depfile = rebase_path(depfile, root_build_dir)
_rebased_android_sdk_jar = rebase_path(android_sdk_jar, root_build_dir)
_rebased_classpath = [ _rebased_android_sdk_jar ] +
rebase_path(android_support_jars, root_build_dir)
rebase_path(embedding_dependencies_jars, root_build_dir)

args = [
"--depfile=$_rebased_depfile",
Expand Down Expand Up @@ -357,10 +353,10 @@ action("android_jar") {
}

action("pom_libflutter") {
script = "//flutter/tools/android_support/generate_pom_file.py"
script = "//flutter/tools/androidx/generate_pom_file.py"

inputs = [
"//flutter/tools/android_support/files.json",
"//flutter/tools/androidx/files.json",
]

artifact_id =
Expand All @@ -381,10 +377,10 @@ action("pom_libflutter") {
}

action("pom_embedding") {
script = "//flutter/tools/android_support/generate_pom_file.py"
script = "//flutter/tools/androidx/generate_pom_file.py"

inputs = [
"//flutter/tools/android_support/files.json",
"//flutter/tools/androidx/files.json",
]

artifact_id = "flutter_embedding_$flutter_runtime_mode"
Expand Down Expand Up @@ -451,21 +447,9 @@ action("robolectric_tests") {
]

_jar_dependencies = [
android_sdk_jar,
embedding_jar_path,
"//third_party/robolectric/lib/junit-3.8.jar",
"//third_party/robolectric/lib/junit-4.13-beta-3.jar",
"//third_party/robolectric/lib/robolectric-3.8.jar",
"//third_party/robolectric/lib/shadows-framework-3.8.jar",
"//third_party/robolectric/lib/annotations-3.8.jar",
"//third_party/robolectric/lib/shadowapi-3.8.jar",
"//third_party/robolectric/lib/runtime-1.1.1.jar",
"//third_party/robolectric/lib/common-1.1.1.jar",
"//third_party/robolectric/lib/common-java8-1.1.1.jar",
"//third_party/robolectric/lib/support-annotations-28.0.0.jar",
"//third_party/robolectric/lib/support-fragment-25.2.0.jar",
"//third_party/robolectric/lib/mockito-all-1.10.19.jar",
]
android_sdk_jar,
embedding_jar_path,
] + embedding_dependencies_jars

inputs = _jar_dependencies

Expand Down Expand Up @@ -532,7 +516,7 @@ zip_bundle("android") {
# https://github.com/flutter/flutter/issues/42400
action("gen_android_javadoc") {
script = "//flutter/tools/gen_javadoc.py"
sources = android_java_sources + android_support_jars
sources = android_java_sources + embedding_dependencies_jars

outputs = [
"$target_gen_dir/javadocs",
Expand Down
3 changes: 3 additions & 0 deletions shell/platform/android/embedding_bundle/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Don't include the jars in the engine repo.
lib/
.gradle
22 changes: 9 additions & 13 deletions shell/platform/android/embedding_bundle/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -44,27 +44,23 @@ android {
embedding "androidx.fragment:fragment:1.1.0"

def lifecycle_version = "2.2.0"
embedding "androidx.lifecycle:lifecycle-viewmodel:$lifecycle_version"
embedding "androidx.lifecycle:lifecycle-livedata:$lifecycle_version"
embedding "androidx.lifecycle:lifecycle-runtime:$lifecycle_version"
embedding "androidx.lifecycle:lifecycle-viewmodel-savedstate:$lifecycle_version"
embedding "androidx.lifecycle:lifecycle-compiler:$lifecycle_version"
embedding "androidx.lifecycle:lifecycle-common:$lifecycle_version"
embedding "androidx.lifecycle:lifecycle-common-java8:$lifecycle_version"
embedding "androidx.lifecycle:lifecycle-service:$lifecycle_version"
embedding "androidx.lifecycle:lifecycle-process:$lifecycle_version"
embedding "androidx.lifecycle:lifecycle-reactivestreams:$lifecycle_version"

// Testing
embeddingTesting "androidx.arch.core:core-testing:2.1.0"
embeddingTesting "org.robolectric:android-all:8.1.0-robolectric-4611349"
// This is required by the robolectric test.
embeddingTesting_duplicated "org.robolectric:android-all:4.1.2_r1-robolectric-r1"
embeddingTesting "org.robolectric:robolectric:3.8"
embeddingTesting "org.robolectric:junit:3.8"
embeddingTesting "org.robolectric:shadows-framework:3.8"
embeddingTesting "org.robolectric:resources:3.8"
embeddingTesting "org.mockito:mockito-all:1.10.19"
embeddingTesting "junit:junit:4.13-beta-3"
embeddingTesting ("org.robolectric:robolectric:4.3") {
// org.hamcrest is added by org.mockito:mockito-all
exclude group: "org.hamcrest", module:"hamcrest-core"
}
embeddingTesting ("junit:junit:4.13") {
// org.hamcrest is added by org.mockito:mockito-all
exclude group: "org.hamcrest", module:"hamcrest-core"
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion shell/platform/android/io/flutter/Log.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

package io.flutter;

import android.support.annotation.NonNull;
import androidx.annotation.NonNull;

/**
* Port of {@link android.util.Log} that only logs in {@link io.flutter.BuildConfig#DEBUG} mode and
Expand Down
2 changes: 1 addition & 1 deletion shell/platform/android/io/flutter/app/FlutterActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import android.content.Intent;
import android.content.res.Configuration;
import android.os.Bundle;
import android.support.annotation.NonNull;
import androidx.annotation.NonNull;
import io.flutter.app.FlutterActivityDelegate.ViewFactory;
import io.flutter.plugin.common.PluginRegistry;
import io.flutter.view.FlutterNativeView;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import android.app.Activity;
import android.app.Application;
import android.support.annotation.CallSuper;
import androidx.annotation.CallSuper;
import io.flutter.view.FlutterMain;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import android.content.Intent;
import android.content.res.Configuration;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import androidx.fragment.app.FragmentActivity;
import io.flutter.app.FlutterActivityDelegate.ViewFactory;
import io.flutter.plugin.common.PluginRegistry;
import io.flutter.view.FlutterNativeView;
Expand All @@ -25,7 +25,7 @@
* app to ensure that {@link FragmentActivity} is available at runtime.
*
* @see <a target="_new"
* href="https://developer.android.com/topic/libraries/support-library/setup.html">https://developer.android.com/topic/libraries/support-library/setup.html</a>
* href="https://developer.android.com/training/testing/set-up-project">https://developer.android.com/training/testing/set-up-project</a>
*/
public class FlutterFragmentActivity extends FragmentActivity
implements FlutterView.Provider, PluginRegistry, ViewFactory {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@

package io.flutter.embedding.android;

import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.view.KeyCharacterMap;
import android.view.KeyEvent;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import io.flutter.embedding.engine.systemchannels.KeyEventChannel;
import io.flutter.plugin.editing.TextInputPlugin;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package io.flutter.embedding.android;

import android.os.Build;
import android.support.annotation.IntDef;
import android.support.annotation.NonNull;
import android.view.InputDevice;
import android.view.MotionEvent;
import androidx.annotation.IntDef;
import androidx.annotation.NonNull;
import io.flutter.embedding.engine.renderer.FlutterRenderer;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
import android.content.Context;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.util.AttributeSet;
import android.view.View;
import android.widget.ImageView;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

/**
* {@link SplashScreen} that displays a given {@link Drawable}, which then fades its alpha to zero
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@
import static io.flutter.embedding.android.FlutterActivityLaunchConfigs.SPLASH_SCREEN_META_DATA_KEY;

import android.app.Activity;
import android.arch.lifecycle.Lifecycle;
import android.arch.lifecycle.LifecycleOwner;
import android.arch.lifecycle.LifecycleRegistry;
import android.content.Context;
import android.content.Intent;
import android.content.pm.ActivityInfo;
Expand All @@ -30,12 +27,15 @@
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.annotation.VisibleForTesting;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.VisibleForTesting;
import androidx.lifecycle.Lifecycle;
import androidx.lifecycle.LifecycleOwner;
import androidx.lifecycle.LifecycleRegistry;
import io.flutter.Log;
import io.flutter.embedding.android.FlutterActivityLaunchConfigs.BackgroundMode;
import io.flutter.embedding.engine.FlutterEngine;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,17 @@
import static android.content.ComponentCallbacks2.TRIM_MEMORY_RUNNING_LOW;

import android.app.Activity;
import android.arch.lifecycle.Lifecycle;
import android.content.Context;
import android.content.Intent;
import android.os.Build;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.annotation.VisibleForTesting;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.VisibleForTesting;
import androidx.lifecycle.Lifecycle;
import io.flutter.Log;
import io.flutter.app.FlutterActivity;
import io.flutter.embedding.engine.FlutterEngine;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
package io.flutter.embedding.android;

import android.app.Activity;
import android.arch.lifecycle.Lifecycle;
import android.support.annotation.NonNull;
import androidx.annotation.NonNull;
import androidx.lifecycle.Lifecycle;
import io.flutter.embedding.engine.FlutterEngine;

/**
* Configures a {@link FlutterEngine} after it is created, e.g., adds plugins.
*
* <p>This interface may be applied to a {@link android.support.v4.app.FragmentActivity} that owns a
* <p>This interface may be applied to a {@link androidx.fragment.app.FragmentActivity} that owns a
* {@code FlutterFragment}.
*/
public interface FlutterEngineConfigurator {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
package io.flutter.embedding.android;

import android.content.Context;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import io.flutter.embedding.engine.FlutterEngine;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,18 @@
package io.flutter.embedding.android;

import android.app.Activity;
import android.arch.lifecycle.Lifecycle;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.annotation.VisibleForTesting;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.VisibleForTesting;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentActivity;
import androidx.lifecycle.Lifecycle;
import io.flutter.Log;
import io.flutter.embedding.engine.FlutterEngine;
import io.flutter.embedding.engine.FlutterShellArgs;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentManager;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.view.WindowManager;
import android.widget.FrameLayout;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.FragmentActivity;
import androidx.fragment.app.FragmentManager;
import io.flutter.Log;
import io.flutter.embedding.android.FlutterActivityLaunchConfigs.BackgroundMode;
import io.flutter.embedding.engine.FlutterEngine;
Expand Down
Loading

1 comment on commit 025e2d8

@cwlp8024
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When I use PlatformView with GestureDetector and swipe it quickly with multiple fingers in flutter app, the program crashes

#61421

Please sign in to comment.