diff --git a/engine/src/build/config/android/config.gni b/engine/src/build/config/android/config.gni index 0cf362de747..faf04fe2c9c 100644 --- a/engine/src/build/config/android/config.gni +++ b/engine/src/build/config/android/config.gni @@ -19,7 +19,7 @@ if (is_android) { # Unused. Required for GN files maintained in other buildroots. enable_java_templates = false - android_api_level = 22 + android_api_level = 24 } # Host stuff ----------------------------------------------------------------- diff --git a/engine/src/build/toolchain/android/BUILD.gn b/engine/src/build/toolchain/android/BUILD.gn index 4bd89c1046a..1fd53092ddb 100644 --- a/engine/src/build/toolchain/android/BUILD.gn +++ b/engine/src/build/toolchain/android/BUILD.gn @@ -146,7 +146,7 @@ android_toolchains_helper("arm64") { # This toolchain should only be used to build the target # //third_party/vulkan_validation_layers. This is because vulkan validation # layers requires API level >= 26, but Flutter officially supports down to API -# level 22, which is the default value of the android_api_level argument. +# level 24, which is the default value of the android_api_level argument. android_toolchains_helper("arm64_apilevel26") { toolchain_cpu = "arm64" extra_toolchain_args = { diff --git a/engine/src/flutter/shell/platform/android/AndroidManifest.xml b/engine/src/flutter/shell/platform/android/AndroidManifest.xml index f9a98fc368b..b2e2c9e0dfb 100644 --- a/engine/src/flutter/shell/platform/android/AndroidManifest.xml +++ b/engine/src/flutter/shell/platform/android/AndroidManifest.xml @@ -5,7 +5,7 @@ --> - + diff --git a/engine/src/flutter/shell/platform/android/BUILD.gn b/engine/src/flutter/shell/platform/android/BUILD.gn index f6f495271e7..0fac68b10f3 100644 --- a/engine/src/flutter/shell/platform/android/BUILD.gn +++ b/engine/src/flutter/shell/platform/android/BUILD.gn @@ -371,7 +371,6 @@ android_java_sources = [ "io/flutter/util/HandlerCompat.java", "io/flutter/util/PathUtils.java", "io/flutter/util/Preconditions.java", - "io/flutter/util/Predicate.java", "io/flutter/util/TraceSection.java", "io/flutter/util/ViewUtils.java", "io/flutter/view/AccessibilityBridge.java", diff --git a/engine/src/flutter/shell/platform/android/io/flutter/embedding/android/FlutterView.java b/engine/src/flutter/shell/platform/android/io/flutter/embedding/android/FlutterView.java index 5feac48ce0c..ccedb57b047 100644 --- a/engine/src/flutter/shell/platform/android/io/flutter/embedding/android/FlutterView.java +++ b/engine/src/flutter/shell/platform/android/io/flutter/embedding/android/FlutterView.java @@ -619,7 +619,7 @@ public class FlutterView extends FrameLayout return ZeroSides.RIGHT; } else if (rotation == Surface.ROTATION_270) { // In android API >= 23, the nav bar always appears on the "bottom" (USB) side. - return Build.VERSION.SDK_INT >= API_LEVELS.API_23 ? ZeroSides.LEFT : ZeroSides.RIGHT; + return ZeroSides.LEFT; } // Ambiguous orientation due to landscape left/right default. Zero both sides. else if (rotation == Surface.ROTATION_0 || rotation == Surface.ROTATION_180) { diff --git a/engine/src/flutter/shell/platform/android/io/flutter/plugin/editing/TextInputPlugin.java b/engine/src/flutter/shell/platform/android/io/flutter/plugin/editing/TextInputPlugin.java index 4f1b5ee27c5..67cda46e3b2 100644 --- a/engine/src/flutter/shell/platform/android/io/flutter/plugin/editing/TextInputPlugin.java +++ b/engine/src/flutter/shell/platform/android/io/flutter/plugin/editing/TextInputPlugin.java @@ -364,7 +364,7 @@ public class TextInputPlugin implements ListenableEditingState.EditingStateWatch } outAttrs.imeOptions |= enterAction; - if (Build.VERSION.SDK_INT >= API_LEVELS.API_24 && configuration.hintLocales != null) { + if (configuration.hintLocales != null) { outAttrs.hintLocales = new LocaleList(configuration.hintLocales); } diff --git a/engine/src/flutter/shell/platform/android/io/flutter/plugin/localization/LocalizationPlugin.java b/engine/src/flutter/shell/platform/android/io/flutter/plugin/localization/LocalizationPlugin.java index 1ef443f524c..090faabfd8b 100644 --- a/engine/src/flutter/shell/platform/android/io/flutter/plugin/localization/LocalizationPlugin.java +++ b/engine/src/flutter/shell/platform/android/io/flutter/plugin/localization/LocalizationPlugin.java @@ -106,7 +106,7 @@ public class LocalizationPlugin { return platformResolvedLocale; } return supportedLocales.get(0); - } else if (Build.VERSION.SDK_INT >= API_LEVELS.API_24) { + } else { // Modern locale resolution without languageRange // https://developer.android.com/guide/topics/resources/multilingual-support#postN LocaleList localeList = context.getResources().getConfiguration().getLocales(); @@ -133,25 +133,6 @@ public class LocalizationPlugin { } return supportedLocales.get(0); } - - // Legacy locale resolution - // https://developer.android.com/guide/topics/resources/multilingual-support#preN - Locale preferredLocale = context.getResources().getConfiguration().locale; - if (preferredLocale != null) { - // Look for exact match. - for (Locale locale : supportedLocales) { - if (preferredLocale.equals(locale)) { - return locale; - } - } - // Look for exact language only match. - for (Locale locale : supportedLocales) { - if (preferredLocale.getLanguage().equals(locale.toString())) { - return locale; - } - } - } - return supportedLocales.get(0); } /** @@ -162,15 +143,11 @@ public class LocalizationPlugin { @SuppressWarnings("deprecation") public void sendLocalesToFlutter(@NonNull Configuration config) { List locales = new ArrayList<>(); - if (Build.VERSION.SDK_INT >= API_LEVELS.API_24) { - LocaleList localeList = config.getLocales(); - int localeCount = localeList.size(); - for (int index = 0; index < localeCount; ++index) { - Locale locale = localeList.get(index); - locales.add(locale); - } - } else { - locales.add(config.locale); + LocaleList localeList = config.getLocales(); + int localeCount = localeList.size(); + for (int index = 0; index < localeCount; ++index) { + Locale locale = localeList.get(index); + locales.add(locale); } localizationChannel.sendLocales(locales); diff --git a/engine/src/flutter/shell/platform/android/io/flutter/plugin/platform/PlatformPlugin.java b/engine/src/flutter/shell/platform/android/io/flutter/plugin/platform/PlatformPlugin.java index 3c3ceea6f7b..cdd0ad35d14 100644 --- a/engine/src/flutter/shell/platform/android/io/flutter/plugin/platform/PlatformPlugin.java +++ b/engine/src/flutter/shell/platform/android/io/flutter/plugin/platform/PlatformPlugin.java @@ -202,9 +202,7 @@ public class PlatformPlugin { view.performHapticFeedback(HapticFeedbackConstants.KEYBOARD_TAP); break; case HEAVY_IMPACT: - if (Build.VERSION.SDK_INT >= API_LEVELS.API_23) { - view.performHapticFeedback(HapticFeedbackConstants.CONTEXT_CLICK); - } + view.performHapticFeedback(HapticFeedbackConstants.CONTEXT_CLICK); break; case SELECTION_CLICK: view.performHapticFeedback(HapticFeedbackConstants.CLOCK_TICK); @@ -463,25 +461,23 @@ public class PlatformPlugin { // If transparent, SDK 29 and higher may apply a translucent scrim behind the bar to ensure // proper contrast. This can be overridden with // SystemChromeStyle.systemStatusBarContrastEnforced. - if (Build.VERSION.SDK_INT >= API_LEVELS.API_23) { - if (systemChromeStyle.statusBarIconBrightness != null) { - switch (systemChromeStyle.statusBarIconBrightness) { - case DARK: - // Dark status bar icon brightness. - // Light status bar appearance. - windowInsetsControllerCompat.setAppearanceLightStatusBars(true); - break; - case LIGHT: - // Light status bar icon brightness. - // Dark status bar appearance. - windowInsetsControllerCompat.setAppearanceLightStatusBars(false); - break; - } + if (systemChromeStyle.statusBarIconBrightness != null) { + switch (systemChromeStyle.statusBarIconBrightness) { + case DARK: + // Dark status bar icon brightness. + // Light status bar appearance. + windowInsetsControllerCompat.setAppearanceLightStatusBars(true); + break; + case LIGHT: + // Light status bar icon brightness. + // Dark status bar appearance. + windowInsetsControllerCompat.setAppearanceLightStatusBars(false); + break; } + } - if (systemChromeStyle.statusBarColor != null) { - window.setStatusBarColor(systemChromeStyle.statusBarColor); - } + if (systemChromeStyle.statusBarColor != null) { + window.setStatusBarColor(systemChromeStyle.statusBarColor); } // You can't override the enforced contrast for a transparent status bar until SDK 29. // This overrides the translucent scrim that may be placed behind the bar on SDK 29+ to ensure diff --git a/engine/src/flutter/shell/platform/android/io/flutter/plugin/platform/PlatformViewsController.java b/engine/src/flutter/shell/platform/android/io/flutter/plugin/platform/PlatformViewsController.java index 22bacd050c1..b45ca244961 100644 --- a/engine/src/flutter/shell/platform/android/io/flutter/plugin/platform/PlatformViewsController.java +++ b/engine/src/flutter/shell/platform/android/io/flutter/plugin/platform/PlatformViewsController.java @@ -229,8 +229,7 @@ public class PlatformViewsController implements PlatformViewsAccessibilityDelega // view hierarchy via callbacks such as ViewParent#onDescendantInvalidated(). // - The API level is <23, due to TLHC implementation API requirements. final boolean supportsTextureLayerMode = - Build.VERSION.SDK_INT >= API_LEVELS.API_23 - && !ViewUtils.hasChildViewOfType(embeddedView, VIEW_TYPES_REQUIRE_NON_TLHC); + !ViewUtils.hasChildViewOfType(embeddedView, VIEW_TYPES_REQUIRE_NON_TLHC); // Fall back to Hybrid Composition or Virtual Display when necessary, depending on which // fallback mode is requested. diff --git a/engine/src/flutter/shell/platform/android/io/flutter/plugin/platform/SurfaceTexturePlatformViewRenderTarget.java b/engine/src/flutter/shell/platform/android/io/flutter/plugin/platform/SurfaceTexturePlatformViewRenderTarget.java index 51b9f467e68..d87f58b80a8 100644 --- a/engine/src/flutter/shell/platform/android/io/flutter/plugin/platform/SurfaceTexturePlatformViewRenderTarget.java +++ b/engine/src/flutter/shell/platform/android/io/flutter/plugin/platform/SurfaceTexturePlatformViewRenderTarget.java @@ -61,11 +61,6 @@ public class SurfaceTexturePlatformViewRenderTarget implements PlatformViewRende /** Implementation of PlatformViewRenderTarget */ public SurfaceTexturePlatformViewRenderTarget(SurfaceTextureEntry surfaceTextureEntry) { - if (Build.VERSION.SDK_INT < API_LEVELS.API_23) { - throw new UnsupportedOperationException( - "Platform views cannot be displayed below API level 23" - + "You can prevent this issue by setting `minSdkVersion: 23` in build.gradle."); - } this.surfaceTextureEntry = surfaceTextureEntry; this.surfaceTexture = surfaceTextureEntry.surfaceTexture(); surfaceTextureEntry.setOnTrimMemoryListener(trimMemoryListener); diff --git a/engine/src/flutter/shell/platform/android/io/flutter/plugin/text/ProcessTextPlugin.java b/engine/src/flutter/shell/platform/android/io/flutter/plugin/text/ProcessTextPlugin.java index 6383bdd4a96..d9213988fd2 100644 --- a/engine/src/flutter/shell/platform/android/io/flutter/plugin/text/ProcessTextPlugin.java +++ b/engine/src/flutter/shell/platform/android/io/flutter/plugin/text/ProcessTextPlugin.java @@ -71,11 +71,6 @@ public class ProcessTextPlugin return; } - if (Build.VERSION.SDK_INT < API_LEVELS.API_23) { - result.error("error", "Android version not supported", null); - return; - } - if (resolveInfosById == null) { result.error("error", "Can not process text actions before calling queryTextActions", null); return; @@ -106,10 +101,6 @@ public class ProcessTextPlugin private void cacheResolveInfos() { resolveInfosById = new HashMap(); - if (Build.VERSION.SDK_INT < API_LEVELS.API_23) { - return; - } - Intent intent = new Intent().setAction(Intent.ACTION_PROCESS_TEXT).setType("text/plain"); List infos; diff --git a/engine/src/flutter/shell/platform/android/io/flutter/util/PathUtils.java b/engine/src/flutter/shell/platform/android/io/flutter/util/PathUtils.java index 15b6d1e7528..1222261c7a9 100644 --- a/engine/src/flutter/shell/platform/android/io/flutter/util/PathUtils.java +++ b/engine/src/flutter/shell/platform/android/io/flutter/util/PathUtils.java @@ -4,10 +4,7 @@ package io.flutter.util; -import static io.flutter.Build.API_LEVELS; - import android.content.Context; -import android.os.Build; import androidx.annotation.NonNull; import java.io.File; @@ -50,10 +47,6 @@ public final class PathUtils { } private static String getDataDirPath(Context applicationContext) { - if (Build.VERSION.SDK_INT >= API_LEVELS.API_24) { - return applicationContext.getDataDir().getPath(); - } else { - return applicationContext.getApplicationInfo().dataDir; - } + return applicationContext.getDataDir().getPath(); } } diff --git a/engine/src/flutter/shell/platform/android/io/flutter/util/Predicate.java b/engine/src/flutter/shell/platform/android/io/flutter/util/Predicate.java deleted file mode 100644 index 074fbd6b3ec..00000000000 --- a/engine/src/flutter/shell/platform/android/io/flutter/util/Predicate.java +++ /dev/null @@ -1,11 +0,0 @@ -// 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.util; - -// TODO(dnfield): remove this if/when we can use appcompat to support it. -// java.util.function.Predicate isn't available until API24 -public interface Predicate { - public abstract boolean test(T t); -} diff --git a/engine/src/flutter/shell/platform/android/io/flutter/view/AccessibilityBridge.java b/engine/src/flutter/shell/platform/android/io/flutter/view/AccessibilityBridge.java index f05ce4c96c2..45c8e1dc79f 100644 --- a/engine/src/flutter/shell/platform/android/io/flutter/view/AccessibilityBridge.java +++ b/engine/src/flutter/shell/platform/android/io/flutter/view/AccessibilityBridge.java @@ -34,7 +34,6 @@ import io.flutter.BuildConfig; import io.flutter.Log; import io.flutter.embedding.engine.systemchannels.AccessibilityChannel; import io.flutter.plugin.platform.PlatformViewsAccessibilityDelegate; -import io.flutter.util.Predicate; import io.flutter.util.ViewUtils; import io.flutter.view.AccessibilityStringBuilder.LocaleStringAttribute; import io.flutter.view.AccessibilityStringBuilder.SpellOutStringAttribute; @@ -45,6 +44,7 @@ import java.nio.ByteOrder; import java.nio.charset.Charset; import java.nio.charset.StandardCharsets; import java.util.*; +import java.util.function.Predicate; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -271,7 +271,7 @@ public class AccessibilityBridge extends AccessibilityNodeProvider { // not get left behind. @NonNull private final List flutterNavigationStack = new ArrayList<>(); - // TODO(mattcarroll): why do we need previouseRouteId if we have flutterNavigationStack + // TODO(mattcarroll): why do we need previousRouteId if we have flutterNavigationStack private int previousRouteId = ROOT_NODE_ID; // Tracks the left system inset of the screen because Flutter needs to manually adjust @@ -516,7 +516,8 @@ public class AccessibilityBridge extends AccessibilityNodeProvider { this.contentResolver.registerContentObserver(transitionUri, false, animationScaleObserver); // Tells Flutter whether the text should be bolded or not. If the user changes bold text - // setting, the configuration will change and trigger a re-build of the accessibilityBridge. + // setting, the configuration will change and trigger a re-build of the + // accessibilityBridge. if (Build.VERSION.SDK_INT >= API_LEVELS.API_31) { setBoldTextFlag(); } @@ -719,9 +720,7 @@ public class AccessibilityBridge extends AccessibilityNodeProvider { if (flutterSemanticsTree.containsKey(ROOT_NODE_ID)) { result.addChild(rootAccessibilityView, ROOT_NODE_ID); } - if (Build.VERSION.SDK_INT >= API_LEVELS.API_24) { - result.setImportantForAccessibility(false); - } + result.setImportantForAccessibility(false); return result; } @@ -755,9 +754,7 @@ public class AccessibilityBridge extends AccessibilityNodeProvider { // Accessibility Scanner uses isImportantForAccessibility to decide whether to check // or skip this node. - if (Build.VERSION.SDK_INT >= API_LEVELS.API_24) { - result.setImportantForAccessibility(isImportant(semanticsNode)); - } + result.setImportantForAccessibility(isImportant(semanticsNode)); // Work around for https://github.com/flutter/flutter/issues/21030 result.setViewIdResourceName(""); diff --git a/engine/src/flutter/shell/platform/android/io/flutter/view/AccessibilityViewEmbedder.java b/engine/src/flutter/shell/platform/android/io/flutter/view/AccessibilityViewEmbedder.java index 7260d4a8681..6c0286caf9d 100644 --- a/engine/src/flutter/shell/platform/android/io/flutter/view/AccessibilityViewEmbedder.java +++ b/engine/src/flutter/shell/platform/android/io/flutter/view/AccessibilityViewEmbedder.java @@ -244,15 +244,9 @@ class AccessibilityViewEmbedder { output.setRangeInfo(input.getRangeInfo()); output.setError(input.getError()); output.setMaxTextLength(input.getMaxTextLength()); - if (Build.VERSION.SDK_INT >= API_LEVELS.API_23) { - output.setContextClickable(input.isContextClickable()); - // TODO(amirh): copy traversal before and after. - // https://github.com/flutter/flutter/issues/29718 - } - if (Build.VERSION.SDK_INT >= API_LEVELS.API_24) { - output.setDrawingOrder(input.getDrawingOrder()); - output.setImportantForAccessibility(input.isImportantForAccessibility()); - } + output.setContextClickable(input.isContextClickable()); + output.setDrawingOrder(input.getDrawingOrder()); + output.setImportantForAccessibility(input.isImportantForAccessibility()); if (Build.VERSION.SDK_INT >= API_LEVELS.API_26) { output.setAvailableExtraData(input.getAvailableExtraData()); output.setHintText(input.getHintText());