Skip to content

Commit

Permalink
Upgrade Android SDK to 34 "UpsideDownCake" (flutter#47609)
Browse files Browse the repository at this point in the history
~**This should not land until flutter/buildroot#790 (re)lands, and I swap the buildroot url back to the latest commit.**~ ~Reland of PR to update buildroot at flutter/buildroot#792. ~ <- landed, and changed the buildroot commit to the latest in DEPS

Upgrades to android api 34

Also:
1. Upgrades to java 17 in DEPS/ci, because the linter now requires it.
2. Stops running some roboelectric tests on android apis 16-18, because Roboelectric indicated those versions were unsupported and we don't support them either.
3. Applies the four trivial new suggestions from the newer linter.
4. Updates the baseline lint to include the new non-trivial lint ([fixed in a different PR](https://github.com/flutter/engine/pull/47817/files)).
5. Changes some instances where we were hardcoding android apis as numbers (e.g. `sdk = 16') to use version codes (see the [comment below](flutter#47609 (comment))).

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
  • Loading branch information
gmackall authored Nov 8, 2023
1 parent 93f3d6c commit aec3b0f
Show file tree
Hide file tree
Showing 18 changed files with 83 additions and 77 deletions.
6 changes: 3 additions & 3 deletions .ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ platform_properties:
# CIPD flutter/java/openjdk/$platform
dependencies: >-
[
{"dependency": "open_jdk", "version": "version:11"},
{"dependency": "open_jdk", "version": "version:17"},
{"dependency": "gradle_cache", "version": "none"}
]
device_type: none
Expand All @@ -49,7 +49,7 @@ platform_properties:
# CIPD flutter/java/openjdk/$platform
dependencies: >-
[
{"dependency": "open_jdk", "version": "version:11"}
{"dependency": "open_jdk", "version": "version:17"}
]
device_type: none
cpu: x86
Expand All @@ -76,7 +76,7 @@ platform_properties:
# CIPD flutter/java/openjdk/$platform
dependencies: >-
[
{"dependency": "open_jdk", "version": "version:11"}
{"dependency": "open_jdk", "version": "version:17"}
]
device_type: none
os: Windows-10
Expand Down
6 changes: 3 additions & 3 deletions DEPS
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ allowed_hosts = [
]

deps = {
'src': 'https://github.com/flutter/buildroot.git' + '@' + '5ced4367fee2721f6eda34802dc28b1335637c63',
'src': 'https://github.com/flutter/buildroot.git' + '@' + '44ca359ea6fada2fa1bb007b81994fa4dc8ce2ec',

'src/flutter/third_party/rapidjson':
Var('fuchsia_git') + '/third_party/rapidjson' + '@' + 'ef3564c5c8824989393b87df25355baf35ff544b',
Expand Down Expand Up @@ -766,7 +766,7 @@ deps = {
'packages': [
{
'package': 'flutter/android/sdk/all/${{platform}}',
'version': 'version:33v6'
'version': 'version:34v3'
}
],
'condition': 'download_android_deps',
Expand Down Expand Up @@ -798,7 +798,7 @@ deps = {
'packages': [
{
'package': 'flutter/java/openjdk/${{platform}}',
'version': 'version:11'
'version': 'version:17'
}
],
'condition': 'download_android_deps',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ public FlutterView(@NonNull Context context, @NonNull RenderMode renderMode) {
renderSurface = flutterTextureView;
} else {
throw new IllegalArgumentException(
String.format("RenderMode not supported with this constructor: %s", renderMode));
"RenderMode not supported with this constructor: " + renderMode);
}

init();
Expand Down Expand Up @@ -327,7 +327,7 @@ public FlutterView(
renderSurface = flutterTextureView;
} else {
throw new IllegalArgumentException(
String.format("RenderMode not supported with this constructor: %s", renderMode));
"RenderMode not supported with this constructor: " + renderMode);
}

init();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -330,17 +330,17 @@ public void installDeferredComponent(int loadingUnitId, @Nullable String compone
case SplitInstallErrorCode.NETWORK_ERROR:
flutterJNI.deferredComponentInstallFailure(
loadingUnitId,
String.format(
"Install of deferred component module \"%s\" failed with a network error",
componentName),
"Install of deferred component module \""
+ componentName
+ "\" failed with a network error",
true);
break;
case SplitInstallErrorCode.MODULE_UNAVAILABLE:
flutterJNI.deferredComponentInstallFailure(
loadingUnitId,
String.format(
"Install of deferred component module \"%s\" failed as it is unavailable",
componentName),
"Install of deferred component module \""
+ componentName
+ "\" failed as it is unavailable",
false);
break;
default:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
* EmbeddedView
*/
@Keep
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
@TargetApi(Build.VERSION_CODES.KITKAT)
class SingleViewPresentation extends Presentation {
private static final String TAG = "PlatformViewsController";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,7 @@ public void itReleaseEngineWhenOnDestroy() {
}

@Test
@Config(minSdk = Build.VERSION_CODES.JELLY_BEAN, maxSdk = Build.VERSION_CODES.P)
@Config(minSdk = Build.VERSION_CODES.KITKAT, maxSdk = Build.VERSION_CODES.P)
public void fullyDrawn_beforeAndroidQ() {
Intent intent = FlutterActivityWithReportFullyDrawn.createDefaultIntent(ctx);
ActivityController<FlutterActivityWithReportFullyDrawn> activityController =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ public void computePlatformResolvedLocale_fromAndroidN() {
// Tests the legacy pre API 24 algorithm.
@Test
@Config(
minSdk = Build.VERSION_CODES.JELLY_BEAN,
minSdk = Build.VERSION_CODES.KITKAT,
maxSdk = Build.VERSION_CODES.M,
qualifiers = "es-rMX")
public void computePlatformResolvedLocale_emptySupportedLocales_beforeAndroidN() {
Expand All @@ -252,7 +252,7 @@ public void computePlatformResolvedLocale_emptySupportedLocales_beforeAndroidN()
}

@Test
@Config(minSdk = Build.VERSION_CODES.JELLY_BEAN, maxSdk = Build.VERSION_CODES.M, qualifiers = "")
@Config(minSdk = Build.VERSION_CODES.KITKAT, maxSdk = Build.VERSION_CODES.M, qualifiers = "")
public void computePlatformResolvedLocale_selectFirstLocaleWhenNoUserSetting_beforeAndroidN() {
FlutterJNI flutterJNI = new FlutterJNI();
DartExecutor dartExecutor = mock(DartExecutor.class);
Expand All @@ -273,7 +273,7 @@ public void computePlatformResolvedLocale_selectFirstLocaleWhenNoUserSetting_bef

@Test
@Config(
minSdk = Build.VERSION_CODES.JELLY_BEAN,
minSdk = Build.VERSION_CODES.KITKAT,
maxSdk = Build.VERSION_CODES.M,
qualifiers = "fr-rCH")
public void computePlatformResolvedLocale_selectFirstLocaleWhenNoExactMatch_beforeAndroidN() {
Expand All @@ -299,7 +299,7 @@ public void computePlatformResolvedLocale_selectFirstLocaleWhenNoExactMatch_befo

@Test
@Config(
minSdk = Build.VERSION_CODES.JELLY_BEAN,
minSdk = Build.VERSION_CODES.KITKAT,
maxSdk = Build.VERSION_CODES.M,
qualifiers = "it-rIT")
public void computePlatformResolvedLocale_selectExactMatchLocale_beforeAndroidN() {
Expand All @@ -325,7 +325,7 @@ public void computePlatformResolvedLocale_selectExactMatchLocale_beforeAndroidN(

@Test
@Config(
minSdk = Build.VERSION_CODES.JELLY_BEAN,
minSdk = Build.VERSION_CODES.KITKAT,
maxSdk = Build.VERSION_CODES.M,
qualifiers = "fr-rCH")
public void computePlatformResolvedLocale_selectOnlyLanguageLocale_beforeAndroidN() {
Expand All @@ -351,35 +351,35 @@ public void computePlatformResolvedLocale_selectOnlyLanguageLocale_beforeAndroid
}

// Tests the legacy pre API 21 algorithm.
@Config(sdk = 16)
@Config(sdk = Build.VERSION_CODES.KITKAT)
@Test
public void localeFromString_languageOnly() {
Locale locale = LocalizationPlugin.localeFromString("en");
assertEquals(locale, new Locale("en"));
}

@Config(sdk = 16)
@Config(sdk = Build.VERSION_CODES.KITKAT)
@Test
public void localeFromString_languageAndCountry() {
Locale locale = LocalizationPlugin.localeFromString("en-US");
assertEquals(locale, new Locale("en", "US"));
}

@Config(sdk = 16)
@Config(sdk = Build.VERSION_CODES.KITKAT)
@Test
public void localeFromString_languageCountryAndVariant() {
Locale locale = LocalizationPlugin.localeFromString("zh-Hans-CN");
assertEquals(locale, new Locale("zh", "CN", "Hans"));
}

@Config(sdk = 16)
@Config(sdk = Build.VERSION_CODES.KITKAT)
@Test
public void localeFromString_underscore() {
Locale locale = LocalizationPlugin.localeFromString("zh_Hans_CN");
assertEquals(locale, new Locale("zh", "CN", "Hans"));
}

@Config(sdk = 16)
@Config(sdk = Build.VERSION_CODES.KITKAT)
@Test
public void localeFromString_additionalVariantsAreIgnored() {
Locale locale = LocalizationPlugin.localeFromString("de-DE-u-co-phonebk");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
public class PlatformPluginTest {
private final Context ctx = ApplicationProvider.getApplicationContext();

@Config(sdk = 16)
@Config(sdk = Build.VERSION_CODES.KITKAT)
@Test
public void itIgnoresNewHapticEventsOnOldAndroidPlatforms() {
View fakeDecorView = mock(View.class);
Expand All @@ -70,7 +70,7 @@ public void itIgnoresNewHapticEventsOnOldAndroidPlatforms() {
platformPlugin.vibrateHapticFeedback(PlatformChannel.HapticFeedbackType.SELECTION_CLICK);
}

@Config(sdk = 29)
@Config(sdk = Build.VERSION_CODES.Q)
@Test
public void platformPlugin_getClipboardData() throws IOException {
ClipboardManager clipboardManager = ctx.getSystemService(ClipboardManager.class);
Expand Down Expand Up @@ -100,7 +100,7 @@ public void platformPlugin_getClipboardData() throws IOException {

@SuppressWarnings("deprecation")
// ClipboardManager.getText
@Config(sdk = 28)
@Config(sdk = Build.VERSION_CODES.P)
@Test
public void platformPlugin_hasStrings() {
ClipboardManager clipboardManager = spy(ctx.getSystemService(ClipboardManager.class));
Expand Down Expand Up @@ -154,7 +154,7 @@ public void platformPlugin_hasStrings() {
verify(clipboardManager, never()).getText();
}

@Config(sdk = 29)
@Config(sdk = Build.VERSION_CODES.Q)
@Test
public void setNavigationBarDividerColor() {
View fakeDecorView = mock(View.class);
Expand Down Expand Up @@ -229,7 +229,7 @@ public void setNavigationBarDividerColor() {
}
}

@Config(sdk = 30)
@Config(sdk = Build.VERSION_CODES.R)
@Test
public void setNavigationBarIconBrightness() {
if (Build.VERSION.SDK_INT >= 30) {
Expand Down Expand Up @@ -276,7 +276,7 @@ public void setNavigationBarIconBrightness() {
}
}

@Config(sdk = 30)
@Config(sdk = Build.VERSION_CODES.R)
@Test
public void setStatusBarIconBrightness() {
if (Build.VERSION.SDK_INT >= 30) {
Expand Down Expand Up @@ -323,7 +323,7 @@ public void setStatusBarIconBrightness() {

@SuppressWarnings("deprecation")
// SYSTEM_UI_FLAG_*, setSystemUiVisibility
@Config(sdk = 29)
@Config(sdk = Build.VERSION_CODES.Q)
@Test
public void setSystemUiMode() {
View fakeDecorView = mock(View.class);
Expand Down Expand Up @@ -440,7 +440,7 @@ public void setSystemUiModeListener_overlaysAreVisible() {

@SuppressWarnings("deprecation")
// SYSTEM_UI_FLAG_*, setSystemUiVisibility
@Config(sdk = 28)
@Config(sdk = Build.VERSION_CODES.P)
@Test
public void doNotEnableEdgeToEdgeOnOlderSdk() {
View fakeDecorView = mock(View.class);
Expand All @@ -462,7 +462,7 @@ public void doNotEnableEdgeToEdgeOnOlderSdk() {

@SuppressWarnings("deprecation")
// FLAG_TRANSLUCENT_STATUS, FLAG_TRANSLUCENT_NAVIGATION
@Config(sdk = 29)
@Config(sdk = Build.VERSION_CODES.Q)
@Test
public void verifyWindowFlagsSetToStyleOverlays() {
View fakeDecorView = mock(View.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

package io.flutter.plugin.platform;

import static android.os.Build.VERSION_CODES.JELLY_BEAN_MR1;
import static android.os.Build.VERSION_CODES.KITKAT;
import static android.os.Build.VERSION_CODES.P;
import static android.os.Build.VERSION_CODES.R;
import static org.junit.Assert.assertEquals;
Expand All @@ -28,7 +28,7 @@
@TargetApi(P)
public class SingleViewPresentationTest {
@Test
@Config(minSdk = JELLY_BEAN_MR1, maxSdk = R)
@Config(minSdk = KITKAT, maxSdk = R)
public void returnsOuterContextInputMethodManager() {
// There's a bug in Android Q caused by the IMM being instanced per display.
// https://github.com/flutter/flutter/issues/38375. We need the context returned by
Expand Down Expand Up @@ -59,7 +59,7 @@ public void returnsOuterContextInputMethodManager() {
}

@Test
@Config(minSdk = JELLY_BEAN_MR1, maxSdk = R)
@Config(minSdk = KITKAT, maxSdk = R)
public void returnsOuterContextInputMethodManager_createDisplayContext() {
// The IMM should also persist across display contexts created from the base context.

Expand Down
4 changes: 2 additions & 2 deletions shell/platform/android/test_runner/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ println "AVAILABLE PROCESSORS: $availableProcessors"
println "=========================================="

android {
compileSdkVersion 33
compileSdkVersion 34

defaultConfig {
minSdkVersion 16
minSdkVersion 19
}

compileOptions {
Expand Down
8 changes: 4 additions & 4 deletions testing/android_background_image/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,16 @@ android {
// The others are irrelevant for a test application.
disable 'UnpackedNativeCode','MissingApplicationIcon','GoogleAppIndexingApiWarning','GoogleAppIndexingWarning','GradleDependency','NewerVersionAvailable'
}
buildToolsVersion = '33.0.0'
compileSdkVersion 33
buildToolsVersion = '34.0.0'
compileSdkVersion 34
compileOptions {
sourceCompatibility JavaVersion.VERSION_11
targetCompatibility JavaVersion.VERSION_11
}
defaultConfig {
applicationId 'dev.flutter.android_background_image'
minSdkVersion 16
targetSdkVersion 33
minSdkVersion 19
targetSdkVersion 34
versionCode 1
versionName '1.0'
}
Expand Down
8 changes: 4 additions & 4 deletions testing/scenario_app/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,16 @@ android {
// The others are irrelevant for a test application.
disable 'UnpackedNativeCode','MissingApplicationIcon','GoogleAppIndexingApiWarning','GoogleAppIndexingWarning','GradleDependency','NewerVersionAvailable','Registered'
}
buildToolsVersion = '33.0.0'
compileSdkVersion 33
buildToolsVersion = '34.0.0'
compileSdkVersion 34
compileOptions {
sourceCompatibility JavaVersion.VERSION_11
targetCompatibility JavaVersion.VERSION_11
}
defaultConfig {
applicationId 'dev.flutter.scenarios'
minSdkVersion 18
targetSdkVersion 33
minSdkVersion 19
targetSdkVersion 34
versionCode 1
versionName '1.0'
testInstrumentationRunner 'dev.flutter.TestRunner'
Expand Down
Loading

0 comments on commit aec3b0f

Please sign in to comment.