diff --git a/bin/.gitignore b/bin/.gitignore
deleted file mode 100644
index edfcb72f1..000000000
--- a/bin/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-[^.]
diff --git a/src/com/android/keepass/.gitignore b/src/com/android/keepass/.gitignore
new file mode 100644
index 000000000..48c029696
--- /dev/null
+++ b/src/com/android/keepass/.gitignore
@@ -0,0 +1 @@
+R.java
diff --git a/src/com/android/keepass/services/TimeoutService.java b/src/com/android/keepass/services/TimeoutService.java
new file mode 100644
index 000000000..4553c3370
--- /dev/null
+++ b/src/com/android/keepass/services/TimeoutService.java
@@ -0,0 +1,70 @@
+/*
+ * Copyright 2009 Brian Pellin.
+ *
+ * This file is part of KeePassDroid.
+ *
+ * KeePassDroid is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * KeePassDroid is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with KeePassDroid. If not, see .
+ *
+ */
+package com.android.keepass.services;
+
+import java.util.Timer;
+import java.util.TimerTask;
+
+import android.app.Service;
+import android.content.Intent;
+import android.os.Binder;
+import android.os.IBinder;
+
+public class TimeoutService extends Service {
+
+ private boolean timeout = false;
+ private Timer mTimer = new Timer();
+
+ public class TimeoutBinder extends Binder {
+ public TimeoutService getService() {
+ return TimeoutService.this;
+ }
+ }
+
+ private final IBinder mBinder = new TimeoutBinder();
+
+ @Override
+ public IBinder onBind(Intent intent) {
+ // TODO Auto-generated method stub
+ return mBinder;
+ }
+
+ private class TimeoutTask extends TimerTask {
+
+ @Override
+ public void run() {
+ timeout = true;
+ }
+
+ }
+
+ public void startTimeout(long seconds) {
+ mTimer.schedule(new TimeoutTask(), seconds);
+ }
+
+ public void cancel() {
+ mTimer.cancel();
+ timeout = false;
+ }
+
+ public boolean HasTimedOut() {
+ return timeout;
+ }
+}
diff --git a/tests/src/com/android/keepass/tests/services/TimeoutServiceTest.java b/tests/src/com/android/keepass/tests/services/TimeoutServiceTest.java
new file mode 100644
index 000000000..56b33d04c
--- /dev/null
+++ b/tests/src/com/android/keepass/tests/services/TimeoutServiceTest.java
@@ -0,0 +1,67 @@
+/* Copyright 2009 Brian Pellin.
+ *
+ * This file is part of KeePassDroid.
+ *
+ * KeePassDroid is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * KeePassDroid is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with KeePassDroid. If not, see .
+ *
+ */
+package com.android.keepass.tests.services;
+
+import java.util.concurrent.Semaphore;
+import java.util.concurrent.TimeUnit;
+
+import android.content.ComponentName;
+import android.content.Context;
+import android.content.Intent;
+import android.content.ServiceConnection;
+import android.os.IBinder;
+import android.test.ServiceTestCase;
+
+import com.android.keepass.services.TimeoutService;
+
+public class TimeoutServiceTest extends ServiceTestCase {
+ public TimeoutServiceTest() {
+ super(TimeoutService.class);
+ }
+
+ private TimeoutService mService;
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+
+ startService(new Intent(getContext(), TimeoutService.class));
+ mService = getService();
+ assertNotNull(mService);
+ }
+
+
+
+ public void testTimeout() {
+ assertFalse("Timeout is not set at the beginning.", mService.HasTimedOut() );
+
+ mService.startTimeout(1000);
+
+ assertFalse("Timeout too early.", mService.HasTimedOut() );
+
+ try {
+ Thread.sleep(2000);
+ } catch (InterruptedException e) {
+ assertTrue("Thread interrupted.", false);
+ }
+
+ assertTrue("Timeout was not set.", mService.HasTimedOut());
+
+ }
+}