From b6eefbdb3615635cf436f61733698ce7df9fbdf5 Mon Sep 17 00:00:00 2001 From: "Alinson S. Xavier" Date: Fri, 27 Nov 2020 18:35:52 -0600 Subject: [PATCH] setSystemTime: Try two methods --- .../java/org/isoron/uhabits/BaseAndroidTest.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/android/uhabits-android/src/androidTest/java/org/isoron/uhabits/BaseAndroidTest.java b/android/uhabits-android/src/androidTest/java/org/isoron/uhabits/BaseAndroidTest.java index 705097ba0..81b49dea7 100644 --- a/android/uhabits-android/src/androidTest/java/org/isoron/uhabits/BaseAndroidTest.java +++ b/android/uhabits-android/src/androidTest/java/org/isoron/uhabits/BaseAndroidTest.java @@ -257,10 +257,17 @@ public class BaseAndroidTest extends TestCase cal.get(Calendar.YEAR), cal.get(Calendar.SECOND)); + // Set time (method 1) // Run twice to override daylight saving time device.executeShellCommand("date " + date); device.executeShellCommand("date " + date); + // Set time (method 2) + // Run in addition to the method above because one of these mail fail, depending + // on the Android API version. + command = String.format("date -u @%d", cal.getTimeInMillis() / 1000); + device.executeShellCommand(command); + // Wait for system events to settle Thread.sleep(1000); }