Repository: flutter
Issue: [add_to_app] Keyboard doesn't show when `TextField` has `autofocus: true`
Labels: a: text input,platform-android,framework,a: existing-apps,P2,found in release: 3.0,found in release: 3.1,team-text-input,triaged-text-input

## Steps to Reproduce

1. Execute `cd add_to_app/multiple_flutters/multiple_flutters_module && flutter pub get` 
2. Execute `cd add_to_app/multiple_flutters/multiple_flutters_android && ./gradlew clean installDebug`  or installRelease
3. Open App -> "NEXT" button
4. TextField not active IME

add_to_app:
```
W/InputMethodManager: Ignoring showSoftInput() as view=io.flutter.embedding.android.FlutterView{2205904 VFE...... .F....ID 0,0-1080,2210 #1} is not served.
W/InputMethodManager: Ignoring showSoftInput() as view=io.flutter.embedding.android.FlutterView{2205904 VFE...... .F....ID 0,0-1080,2210 #1} is not served.
```

If I create a flutter application from AndroidStudio on flutter sdk stable 3.0.5:
Debug mode is ok (log below), release also failed with reason `SHOW_SOFT_INPUT`

```
W/InputMethodManager(13319): Ignoring showSoftInput() as view=io.flutter.embedding.android.FlutterView{c1acb50 VFE...... .F....ID 0,0-1080,2210 #1} is not served.
D/DecorView[](13319): onWindowFocusChanged hasWindowFocus true
D/InputMethodManager(13319): showSoftInput() view=io.flutter.embedding.android.FlutterView{c1acb50 VFE...... .F...... 0,0-1080,2210 #1 aid=1073741824} flags=0 reason=SHOW_SOFT_INPUT
```


**Expected results:**
TextField can active IME when set `autofocus: true`. [Debug and Release]


**Actual results:**
TextField not active IME when set `autofocus: true`. [Debug and Release]

<details>
<summary>Code sample</summary>

```dart
// Copyright 2021 The Flutter team. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:url_launcher/url_launcher.dart' as launcher;

void main() => runApp(const MyApp(color: Colors.blue));

@pragma('vm:entry-point')
void topMain() => runApp(const MyApp(color: Colors.green));

@pragma('vm:entry-point')
void bottomMain() => runApp(const MyApp(color: Colors.purple));

class MyApp extends StatelessWidget {
  const MyApp({super.key, required this.color});

  final MaterialColor color;

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: color,
      ),
      home: const MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({super.key, required this.title});
  final String title;

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  int? _counter = 0;
  late MethodChannel _channel;

  @override
  void initState() {
    super.initState();
    _channel = const MethodChannel('multiple-flutters');
    _channel.setMethodCallHandler((call) async {
      if (call.method == "setCount") {
        // A notification that the host platform's data model has been updated.
        setState(() {
          _counter = call.arguments as int?;
        });
      } else {
        throw Exception('not implemented ${call.method}');
      }
    });
  }

  void _incrementCounter() {
    // Mutations to the data model are forwarded to the host platform.
    _channel.invokeMethod<void>("incrementCount", _counter);
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: [
            const Text(
              'You have pushed the button this many times:',
            ),
            Text(
              '$_counter',
              style: Theme.of(context).textTheme.headline4,
            ),
            TextButton(
              onPressed: _incrementCounter,
              child: const Text('Add'),
            ),
            TextButton(
              onPressed: () {
                _channel.invokeMethod<void>("next", _counter);
              },
              child: const Text('Next'),
            ),
            ElevatedButton(
              onPressed: () async {
                // Use the url_launcher plugin to open the Flutter docs in
                // a browser.
                final url = Uri.parse('https://flutter.dev/docs');
                if (await launcher.canLaunchUrl(url)) {
                  await launcher.launchUrl(url);
                }
              },
              child: const Text('Open Flutter Docs'),
            ),
            const TextField(
              autofocus: true,
            )
          ],
        ),
      ),
    );
  }
}
```

</details>

<details>
  <summary>Logs</summary>

