Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
0c9a4205
Unverified
Commit
0c9a4205
authored
Oct 30, 2021
by
Jenn Magder
Committed by
GitHub
Oct 30, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Migrate android_device to null safety (#92128)
parent
53e04de6
Changes
9
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
205 additions
and
251 deletions
+205
-251
android_device.dart
packages/flutter_tools/lib/src/android/android_device.dart
+166
-170
android_device_discovery.dart
...utter_tools/lib/src/android/android_device_discovery.dart
+23
-25
adb_log_reader_test.dart
...tools/test/general.shard/android/adb_log_reader_test.dart
+1
-3
android_device_discovery_test.dart
.../general.shard/android/android_device_discovery_test.dart
+0
-1
android_device_port_forwarder_test.dart
...ral.shard/android/android_device_port_forwarder_test.dart
+0
-2
android_device_start_test.dart
...test/general.shard/android/android_device_start_test.dart
+3
-5
android_device_stop_test.dart
.../test/general.shard/android/android_device_stop_test.dart
+0
-31
android_device_test.dart
...tools/test/general.shard/android/android_device_test.dart
+6
-7
android_install_test.dart
...ools/test/general.shard/android/android_install_test.dart
+6
-7
No files found.
packages/flutter_tools/lib/src/android/android_device.dart
View file @
0c9a4205
This diff is collapsed.
Click to expand it.
packages/flutter_tools/lib/src/android/android_device_discovery.dart
View file @
0c9a4205
...
@@ -2,9 +2,6 @@
...
@@ -2,9 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// found in the LICENSE file.
// @dart = 2.8
import
'package:meta/meta.dart'
;
import
'package:process/process.dart'
;
import
'package:process/process.dart'
;
import
'../base/common.dart'
;
import
'../base/common.dart'
;
...
@@ -29,13 +26,13 @@ import 'android_workflow.dart';
...
@@ -29,13 +26,13 @@ import 'android_workflow.dart';
/// * [AndroidDevice], the type of discovered device.
/// * [AndroidDevice], the type of discovered device.
class
AndroidDevices
extends
PollingDeviceDiscovery
{
class
AndroidDevices
extends
PollingDeviceDiscovery
{
AndroidDevices
({
AndroidDevices
({
@
required
AndroidWorkflow
androidWorkflow
,
required
AndroidWorkflow
androidWorkflow
,
@
required
ProcessManager
processManager
,
required
ProcessManager
processManager
,
@
required
Logger
logger
,
required
Logger
logger
,
@required
AndroidSdk
androidSdk
,
AndroidSdk
?
androidSdk
,
@
required
FileSystem
fileSystem
,
required
FileSystem
fileSystem
,
@
required
Platform
platform
,
required
Platform
platform
,
@
required
UserMessages
userMessages
,
required
UserMessages
userMessages
,
})
:
_androidWorkflow
=
androidWorkflow
,
})
:
_androidWorkflow
=
androidWorkflow
,
_androidSdk
=
androidSdk
,
_androidSdk
=
androidSdk
,
_processUtils
=
ProcessUtils
(
_processUtils
=
ProcessUtils
(
...
@@ -51,7 +48,7 @@ class AndroidDevices extends PollingDeviceDiscovery {
...
@@ -51,7 +48,7 @@ class AndroidDevices extends PollingDeviceDiscovery {
final
AndroidWorkflow
_androidWorkflow
;
final
AndroidWorkflow
_androidWorkflow
;
final
ProcessUtils
_processUtils
;
final
ProcessUtils
_processUtils
;
final
AndroidSdk
_androidSdk
;
final
AndroidSdk
?
_androidSdk
;
final
ProcessManager
_processManager
;
final
ProcessManager
_processManager
;
final
Logger
_logger
;
final
Logger
_logger
;
final
FileSystem
_fileSystem
;
final
FileSystem
_fileSystem
;
...
@@ -65,13 +62,13 @@ class AndroidDevices extends PollingDeviceDiscovery {
...
@@ -65,13 +62,13 @@ class AndroidDevices extends PollingDeviceDiscovery {
bool
get
canListAnything
=>
_androidWorkflow
.
canListDevices
;
bool
get
canListAnything
=>
_androidWorkflow
.
canListDevices
;
@override
@override
Future
<
List
<
Device
>>
pollingGetDevices
({
Duration
timeout
})
async
{
Future
<
List
<
Device
>>
pollingGetDevices
({
Duration
?
timeout
})
async
{
if
(
_doesNotHaveAdb
())
{
if
(
_doesNotHaveAdb
())
{
return
<
AndroidDevice
>[];
return
<
AndroidDevice
>[];
}
}
String
text
;
String
text
;
try
{
try
{
text
=
(
await
_processUtils
.
run
(<
String
>[
_androidSdk
.
adbPath
,
'devices'
,
'-l'
],
text
=
(
await
_processUtils
.
run
(<
String
>[
_androidSdk
!.
adbPath
!
,
'devices'
,
'-l'
],
throwOnError:
true
,
throwOnError:
true
,
)).
stdout
.
trim
();
)).
stdout
.
trim
();
}
on
ProcessException
catch
(
exception
)
{
}
on
ProcessException
catch
(
exception
)
{
...
@@ -94,7 +91,7 @@ class AndroidDevices extends PollingDeviceDiscovery {
...
@@ -94,7 +91,7 @@ class AndroidDevices extends PollingDeviceDiscovery {
return
<
String
>[];
return
<
String
>[];
}
}
final
RunResult
result
=
await
_processUtils
.
run
(<
String
>[
_androidSdk
.
adbPath
,
'devices'
,
'-l'
]);
final
RunResult
result
=
await
_processUtils
.
run
(<
String
>[
_androidSdk
!.
adbPath
!
,
'devices'
,
'-l'
]);
if
(
result
.
exitCode
!=
0
)
{
if
(
result
.
exitCode
!=
0
)
{
return
<
String
>[];
return
<
String
>[];
}
}
...
@@ -108,8 +105,8 @@ class AndroidDevices extends PollingDeviceDiscovery {
...
@@ -108,8 +105,8 @@ class AndroidDevices extends PollingDeviceDiscovery {
bool
_doesNotHaveAdb
()
{
bool
_doesNotHaveAdb
()
{
return
_androidSdk
==
null
||
return
_androidSdk
==
null
||
_androidSdk
.
adbPath
==
null
||
_androidSdk
?
.
adbPath
==
null
||
!
_processManager
.
canRun
(
_androidSdk
.
adbPath
);
!
_processManager
.
canRun
(
_androidSdk
!
.
adbPath
);
}
}
// 015d172c98400a03 device usb:340787200X product:nakasi model:Nexus_7 device:grouper
// 015d172c98400a03 device usb:340787200X product:nakasi model:Nexus_7 device:grouper
...
@@ -120,8 +117,8 @@ class AndroidDevices extends PollingDeviceDiscovery {
...
@@ -120,8 +117,8 @@ class AndroidDevices extends PollingDeviceDiscovery {
/// in which case information for that parameter won't be populated.
/// in which case information for that parameter won't be populated.
void
_parseADBDeviceOutput
(
void
_parseADBDeviceOutput
(
String
text
,
{
String
text
,
{
List
<
AndroidDevice
>
devices
,
List
<
AndroidDevice
>
?
devices
,
List
<
String
>
diagnostics
,
List
<
String
>
?
diagnostics
,
})
{
})
{
// Check for error messages from adb
// Check for error messages from adb
if
(!
text
.
contains
(
'List of devices'
))
{
if
(!
text
.
contains
(
'List of devices'
))
{
...
@@ -146,11 +143,11 @@ class AndroidDevices extends PollingDeviceDiscovery {
...
@@ -146,11 +143,11 @@ class AndroidDevices extends PollingDeviceDiscovery {
}
}
if
(
_kDeviceRegex
.
hasMatch
(
line
))
{
if
(
_kDeviceRegex
.
hasMatch
(
line
))
{
final
Match
match
=
_kDeviceRegex
.
firstMatch
(
line
);
final
Match
match
=
_kDeviceRegex
.
firstMatch
(
line
)
!
;
final
String
deviceID
=
match
[
1
];
final
String
deviceID
=
match
[
1
]
!
;
final
String
deviceState
=
match
[
2
];
final
String
deviceState
=
match
[
2
]
!
;
String
rest
=
match
[
3
];
String
rest
=
match
[
3
]
!
;
final
Map
<
String
,
String
>
info
=
<
String
,
String
>{};
final
Map
<
String
,
String
>
info
=
<
String
,
String
>{};
if
(
rest
!=
null
&&
rest
.
isNotEmpty
)
{
if
(
rest
!=
null
&&
rest
.
isNotEmpty
)
{
...
@@ -163,8 +160,9 @@ class AndroidDevices extends PollingDeviceDiscovery {
...
@@ -163,8 +160,9 @@ class AndroidDevices extends PollingDeviceDiscovery {
}
}
}
}
if
(
info
[
'model'
]
!=
null
)
{
final
String
?
model
=
info
[
'model'
];
info
[
'model'
]
=
cleanAdbDeviceName
(
info
[
'model'
]);
if
(
model
!=
null
)
{
info
[
'model'
]
=
cleanAdbDeviceName
(
model
);
}
}
if
(
deviceState
==
'unauthorized'
)
{
if
(
deviceState
==
'unauthorized'
)
{
...
@@ -180,7 +178,7 @@ class AndroidDevices extends PollingDeviceDiscovery {
...
@@ -180,7 +178,7 @@ class AndroidDevices extends PollingDeviceDiscovery {
productID:
info
[
'product'
],
productID:
info
[
'product'
],
modelID:
info
[
'model'
]
??
deviceID
,
modelID:
info
[
'model'
]
??
deviceID
,
deviceCodeName:
info
[
'device'
],
deviceCodeName:
info
[
'device'
],
androidSdk:
_androidSdk
,
androidSdk:
_androidSdk
!
,
fileSystem:
_fileSystem
,
fileSystem:
_fileSystem
,
logger:
_logger
,
logger:
_logger
,
platform:
_platform
,
platform:
_platform
,
...
...
packages/flutter_tools/test/general.shard/android/adb_log_reader_test.dart
View file @
0c9a4205
...
@@ -2,8 +2,6 @@
...
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// found in the LICENSE file.
// @dart = 2.8
import
'dart:async'
;
import
'dart:async'
;
import
'package:flutter_tools/src/android/android_device.dart'
;
import
'package:flutter_tools/src/android/android_device.dart'
;
...
@@ -183,7 +181,7 @@ void main() {
...
@@ -183,7 +181,7 @@ void main() {
});
});
}
}
AndroidDevice
createFakeDevice
(
int
sdkLevel
)
{
AndroidDevice
createFakeDevice
(
int
?
sdkLevel
)
{
return
FakeAndroidDevice
(
return
FakeAndroidDevice
(
sdkLevel
.
toString
(),
sdkLevel
.
toString
(),
kLastLogcatTimestamp
,
kLastLogcatTimestamp
,
...
...
packages/flutter_tools/test/general.shard/android/android_device_discovery_test.dart
View file @
0c9a4205
...
@@ -72,7 +72,6 @@ void main() {
...
@@ -72,7 +72,6 @@ void main() {
testWithoutContext
(
'AndroidDevices returns empty device list and diagnostics on null Android SDK'
,
()
async
{
testWithoutContext
(
'AndroidDevices returns empty device list and diagnostics on null Android SDK'
,
()
async
{
final
AndroidDevices
androidDevices
=
AndroidDevices
(
final
AndroidDevices
androidDevices
=
AndroidDevices
(
androidSdk:
null
,
logger:
BufferLogger
.
test
(),
logger:
BufferLogger
.
test
(),
androidWorkflow:
AndroidWorkflow
(
androidWorkflow:
AndroidWorkflow
(
androidSdk:
FakeAndroidSdk
(
null
),
androidSdk:
FakeAndroidSdk
(
null
),
...
...
packages/flutter_tools/test/general.shard/android/android_device_port_forwarder_test.dart
View file @
0c9a4205
...
@@ -2,8 +2,6 @@
...
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// found in the LICENSE file.
// @dart = 2.8
import
'package:flutter_tools/src/android/android_device.dart'
;
import
'package:flutter_tools/src/android/android_device.dart'
;
import
'package:flutter_tools/src/base/logger.dart'
;
import
'package:flutter_tools/src/base/logger.dart'
;
import
'package:flutter_tools/src/device_port_forwarder.dart'
;
import
'package:flutter_tools/src/device_port_forwarder.dart'
;
...
...
packages/flutter_tools/test/general.shard/android/android_device_start_test.dart
View file @
0c9a4205
...
@@ -2,8 +2,6 @@
...
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// found in the LICENSE file.
// @dart = 2.8
import
'package:file/memory.dart'
;
import
'package:file/memory.dart'
;
import
'package:flutter_tools/src/android/android_device.dart'
;
import
'package:flutter_tools/src/android/android_device.dart'
;
import
'package:flutter_tools/src/android/android_sdk.dart'
;
import
'package:flutter_tools/src/android/android_sdk.dart'
;
...
@@ -42,9 +40,9 @@ const FakeCommand kShaCommand = FakeCommand(
...
@@ -42,9 +40,9 @@ const FakeCommand kShaCommand = FakeCommand(
);
);
void
main
(
)
{
void
main
(
)
{
FileSystem
fileSystem
;
late
FileSystem
fileSystem
;
FakeProcessManager
processManager
;
late
FakeProcessManager
processManager
;
AndroidSdk
androidSdk
;
late
AndroidSdk
androidSdk
;
setUp
(()
{
setUp
(()
{
processManager
=
FakeProcessManager
.
empty
();
processManager
=
FakeProcessManager
.
empty
();
...
...
packages/flutter_tools/test/general.shard/android/android_device_stop_test.dart
deleted
100644 → 0
View file @
53e04de6
// Copyright 2014 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.
// @dart = 2.8
import
'package:file/memory.dart'
;
import
'package:flutter_tools/src/android/android_device.dart'
;
import
'package:flutter_tools/src/android/android_sdk.dart'
;
import
'package:flutter_tools/src/base/logger.dart'
;
import
'package:flutter_tools/src/base/platform.dart'
;
import
'package:test/fake.dart'
;
import
'../../src/common.dart'
;
import
'../../src/fake_process_manager.dart'
;
void
main
(
)
{
testWithoutContext
(
'AndroidDevice.stopApp handles a null ApplicationPackage'
,
()
async
{
final
AndroidDevice
androidDevice
=
AndroidDevice
(
'1234'
,
androidSdk:
FakeAndroidSdk
(),
fileSystem:
MemoryFileSystem
.
test
(),
logger:
BufferLogger
.
test
(),
platform:
FakePlatform
(),
processManager:
FakeProcessManager
.
any
(),
);
expect
(
await
androidDevice
.
stopApp
(
null
),
false
);
});
}
class
FakeAndroidSdk
extends
Fake
implements
AndroidSdk
{
}
packages/flutter_tools/test/general.shard/android/android_device_test.dart
View file @
0c9a4205
...
@@ -2,8 +2,6 @@
...
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// found in the LICENSE file.
// @dart = 2.8
import
'dart:async'
;
import
'dart:async'
;
import
'dart:convert'
;
import
'dart:convert'
;
import
'dart:typed_data'
;
import
'dart:typed_data'
;
...
@@ -459,15 +457,16 @@ Uptime: 441088659 Realtime: 521464097
...
@@ -459,15 +457,16 @@ Uptime: 441088659 Realtime: 521464097
}
}
AndroidDevice
setUpAndroidDevice
(
{
AndroidDevice
setUpAndroidDevice
(
{
String
id
,
String
?
id
,
AndroidSdk
androidSdk
,
AndroidSdk
?
androidSdk
,
FileSystem
fileSystem
,
FileSystem
?
fileSystem
,
ProcessManager
processManager
,
ProcessManager
?
processManager
,
Platform
platform
,
Platform
?
platform
,
AndroidConsoleSocketFactory
androidConsoleSocketFactory
=
kAndroidConsoleSocketFactory
,
AndroidConsoleSocketFactory
androidConsoleSocketFactory
=
kAndroidConsoleSocketFactory
,
})
{
})
{
androidSdk
??=
FakeAndroidSdk
();
androidSdk
??=
FakeAndroidSdk
();
return
AndroidDevice
(
id
??
'1234'
,
return
AndroidDevice
(
id
??
'1234'
,
modelID:
'TestModel'
,
logger:
BufferLogger
.
test
(),
logger:
BufferLogger
.
test
(),
platform:
platform
??
FakePlatform
(),
platform:
platform
??
FakePlatform
(),
androidSdk:
androidSdk
,
androidSdk:
androidSdk
,
...
...
packages/flutter_tools/test/general.shard/android/android_install_test.dart
View file @
0c9a4205
...
@@ -2,8 +2,6 @@
...
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// found in the LICENSE file.
// @dart = 2.8
import
'package:file/memory.dart'
;
import
'package:file/memory.dart'
;
import
'package:flutter_tools/src/android/android_device.dart'
;
import
'package:flutter_tools/src/android/android_device.dart'
;
import
'package:flutter_tools/src/android/android_sdk.dart'
;
import
'package:flutter_tools/src/android/android_sdk.dart'
;
...
@@ -41,8 +39,8 @@ const FakeCommand kStoreShaCommand = FakeCommand(
...
@@ -41,8 +39,8 @@ const FakeCommand kStoreShaCommand = FakeCommand(
);
);
void
main
(
)
{
void
main
(
)
{
FileSystem
fileSystem
;
late
FileSystem
fileSystem
;
BufferLogger
logger
;
late
BufferLogger
logger
;
setUp
(()
{
setUp
(()
{
fileSystem
=
MemoryFileSystem
.
test
();
fileSystem
=
MemoryFileSystem
.
test
();
...
@@ -50,15 +48,16 @@ void main() {
...
@@ -50,15 +48,16 @@ void main() {
});
});
AndroidDevice
setUpAndroidDevice
({
AndroidDevice
setUpAndroidDevice
({
AndroidSdk
androidSdk
,
AndroidSdk
?
androidSdk
,
ProcessManager
processManager
,
ProcessManager
?
processManager
,
})
{
})
{
androidSdk
??=
FakeAndroidSdk
();
androidSdk
??=
FakeAndroidSdk
();
return
AndroidDevice
(
'1234'
,
return
AndroidDevice
(
'1234'
,
modelID:
'TestModel'
,
logger:
logger
,
logger:
logger
,
platform:
FakePlatform
(),
platform:
FakePlatform
(),
androidSdk:
androidSdk
,
androidSdk:
androidSdk
,
fileSystem:
fileSystem
??
MemoryFileSystem
.
test
()
,
fileSystem:
fileSystem
,
processManager:
processManager
??
FakeProcessManager
.
any
(),
processManager:
processManager
??
FakeProcessManager
.
any
(),
);
);
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment