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
e8bc5c5a
Unverified
Commit
e8bc5c5a
authored
Feb 11, 2022
by
keyonghan
Committed by
GitHub
Feb 11, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Support Samsung phone when getting device `wakefulness` status (#98146)
parent
e907b03c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
1 deletion
+16
-1
devices.dart
dev/devicelab/lib/framework/devices.dart
+4
-1
adb_test.dart
dev/devicelab/test/adb_test.dart
+12
-0
No files found.
dev/devicelab/lib/framework/devices.dart
View file @
e8bc5c5a
...
...
@@ -505,7 +505,10 @@ class AndroidDevice extends Device {
/// See: https://android.googlesource.com/platform/frameworks/base/+/master/core/java/android/os/PowerManagerInternal.java
Future
<
String
>
_getWakefulness
()
async
{
final
String
powerInfo
=
await
shellEval
(
'dumpsys'
,
<
String
>[
'power'
]);
final
String
wakefulness
=
grep
(
'mWakefulness='
,
from:
powerInfo
).
single
.
split
(
'='
)[
1
].
trim
();
// A motoG4 phone returns `mWakefulness=Awake`.
// A Samsung phone returns `getWakefullnessLocked()=Awake`.
final
RegExp
wakefulnessRegexp
=
RegExp
(
r'.*(mWakefulness=|getWakefulnessLocked\(\)=).*'
);
final
String
wakefulness
=
grep
(
wakefulnessRegexp
,
from:
powerInfo
).
single
.
split
(
'='
)[
1
].
trim
();
return
wakefulness
;
}
...
...
dev/devicelab/test/adb_test.dart
View file @
e8bc5c5a
...
...
@@ -40,6 +40,12 @@ void main() {
expect
(
await
device
.
isAsleep
(),
isFalse
);
});
test
(
'reads Awake - samsung devices'
,
()
async
{
FakeDevice
.
pretendAwakeSamsung
();
expect
(
await
device
.
isAwake
(),
isTrue
);
expect
(
await
device
.
isAsleep
(),
isFalse
);
});
test
(
'reads Asleep'
,
()
async
{
FakeDevice
.
pretendAsleep
();
expect
(
await
device
.
isAwake
(),
isFalse
);
...
...
@@ -190,6 +196,12 @@ class FakeDevice extends AndroidDevice {
'''
;
}
static
void
pretendAwakeSamsung
()
{
output
=
'''
getWakefulnessLocked()=Awake
'''
;
}
static
void
pretendAsleep
()
{
output
=
'''
mWakefulness=Asleep
...
...
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