mirror of
https://github.com/syncthing/syncthing-android.git
synced 2024-11-29 15:51:17 +00:00
Make status LED un-clickable, Reduce verbose logging (#254)
Change summary: * Make status light un-clickable * Add configurable verbose logging * Reduce verbose logging * Initialize model#Folder.label * EventProcessor: Ignore event "FolderResumed" Detailed changelog: * Make status light un-clickable * Initialize model#Folder.label * Rename func to applyCustomRunConditions * RunConditionMonitor: Make verbose log configurable * ReceiverManager: Make verbose log configurable * StatusFragment: Make verbose log configurable * FolderListFragment: Make verbose log configurable * DeviceListFragment: Make verbose log configurable * RestApi: Make verbose log configurable * SyncthingService: Make verbose log configurable - Remove duplicate log lines referring to the same logic that happened - Improved log levels * RestApi: Log.v => LogV * SyncthingApp ThreadPolicy - I'll need this later * RestApi: Reduce logging * applyCustomRunConditions: Log changes and result in non-verbose level * EventProcessor: Ignore event "FolderResumed" * RestApi#readConfigFromRestApi: Change log level to verbose * SyncthingRunnable: Reduce log, make verbose log configurable
This commit is contained in:
parent
f0d72e7a4b
commit
979088f4ca
12 changed files with 177 additions and 99 deletions
|
@ -23,11 +23,21 @@ public class SyncthingApp extends Application {
|
||||||
new Languages(this).setLanguage(this);
|
new Languages(this).setLanguage(this);
|
||||||
|
|
||||||
// Set VM policy to avoid crash when sending folder URI to file manager.
|
// Set VM policy to avoid crash when sending folder URI to file manager.
|
||||||
StrictMode.VmPolicy policy = new StrictMode.VmPolicy.Builder()
|
StrictMode.VmPolicy vmPolicy = new StrictMode.VmPolicy.Builder()
|
||||||
.detectAll()
|
.detectAll()
|
||||||
.penaltyLog()
|
.penaltyLog()
|
||||||
.build();
|
.build();
|
||||||
StrictMode.setVmPolicy(policy);
|
StrictMode.setVmPolicy(vmPolicy);
|
||||||
|
|
||||||
|
/*
|
||||||
|
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.P)
|
||||||
|
{
|
||||||
|
StrictMode.ThreadPolicy threadPolicy = new StrictMode.ThreadPolicy.Builder()
|
||||||
|
.permitAll()
|
||||||
|
.build();
|
||||||
|
StrictMode.setThreadPolicy(threadPolicy);
|
||||||
|
}
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
public DaggerComponent component() {
|
public DaggerComponent component() {
|
||||||
|
|
|
@ -35,6 +35,8 @@ public class DeviceListFragment extends ListFragment implements SyncthingService
|
||||||
|
|
||||||
private final static String TAG = "DeviceListFragment";
|
private final static String TAG = "DeviceListFragment";
|
||||||
|
|
||||||
|
private static final Boolean ENABLE_VERBOSE_LOG = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Compares devices by name, uses the device ID as fallback if the name is empty
|
* Compares devices by name, uses the device ID as fallback if the name is empty
|
||||||
*/
|
*/
|
||||||
|
@ -86,13 +88,13 @@ public class DeviceListFragment extends ListFragment implements SyncthingService
|
||||||
}
|
}
|
||||||
|
|
||||||
private void startUpdateListHandler() {
|
private void startUpdateListHandler() {
|
||||||
Log.v(TAG, "startUpdateListHandler");
|
LogV("startUpdateListHandler");
|
||||||
mUpdateListHandler.removeCallbacks(mUpdateListRunnable);
|
mUpdateListHandler.removeCallbacks(mUpdateListRunnable);
|
||||||
mUpdateListHandler.post(mUpdateListRunnable);
|
mUpdateListHandler.post(mUpdateListRunnable);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void stopUpdateListHandler() {
|
private void stopUpdateListHandler() {
|
||||||
Log.v(TAG, "stopUpdateListHandler");
|
LogV("stopUpdateListHandler");
|
||||||
mUpdateListHandler.removeCallbacks(mUpdateListRunnable);
|
mUpdateListHandler.removeCallbacks(mUpdateListRunnable);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -122,7 +124,7 @@ public class DeviceListFragment extends ListFragment implements SyncthingService
|
||||||
if (mainActivity.isFinishing()) {
|
if (mainActivity.isFinishing()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Log.v(TAG, "Invoking updateList on UI thread");
|
LogV("Invoking updateList on UI thread");
|
||||||
mainActivity.runOnUiThread(DeviceListFragment.this::updateList);
|
mainActivity.runOnUiThread(DeviceListFragment.this::updateList);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -193,4 +195,9 @@ public class DeviceListFragment extends ListFragment implements SyncthingService
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void LogV(String logMessage) {
|
||||||
|
if (ENABLE_VERBOSE_LOG) {
|
||||||
|
Log.v(TAG, logMessage);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,7 +30,9 @@ import java.util.List;
|
||||||
public class FolderListFragment extends ListFragment implements SyncthingService.OnServiceStateChangeListener,
|
public class FolderListFragment extends ListFragment implements SyncthingService.OnServiceStateChangeListener,
|
||||||
AdapterView.OnItemClickListener {
|
AdapterView.OnItemClickListener {
|
||||||
|
|
||||||
private final static String TAG = "FolderListFragment";
|
private static final String TAG = "FolderListFragment";
|
||||||
|
|
||||||
|
private static final Boolean ENABLE_VERBOSE_LOG = false;
|
||||||
|
|
||||||
private Runnable mUpdateListRunnable = new Runnable() {
|
private Runnable mUpdateListRunnable = new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -74,13 +76,13 @@ public class FolderListFragment extends ListFragment implements SyncthingService
|
||||||
}
|
}
|
||||||
|
|
||||||
private void startUpdateListHandler() {
|
private void startUpdateListHandler() {
|
||||||
Log.v(TAG, "startUpdateListHandler");
|
LogV("startUpdateListHandler");
|
||||||
mUpdateListHandler.removeCallbacks(mUpdateListRunnable);
|
mUpdateListHandler.removeCallbacks(mUpdateListRunnable);
|
||||||
mUpdateListHandler.post(mUpdateListRunnable);
|
mUpdateListHandler.post(mUpdateListRunnable);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void stopUpdateListHandler() {
|
private void stopUpdateListHandler() {
|
||||||
Log.v(TAG, "stopUpdateListHandler");
|
LogV("stopUpdateListHandler");
|
||||||
mUpdateListHandler.removeCallbacks(mUpdateListRunnable);
|
mUpdateListHandler.removeCallbacks(mUpdateListRunnable);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -110,7 +112,7 @@ public class FolderListFragment extends ListFragment implements SyncthingService
|
||||||
if (mainActivity.isFinishing()) {
|
if (mainActivity.isFinishing()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Log.v(TAG, "Invoking updateList on UI thread");
|
LogV("Invoking updateList on UI thread");
|
||||||
mainActivity.runOnUiThread(FolderListFragment.this::updateList);
|
mainActivity.runOnUiThread(FolderListFragment.this::updateList);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -180,4 +182,9 @@ public class FolderListFragment extends ListFragment implements SyncthingService
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void LogV(String logMessage) {
|
||||||
|
if (ENABLE_VERBOSE_LOG) {
|
||||||
|
Log.v(TAG, logMessage);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,6 +39,8 @@ public class StatusFragment extends ListFragment implements SyncthingService.OnS
|
||||||
|
|
||||||
private static final String TAG = "StatusFragment";
|
private static final String TAG = "StatusFragment";
|
||||||
|
|
||||||
|
private static final Boolean ENABLE_VERBOSE_LOG = false;
|
||||||
|
|
||||||
private Runnable mRestApiQueryRunnable = new Runnable() {
|
private Runnable mRestApiQueryRunnable = new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
@ -97,13 +99,13 @@ public class StatusFragment extends ListFragment implements SyncthingService.OnS
|
||||||
}
|
}
|
||||||
|
|
||||||
private void startRestApiQueryHandler() {
|
private void startRestApiQueryHandler() {
|
||||||
Log.v(TAG, "startUpdateListHandler");
|
LogV("startUpdateListHandler");
|
||||||
mRestApiQueryHandler.removeCallbacks(mRestApiQueryRunnable);
|
mRestApiQueryHandler.removeCallbacks(mRestApiQueryRunnable);
|
||||||
mRestApiQueryHandler.post(mRestApiQueryRunnable);
|
mRestApiQueryHandler.post(mRestApiQueryRunnable);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void stopRestApiQueryHandler() {
|
private void stopRestApiQueryHandler() {
|
||||||
Log.v(TAG, "stopUpdateListHandler");
|
LogV("stopUpdateListHandler");
|
||||||
mRestApiQueryHandler.removeCallbacks(mRestApiQueryRunnable);
|
mRestApiQueryHandler.removeCallbacks(mRestApiQueryRunnable);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -239,7 +241,7 @@ public class StatusFragment extends ListFragment implements SyncthingService.OnS
|
||||||
if (restApi == null) {
|
if (restApi == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Log.v(TAG, "Invoking REST status queries");
|
LogV("Invoking REST status queries");
|
||||||
restApi.getSystemStatus(this::onReceiveSystemStatus);
|
restApi.getSystemStatus(this::onReceiveSystemStatus);
|
||||||
restApi.getConnections(this::onReceiveConnections);
|
restApi.getConnections(this::onReceiveConnections);
|
||||||
// onReceiveSystemStatus, onReceiveConnections will call {@link #updateStatus}.
|
// onReceiveSystemStatus, onReceiveConnections will call {@link #updateStatus}.
|
||||||
|
@ -300,4 +302,9 @@ public class StatusFragment extends ListFragment implements SyncthingService.OnS
|
||||||
updateStatus();
|
updateStatus();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void LogV(String logMessage) {
|
||||||
|
if (ENABLE_VERBOSE_LOG) {
|
||||||
|
Log.v(TAG, logMessage);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,7 @@ public class Folder {
|
||||||
|
|
||||||
// Folder Configuration
|
// Folder Configuration
|
||||||
public String id;
|
public String id;
|
||||||
public String label;
|
public String label = "";
|
||||||
public String filesystemType = "basic";
|
public String filesystemType = "basic";
|
||||||
public String path;
|
public String path;
|
||||||
public String type = Constants.FOLDER_TYPE_SEND_RECEIVE;
|
public String type = Constants.FOLDER_TYPE_SEND_RECEIVE;
|
||||||
|
|
|
@ -84,7 +84,7 @@ public class EventProcessor implements Runnable, RestApi.OnReceiveEventListener
|
||||||
public void onDone(long lastId) {
|
public void onDone(long lastId) {
|
||||||
if (lastId < mLastEventId) mLastEventId = 0;
|
if (lastId < mLastEventId) mLastEventId = 0;
|
||||||
|
|
||||||
Log.d(TAG, "Reading events starting with id " + mLastEventId);
|
LogV("Reading events starting with id " + mLastEventId);
|
||||||
|
|
||||||
mRestApi.getEvents(mLastEventId, 0, EventProcessor.this);
|
mRestApi.getEvents(mLastEventId, 0, EventProcessor.this);
|
||||||
}
|
}
|
||||||
|
@ -99,7 +99,7 @@ public class EventProcessor implements Runnable, RestApi.OnReceiveEventListener
|
||||||
switch (event.type) {
|
switch (event.type) {
|
||||||
case "ConfigSaved":
|
case "ConfigSaved":
|
||||||
if (mRestApi != null) {
|
if (mRestApi != null) {
|
||||||
Log.d(TAG, "Forwarding ConfigSaved event to RestApi to get the updated config.");
|
LogV("Forwarding ConfigSaved event to RestApi to get the updated config.");
|
||||||
mRestApi.reloadConfig();
|
mRestApi.reloadConfig();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -157,6 +157,7 @@ public class EventProcessor implements Runnable, RestApi.OnReceiveEventListener
|
||||||
case "DeviceDiscovered":
|
case "DeviceDiscovered":
|
||||||
case "DownloadProgress":
|
case "DownloadProgress":
|
||||||
case "FolderPaused":
|
case "FolderPaused":
|
||||||
|
case "FolderResumed":
|
||||||
case "FolderScanProgress":
|
case "FolderScanProgress":
|
||||||
case "FolderSummary":
|
case "FolderSummary":
|
||||||
case "FolderWatchStateChanged":
|
case "FolderWatchStateChanged":
|
||||||
|
@ -169,7 +170,7 @@ public class EventProcessor implements Runnable, RestApi.OnReceiveEventListener
|
||||||
case "StartupComplete":
|
case "StartupComplete":
|
||||||
case "StateChanged":
|
case "StateChanged":
|
||||||
if (ENABLE_VERBOSE_LOG) {
|
if (ENABLE_VERBOSE_LOG) {
|
||||||
Log.v(TAG, "Ignored event " + event.type + ", data " + event.data);
|
LogV("Ignored event " + event.type + ", data " + event.data);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -339,4 +340,10 @@ public class EventProcessor implements Runnable, RestApi.OnReceiveEventListener
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void LogV(String logMessage) {
|
||||||
|
if (ENABLE_VERBOSE_LOG) {
|
||||||
|
Log.v(TAG, logMessage);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,12 +13,14 @@ public class ReceiverManager {
|
||||||
|
|
||||||
private static final String TAG = "ReceiverManager";
|
private static final String TAG = "ReceiverManager";
|
||||||
|
|
||||||
|
private static final Boolean ENABLE_VERBOSE_LOG = false;
|
||||||
|
|
||||||
private static List<BroadcastReceiver> mReceivers = new ArrayList<BroadcastReceiver>();
|
private static List<BroadcastReceiver> mReceivers = new ArrayList<BroadcastReceiver>();
|
||||||
|
|
||||||
public static synchronized void registerReceiver(Context context, BroadcastReceiver receiver, IntentFilter intentFilter) {
|
public static synchronized void registerReceiver(Context context, BroadcastReceiver receiver, IntentFilter intentFilter) {
|
||||||
mReceivers.add(receiver);
|
mReceivers.add(receiver);
|
||||||
context.registerReceiver(receiver, intentFilter);
|
context.registerReceiver(receiver, intentFilter);
|
||||||
Log.v(TAG, "Registered receiver: " + receiver + " with filter: " + intentFilter);
|
LogV("Registered receiver: " + receiver + " with filter: " + intentFilter);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static synchronized boolean isReceiverRegistered(BroadcastReceiver receiver) {
|
public static synchronized boolean isReceiverRegistered(BroadcastReceiver receiver) {
|
||||||
|
@ -36,7 +38,7 @@ public class ReceiverManager {
|
||||||
if (isReceiverRegistered(receiver)) {
|
if (isReceiverRegistered(receiver)) {
|
||||||
try {
|
try {
|
||||||
context.unregisterReceiver(receiver);
|
context.unregisterReceiver(receiver);
|
||||||
Log.v(TAG, "Unregistered receiver: " + receiver);
|
LogV("Unregistered receiver: " + receiver);
|
||||||
} catch(IllegalArgumentException e) {
|
} catch(IllegalArgumentException e) {
|
||||||
// We have to catch the race condition a registration is still pending in android
|
// We have to catch the race condition a registration is still pending in android
|
||||||
// according to https://stackoverflow.com/a/3568906
|
// according to https://stackoverflow.com/a/3568906
|
||||||
|
@ -46,4 +48,10 @@ public class ReceiverManager {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void LogV(String logMessage) {
|
||||||
|
if (ENABLE_VERBOSE_LOG) {
|
||||||
|
Log.v(TAG, logMessage);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,6 +64,8 @@ public class RestApi {
|
||||||
|
|
||||||
private static final String TAG = "RestApi";
|
private static final String TAG = "RestApi";
|
||||||
|
|
||||||
|
private static final Boolean ENABLE_VERBOSE_LOG = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Compares folders by labels, uses the folder ID as fallback if the label is empty
|
* Compares folders by labels, uses the folder ID as fallback if the label is empty
|
||||||
*/
|
*/
|
||||||
|
@ -166,7 +168,7 @@ public class RestApi {
|
||||||
* Gets local device ID, syncthing version and config, then calls all OnApiAvailableListeners.
|
* Gets local device ID, syncthing version and config, then calls all OnApiAvailableListeners.
|
||||||
*/
|
*/
|
||||||
public void readConfigFromRestApi() {
|
public void readConfigFromRestApi() {
|
||||||
Log.v(TAG, "Reading config from REST ...");
|
LogV("Querying config from REST ...");
|
||||||
synchronized (mAsyncQueryCompleteLock) {
|
synchronized (mAsyncQueryCompleteLock) {
|
||||||
asyncQueryVersionComplete = false;
|
asyncQueryVersionComplete = false;
|
||||||
asyncQueryConfigComplete = false;
|
asyncQueryConfigComplete = false;
|
||||||
|
@ -175,7 +177,6 @@ public class RestApi {
|
||||||
new GetRequest(mContext, mUrl, GetRequest.URI_VERSION, mApiKey, null, result -> {
|
new GetRequest(mContext, mUrl, GetRequest.URI_VERSION, mApiKey, null, result -> {
|
||||||
JsonObject json = new JsonParser().parse(result).getAsJsonObject();
|
JsonObject json = new JsonParser().parse(result).getAsJsonObject();
|
||||||
mVersion = json.get("version").getAsString();
|
mVersion = json.get("version").getAsString();
|
||||||
Log.i(TAG, "Syncthing version is " + mVersion);
|
|
||||||
updateDebugFacilitiesCache();
|
updateDebugFacilitiesCache();
|
||||||
synchronized (mAsyncQueryCompleteLock) {
|
synchronized (mAsyncQueryCompleteLock) {
|
||||||
asyncQueryVersionComplete = true;
|
asyncQueryVersionComplete = true;
|
||||||
|
@ -201,7 +202,8 @@ public class RestApi {
|
||||||
|
|
||||||
private void checkReadConfigFromRestApiCompleted() {
|
private void checkReadConfigFromRestApiCompleted() {
|
||||||
if (asyncQueryVersionComplete && asyncQueryConfigComplete && asyncQuerySystemStatusComplete) {
|
if (asyncQueryVersionComplete && asyncQueryConfigComplete && asyncQuerySystemStatusComplete) {
|
||||||
Log.v(TAG, "Reading config from REST completed.");
|
LogV("Reading config from REST completed. Syncthing version is " + mVersion);
|
||||||
|
// Tell SyncthingService it can transition to State.ACTIVE.
|
||||||
mOnApiAvailableListener.onApiAvailable();
|
mOnApiAvailableListener.onApiAvailable();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -219,11 +221,9 @@ public class RestApi {
|
||||||
if (!configParseSuccess) {
|
if (!configParseSuccess) {
|
||||||
throw new RuntimeException("config is null: " + result);
|
throw new RuntimeException("config is null: " + result);
|
||||||
}
|
}
|
||||||
Log.v(TAG, "onReloadConfigComplete: Successfully parsed configuration.");
|
Log.d(TAG, "onReloadConfigComplete: Successfully parsed configuration.");
|
||||||
if (BuildConfig.DEBUG) {
|
LogV("mConfig.pendingDevices = " + new Gson().toJson(mConfig.pendingDevices));
|
||||||
Log.v(TAG, "mConfig.pendingDevices = " + new Gson().toJson(mConfig.pendingDevices));
|
LogV("mConfig.remoteIgnoredDevices = " + new Gson().toJson(mConfig.remoteIgnoredDevices));
|
||||||
Log.v(TAG, "mConfig.remoteIgnoredDevices = " + new Gson().toJson(mConfig.remoteIgnoredDevices));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Update cached device and folder information stored in the mCompletion model.
|
// Update cached device and folder information stored in the mCompletion model.
|
||||||
mCompletion.updateFromConfig(getDevices(true), getFolders());
|
mCompletion.updateFromConfig(getDevices(true), getFolders());
|
||||||
|
@ -340,10 +340,8 @@ public class RestApi {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
device.ignoredFolders.add(ignoredFolder);
|
device.ignoredFolders.add(ignoredFolder);
|
||||||
if (BuildConfig.DEBUG) {
|
LogV("device.pendingFolders = " + new Gson().toJson(device.pendingFolders));
|
||||||
Log.v(TAG, "device.pendingFolders = " + new Gson().toJson(device.pendingFolders));
|
LogV("device.ignoredFolders = " + new Gson().toJson(device.ignoredFolders));
|
||||||
Log.v(TAG, "device.ignoredFolders = " + new Gson().toJson(device.ignoredFolders));
|
|
||||||
}
|
|
||||||
sendConfig();
|
sendConfig();
|
||||||
Log.d(TAG, "Ignored folder [" + folderId + "] announced by device [" + deviceId + "]");
|
Log.d(TAG, "Ignored folder [" + folderId + "] announced by device [" + deviceId + "]");
|
||||||
|
|
||||||
|
@ -521,7 +519,7 @@ public class RestApi {
|
||||||
if (devices.isEmpty()) {
|
if (devices.isEmpty()) {
|
||||||
throw new RuntimeException("RestApi.getLocalDevice: devices is empty.");
|
throw new RuntimeException("RestApi.getLocalDevice: devices is empty.");
|
||||||
}
|
}
|
||||||
Log.v(TAG, "getLocalDevice: Looking for local device ID " + mLocalDeviceId);
|
LogV("getLocalDevice: Looking for local device ID " + mLocalDeviceId);
|
||||||
for (Device d : devices) {
|
for (Device d : devices) {
|
||||||
if (d.deviceID.equals(mLocalDeviceId)) {
|
if (d.deviceID.equals(mLocalDeviceId)) {
|
||||||
return deepCopy(d, Device.class);
|
return deepCopy(d, Device.class);
|
||||||
|
@ -816,21 +814,21 @@ public class RestApi {
|
||||||
/**
|
/**
|
||||||
* Event triggered by {@link RunConditionMonitor} routed here through {@link SyncthingService}.
|
* Event triggered by {@link RunConditionMonitor} routed here through {@link SyncthingService}.
|
||||||
*/
|
*/
|
||||||
public void onSyncPreconditionChanged(RunConditionMonitor runConditionMonitor) {
|
public void applyCustomRunConditions(RunConditionMonitor runConditionMonitor) {
|
||||||
Log.v(TAG, "onSyncPreconditionChanged: Event fired.");
|
|
||||||
SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(mContext);
|
SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(mContext);
|
||||||
synchronized (mConfigLock) {
|
synchronized (mConfigLock) {
|
||||||
Boolean configChanged = false;
|
Boolean configChanged = false;
|
||||||
|
|
||||||
// Check if the config has been loaded.
|
// Check if the config has been loaded.
|
||||||
if (mConfig == null) {
|
if (mConfig == null) {
|
||||||
Log.d(TAG, "onSyncPreconditionChanged: mConfig is not ready yet.");
|
Log.w(TAG, "applyCustomRunConditions: mConfig is not ready yet.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if the folders are available from config.
|
// Check if the folders are available from config.
|
||||||
if (mConfig.folders != null) {
|
if (mConfig.folders != null) {
|
||||||
for (Folder folder : mConfig.folders) {
|
for (Folder folder : mConfig.folders) {
|
||||||
|
// LogV("applyCustomRunConditions: Processing config of folder(" + folder.label + ")");
|
||||||
Boolean folderCustomSyncConditionsEnabled = sharedPreferences.getBoolean(
|
Boolean folderCustomSyncConditionsEnabled = sharedPreferences.getBoolean(
|
||||||
Constants.DYN_PREF_OBJECT_CUSTOM_SYNC_CONDITIONS(Constants.PREF_OBJECT_PREFIX_FOLDER + folder.id), false
|
Constants.DYN_PREF_OBJECT_CUSTOM_SYNC_CONDITIONS(Constants.PREF_OBJECT_PREFIX_FOLDER + folder.id), false
|
||||||
);
|
);
|
||||||
|
@ -838,22 +836,23 @@ public class RestApi {
|
||||||
Boolean syncConditionsMet = runConditionMonitor.checkObjectSyncConditions(
|
Boolean syncConditionsMet = runConditionMonitor.checkObjectSyncConditions(
|
||||||
Constants.PREF_OBJECT_PREFIX_FOLDER + folder.id
|
Constants.PREF_OBJECT_PREFIX_FOLDER + folder.id
|
||||||
);
|
);
|
||||||
Log.v(TAG, "onSyncPreconditionChanged: syncFolder(" + folder.id + ")=" + (syncConditionsMet ? "1" : "0"));
|
LogV("applyCustomRunConditions: f(" + folder.label + ")=" + (syncConditionsMet ? "1" : "0"));
|
||||||
if (folder.paused != !syncConditionsMet) {
|
if (folder.paused != !syncConditionsMet) {
|
||||||
folder.paused = !syncConditionsMet;
|
folder.paused = !syncConditionsMet;
|
||||||
Log.d(TAG, "onSyncPreconditionChanged: syncFolder(" + folder.id + ")=" + (syncConditionsMet ? ">1" : ">0"));
|
Log.d(TAG, "applyCustomRunConditions: f(" + folder.label + ")=" + (syncConditionsMet ? ">1" : ">0"));
|
||||||
configChanged = true;
|
configChanged = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Log.d(TAG, "onSyncPreconditionChanged: mConfig.folders is not ready yet.");
|
Log.d(TAG, "applyCustomRunConditions: mConfig.folders is not ready yet.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if the devices are available from config.
|
// Check if the devices are available from config.
|
||||||
if (mConfig.devices != null) {
|
if (mConfig.devices != null) {
|
||||||
for (Device device : mConfig.devices) {
|
for (Device device : mConfig.devices) {
|
||||||
|
// LogV("applyCustomRunConditions: Processing config of device(" + device.name + ")");
|
||||||
Boolean deviceCustomSyncConditionsEnabled = sharedPreferences.getBoolean(
|
Boolean deviceCustomSyncConditionsEnabled = sharedPreferences.getBoolean(
|
||||||
Constants.DYN_PREF_OBJECT_CUSTOM_SYNC_CONDITIONS(Constants.PREF_OBJECT_PREFIX_DEVICE + device.deviceID), false
|
Constants.DYN_PREF_OBJECT_CUSTOM_SYNC_CONDITIONS(Constants.PREF_OBJECT_PREFIX_DEVICE + device.deviceID), false
|
||||||
);
|
);
|
||||||
|
@ -861,23 +860,31 @@ public class RestApi {
|
||||||
Boolean syncConditionsMet = runConditionMonitor.checkObjectSyncConditions(
|
Boolean syncConditionsMet = runConditionMonitor.checkObjectSyncConditions(
|
||||||
Constants.PREF_OBJECT_PREFIX_DEVICE + device.deviceID
|
Constants.PREF_OBJECT_PREFIX_DEVICE + device.deviceID
|
||||||
);
|
);
|
||||||
Log.v(TAG, "onSyncPreconditionChanged: syncDevice(" + device.deviceID + ")=" + (syncConditionsMet ? "1" : "0"));
|
LogV("applyCustomRunConditions: d(" + device.name + ")=" + (syncConditionsMet ? "1" : "0"));
|
||||||
if (device.paused != !syncConditionsMet) {
|
if (device.paused != !syncConditionsMet) {
|
||||||
device.paused = !syncConditionsMet;
|
device.paused = !syncConditionsMet;
|
||||||
Log.d(TAG, "onSyncPreconditionChanged: syncDevice(" + device.deviceID + ")=" + (syncConditionsMet ? ">1" : ">0"));
|
Log.d(TAG, "applyCustomRunConditions: d(" + device.name + ")=" + (syncConditionsMet ? ">1" : ">0"));
|
||||||
configChanged = true;
|
configChanged = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Log.d(TAG, "onSyncPreconditionChanged: mConfig.devices is not ready yet.");
|
Log.d(TAG, "applyCustomRunConditions: mConfig.devices is not ready yet.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (configChanged) {
|
if (configChanged) {
|
||||||
Log.v(TAG, "onSyncPreconditionChanged: Sending changed config ...");
|
LogV("applyCustomRunConditions: Sending changed config ...");
|
||||||
sendConfig();
|
sendConfig();
|
||||||
|
} else {
|
||||||
|
LogV("applyCustomRunConditions: No action was necessary.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void LogV(String logMessage) {
|
||||||
|
if (ENABLE_VERBOSE_LOG) {
|
||||||
|
Log.v(TAG, logMessage);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,6 +39,8 @@ public class RunConditionMonitor {
|
||||||
|
|
||||||
private static final String TAG = "RunConditionMonitor";
|
private static final String TAG = "RunConditionMonitor";
|
||||||
|
|
||||||
|
private static final Boolean ENABLE_VERBOSE_LOG = false;
|
||||||
|
|
||||||
private static final String POWER_SOURCE_CHARGER_BATTERY = "ac_and_battery_power";
|
private static final String POWER_SOURCE_CHARGER_BATTERY = "ac_and_battery_power";
|
||||||
private static final String POWER_SOURCE_CHARGER = "ac_power";
|
private static final String POWER_SOURCE_CHARGER = "ac_power";
|
||||||
private static final String POWER_SOURCE_BATTERY = "battery_power";
|
private static final String POWER_SOURCE_BATTERY = "battery_power";
|
||||||
|
@ -109,7 +111,7 @@ public class RunConditionMonitor {
|
||||||
public RunConditionMonitor(Context context,
|
public RunConditionMonitor(Context context,
|
||||||
OnShouldRunChangedListener onShouldRunChangedListener,
|
OnShouldRunChangedListener onShouldRunChangedListener,
|
||||||
OnSyncPreconditionChangedListener onSyncPreconditionChangedListener) {
|
OnSyncPreconditionChangedListener onSyncPreconditionChangedListener) {
|
||||||
Log.v(TAG, "Created new instance");
|
LogV("Created new instance");
|
||||||
((SyncthingApp) context.getApplicationContext()).component().inject(this);
|
((SyncthingApp) context.getApplicationContext()).component().inject(this);
|
||||||
mContext = context;
|
mContext = context;
|
||||||
res = mContext.getResources();
|
res = mContext.getResources();
|
||||||
|
@ -144,7 +146,7 @@ public class RunConditionMonitor {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void shutdown() {
|
public void shutdown() {
|
||||||
Log.v(TAG, "Shutting down");
|
LogV("Shutting down");
|
||||||
if (mSyncStatusObserverHandle != null) {
|
if (mSyncStatusObserverHandle != null) {
|
||||||
ContentResolver.removeStatusChangeListener(mSyncStatusObserverHandle);
|
ContentResolver.removeStatusChangeListener(mSyncStatusObserverHandle);
|
||||||
mSyncStatusObserverHandle = null;
|
mSyncStatusObserverHandle = null;
|
||||||
|
@ -303,14 +305,14 @@ public class RunConditionMonitor {
|
||||||
switch (prefPowerSource) {
|
switch (prefPowerSource) {
|
||||||
case POWER_SOURCE_CHARGER:
|
case POWER_SOURCE_CHARGER:
|
||||||
if (!isCharging()) {
|
if (!isCharging()) {
|
||||||
Log.v(TAG, "decideShouldRun: POWER_SOURCE_AC && !isCharging");
|
LogV("decideShouldRun: POWER_SOURCE_AC && !isCharging");
|
||||||
mRunDecisionExplanation = res.getString(R.string.reason_not_charging);
|
mRunDecisionExplanation = res.getString(R.string.reason_not_charging);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case POWER_SOURCE_BATTERY:
|
case POWER_SOURCE_BATTERY:
|
||||||
if (isCharging()) {
|
if (isCharging()) {
|
||||||
Log.v(TAG, "decideShouldRun: POWER_SOURCE_BATTERY && isCharging");
|
LogV("decideShouldRun: POWER_SOURCE_BATTERY && isCharging");
|
||||||
mRunDecisionExplanation = res.getString(R.string.reason_not_on_battery_power);
|
mRunDecisionExplanation = res.getString(R.string.reason_not_on_battery_power);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -323,7 +325,7 @@ public class RunConditionMonitor {
|
||||||
// Power saving
|
// Power saving
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||||
if (prefRespectPowerSaving && isPowerSaving()) {
|
if (prefRespectPowerSaving && isPowerSaving()) {
|
||||||
Log.v(TAG, "decideShouldRun: prefRespectPowerSaving && isPowerSaving");
|
LogV("decideShouldRun: prefRespectPowerSaving && isPowerSaving");
|
||||||
mRunDecisionExplanation = res.getString(R.string.reason_not_while_power_saving);
|
mRunDecisionExplanation = res.getString(R.string.reason_not_while_power_saving);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -331,7 +333,7 @@ public class RunConditionMonitor {
|
||||||
|
|
||||||
// Android global AutoSync setting.
|
// Android global AutoSync setting.
|
||||||
if (prefRespectMasterSync && !ContentResolver.getMasterSyncAutomatically()) {
|
if (prefRespectMasterSync && !ContentResolver.getMasterSyncAutomatically()) {
|
||||||
Log.v(TAG, "decideShouldRun: prefRespectMasterSync && !getMasterSyncAutomatically");
|
LogV("decideShouldRun: prefRespectMasterSync && !getMasterSyncAutomatically");
|
||||||
mRunDecisionExplanation = res.getString(R.string.reason_not_while_auto_sync_data_disabled);
|
mRunDecisionExplanation = res.getString(R.string.reason_not_while_auto_sync_data_disabled);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -341,7 +343,7 @@ public class RunConditionMonitor {
|
||||||
mRunDecisionExplanation += scr.explanation;
|
mRunDecisionExplanation += scr.explanation;
|
||||||
if (scr.conditionMet) {
|
if (scr.conditionMet) {
|
||||||
// Mobile data is connected.
|
// Mobile data is connected.
|
||||||
Log.v(TAG, "decideShouldRun: checkConditionSyncOnMobileData");
|
LogV("decideShouldRun: checkConditionSyncOnMobileData");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -350,19 +352,19 @@ public class RunConditionMonitor {
|
||||||
mRunDecisionExplanation += scr.explanation;
|
mRunDecisionExplanation += scr.explanation;
|
||||||
if (scr.conditionMet) {
|
if (scr.conditionMet) {
|
||||||
// Wifi is connected.
|
// Wifi is connected.
|
||||||
Log.v(TAG, "decideShouldRun: checkConditionSyncOnWifi");
|
LogV("decideShouldRun: checkConditionSyncOnWifi");
|
||||||
|
|
||||||
scr = checkConditionSyncOnMeteredWifi(Constants.PREF_RUN_ON_METERED_WIFI);
|
scr = checkConditionSyncOnMeteredWifi(Constants.PREF_RUN_ON_METERED_WIFI);
|
||||||
mRunDecisionExplanation += scr.explanation;
|
mRunDecisionExplanation += scr.explanation;
|
||||||
if (scr.conditionMet) {
|
if (scr.conditionMet) {
|
||||||
// Wifi type is allowed.
|
// Wifi type is allowed.
|
||||||
Log.v(TAG, "decideShouldRun: checkConditionSyncOnWifi && checkConditionSyncOnMeteredWifi");
|
LogV("decideShouldRun: checkConditionSyncOnWifi && checkConditionSyncOnMeteredWifi");
|
||||||
|
|
||||||
scr = checkConditionSyncOnWhitelistedWifi(Constants.PREF_USE_WIFI_SSID_WHITELIST, Constants.PREF_WIFI_SSID_WHITELIST);
|
scr = checkConditionSyncOnWhitelistedWifi(Constants.PREF_USE_WIFI_SSID_WHITELIST, Constants.PREF_WIFI_SSID_WHITELIST);
|
||||||
mRunDecisionExplanation += scr.explanation;
|
mRunDecisionExplanation += scr.explanation;
|
||||||
if (scr.conditionMet) {
|
if (scr.conditionMet) {
|
||||||
// Wifi is whitelisted.
|
// Wifi is whitelisted.
|
||||||
Log.v(TAG, "decideShouldRun: checkConditionSyncOnWifi && checkConditionSyncOnMeteredWifi && checkConditionSyncOnWhitelistedWifi");
|
LogV("decideShouldRun: checkConditionSyncOnWifi && checkConditionSyncOnMeteredWifi && checkConditionSyncOnWhitelistedWifi");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -370,7 +372,7 @@ public class RunConditionMonitor {
|
||||||
|
|
||||||
// Run in flight mode.
|
// Run in flight mode.
|
||||||
if (prefRunInFlightMode && isFlightMode()) {
|
if (prefRunInFlightMode && isFlightMode()) {
|
||||||
Log.v(TAG, "decideShouldRun: prefRunInFlightMode && isFlightMode");
|
LogV("decideShouldRun: prefRunInFlightMode && isFlightMode");
|
||||||
mRunDecisionExplanation += "\n" + res.getString(R.string.reason_on_flight_mode);
|
mRunDecisionExplanation += "\n" + res.getString(R.string.reason_on_flight_mode);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -378,7 +380,7 @@ public class RunConditionMonitor {
|
||||||
/**
|
/**
|
||||||
* If none of the above run conditions matched, don't run.
|
* If none of the above run conditions matched, don't run.
|
||||||
*/
|
*/
|
||||||
Log.v(TAG, "decideShouldRun: return false");
|
LogV("decideShouldRun: return false");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -390,7 +392,7 @@ public class RunConditionMonitor {
|
||||||
SyncConditionResult scr = checkConditionSyncOnMobileData(Constants.DYN_PREF_OBJECT_SYNC_ON_MOBILE_DATA(objectPrefixAndId));
|
SyncConditionResult scr = checkConditionSyncOnMobileData(Constants.DYN_PREF_OBJECT_SYNC_ON_MOBILE_DATA(objectPrefixAndId));
|
||||||
if (scr.conditionMet) {
|
if (scr.conditionMet) {
|
||||||
// Mobile data is connected.
|
// Mobile data is connected.
|
||||||
Log.v(TAG, "checkObjectSyncConditions(" + objectPrefixAndId + "): checkConditionSyncOnMobileData");
|
LogV("checkObjectSyncConditions(" + objectPrefixAndId + "): checkConditionSyncOnMobileData");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -398,12 +400,12 @@ public class RunConditionMonitor {
|
||||||
scr = checkConditionSyncOnWifi(Constants.DYN_PREF_OBJECT_SYNC_ON_WIFI(objectPrefixAndId));
|
scr = checkConditionSyncOnWifi(Constants.DYN_PREF_OBJECT_SYNC_ON_WIFI(objectPrefixAndId));
|
||||||
if (scr.conditionMet) {
|
if (scr.conditionMet) {
|
||||||
// Wifi is connected.
|
// Wifi is connected.
|
||||||
Log.v(TAG, "checkObjectSyncConditions(" + objectPrefixAndId + "): checkConditionSyncOnWifi");
|
LogV("checkObjectSyncConditions(" + objectPrefixAndId + "): checkConditionSyncOnWifi");
|
||||||
|
|
||||||
scr = checkConditionSyncOnMeteredWifi(Constants.DYN_PREF_OBJECT_SYNC_ON_METERED_WIFI(objectPrefixAndId));
|
scr = checkConditionSyncOnMeteredWifi(Constants.DYN_PREF_OBJECT_SYNC_ON_METERED_WIFI(objectPrefixAndId));
|
||||||
if (scr.conditionMet) {
|
if (scr.conditionMet) {
|
||||||
// Wifi type is allowed.
|
// Wifi type is allowed.
|
||||||
Log.v(TAG, "checkObjectSyncConditions(" + objectPrefixAndId + "): checkConditionSyncOnWifi && checkConditionSyncOnMeteredWifi");
|
LogV("checkObjectSyncConditions(" + objectPrefixAndId + "): checkConditionSyncOnWifi && checkConditionSyncOnMeteredWifi");
|
||||||
|
|
||||||
scr = checkConditionSyncOnWhitelistedWifi(
|
scr = checkConditionSyncOnWhitelistedWifi(
|
||||||
Constants.DYN_PREF_OBJECT_USE_WIFI_SSID_WHITELIST(objectPrefixAndId),
|
Constants.DYN_PREF_OBJECT_USE_WIFI_SSID_WHITELIST(objectPrefixAndId),
|
||||||
|
@ -411,7 +413,7 @@ public class RunConditionMonitor {
|
||||||
);
|
);
|
||||||
if (scr.conditionMet) {
|
if (scr.conditionMet) {
|
||||||
// Wifi is whitelisted.
|
// Wifi is whitelisted.
|
||||||
Log.v(TAG, "checkObjectSyncConditions(" + objectPrefixAndId + "): checkConditionSyncOnWifi && checkConditionSyncOnMeteredWifi && checkConditionSyncOnWhitelistedWifi");
|
LogV("checkObjectSyncConditions(" + objectPrefixAndId + "): checkConditionSyncOnWifi && checkConditionSyncOnMeteredWifi && checkConditionSyncOnWhitelistedWifi");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -426,11 +428,11 @@ public class RunConditionMonitor {
|
||||||
private boolean wifiWhitelistConditionMet (boolean prefWifiWhitelistEnabled,
|
private boolean wifiWhitelistConditionMet (boolean prefWifiWhitelistEnabled,
|
||||||
Set<String> whitelistedWifiSsids) throws LocationUnavailableException {
|
Set<String> whitelistedWifiSsids) throws LocationUnavailableException {
|
||||||
if (!prefWifiWhitelistEnabled) {
|
if (!prefWifiWhitelistEnabled) {
|
||||||
Log.v(TAG, "handleWifiWhitelist: !prefWifiWhitelistEnabled");
|
LogV("handleWifiWhitelist: !prefWifiWhitelistEnabled");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (isWifiConnectionWhitelisted(whitelistedWifiSsids)) {
|
if (isWifiConnectionWhitelisted(whitelistedWifiSsids)) {
|
||||||
Log.v(TAG, "handleWifiWhitelist: isWifiConnectionWhitelisted");
|
LogV("handleWifiWhitelist: isWifiConnectionWhitelisted");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -572,4 +574,9 @@ public class RunConditionMonitor {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void LogV(String logMessage) {
|
||||||
|
if (ENABLE_VERBOSE_LOG) {
|
||||||
|
Log.v(TAG, logMessage);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,6 +52,8 @@ public class SyncthingRunnable implements Runnable {
|
||||||
private static final String TAG = "SyncthingRunnable";
|
private static final String TAG = "SyncthingRunnable";
|
||||||
private static final String TAG_NATIVE = "SyncthingNativeCode";
|
private static final String TAG_NATIVE = "SyncthingNativeCode";
|
||||||
private static final String TAG_NICE = "SyncthingRunnableIoNice";
|
private static final String TAG_NICE = "SyncthingRunnableIoNice";
|
||||||
|
|
||||||
|
private static final Boolean ENABLE_VERBOSE_LOG = false;
|
||||||
private static final int LOG_FILE_MAX_LINES = 10;
|
private static final int LOG_FILE_MAX_LINES = 10;
|
||||||
|
|
||||||
private static final AtomicReference<Process> mSyncthing = new AtomicReference<>();
|
private static final AtomicReference<Process> mSyncthing = new AtomicReference<>();
|
||||||
|
@ -178,7 +180,7 @@ public class SyncthingRunnable implements Runnable {
|
||||||
br = new BufferedReader(new InputStreamReader(process.getInputStream(), Charsets.UTF_8));
|
br = new BufferedReader(new InputStreamReader(process.getInputStream(), Charsets.UTF_8));
|
||||||
String line;
|
String line;
|
||||||
while ((line = br.readLine()) != null) {
|
while ((line = br.readLine()) != null) {
|
||||||
Log.println(Log.INFO, TAG_NATIVE, line);
|
Log.i(TAG_NATIVE, line);
|
||||||
capturedStdOut = capturedStdOut + line + "\n";
|
capturedStdOut = capturedStdOut + line + "\n";
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
|
@ -195,7 +197,7 @@ public class SyncthingRunnable implements Runnable {
|
||||||
niceSyncthing();
|
niceSyncthing();
|
||||||
|
|
||||||
exitCode = process.waitFor();
|
exitCode = process.waitFor();
|
||||||
Log.i(TAG, "Syncthing exited with code " + exitCode);
|
LogV("Syncthing exited with code " + exitCode);
|
||||||
mSyncthing.set(null);
|
mSyncthing.set(null);
|
||||||
if (lInfo != null) {
|
if (lInfo != null) {
|
||||||
lInfo.join();
|
lInfo.join();
|
||||||
|
@ -381,13 +383,13 @@ public class SyncthingRunnable implements Runnable {
|
||||||
int exitCode;
|
int exitCode;
|
||||||
List<String> syncthingPIDs = getSyncthingPIDs(true);
|
List<String> syncthingPIDs = getSyncthingPIDs(true);
|
||||||
if (syncthingPIDs.isEmpty()) {
|
if (syncthingPIDs.isEmpty()) {
|
||||||
Log.d(TAG, "killSyncthing: Found no running instances of " + Constants.FILENAME_SYNCTHING_BINARY);
|
LogV("killSyncthing: Found no running instances of " + Constants.FILENAME_SYNCTHING_BINARY);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for (String syncthingPID : syncthingPIDs) {
|
for (String syncthingPID : syncthingPIDs) {
|
||||||
exitCode = Util.runShellCommand("kill -SIGINT " + syncthingPID + "\n", mUseRoot);
|
exitCode = Util.runShellCommand("kill -SIGINT " + syncthingPID + "\n", mUseRoot);
|
||||||
if (exitCode == 0) {
|
if (exitCode == 0) {
|
||||||
Log.d(TAG, "Sent kill SIGINT to process " + syncthingPID);
|
LogV("Sent kill SIGINT to process " + syncthingPID);
|
||||||
} else {
|
} else {
|
||||||
Log.w(TAG, "Failed to send kill SIGINT to process " + syncthingPID +
|
Log.w(TAG, "Failed to send kill SIGINT to process " + syncthingPID +
|
||||||
" exit code " + Integer.toString(exitCode));
|
" exit code " + Integer.toString(exitCode));
|
||||||
|
@ -397,11 +399,11 @@ public class SyncthingRunnable implements Runnable {
|
||||||
/**
|
/**
|
||||||
* Wait for the syncthing instance to end.
|
* Wait for the syncthing instance to end.
|
||||||
*/
|
*/
|
||||||
Log.v(TAG, "Waiting for all syncthing instances to end ...");
|
LogV("Waiting for all syncthing instances to end ...");
|
||||||
while (!getSyncthingPIDs(false).isEmpty()) {
|
while (!getSyncthingPIDs(false).isEmpty()) {
|
||||||
SystemClock.sleep(50);
|
SystemClock.sleep(50);
|
||||||
}
|
}
|
||||||
Log.v(TAG, "killSyncthing: Complete.");
|
Log.d(TAG, "killSyncthing: Complete.");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -556,4 +558,10 @@ public class SyncthingRunnable implements Runnable {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void LogV(String logMessage) {
|
||||||
|
if (ENABLE_VERBOSE_LOG) {
|
||||||
|
Log.v(TAG, logMessage);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,6 +48,8 @@ public class SyncthingService extends Service {
|
||||||
|
|
||||||
private static final String TAG = "SyncthingService";
|
private static final String TAG = "SyncthingService";
|
||||||
|
|
||||||
|
private static final Boolean ENABLE_VERBOSE_LOG = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Intent action to perform a Syncthing restart.
|
* Intent action to perform a Syncthing restart.
|
||||||
*/
|
*/
|
||||||
|
@ -217,7 +219,7 @@ public class SyncthingService extends Service {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void onCreate() {
|
public void onCreate() {
|
||||||
Log.v(TAG, "onCreate");
|
LogV("onCreate");
|
||||||
super.onCreate();
|
super.onCreate();
|
||||||
PRNGFixes.apply();
|
PRNGFixes.apply();
|
||||||
((SyncthingApp) getApplication()).component().inject(this);
|
((SyncthingApp) getApplication()).component().inject(this);
|
||||||
|
@ -245,7 +247,7 @@ public class SyncthingService extends Service {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public int onStartCommand(Intent intent, int flags, int startId) {
|
public int onStartCommand(Intent intent, int flags, int startId) {
|
||||||
Log.v(TAG, "onStartCommand");
|
Log.d(TAG, "onStartCommand");
|
||||||
if (!mStoragePermissionGranted) {
|
if (!mStoragePermissionGranted) {
|
||||||
Log.e(TAG, "User revoked storage permission. Stopping service.");
|
Log.e(TAG, "User revoked storage permission. Stopping service.");
|
||||||
if (mNotificationHandler != null) {
|
if (mNotificationHandler != null) {
|
||||||
|
@ -286,7 +288,7 @@ public class SyncthingService extends Service {
|
||||||
*/
|
*/
|
||||||
mRunConditionMonitor = new RunConditionMonitor(SyncthingService.this,
|
mRunConditionMonitor = new RunConditionMonitor(SyncthingService.this,
|
||||||
this::onShouldRunDecisionChanged,
|
this::onShouldRunDecisionChanged,
|
||||||
this::onSyncPreconditionChanged
|
this::applyCustomRunConditions
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -400,7 +402,6 @@ public class SyncthingService extends Service {
|
||||||
if (mCurrentState == State.DISABLED) {
|
if (mCurrentState == State.DISABLED) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Log.v(TAG, "Stopping syncthing");
|
|
||||||
shutdown(State.DISABLED);
|
shutdown(State.DISABLED);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -410,16 +411,15 @@ public class SyncthingService extends Service {
|
||||||
* After sync preconditions changed, we need to inform {@link RestApi} to pause or
|
* After sync preconditions changed, we need to inform {@link RestApi} to pause or
|
||||||
* unpause devices and folders as defined in per-object sync preferences.
|
* unpause devices and folders as defined in per-object sync preferences.
|
||||||
*/
|
*/
|
||||||
private void onSyncPreconditionChanged(RunConditionMonitor runConditionMonitor) {
|
private void applyCustomRunConditions(RunConditionMonitor runConditionMonitor) {
|
||||||
synchronized (mStateLock) {
|
synchronized (mStateLock) {
|
||||||
if (mRestApi != null && mCurrentState == State.ACTIVE) {
|
if (mRestApi != null && mCurrentState == State.ACTIVE) {
|
||||||
// Forward event because syncthing is running.
|
// Forward event because syncthing is running.
|
||||||
mRestApi.onSyncPreconditionChanged(runConditionMonitor);
|
mRestApi.applyCustomRunConditions(runConditionMonitor);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Log.v(TAG, "onSyncPreconditionChanged: Event fired while syncthing is not running.");
|
|
||||||
Boolean configChanged = false;
|
Boolean configChanged = false;
|
||||||
ConfigXml configXml;
|
ConfigXml configXml;
|
||||||
|
|
||||||
|
@ -428,7 +428,7 @@ public class SyncthingService extends Service {
|
||||||
try {
|
try {
|
||||||
configXml.loadConfig();
|
configXml.loadConfig();
|
||||||
} catch (ConfigXml.OpenConfigException e) {
|
} catch (ConfigXml.OpenConfigException e) {
|
||||||
mNotificationHandler.showCrashedNotification(R.string.config_read_failed, "onSyncPreconditionChanged:ConfigXml.OpenConfigException");
|
mNotificationHandler.showCrashedNotification(R.string.config_read_failed, "applyCustomRunConditions:ConfigXml.OpenConfigException");
|
||||||
synchronized (mStateLock) {
|
synchronized (mStateLock) {
|
||||||
onServiceStateChange(State.ERROR);
|
onServiceStateChange(State.ERROR);
|
||||||
}
|
}
|
||||||
|
@ -439,7 +439,7 @@ public class SyncthingService extends Service {
|
||||||
List<Folder> folders = configXml.getFolders();
|
List<Folder> folders = configXml.getFolders();
|
||||||
if (folders != null) {
|
if (folders != null) {
|
||||||
for (Folder folder : folders) {
|
for (Folder folder : folders) {
|
||||||
// Log.v(TAG, "onSyncPreconditionChanged: Processing config of folder.id=" + folder.id);
|
// LogV("applyCustomRunConditions: Processing config of folder(" + folder.label + ")");
|
||||||
Boolean folderCustomSyncConditionsEnabled = mPreferences.getBoolean(
|
Boolean folderCustomSyncConditionsEnabled = mPreferences.getBoolean(
|
||||||
Constants.DYN_PREF_OBJECT_CUSTOM_SYNC_CONDITIONS(Constants.PREF_OBJECT_PREFIX_FOLDER + folder.id), false
|
Constants.DYN_PREF_OBJECT_CUSTOM_SYNC_CONDITIONS(Constants.PREF_OBJECT_PREFIX_FOLDER + folder.id), false
|
||||||
);
|
);
|
||||||
|
@ -447,16 +447,16 @@ public class SyncthingService extends Service {
|
||||||
Boolean syncConditionsMet = runConditionMonitor.checkObjectSyncConditions(
|
Boolean syncConditionsMet = runConditionMonitor.checkObjectSyncConditions(
|
||||||
Constants.PREF_OBJECT_PREFIX_FOLDER + folder.id
|
Constants.PREF_OBJECT_PREFIX_FOLDER + folder.id
|
||||||
);
|
);
|
||||||
Log.v(TAG, "onSyncPreconditionChanged: syncFolder(" + folder.id + ")=" + (syncConditionsMet ? "1" : "0"));
|
LogV("applyCustomRunConditions: f(" + folder.label + ")=" + (syncConditionsMet ? "1" : "0"));
|
||||||
if (folder.paused != !syncConditionsMet) {
|
if (folder.paused != !syncConditionsMet) {
|
||||||
configXml.setFolderPause(folder.id, !syncConditionsMet);
|
configXml.setFolderPause(folder.id, !syncConditionsMet);
|
||||||
Log.d(TAG, "onSyncPreconditionChanged: syncFolder(" + folder.id + ")=" + (syncConditionsMet ? ">1" : ">0"));
|
Log.d(TAG, "applyCustomRunConditions: f(" + folder.label + ")=" + (syncConditionsMet ? ">1" : ">0"));
|
||||||
configChanged = true;
|
configChanged = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Log.d(TAG, "onSyncPreconditionChanged: folders == null");
|
Log.d(TAG, "applyCustomRunConditions: folders == null");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -464,7 +464,7 @@ public class SyncthingService extends Service {
|
||||||
List<Device> devices = configXml.getDevices(false);
|
List<Device> devices = configXml.getDevices(false);
|
||||||
if (devices != null) {
|
if (devices != null) {
|
||||||
for (Device device : devices) {
|
for (Device device : devices) {
|
||||||
// Log.v(TAG, "onSyncPreconditionChanged: Processing config of device.id=" + device.deviceID);
|
// LogV("applyCustomRunConditions: Processing config of device(" + device.name + ")");
|
||||||
Boolean deviceCustomSyncConditionsEnabled = mPreferences.getBoolean(
|
Boolean deviceCustomSyncConditionsEnabled = mPreferences.getBoolean(
|
||||||
Constants.DYN_PREF_OBJECT_CUSTOM_SYNC_CONDITIONS(Constants.PREF_OBJECT_PREFIX_DEVICE + device.deviceID), false
|
Constants.DYN_PREF_OBJECT_CUSTOM_SYNC_CONDITIONS(Constants.PREF_OBJECT_PREFIX_DEVICE + device.deviceID), false
|
||||||
);
|
);
|
||||||
|
@ -472,22 +472,24 @@ public class SyncthingService extends Service {
|
||||||
Boolean syncConditionsMet = runConditionMonitor.checkObjectSyncConditions(
|
Boolean syncConditionsMet = runConditionMonitor.checkObjectSyncConditions(
|
||||||
Constants.PREF_OBJECT_PREFIX_DEVICE + device.deviceID
|
Constants.PREF_OBJECT_PREFIX_DEVICE + device.deviceID
|
||||||
);
|
);
|
||||||
Log.v(TAG, "onSyncPreconditionChanged: syncDevice(" + device.deviceID + ")=" + (syncConditionsMet ? "1" : "0"));
|
LogV("applyCustomRunConditions: d(" + device.name + ")=" + (syncConditionsMet ? "1" : "0"));
|
||||||
if (device.paused != !syncConditionsMet) {
|
if (device.paused != !syncConditionsMet) {
|
||||||
configXml.setDevicePause(device.deviceID, !syncConditionsMet);
|
configXml.setDevicePause(device.deviceID, !syncConditionsMet);
|
||||||
Log.d(TAG, "onSyncPreconditionChanged: syncDevice(" + device.deviceID + ")=" + (syncConditionsMet ? ">1" : ">0"));
|
Log.d(TAG, "applyCustomRunConditions: d(" + device.name + ")=" + (syncConditionsMet ? ">1" : ">0"));
|
||||||
configChanged = true;
|
configChanged = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Log.d(TAG, "onSyncPreconditionChanged: devices == null");
|
Log.d(TAG, "applyCustomRunConditions: devices == null");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (configChanged) {
|
if (configChanged) {
|
||||||
Log.v(TAG, "onSyncPreconditionChanged: Saving changed config to disk ...");
|
LogV("applyCustomRunConditions: Saving changed config ...");
|
||||||
configXml.saveChanges();
|
configXml.saveChanges();
|
||||||
|
} else {
|
||||||
|
LogV("applyCustomRunConditions: No action was necessary.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -587,7 +589,7 @@ public class SyncthingService extends Service {
|
||||||
onServiceStateChange(State.ACTIVE);
|
onServiceStateChange(State.ACTIVE);
|
||||||
}
|
}
|
||||||
if (mRestApi != null && mRunConditionMonitor != null) {
|
if (mRestApi != null && mRunConditionMonitor != null) {
|
||||||
mRestApi.onSyncPreconditionChanged(mRunConditionMonitor);
|
mRestApi.applyCustomRunConditions(mRunConditionMonitor);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -618,7 +620,7 @@ public class SyncthingService extends Service {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void onDestroy() {
|
public void onDestroy() {
|
||||||
Log.v(TAG, "onDestroy");
|
Log.d(TAG, "onDestroy");
|
||||||
if (mRunConditionMonitor != null) {
|
if (mRunConditionMonitor != null) {
|
||||||
/**
|
/**
|
||||||
* Shut down the OnShouldRunChangedListener so we won't get interrupted by run
|
* Shut down the OnShouldRunChangedListener so we won't get interrupted by run
|
||||||
|
@ -662,7 +664,6 @@ public class SyncthingService extends Service {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Log.i(TAG, "Shutting down");
|
|
||||||
synchronized (mStateLock) {
|
synchronized (mStateLock) {
|
||||||
onServiceStateChange(newState);
|
onServiceStateChange(newState);
|
||||||
}
|
}
|
||||||
|
@ -685,13 +686,13 @@ public class SyncthingService extends Service {
|
||||||
if (mSyncthingRunnable != null) {
|
if (mSyncthingRunnable != null) {
|
||||||
mSyncthingRunnable.killSyncthing();
|
mSyncthingRunnable.killSyncthing();
|
||||||
if (mSyncthingRunnableThread != null) {
|
if (mSyncthingRunnableThread != null) {
|
||||||
Log.v(TAG, "Waiting for mSyncthingRunnableThread to finish after killSyncthing ...");
|
LogV("Waiting for mSyncthingRunnableThread to finish after killSyncthing ...");
|
||||||
try {
|
try {
|
||||||
mSyncthingRunnableThread.join();
|
mSyncthingRunnableThread.join();
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
Log.w(TAG, "mSyncthingRunnableThread InterruptedException");
|
Log.w(TAG, "mSyncthingRunnableThread InterruptedException");
|
||||||
}
|
}
|
||||||
Log.v(TAG, "Finished mSyncthingRunnableThread.");
|
Log.d(TAG, "Finished mSyncthingRunnableThread.");
|
||||||
mSyncthingRunnableThread = null;
|
mSyncthingRunnableThread = null;
|
||||||
}
|
}
|
||||||
mSyncthingRunnable = null;
|
mSyncthingRunnable = null;
|
||||||
|
@ -711,7 +712,7 @@ public class SyncthingService extends Service {
|
||||||
if (mRunConditionMonitor == null) {
|
if (mRunConditionMonitor == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Log.v(TAG, "Forced re-evaluating run conditions ...");
|
Log.d(TAG, "Forced re-evaluating run conditions ...");
|
||||||
mRunConditionMonitor.updateShouldRunDecision();
|
mRunConditionMonitor.updateShouldRunDecision();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -742,7 +743,7 @@ public class SyncthingService extends Service {
|
||||||
* Called to notify listeners of an API change.
|
* Called to notify listeners of an API change.
|
||||||
*/
|
*/
|
||||||
private void onServiceStateChange(State newState) {
|
private void onServiceStateChange(State newState) {
|
||||||
Log.v(TAG, "onServiceStateChange: from " + mCurrentState + " to " + newState);
|
Log.i(TAG, "onServiceStateChange: from " + mCurrentState + " to " + newState);
|
||||||
mCurrentState = newState;
|
mCurrentState = newState;
|
||||||
mHandler.post(() -> {
|
mHandler.post(() -> {
|
||||||
mNotificationHandler.updatePersistentNotification(this);
|
mNotificationHandler.updatePersistentNotification(this);
|
||||||
|
@ -793,7 +794,7 @@ public class SyncthingService extends Service {
|
||||||
*/
|
*/
|
||||||
public boolean exportConfig() {
|
public boolean exportConfig() {
|
||||||
Boolean failSuccess = true;
|
Boolean failSuccess = true;
|
||||||
Log.v(TAG, "exportConfig BEGIN");
|
Log.d(TAG, "exportConfig BEGIN");
|
||||||
|
|
||||||
if (mCurrentState != State.DISABLED) {
|
if (mCurrentState != State.DISABLED) {
|
||||||
// Shutdown synchronously.
|
// Shutdown synchronously.
|
||||||
|
@ -849,7 +850,7 @@ public class SyncthingService extends Service {
|
||||||
* https://developer.android.com/reference/java/nio/file/package-summary
|
* https://developer.android.com/reference/java/nio/file/package-summary
|
||||||
*/
|
*/
|
||||||
if (Build.VERSION.SDK_INT >= 26) {
|
if (Build.VERSION.SDK_INT >= 26) {
|
||||||
Log.v(TAG, "exportConfig: Exporting index database");
|
Log.d(TAG, "exportConfig: Exporting index database");
|
||||||
Path databaseSourcePath = Paths.get(this.getFilesDir() + "/" + Constants.INDEX_DB_FOLDER);
|
Path databaseSourcePath = Paths.get(this.getFilesDir() + "/" + Constants.INDEX_DB_FOLDER);
|
||||||
Path databaseExportPath = Paths.get(Constants.EXPORT_PATH + "/" + Constants.INDEX_DB_FOLDER);
|
Path databaseExportPath = Paths.get(Constants.EXPORT_PATH + "/" + Constants.INDEX_DB_FOLDER);
|
||||||
if (java.nio.file.Files.exists(databaseExportPath)) {
|
if (java.nio.file.Files.exists(databaseExportPath)) {
|
||||||
|
@ -871,7 +872,7 @@ public class SyncthingService extends Service {
|
||||||
Log.e(TAG, "Failed to copy directory '" + databaseSourcePath + "' to '" + databaseExportPath + "'");
|
Log.e(TAG, "Failed to copy directory '" + databaseSourcePath + "' to '" + databaseExportPath + "'");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Log.v(TAG, "exportConfig END");
|
Log.d(TAG, "exportConfig END");
|
||||||
|
|
||||||
// Start syncthing after export if run conditions apply.
|
// Start syncthing after export if run conditions apply.
|
||||||
if (mLastDeterminedShouldRun) {
|
if (mLastDeterminedShouldRun) {
|
||||||
|
@ -897,7 +898,7 @@ public class SyncthingService extends Service {
|
||||||
*/
|
*/
|
||||||
public boolean importConfig() {
|
public boolean importConfig() {
|
||||||
Boolean failSuccess = true;
|
Boolean failSuccess = true;
|
||||||
Log.v(TAG, "importConfig BEGIN");
|
Log.d(TAG, "importConfig BEGIN");
|
||||||
|
|
||||||
if (mCurrentState != State.DISABLED) {
|
if (mCurrentState != State.DISABLED) {
|
||||||
// Shutdown synchronously.
|
// Shutdown synchronously.
|
||||||
|
@ -949,17 +950,17 @@ public class SyncthingService extends Service {
|
||||||
case "notification_type":
|
case "notification_type":
|
||||||
case "notify_crashes":
|
case "notify_crashes":
|
||||||
case "start_into_web_gui":
|
case "start_into_web_gui":
|
||||||
Log.v(TAG, "importConfig: Ignoring deprecated pref \"" + prefKey + "\".");
|
LogV("importConfig: Ignoring deprecated pref \"" + prefKey + "\".");
|
||||||
break;
|
break;
|
||||||
// Cached information which is not available on SettingsActivity.
|
// Cached information which is not available on SettingsActivity.
|
||||||
case Constants.PREF_DEBUG_FACILITIES_AVAILABLE:
|
case Constants.PREF_DEBUG_FACILITIES_AVAILABLE:
|
||||||
case Constants.PREF_EVENT_PROCESSOR_LAST_SYNC_ID:
|
case Constants.PREF_EVENT_PROCESSOR_LAST_SYNC_ID:
|
||||||
case Constants.PREF_LAST_BINARY_VERSION:
|
case Constants.PREF_LAST_BINARY_VERSION:
|
||||||
case Constants.PREF_LOCAL_DEVICE_ID:
|
case Constants.PREF_LOCAL_DEVICE_ID:
|
||||||
Log.v(TAG, "importConfig: Ignoring cache pref \"" + prefKey + "\".");
|
LogV("importConfig: Ignoring cache pref \"" + prefKey + "\".");
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
Log.v(TAG, "importConfig: Adding pref \"" + prefKey + "\" to commit ...");
|
Log.i(TAG, "importConfig: Adding pref \"" + prefKey + "\" to commit ...");
|
||||||
|
|
||||||
// The editor only provides typed setters.
|
// The editor only provides typed setters.
|
||||||
if (e.getValue() instanceof Boolean) {
|
if (e.getValue() instanceof Boolean) {
|
||||||
|
@ -975,7 +976,7 @@ public class SyncthingService extends Service {
|
||||||
} else if (e.getValue() instanceof Set) {
|
} else if (e.getValue() instanceof Set) {
|
||||||
editor.putStringSet(prefKey, (Set<String>) e.getValue());
|
editor.putStringSet(prefKey, (Set<String>) e.getValue());
|
||||||
} else {
|
} else {
|
||||||
Log.v(TAG, "importConfig: SharedPref type " + e.getValue().getClass().getName() + " is unknown");
|
Log.w(TAG, "importConfig: SharedPref type " + e.getValue().getClass().getName() + " is unknown");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1017,7 +1018,7 @@ public class SyncthingService extends Service {
|
||||||
if (Build.VERSION.SDK_INT >= 26) {
|
if (Build.VERSION.SDK_INT >= 26) {
|
||||||
Path databaseImportPath = Paths.get(Constants.EXPORT_PATH + "/" + Constants.INDEX_DB_FOLDER);
|
Path databaseImportPath = Paths.get(Constants.EXPORT_PATH + "/" + Constants.INDEX_DB_FOLDER);
|
||||||
if (java.nio.file.Files.exists(databaseImportPath)) {
|
if (java.nio.file.Files.exists(databaseImportPath)) {
|
||||||
Log.v(TAG, "importConfig: Importing index database");
|
Log.d(TAG, "importConfig: Importing index database");
|
||||||
Path databaseTargetPath = Paths.get(this.getFilesDir() + "/" + Constants.INDEX_DB_FOLDER);
|
Path databaseTargetPath = Paths.get(this.getFilesDir() + "/" + Constants.INDEX_DB_FOLDER);
|
||||||
try {
|
try {
|
||||||
FileUtils.deleteDirectoryRecursively(databaseTargetPath);
|
FileUtils.deleteDirectoryRecursively(databaseTargetPath);
|
||||||
|
@ -1037,7 +1038,7 @@ public class SyncthingService extends Service {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Log.v(TAG, "importConfig END");
|
Log.d(TAG, "importConfig END");
|
||||||
|
|
||||||
// Start syncthing after import if run conditions apply.
|
// Start syncthing after import if run conditions apply.
|
||||||
if (mLastDeterminedShouldRun) {
|
if (mLastDeterminedShouldRun) {
|
||||||
|
@ -1052,4 +1053,10 @@ public class SyncthingService extends Service {
|
||||||
}
|
}
|
||||||
return failSuccess;
|
return failSuccess;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void LogV(String logMessage) {
|
||||||
|
if (ENABLE_VERBOSE_LOG) {
|
||||||
|
Log.v(TAG, logMessage);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:checked="true"
|
android:checked="true"
|
||||||
android:focusable="false"
|
android:focusable="false"
|
||||||
|
android:clickable="false"
|
||||||
android:visibility="gone"
|
android:visibility="gone"
|
||||||
app:buttonTint="#76ff03"/>
|
app:buttonTint="#76ff03"/>
|
||||||
|
|
||||||
|
@ -31,6 +32,7 @@
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:checked="true"
|
android:checked="true"
|
||||||
android:focusable="false"
|
android:focusable="false"
|
||||||
|
android:clickable="false"
|
||||||
android:visibility="gone"
|
android:visibility="gone"
|
||||||
app:buttonTint="#fff103"/>
|
app:buttonTint="#fff103"/>
|
||||||
|
|
||||||
|
@ -40,6 +42,7 @@
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:checked="true"
|
android:checked="true"
|
||||||
android:focusable="false"
|
android:focusable="false"
|
||||||
|
android:clickable="false"
|
||||||
android:visibility="gone"
|
android:visibility="gone"
|
||||||
app:buttonTint="#ffae03"/>
|
app:buttonTint="#ffae03"/>
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue