Buggy code:
public class TapPatternDetectorService extends Service implements ITapDetector . TapObserver { static final int MSG_REQ_RECENT_TAPS = 1 ; static final int MSG_RESP_RECENT_TAPS = 2 ; static final int MSG_SUB_PATTERN = 3 ; static final int MSG_PUB_PATTERN_MATCH = 4 ; static final String KEY_TAP_DETECTOR_CLASS = "TapDetectorClass" ; final Messenger mMessenger = new Messenger ( new TapPatternDetectorService . TapObserverHandler ( ) ) ; private ArrayList < Long > timestamps ; private ArrayList < DeviceSide > sides ; private ArrayList < TapPatternDetectorService . SubscriptionEntry > subscriptions ; static Message createRecentTapsRequestMsg ( Messenger replyTo , long fromTime , long toTime ) { } static Message createSubscribeMsg ( Messenger replyTo , TapPattern pattern ) { } static Message createUnsubscribeMsg ( Messenger replyTo , TapPattern pattern ) { } @ Override public void onCreate ( ) { } @ Override public int onStartCommand ( Intent intent , int flags , int startId ) { } @ Override public boolean onUnbind ( Intent intent ) { } @ Override public IBinder onBind ( Intent intent ) { } @ Override public synchronized void onTap ( long timestamp , long now , DeviceSide side ) { } private void checkSubscriptions ( ) { } private void notifySubscriber ( TapPatternDetectorService . SubscriptionEntry subscription , TapPattern match ) { } private void logI ( String s ) { } private void logI ( String format , Object ... args ) { } private synchronized Message handleRecentTapsRequest ( Message req ) { try { Long [ ] timeFrame = ( ( Long [ ] ) ( req . obj ) ) ; if ( ( timeFrame [ 0 ] ) >= ( timeFrame [ 1 ] ) ) { return null ; } <START_BUG> long now = 1000L * ( System . currentTimeMillis ( ) ) ; <END_BUG> long minTime = now + ( timeFrame [ 0 ] ) ; long maxTime = now + ( timeFrame [ 1 ] ) ; logI ( "minTime<seq2seq4repair_space>%d" , minTime ) ; logI ( "maxTime<seq2seq4repair_space>%d" , maxTime ) ; TapPattern p = new TapPattern ( ) ; for ( int i = 0 ; i < ( this . sides . size ( ) ) ; i ++ ) { logI ( "Tap<seq2seq4repair_space>Timestamp<seq2seq4repair_space>%d" , this . timestamps . get ( i ) ) ; boolean notToOld = minTime <= ( this . timestamps . get ( i ) ) ; boolean notToYoung = ( this . timestamps . get ( i ) ) <= maxTime ; if ( notToOld && notToYoung ) { long pause = 0 ; if ( i > 0 ) { pause = ( this . timestamps . get ( i ) ) - ( this . timestamps . get ( ( i - 1 ) ) ) ; } logI ( "Appending<seq2seq4repair_space>Tap<seq2seq4repair_space>%s<seq2seq4repair_space>%d" , this . sides . get ( i ) . name ( ) , pause ) ; p . appendTap ( this . sides . get ( i ) , ( ( int ) ( pause ) ) ) ; } } Message reply = Message . obtain ( null , TapPatternDetectorService . MSG_RESP_RECENT_TAPS ) ; reply . setData ( p . toBundle ( ) ) ; return reply ; } catch ( Exception e ) { return null ; } } private void addSubscription ( TapPatternDetectorService . SubscriptionEntry s ) { } private synchronized Message handlePatternSubscription ( Message msg ) { } @ Override public void onDestroy ( ) { } class TapObserverHandler extends Handler { @ Override public void handleMessage ( Message msg ) { } } private class SubscriptionEntry implements Comparable < TapPatternDetectorService . SubscriptionEntry > { public Messenger subscriber ; public TapPattern pattern ; public SubscriptionEntry ( Messenger subscriber , TapPattern pattern ) { } @ Override public boolean equals ( Object o ) { } @ Override public int hashCode ( ) { } @ Override public int compareTo ( TapPatternDetectorService . SubscriptionEntry subscriptionEntry ) { } } }

Fix:
long now = 1000000L * ( System . currentTimeMillis ( ) ) ;