```
2022-08-09 11:12:02.763 5701-7977/dev.flutter.multipleflutters I/flutter: The Dart VM service is listening on http://127.0.0.1:37959/UrrsqGWIk-0=/
2022-08-09 11:12:02.815 5701-7961/dev.flutter.multipleflutters V/DartMessenger: Received message from Dart over channel 'flutter/isolate'
2022-08-09 11:12:02.820 5701-5701/dev.flutter.multipleflutters V/DartMessenger: Deferring to registered handler to process message.
2022-08-09 11:12:02.885 5701-5701/dev.flutter.multipleflutters V/DartMessenger: Received message reply from Dart.
2022-08-09 11:12:03.011 5701-7961/dev.flutter.multipleflutters V/DartMessenger: Received message from Dart over channel 'flutter/platform'
2022-08-09 11:12:03.019 5701-5701/dev.flutter.multipleflutters V/DartMessenger: Deferring to registered handler to process message.
2022-08-09 11:12:03.019 5701-5701/dev.flutter.multipleflutters V/PlatformChannel: Received 'SystemChrome.setApplicationSwitcherDescription' message.
2022-08-09 11:12:03.051 5701-7961/dev.flutter.multipleflutters V/DartMessenger: Received message from Dart over channel 'flutter/navigation'
2022-08-09 11:12:03.052 5701-5701/dev.flutter.multipleflutters V/DartMessenger: Deferring to registered handler to process message.
2022-08-09 11:12:03.073 5701-7961/dev.flutter.multipleflutters V/DartMessenger: Received message from Dart over channel 'flutter/navigation'
2022-08-09 11:12:03.074 5701-5701/dev.flutter.multipleflutters V/DartMessenger: Deferring to registered handler to process message.
2022-08-09 11:12:03.286 5701-7961/dev.flutter.multipleflutters V/DartMessenger: Received message from Dart over channel 'flutter/platform'
2022-08-09 11:12:03.297 5701-5701/dev.flutter.multipleflutters V/DartMessenger: Deferring to registered handler to process message.
2022-08-09 11:12:03.297 5701-5701/dev.flutter.multipleflutters V/PlatformChannel: Received 'Clipboard.hasStrings' message.
2022-08-09 11:12:03.369 5701-5701/dev.flutter.multipleflutters V/DartMessenger: Received message reply from Dart.
2022-08-09 11:12:03.369 5701-5701/dev.flutter.multipleflutters V/DartMessenger: Received message reply from Dart.
2022-08-09 11:12:03.529 5701-7961/dev.flutter.multipleflutters V/DartMessenger: Received message from Dart over channel 'flutter/platform'
2022-08-09 11:12:03.530 5701-5701/dev.flutter.multipleflutters V/DartMessenger: Deferring to registered handler to process message.
2022-08-09 11:12:03.530 5701-5701/dev.flutter.multipleflutters V/PlatformChannel: Received 'SystemChrome.setSystemUIOverlayStyle' message.
2022-08-09 11:12:03.539 5701-7961/dev.flutter.multipleflutters V/DartMessenger: Received message from Dart over channel 'flutter/textinput'
2022-08-09 11:12:03.540 5701-7961/dev.flutter.multipleflutters V/DartMessenger: Received message from Dart over channel 'flutter/textinput'
2022-08-09 11:12:03.541 5701-5701/dev.flutter.multipleflutters V/DartMessenger: Deferring to registered handler to process message.
2022-08-09 11:12:03.541 5701-5701/dev.flutter.multipleflutters V/TextInputChannel: Received 'TextInput.setClient' message.
2022-08-09 11:12:03.542 5701-5701/dev.flutter.multipleflutters V/DartMessenger: Deferring to registered handler to process message.
2022-08-09 11:12:03.542 5701-5701/dev.flutter.multipleflutters V/TextInputChannel: Received 'TextInput.setEditableSizeAndTransform' message.
2022-08-09 11:12:03.543 5701-7961/dev.flutter.multipleflutters V/DartMessenger: Received message from Dart over channel 'flutter/textinput'
2022-08-09 11:12:03.543 5701-7961/dev.flutter.multipleflutters V/DartMessenger: Received message from Dart over channel 'flutter/textinput'
2022-08-09 11:12:03.544 5701-7961/dev.flutter.multipleflutters V/DartMessenger: Received message from Dart over channel 'flutter/textinput'
2022-08-09 11:12:03.544 5701-7961/dev.flutter.multipleflutters V/DartMessenger: Received message from Dart over channel 'flutter/textinput'
2022-08-09 11:12:03.544 5701-7961/dev.flutter.multipleflutters V/DartMessenger: Received message from Dart over channel 'flutter/textinput'
2022-08-09 11:12:03.549 5701-7961/dev.flutter.multipleflutters V/DartMessenger: Received message from Dart over channel 'flutter/textinput'
2022-08-09 11:12:03.550 5701-7961/dev.flutter.multipleflutters V/DartMessenger: Received message from Dart over channel 'flutter/textinput'
2022-08-09 11:12:03.552 5701-5701/dev.flutter.multipleflutters V/DartMessenger: Deferring to registered handler to process message.
2022-08-09 11:12:03.552 5701-5701/dev.flutter.multipleflutters V/TextInputChannel: Received 'TextInput.setMarkedTextRect' message.
2022-08-09 11:12:03.552 5701-5701/dev.flutter.multipleflutters V/DartMessenger: Deferring to registered handler to process message.
2022-08-09 11:12:03.552 5701-5701/dev.flutter.multipleflutters V/TextInputChannel: Received 'TextInput.setStyle' message.
2022-08-09 11:12:03.553 5701-5701/dev.flutter.multipleflutters V/DartMessenger: Deferring to registered handler to process message.
2022-08-09 11:12:03.553 5701-5701/dev.flutter.multipleflutters V/TextInputChannel: Received 'TextInput.setEditingState' message.
2022-08-09 11:12:03.553 5701-5701/dev.flutter.multipleflutters V/ListenableEditingState: didFinishBatchEdit with 1 listener(s)
2022-08-09 11:12:03.553 5701-5701/dev.flutter.multipleflutters V/DartMessenger: Deferring to registered handler to process message.
2022-08-09 11:12:03.553 5701-5701/dev.flutter.multipleflutters V/TextInputChannel: Received 'TextInput.show' message.
2022-08-09 11:12:03.553 5701-5701/dev.flutter.multipleflutters W/InputMethodManager: Ignoring showSoftInput() as view=io.flutter.embedding.android.FlutterView{55f4aeb VFE...... .F....ID 0,0-1080,2210 #1} is not served.
2022-08-09 11:12:03.554 5701-5701/dev.flutter.multipleflutters V/DartMessenger: Deferring to registered handler to process message.
2022-08-09 11:12:03.554 5701-5701/dev.flutter.multipleflutters V/TextInputChannel: Received 'TextInput.requestAutofill' message.
2022-08-09 11:12:03.556 5701-5701/dev.flutter.multipleflutters V/DartMessenger: Deferring to registered handler to process message.
2022-08-09 11:12:03.557 5701-5701/dev.flutter.multipleflutters V/TextInputChannel: Received 'TextInput.setEditingState' message.
2022-08-09 11:12:03.557 5701-5701/dev.flutter.multipleflutters V/ListenableEditingState: didFinishBatchEdit with 1 listener(s)
2022-08-09 11:12:03.557 5701-5701/dev.flutter.multipleflutters V/DartMessenger: Deferring to registered handler to process message.
2022-08-09 11:12:03.557 5701-5701/dev.flutter.multipleflutters V/TextInputChannel: Received 'TextInput.show' message.
2022-08-09 11:12:03.557 5701-5701/dev.flutter.multipleflutters W/InputMethodManager: Ignoring showSoftInput() as view=io.flutter.embedding.android.FlutterView{55f4aeb VFE...... .F....ID 0,0-1080,2210 #1} is not served.
2022-08-09 11:12:03.565 5701-5701/dev.flutter.multipleflutters I/AssistStructure: Flattened final assist data: 412 bytes, containing 1 windows, 3 views
2022-08-09 11:12:03.590 5701-7961/dev.flutter.multipleflutters V/DartMessenger: Received message from Dart over channel 'flutter/platform'
2022-08-09 11:12:03.597 5701-5701/dev.flutter.multipleflutters V/DartMessenger: Deferring to registered handler to process message.
2022-08-09 11:12:03.597 5701-5701/dev.flutter.multipleflutters V/PlatformChannel: Received 'Clipboard.hasStrings' message.
2022-08-09 11:12:03.613 5701-7961/dev.flutter.multipleflutters V/DartMessenger: Received message from Dart over channel 'flutter/textinput'
2022-08-09 11:12:03.619 5701-5701/dev.flutter.multipleflutters V/DartMessenger: Deferring to registered handler to process message.
2022-08-09 11:12:03.619 5701-5701/dev.flutter.multipleflutters V/TextInputChannel: Received 'TextInput.setCaretRect' message.
2022-08-09 11:12:03.620 5701-5701/dev.flutter.multipleflutters V/FlutterSurfaceView: onFlutterUiDisplayed()
2022-08-09 11:12:03.649 5701-5701/dev.flutter.multipleflutters E/MFA: onWindowFocusChanged: true
2022-08-09 11:12:03.649 5701-5701/dev.flutter.multipleflutters D/DecorView[]: onWindowFocusChanged hasWindowFocus true

```

```
Flutter 3.0.5 • channel stable • https://github.com/flutter/flutter.git
Framework • revision f1875d570e (4 weeks ago) • 2022-07-13 11:24:16 -0700
Engine • revision e85ea0e79c
Tools • Dart 2.17.6 • DevTools 2.12.2
```

</details>