Yuta HIGUCHI

IntentPushTestCommand: attempt to fix negative duration

Change-Id: Ibb09c9079443de536132f492a44769c373531bfa
...@@ -94,7 +94,7 @@ public class IntentPushTestCommand extends AbstractShellCommand ...@@ -94,7 +94,7 @@ public class IntentPushTestCommand extends AbstractShellCommand
94 94
95 private IntentService service; 95 private IntentService service;
96 private CountDownLatch latch; 96 private CountDownLatch latch;
97 - private long start, end; 97 + private volatile long start, end;
98 private int apps; 98 private int apps;
99 private int intentsPerApp; 99 private int intentsPerApp;
100 private int appIdBase; 100 private int appIdBase;
...@@ -239,11 +239,14 @@ public class IntentPushTestCommand extends AbstractShellCommand ...@@ -239,11 +239,14 @@ public class IntentPushTestCommand extends AbstractShellCommand
239 private static final EnumSet<IntentEvent.Type> IGNORE_EVENT 239 private static final EnumSet<IntentEvent.Type> IGNORE_EVENT
240 = EnumSet.of(Type.INSTALL_REQ, Type.WITHDRAW_REQ); 240 = EnumSet.of(Type.INSTALL_REQ, Type.WITHDRAW_REQ);
241 @Override 241 @Override
242 - public void event(IntentEvent event) { 242 + public synchronized void event(IntentEvent event) {
243 Type expected = add ? Type.INSTALLED : Type.WITHDRAWN; 243 Type expected = add ? Type.INSTALLED : Type.WITHDRAWN;
244 if (event.type() == expected) { 244 if (event.type() == expected) {
245 - end = event.time(); 245 + end = Math.max(end, event.time());
246 if (latch != null) { 246 if (latch != null) {
247 + if (latch.getCount() == 0) {
248 + log.warn("Latch was already 0 before counting down?");
249 + }
247 latch.countDown(); 250 latch.countDown();
248 } else { 251 } else {
249 log.warn("install event latch is null"); 252 log.warn("install event latch is null");
......