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
efcf2c66
Unverified
Commit
efcf2c66
authored
Jan 25, 2021
by
Jonah Williams
Committed by
GitHub
Jan 25, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[flutter_tools] check if process manager can find adb (#74672)
parent
6358f481
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
34 additions
and
2 deletions
+34
-2
android_device_discovery.dart
...utter_tools/lib/src/android/android_device_discovery.dart
+8
-2
android_device_discovery_test.dart
.../general.shard/android/android_device_discovery_test.dart
+26
-0
No files found.
packages/flutter_tools/lib/src/android/android_device_discovery.dart
View file @
efcf2c66
...
...
@@ -64,7 +64,7 @@ class AndroidDevices extends PollingDeviceDiscovery {
@override
Future
<
List
<
Device
>>
pollingGetDevices
({
Duration
timeout
})
async
{
if
(
_
androidSdk
==
null
||
_androidSdk
.
adbPath
==
null
)
{
if
(
_
doesNotHaveAdb
()
)
{
return
<
AndroidDevice
>[];
}
String
text
;
...
...
@@ -88,7 +88,7 @@ class AndroidDevices extends PollingDeviceDiscovery {
@override
Future
<
List
<
String
>>
getDiagnostics
()
async
{
if
(
_
androidSdk
==
null
||
_androidSdk
.
adbPath
==
null
)
{
if
(
_
doesNotHaveAdb
()
)
{
return
<
String
>[];
}
...
...
@@ -104,6 +104,12 @@ class AndroidDevices extends PollingDeviceDiscovery {
return
diagnostics
;
}
bool
_doesNotHaveAdb
()
{
return
_androidSdk
==
null
||
_androidSdk
.
adbPath
==
null
||
!
_processManager
.
canRun
(
_androidSdk
.
adbPath
);
}
// 015d172c98400a03 device usb:340787200X product:nakasi model:Nexus_7 device:grouper
static
final
RegExp
_kDeviceRegex
=
RegExp
(
r'^(\S+)\s+(\S+)(.*)'
);
...
...
packages/flutter_tools/test/general.shard/android/android_device_discovery_test.dart
View file @
efcf2c66
...
...
@@ -44,6 +44,25 @@ void main() {
expect
(
await
androidDevices
.
getDiagnostics
(),
isEmpty
);
});
testWithoutContext
(
'AndroidDevices returns empty device list and diagnostics when adb cannot be run'
,
()
async
{
final
AndroidDevices
androidDevices
=
AndroidDevices
(
androidSdk:
FakeAndroidSdk
(
null
),
logger:
BufferLogger
.
test
(),
androidWorkflow:
AndroidWorkflow
(
androidSdk:
FakeAndroidSdk
(
'adb'
),
featureFlags:
TestFeatureFlags
(),
),
// Will throw an exception if anything other than canRun is invoked
processManager:
FakeProcessManger
(),
fileSystem:
MemoryFileSystem
.
test
(),
platform:
FakePlatform
(),
userMessages:
UserMessages
(),
);
expect
(
await
androidDevices
.
pollingGetDevices
(),
isEmpty
);
expect
(
await
androidDevices
.
getDiagnostics
(),
isEmpty
);
});
testWithoutContext
(
'AndroidDevices returns empty device list and diagnostics on null Android SDK'
,
()
async
{
final
AndroidDevices
androidDevices
=
AndroidDevices
(
androidSdk:
null
,
...
...
@@ -218,3 +237,10 @@ class FakeAndroidSdk extends Fake implements AndroidSdk {
@override
final
String
adbPath
;
}
class
FakeProcessManger
extends
Fake
implements
ProcessManager
{
@override
bool
canRun
(
dynamic
executable
,
{
String
workingDirectory
})
{
return
false
;
}
}
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