forked from firka/flutter
Migrate android_console to null safety (#78923)
This commit is contained in:
@@ -2,9 +2,8 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// @dart = 2.8
|
||||
|
||||
import 'package:async/async.dart';
|
||||
|
||||
import '../base/io.dart';
|
||||
import '../convert.dart';
|
||||
|
||||
@@ -28,20 +27,20 @@ typedef AndroidConsoleSocketFactory = Future<Socket> Function(String host, int p
|
||||
class AndroidConsole {
|
||||
AndroidConsole(this._socket);
|
||||
|
||||
Socket _socket;
|
||||
StreamQueue<String> _queue;
|
||||
Socket? _socket;
|
||||
StreamQueue<String>? _queue;
|
||||
|
||||
Future<void> connect() async {
|
||||
assert(_socket != null);
|
||||
assert(_queue == null);
|
||||
|
||||
_queue = StreamQueue<String>(_socket.asyncMap(ascii.decode));
|
||||
_queue = StreamQueue<String>(_socket!.asyncMap(ascii.decode));
|
||||
|
||||
// Discard any initial connection text.
|
||||
await _readResponse();
|
||||
}
|
||||
|
||||
Future<String> getAvdName() async {
|
||||
Future<String?> getAvdName() async {
|
||||
if (_queue == null) {
|
||||
return null;
|
||||
}
|
||||
@@ -55,17 +54,17 @@ class AndroidConsole {
|
||||
_queue = null;
|
||||
}
|
||||
|
||||
Future<String> _readResponse() async {
|
||||
Future<String?> _readResponse() async {
|
||||
if (_queue == null) {
|
||||
return null;
|
||||
}
|
||||
final StringBuffer output = StringBuffer();
|
||||
while (true) {
|
||||
if (!await _queue.hasNext) {
|
||||
if (!await _queue!.hasNext) {
|
||||
destroy();
|
||||
return null;
|
||||
}
|
||||
final String text = await _queue.next;
|
||||
final String text = await _queue!.next;
|
||||
final String trimmedText = text.trim();
|
||||
if (trimmedText == 'OK') {
|
||||
break;
|
||||
|
||||
@@ -2,8 +2,6 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// @dart = 2.8
|
||||
|
||||
import 'package:meta/meta.dart';
|
||||
|
||||
import 'file_system.dart';
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
|
||||
import 'dart:async';
|
||||
import 'dart:math' as math;
|
||||
|
||||
|
||||
@@ -2,9 +2,6 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// @dart = 2.8
|
||||
|
||||
import 'package:meta/meta.dart';
|
||||
import 'package:process/process.dart';
|
||||
|
||||
import '../base/io.dart';
|
||||
@@ -16,10 +13,10 @@ import '../base/process.dart';
|
||||
/// See https://github.com/libimobiledevice/libusbmuxd.
|
||||
class IProxy {
|
||||
IProxy({
|
||||
@required String iproxyPath,
|
||||
@required Logger logger,
|
||||
@required ProcessManager processManager,
|
||||
@required MapEntry<String, String> dyLdLibEntry,
|
||||
required String iproxyPath,
|
||||
required Logger logger,
|
||||
required ProcessManager processManager,
|
||||
required MapEntry<String, String> dyLdLibEntry,
|
||||
}) : _dyLdLibEntry = dyLdLibEntry,
|
||||
_processUtils = ProcessUtils(processManager: processManager, logger: logger),
|
||||
_iproxyPath = iproxyPath;
|
||||
@@ -29,8 +26,8 @@ class IProxy {
|
||||
/// This specifies the path to iproxy as 'iproxy` and the dyLdLibEntry as
|
||||
/// 'DYLD_LIBRARY_PATH: /path/to/libs'.
|
||||
factory IProxy.test({
|
||||
@required Logger logger,
|
||||
@required ProcessManager processManager,
|
||||
required Logger logger,
|
||||
required ProcessManager processManager,
|
||||
}) {
|
||||
return IProxy(
|
||||
iproxyPath: 'iproxy',
|
||||
|
||||
@@ -2,9 +2,6 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// @dart = 2.8
|
||||
|
||||
import 'package:meta/meta.dart';
|
||||
import 'package:process/process.dart';
|
||||
|
||||
import '../base/file_system.dart';
|
||||
@@ -16,9 +13,9 @@ import '../convert.dart';
|
||||
|
||||
class PlistParser {
|
||||
PlistParser({
|
||||
@required FileSystem fileSystem,
|
||||
@required Logger logger,
|
||||
@required ProcessManager processManager,
|
||||
required FileSystem fileSystem,
|
||||
required Logger logger,
|
||||
required ProcessManager processManager,
|
||||
}) : _fileSystem = fileSystem,
|
||||
_logger = logger,
|
||||
_processUtils = ProcessUtils(logger: logger, processManager: processManager);
|
||||
@@ -58,7 +55,7 @@ class PlistParser {
|
||||
args,
|
||||
throwOnError: true,
|
||||
).stdout.trim();
|
||||
return castStringKeyedMap(json.decode(jsonContent));
|
||||
return castStringKeyedMap(json.decode(jsonContent)) ?? const <String, dynamic>{};
|
||||
} on ProcessException catch (error) {
|
||||
_logger.printTrace('$error');
|
||||
return const <String, dynamic>{};
|
||||
@@ -74,7 +71,7 @@ class PlistParser {
|
||||
/// If [key] is not found in the property list, this will return null.
|
||||
///
|
||||
/// The [plistFilePath] and [key] arguments must not be null.
|
||||
String getValueFromFile(String plistFilePath, String key) {
|
||||
String? getValueFromFile(String plistFilePath, String key) {
|
||||
assert(key != null);
|
||||
final Map<String, dynamic> parsed = parseFile(plistFilePath);
|
||||
return parsed[key] as String;
|
||||
|
||||
Reference in New Issue
Block a user