From 9c2d50c7b075d75ff648486f8fbf906199ef46aa Mon Sep 17 00:00:00 2001 From: Philipp Crocoll Date: Tue, 3 Jun 2025 15:54:34 +0200 Subject: [PATCH] remove debugging code, resolve some TODOs --- .../database/SynchronizeCachedDatabase.cs | 11 ++--------- src/Kp2aBusinessLogic/database/edit/SaveDB.cs | 10 +++------- src/keepass2android-app/Resources/values/strings.xml | 3 +++ .../services/BackgroundSyncService.cs | 9 ++++++--- 4 files changed, 14 insertions(+), 19 deletions(-) diff --git a/src/Kp2aBusinessLogic/database/SynchronizeCachedDatabase.cs b/src/Kp2aBusinessLogic/database/SynchronizeCachedDatabase.cs index 82ab2be6..d12d7985 100644 --- a/src/Kp2aBusinessLogic/database/SynchronizeCachedDatabase.cs +++ b/src/Kp2aBusinessLogic/database/SynchronizeCachedDatabase.cs @@ -46,9 +46,6 @@ namespace keepass2android StatusLogger.UpdateSubMessage(_app.GetResourceString(UiStringKey.DownloadingRemoteFile)); string hash; - //TODO remove - Thread.Sleep(5000); - MemoryStream remoteData; try { @@ -68,14 +65,10 @@ namespace keepass2android //check if remote file was modified: var baseVersionHash = cachingFileStorage.GetBaseVersionHash(ioc); Kp2aLog.Log("Checking for file change. baseVersionHash = " + baseVersionHash); - if (baseVersionHash != hash || - true //TODO remove - ) + if (baseVersionHash != hash) { //remote file is modified - if (cachingFileStorage.HasLocalChanges(ioc) - || true //TODO remove - ) + if (cachingFileStorage.HasLocalChanges(ioc)) { //conflict! need to merge var _saveDb = new SaveDb(_app, new ActionOnOperationFinished(_app, diff --git a/src/Kp2aBusinessLogic/database/edit/SaveDB.cs b/src/Kp2aBusinessLogic/database/edit/SaveDB.cs index 81615a46..d93230bb 100644 --- a/src/Kp2aBusinessLogic/database/edit/SaveDB.cs +++ b/src/Kp2aBusinessLogic/database/edit/SaveDB.cs @@ -143,17 +143,11 @@ namespace keepass2android return; } } - - //TODO remove - Thread.Sleep(5000); - - + bool hasStreamForOrigFile = (_streamForOrigFile != null); bool hasChangeFast = hasStreamForOrigFile || fileStorage.CheckForFileChangeFast(ioc, _db.LastFileVersion); //first try to use the fast change detection; bool hasHashChanged = !requiresSubsequentSync && ( - //TODO remove - true || hasChangeFast || (FileHashChanged(ioc, _db.KpDatabase.HashOfFileOnDisk) == FileHashChange.Changed)); //if that fails, hash the file and compare: @@ -278,7 +272,9 @@ namespace keepass2android PerformSaveWithoutCheck(fileStorage, ioc); new Handler(Looper.MainLooper).Post(() => { + Kp2aLog.Log("OPR: Starting posted UpdateGlobals"); _db.UpdateGlobals(); + Kp2aLog.Log("OPR: Finished posted UpdateGlobals"); }); FinishWithSuccess(); diff --git a/src/keepass2android-app/Resources/values/strings.xml b/src/keepass2android-app/Resources/values/strings.xml index 158e0a8d..257306c9 100644 --- a/src/keepass2android-app/Resources/values/strings.xml +++ b/src/keepass2android-app/Resources/values/strings.xml @@ -726,6 +726,9 @@ Notification about the database being locked with QuickUnlock Entry notifications Notification to simplify access to the currently selected entry. + Synchronization operation + Notification to indicate that a synchronization is performed in the background. + Close database after three failed biometric unlock attempts. Warning! Biometric authentication can be invalidated by Android, e.g. after adding a new fingerprint in your device settings. Make sure you always know how to unlock with your master password! diff --git a/src/keepass2android-app/services/BackgroundSyncService.cs b/src/keepass2android-app/services/BackgroundSyncService.cs index e3d14997..7843cc91 100644 --- a/src/keepass2android-app/services/BackgroundSyncService.cs +++ b/src/keepass2android-app/services/BackgroundSyncService.cs @@ -100,14 +100,17 @@ namespace keepass2android.services { if (Build.VERSION.SdkInt >= BuildVersionCodes.O) { - //TODO - var channelName = "Foreground Service Channel"; - var channelDescription = "Channel for foreground service"; + var channelName = GetString(Resource.String.BackgroundSyncChannel_name); + var channelDescription = GetString(Resource.String.BackgroundSyncChannel_desc); var channelImportance = NotificationImportance.Default; var channel = new NotificationChannel(ChannelId, channelName, channelImportance) { Description = channelDescription }; + channel.EnableLights(false); + channel.EnableVibration(false); + channel.SetSound(null, null); + channel.SetShowBadge(false); var notificationManager = (NotificationManager)GetSystemService(NotificationService); notificationManager.CreateNotificationChannel(channel);