File tree Expand file tree Collapse file tree 2 files changed +25
-4
lines changed Expand file tree Collapse file tree 2 files changed +25
-4
lines changed Original file line number Diff line number Diff line change @@ -685,9 +685,10 @@ class AndroidDevice extends Device {
685685 final String powerInfo = await shellEval ('dumpsys' , < String > ['power' ]);
686686 // A motoG4 phone returns `mWakefulness=Awake`.
687687 // A Samsung phone returns `getWakefullnessLocked()=Awake`.
688- final RegExp wakefulnessRegexp = RegExp (r'(?:mWakefulness|getWakefulnessLocked\(\))=[a-zA-Z]+' );
689- final String wakefulness = grep (wakefulnessRegexp, from: powerInfo).single.split ('=' )[1 ].trim ();
690- return wakefulness;
688+ final RegExp wakefulnessRegexp = RegExp (
689+ r'(?:mWakefulness|getWakefulnessLocked\(\))=\s*([a-zA-Z]+)' ,
690+ );
691+ return wakefulnessRegexp.allMatches (powerInfo).single.group (1 )! ;
691692 }
692693
693694 Future <bool > isArm64 () async {
Original file line number Diff line number Diff line change @@ -23,7 +23,9 @@ void main() {
2323 device = FakeDevice (deviceId: 'fakeDeviceId' );
2424 });
2525
26- tearDown (() {});
26+ tearDown (() {
27+ FakeDevice .resetLog ();
28+ });
2729
2830 group ('cpu check' , () {
2931 test ('arm64' , () async {
@@ -325,20 +327,38 @@ class FakeDevice extends AndroidDevice {
325327 }
326328
327329 static void pretendAwake () {
330+ // Emit an integer value in addition to the state string to ensure only
331+ // the state string is matched.
332+ //
333+ // Regression testing for https://github.com/flutter/flutter/issues/174952.
328334 output = '''
335+ mWakefulness=1
329336 mWakefulness=Awake
337+
330338 ''' ;
331339 }
332340
333341 static void pretendAwakeSamsung () {
342+ // Emit an integer value in addition to the state string to ensure only
343+ // the state string is matched.
344+ //
345+ // Regression testing for https://github.com/flutter/flutter/issues/174952.
334346 output = '''
347+ getWakefulnessLocked()=1
335348 getWakefulnessLocked()=Awake
349+
336350 ''' ;
337351 }
338352
339353 static void pretendAsleep () {
354+ // Emit an integer value in addition to the state string to ensure only
355+ // the state string is matched.
356+ //
357+ // Regression testing for https://github.com/flutter/flutter/issues/174952.
340358 output = '''
359+ mWakefulness=0
341360 mWakefulness=Asleep
361+
342362 ''' ;
343363 }
344364
You can’t perform that action at this time.
0 commit comments