1
0
Fork 0
mirror of https://github.com/syncthing/syncthing-android.git synced 2024-11-26 06:11:19 +00:00

Use public key instead of config to check for first start.

This lets SyncthingService.isFirstStart() return true for a longer
time (previously, it would return false as soon as the config was copied).
This commit is contained in:
Felix Ableitner 2014-05-27 13:59:01 +02:00
parent fa749da4a6
commit 1c1b1e6aa6

View file

@ -67,6 +67,11 @@ public class SyncthingService extends Service {
*/ */
private static final String CONFIG_FILE = "config.xml"; private static final String CONFIG_FILE = "config.xml";
/**
* Name of the public key file in the data directory.
*/
private static final String PUBLIC_KEY_FILE = "cert.pem";
private RestApi mApi; private RestApi mApi;
private final SyncthingServiceBinder mBinder = new SyncthingServiceBinder(this); private final SyncthingServiceBinder mBinder = new SyncthingServiceBinder(this);
@ -363,9 +368,11 @@ public class SyncthingService extends Service {
/** /**
* Returns true if this service has not been started before (ie config.xml does not exist). * Returns true if this service has not been started before (ie config.xml does not exist).
*
* This will return true until the public key file has been generated.
*/ */
public static boolean isFirstStart(Context context) { public static boolean isFirstStart(Context context) {
return !new File(context.getApplicationInfo().dataDir, CONFIG_FILE).exists(); return !new File(context.getApplicationInfo().dataDir, PUBLIC_KEY_FILE).exists();
} }
/** /**