mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
Replace WindowInsetsController... with adb shell commands (flutter/engine#51843)
Previously our screenshots looked like this (when they ran correctly):  Now, sometimes (only on CI unfortunately) they look like this:  This started happening after https://github.com/flutter/engine/pull/51832, but the change should be future-proof as well even if we disable the screen recording feature. h/t @reidbaker
This commit is contained in:
parent
4ec8483024
commit
e124b252ae
@ -9,12 +9,8 @@ import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.view.Window;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.core.view.WindowCompat;
|
||||
import androidx.core.view.WindowInsetsCompat;
|
||||
import androidx.core.view.WindowInsetsControllerCompat;
|
||||
import io.flutter.FlutterInjector;
|
||||
import io.flutter.embedding.engine.FlutterShellArgs;
|
||||
import io.flutter.embedding.engine.loader.FlutterLoader;
|
||||
@ -29,7 +25,6 @@ public abstract class TestActivity extends TestableFlutterActivity {
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
hideSystemBars(getWindow());
|
||||
testFlutterLoaderCallbackWhenInitializedTwice();
|
||||
}
|
||||
|
||||
@ -109,13 +104,4 @@ public abstract class TestActivity extends TestableFlutterActivity {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private static void hideSystemBars(Window window) {
|
||||
final WindowInsetsControllerCompat insetController =
|
||||
WindowCompat.getInsetsController(window, window.getDecorView());
|
||||
assert insetController != null;
|
||||
insetController.setSystemBarsBehavior(
|
||||
WindowInsetsControllerCompat.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE);
|
||||
insetController.hide(WindowInsetsCompat.Type.systemBars());
|
||||
}
|
||||
}
|
||||
|
||||
@ -298,17 +298,23 @@ Future<void> _run({
|
||||
});
|
||||
|
||||
await step('Configuring emulator...', () async {
|
||||
final int exitCode = await pm.runAndForward(<String>[
|
||||
adb.path,
|
||||
'shell',
|
||||
'settings',
|
||||
'put',
|
||||
'secure',
|
||||
'immersive_mode_confirmations',
|
||||
'confirmed',
|
||||
]);
|
||||
if (exitCode != 0) {
|
||||
panic(<String>['could not configure emulator']);
|
||||
final List<List<String>> adbShellCommands = <List<String>> [
|
||||
// Try to close all OS popups in the emulator, like "System UI stopped working".
|
||||
<String>['am', 'broadcast', '-a', 'android.intent.action.CLOSE_SYSTEM_DIALOGS'],
|
||||
|
||||
// Don't show "this is how you exit fullscreen mode".
|
||||
<String>['settings', 'put', 'secure', 'immersive_mode_confirmations', 'confirmed'],
|
||||
|
||||
// Hide all system bars.
|
||||
<String>['settings', 'put', 'global', 'policy_control', 'immersive.full=*'],
|
||||
];
|
||||
|
||||
// Run all the commands.
|
||||
for (final List<String> command in adbShellCommands) {
|
||||
final int exitCode = await pm.runAndForward(<String>[adb.path, 'shell', ...command]);
|
||||
if (exitCode != 0) {
|
||||
panic(<String>['could not run command: ${command.join(' ')}']);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user