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
3f973157
Commit
3f973157
authored
Jan 24, 2020
by
Jason Simmons
Committed by
Flutter GitHub Bot
Jan 24, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[flutter_tools] Do not use the logcat -T flag on Android versions before Lollipop (#49327)
parent
d9f071fd
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
52 additions
and
22 deletions
+52
-22
android_device.dart
packages/flutter_tools/lib/src/android/android_device.dart
+24
-17
android_device_test.dart
...tools/test/general.shard/android/android_device_test.dart
+28
-5
No files found.
packages/flutter_tools/lib/src/android/android_device.dart
View file @
3f973157
...
...
@@ -10,7 +10,7 @@ import '../android/android_builder.dart';
import
'../android/android_sdk.dart'
;
import
'../android/android_workflow.dart'
;
import
'../application_package.dart'
;
import
'../base/common.dart'
show
throwToolExit
;
import
'../base/common.dart'
show
throwToolExit
,
unawaited
;
import
'../base/file_system.dart'
;
import
'../base/io.dart'
;
import
'../base/logger.dart'
;
...
...
@@ -1014,29 +1014,36 @@ class _AdbLogReader extends DeviceLogReader {
@override
String
get
name
=>
device
.
name
;
void
_start
()
{
Future
<
void
>
_start
()
async
{
final
String
lastTimestamp
=
device
.
lastLogcatTimestamp
;
// Start the adb logcat process and filter the most recent logs since `lastTimestamp`.
final
List
<
String
>
args
=
<
String
>[
'logcat'
,
'-v'
,
'time'
,
'-T'
,
lastTimestamp
??
''
,
// Empty `-T` means the timestamp of the logcat command invocation.
];
processUtils
.
start
(
device
.
adbCommandForDevice
(
args
)).
then
<
void
>((
Process
process
)
{
_process
=
process
;
// We expect logcat streams to occasionally contain invalid utf-8,
// see: https://github.com/flutter/flutter/pull/8864.
const
Utf8Decoder
decoder
=
Utf8Decoder
(
reportErrors:
false
);
_process
.
stdout
.
transform
<
String
>(
decoder
).
transform
<
String
>(
const
LineSplitter
()).
listen
(
_onLine
);
_process
.
stderr
.
transform
<
String
>(
decoder
).
transform
<
String
>(
const
LineSplitter
()).
listen
(
_onLine
);
_process
.
exitCode
.
whenComplete
(()
{
if
(
_linesController
.
hasListener
)
{
_linesController
.
close
();
}
});
});
// logcat -T is not supported on Android releases before Lollipop.
const
int
kLollipopVersionCode
=
21
;
final
int
apiVersion
=
int
.
tryParse
(
await
device
.
_apiVersion
);
if
(
apiVersion
!=
null
&&
apiVersion
>=
kLollipopVersionCode
)
{
args
.
addAll
(<
String
>[
'-T'
,
lastTimestamp
??
''
,
// Empty `-T` means the timestamp of the logcat command invocation.
]);
}
_process
=
await
processUtils
.
start
(
device
.
adbCommandForDevice
(
args
));
// We expect logcat streams to occasionally contain invalid utf-8,
// see: https://github.com/flutter/flutter/pull/8864.
const
Utf8Decoder
decoder
=
Utf8Decoder
(
reportErrors:
false
);
_process
.
stdout
.
transform
<
String
>(
decoder
).
transform
<
String
>(
const
LineSplitter
()).
listen
(
_onLine
);
_process
.
stderr
.
transform
<
String
>(
decoder
).
transform
<
String
>(
const
LineSplitter
()).
listen
(
_onLine
);
unawaited
(
_process
.
exitCode
.
whenComplete
(()
{
if
(
_linesController
.
hasListener
)
{
_linesController
.
close
();
}
}));
}
// 'W/ActivityManager(pid): '
...
...
packages/flutter_tools/test/general.shard/android/android_device_test.dart
View file @
3f973157
...
...
@@ -717,21 +717,38 @@ flutter:
setUp
(()
{
mockAndroidSdk
=
MockAndroidSdk
();
mockProcessManager
=
MockProcessManager
();
when
(
mockProcessManager
.
run
(
argThat
(
contains
(
'getprop'
)),
stderrEncoding:
anyNamed
(
'stderrEncoding'
),
stdoutEncoding:
anyNamed
(
'stdoutEncoding'
),
)).
thenAnswer
((
_
)
{
final
StringBuffer
buf
=
StringBuffer
()
..
writeln
(
'[ro.build.version.sdk]: [28]'
);
final
ProcessResult
result
=
ProcessResult
(
1
,
0
,
buf
.
toString
(),
''
);
return
Future
<
ProcessResult
>.
value
(
result
);
});
});
testUsingContext
(
'calls adb logcat with expected flags'
,
()
async
{
const
String
k
lastLocat
catTimestamp
=
'11-27 15:39:04.506'
;
const
String
k
LastLog
catTimestamp
=
'11-27 15:39:04.506'
;
when
(
mockAndroidSdk
.
adbPath
).
thenReturn
(
'adb'
);
when
(
mockProcessManager
.
runSync
(<
String
>[
'adb'
,
'-s'
,
'1234'
,
'shell'
,
'-x'
,
'logcat'
,
'-v'
,
'time'
,
'-t'
,
'1'
]))
.
thenReturn
(
ProcessResult
(
0
,
0
,
'
$klastLocatcatTimestamp
I/flutter: irrelevant'
,
''
));
.
thenReturn
(
ProcessResult
(
0
,
0
,
'
$kLastLogcatTimestamp
I/flutter: irrelevant'
,
''
));
final
Completer
<
void
>
logcatCompleter
=
Completer
<
void
>();
when
(
mockProcessManager
.
start
(
argThat
(
contains
(
'logcat'
))))
.
thenAnswer
((
_
)
=>
Future
<
Process
>.
value
(
createMockProcess
()));
.
thenAnswer
((
_
)
{
logcatCompleter
.
complete
();
return
Future
<
Process
>.
value
(
createMockProcess
());
});
final
AndroidDevice
device
=
AndroidDevice
(
'1234'
);
final
DeviceLogReader
logReader
=
device
.
getLogReader
();
logReader
.
logLines
.
listen
((
_
)
{});
await
logcatCompleter
.
future
;
verify
(
mockProcessManager
.
start
(
const
<
String
>[
'adb'
,
'-s'
,
'1234'
,
'logcat'
,
'-v'
,
'time'
,
'-T'
,
k
lastLocat
catTimestamp
]))
verify
(
mockProcessManager
.
start
(
const
<
String
>[
'adb'
,
'-s'
,
'1234'
,
'logcat'
,
'-v'
,
'time'
,
'-T'
,
k
LastLog
catTimestamp
]))
.
called
(
1
);
},
overrides:
<
Type
,
Generator
>{
AndroidSdk:
()
=>
mockAndroidSdk
,
...
...
@@ -742,12 +759,18 @@ flutter:
when
(
mockAndroidSdk
.
adbPath
).
thenReturn
(
'adb'
);
when
(
mockProcessManager
.
runSync
(<
String
>[
'adb'
,
'-s'
,
'1234'
,
'shell'
,
'-x'
,
'logcat'
,
'-v'
,
'time'
,
'-t'
,
'1'
]))
.
thenReturn
(
ProcessResult
(
0
,
0
,
''
,
''
));
final
Completer
<
void
>
logcatCompleter
=
Completer
<
void
>();
when
(
mockProcessManager
.
start
(
argThat
(
contains
(
'logcat'
))))
.
thenAnswer
((
_
)
=>
Future
<
Process
>.
value
(
createMockProcess
()));
.
thenAnswer
((
_
)
{
logcatCompleter
.
complete
();
return
Future
<
Process
>.
value
(
createMockProcess
());
});
final
AndroidDevice
device
=
AndroidDevice
(
'1234'
);
final
DeviceLogReader
logReader
=
device
.
getLogReader
();
logReader
.
logLines
.
listen
((
_
)
{});
await
logcatCompleter
.
future
;
verify
(
mockProcessManager
.
start
(
const
<
String
>[
'adb'
,
'-s'
,
'1234'
,
'logcat'
,
'-v'
,
'time'
,
'-T'
,
''
]))
.
called
(
1
);
...
...
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