- moved timeout to PINCODE_TIMEOUT
[pub/Android/ownCloud.git] / src / com / owncloud / android / authentication / PinCheck.java
1 package com.owncloud.android.authentication;
2
3 import android.app.Activity;
4 import android.content.SharedPreferences;
5 import android.preference.PreferenceManager;
6
7 import com.owncloud.android.MainApp;
8
9 public class PinCheck extends Activity {
10
11 private static Long timestamp = 0l;
12 private static Long lastStart = 0l;
13 private static int PINCODE_TIMEOUT = 10000;
14
15 public static void setUnlockTimestamp() {
16 timestamp = System.currentTimeMillis();
17 }
18
19 public static boolean checkIfPinEntry(){
20 if ((System.currentTimeMillis() - timestamp) > PINCODE_TIMEOUT &&
21 (System.currentTimeMillis() - lastStart) > PINCODE_TIMEOUT){
22 SharedPreferences appPrefs = PreferenceManager.getDefaultSharedPreferences(MainApp.getAppContext());
23 if (appPrefs.getBoolean("set_pincode", false)) {
24 lastStart = System.currentTimeMillis();
25 return true;
26 }
27 }
28 return false;
29 }
30 }