remove debug logging

This commit is contained in:
Philipp Crocoll
2025-06-03 16:00:24 +02:00
parent 9c2d50c7b0
commit c3c9c8610d
7 changed files with 4 additions and 69 deletions

View File

@@ -60,7 +60,6 @@ public class OperationRunner
public void Run(IKp2aApp app, OperationWithFinishHandler operation, bool runBlocking = false) public void Run(IKp2aApp app, OperationWithFinishHandler operation, bool runBlocking = false)
{ {
Kp2aLog.Log("OPR: Run: " + operation.GetType().Name + ", runBlocking: " + runBlocking);
lock (Instance._taskQueueLock) lock (Instance._taskQueueLock)
{ {
_taskQueue.Enqueue(new OperationWithMetadata(){ Operation = operation, RunBlocking = runBlocking}); _taskQueue.Enqueue(new OperationWithMetadata(){ Operation = operation, RunBlocking = runBlocking});
@@ -81,7 +80,6 @@ public class OperationRunner
{ {
_thread = null; _thread = null;
_statusLogger.EndLogging(); _statusLogger.EndLogging();
Kp2aLog.Log("OPR: task queue empty. Stopping operation runner thread.");
break; break;
} }
else else
@@ -92,13 +90,10 @@ public class OperationRunner
if (_currentlyRunningTask.Value.RunBlocking) if (_currentlyRunningTask.Value.RunBlocking)
{ {
Kp2aLog.Log("OPR: Run. Posting to set up progress dialog for blocking task: " + _currentlyRunningTask?.Operation?.GetType()?.Name ?? "null");
app.UiThreadHandler.Post( app.UiThreadHandler.Post(
() => () =>
{ {
Kp2aLog.Log("OPR: Run. Starting Setting up progress dialog for blocking task: " + _currentlyRunningTask?.Operation?.GetType()?.Name ?? "null");
TrySetupProgressDialog(); TrySetupProgressDialog();
Kp2aLog.Log("OPR: Run. Finished Setting up progress dialog for blocking task: " + _currentlyRunningTask?.Operation?.GetType()?.Name ?? "null");
}); });
} }
@@ -108,20 +103,15 @@ public class OperationRunner
{ {
if (_currentlyRunningTask?.RunBlocking == true) if (_currentlyRunningTask?.RunBlocking == true)
{ {
Kp2aLog.Log("OPR: Run. Blocking task finished: " + _currentlyRunningTask?.Operation?.GetType()?.Name ?? "null");
_app.UiThreadHandler.Post(() => _app.UiThreadHandler.Post(() =>
{ {
Kp2aLog.Log("OPR: Starting Dismissing progress dialog");
_progressDialog?.Dismiss(); _progressDialog?.Dismiss();
Kp2aLog.Log("OPR: Finished Dismissing progress dialog");
} }
); );
} }
Kp2aLog.Log("OPR: Run. Finished handler called for task: " + _currentlyRunningTask?.Operation?.GetType()?.Name ?? "null");
_currentlyRunningTask = null; _currentlyRunningTask = null;
}), originalFinishedHandler); }), originalFinishedHandler);
Kp2aLog.Log("OPR: starting to run " + _currentlyRunningTask?.Operation?.GetType()?.Name ?? "null");
_currentlyRunningTask.Value.Operation.Run(); _currentlyRunningTask.Value.Operation.Run();
while (_currentlyRunningTask != null) while (_currentlyRunningTask != null)
@@ -135,13 +125,12 @@ public class OperationRunner
Kp2aLog.Log("Thread interrupted."); Kp2aLog.Log("Thread interrupted.");
} }
} }
Kp2aLog.Log("OPR: waiting for next task in queue...");
} }
}); });
_thread.Start(); _thread.Start();
} }
else Kp2aLog.Log("OPR: thread already running, only enqueued " + operation.GetType().Name );
} }
@@ -151,7 +140,6 @@ public class OperationRunner
private bool TrySetupProgressDialog() private bool TrySetupProgressDialog()
{ {
Kp2aLog.Log("OPR: TrySetupProgressDialog");
string currentMessage = "Initializing..."; string currentMessage = "Initializing...";
string currentSubmessage = ""; string currentSubmessage = "";
@@ -166,9 +154,7 @@ public class OperationRunner
var pd = _progressDialog; var pd = _progressDialog;
_app.UiThreadHandler.Post(() => _app.UiThreadHandler.Post(() =>
{ {
Kp2aLog.Log("OPR: Starting TrySetupProgressDialog: Dismissing existing progress dialog");
pd.Dismiss(); pd.Dismiss();
Kp2aLog.Log("OPR: Finished TrySetupProgressDialog: Dismissing existing progress dialog");
}); });
} }
@@ -176,7 +162,6 @@ public class OperationRunner
_progressDialog = _app.CreateProgressDialog(_app.ActiveContext); _progressDialog = _app.CreateProgressDialog(_app.ActiveContext);
if (_progressDialog == null) if (_progressDialog == null)
{ {
Kp2aLog.Log("OPR: OperationRunner.TrySetupProgressDialog: _progressDialog is null");
return false; return false;
} }
@@ -192,7 +177,6 @@ public class OperationRunner
public void SetNewActiveContext(IKp2aApp app) public void SetNewActiveContext(IKp2aApp app)
{ {
Kp2aLog.Log("OPR: SetNewActiveContext: " + app.ActiveContext?.GetType().Name);
_app = app; _app = app;
Context? context = app.ActiveContext; Context? context = app.ActiveContext;
bool isAppContext = context == null || (context.ApplicationContext == context); bool isAppContext = context == null || (context.ApplicationContext == context);
@@ -207,12 +191,9 @@ public class OperationRunner
if (_currentlyRunningTask?.RunBlocking == true && (context is Activity { IsFinishing: false, IsDestroyed:false})) if (_currentlyRunningTask?.RunBlocking == true && (context is Activity { IsFinishing: false, IsDestroyed:false}))
{ {
Kp2aLog.Log("OPR: SetNewActiveContext: running blocking task, setting up progress dialog");
app.UiThreadHandler.Post(() => app.UiThreadHandler.Post(() =>
{ {
Kp2aLog.Log("OPR: Starting posted TrySetupProgressDialog");
TrySetupProgressDialog(); TrySetupProgressDialog();
Kp2aLog.Log("OPR: Finished posted TrySetupProgressDialog");
}); });
} }
else else

View File

@@ -121,7 +121,6 @@ namespace keepass2android
{ {
_handler.Post(() => _handler.Post(() =>
{ {
Kp2aLog.Log("OPR: Starting posted SetMessage");
if (!String.IsNullOrEmpty(submessage)) if (!String.IsNullOrEmpty(submessage))
{ {
_progressDialog.SetMessage(_message + " (" + submessage + ")"); _progressDialog.SetMessage(_message + " (" + submessage + ")");
@@ -130,7 +129,6 @@ namespace keepass2android
{ {
_progressDialog.SetMessage(_message); _progressDialog.SetMessage(_message);
} }
Kp2aLog.Log("OPR: Finished posted SetMessage");
} }
); );
} }
@@ -140,9 +138,7 @@ namespace keepass2android
{ {
_handler.Post(() => _handler.Post(() =>
{ {
Kp2aLog.Log("OPR: Starting posted Show");
_progressDialog?.Show(); _progressDialog?.Show();
Kp2aLog.Log("OPR: Finished posted Show");
}); });
} }
@@ -151,9 +147,7 @@ namespace keepass2android
{ {
_handler.Post(() => _handler.Post(() =>
{ {
Kp2aLog.Log("OPR: Starting posted Dismiss");
_progressDialog?.Dismiss(); _progressDialog?.Dismiss();
Kp2aLog.Log("OPR: Finished posted Dismiss");
}); });
} }
@@ -166,9 +160,7 @@ namespace keepass2android
{ {
_handler.Post(() => _handler.Post(() =>
{ {
Kp2aLog.Log("OPR: Starting posted SetMessage");
_progressDialog.SetMessage(message); _progressDialog.SetMessage(message);
Kp2aLog.Log("OPR: Finishing posted SetMessage");
}); });
} }
} }

View File

@@ -47,9 +47,7 @@ namespace keepass2android
{ {
Handler.Post(() => Handler.Post(() =>
{ {
Kp2aLog.Log("OPR: Starting posted actionToPerform ");
_actionToPerform(Success, Message, ActiveContext); _actionToPerform(Success, Message, ActiveContext);
Kp2aLog.Log("OPR: Finished posted actionToPerform ");
}); });
} }
else else

View File

@@ -103,9 +103,7 @@ namespace keepass2android
if (handler != null ) { if (handler != null ) {
handler.Post(() => handler.Post(() =>
{ {
Kp2aLog.Log("OPR: Starting posted NextOnOperationFinishedHandler");
NextOnOperationFinishedHandler.Run(); NextOnOperationFinishedHandler.Run();
Kp2aLog.Log("OPR: Finished posted NextOnOperationFinishedHandler");
}); });
} else { } else {
NextOnOperationFinishedHandler.Run(); NextOnOperationFinishedHandler.Run();

View File

@@ -272,9 +272,7 @@ namespace keepass2android
PerformSaveWithoutCheck(fileStorage, ioc); PerformSaveWithoutCheck(fileStorage, ioc);
new Handler(Looper.MainLooper).Post(() => new Handler(Looper.MainLooper).Post(() =>
{ {
Kp2aLog.Log("OPR: Starting posted UpdateGlobals");
_db.UpdateGlobals(); _db.UpdateGlobals();
Kp2aLog.Log("OPR: Finished posted UpdateGlobals");
}); });
FinishWithSuccess(); FinishWithSuccess();

View File

@@ -651,8 +651,6 @@ namespace keepass2android
{ {
if (app.ActiveContext is Activity activity) if (app.ActiveContext is Activity activity)
{ {
Kp2aLog.Log("OPR: Will show YesNoCancel dialog because active context is an Activity.");
if (_dialog is { IsShowing: true }) if (_dialog is { IsShowing: true })
{ {
try try
@@ -752,7 +750,6 @@ namespace keepass2android
} }
else else
{ {
Kp2aLog.Log("OPR: Cannot show YesNoCancel dialog because active context is not an Activity.");
OperationRunner.Instance.StatusLogger?.UpdateSubMessage(App.Context.GetString(Resource.String.user_interaction_required)); OperationRunner.Instance.StatusLogger?.UpdateSubMessage(App.Context.GetString(Resource.String.user_interaction_required));
return false; return false;
} }
@@ -770,8 +767,6 @@ namespace keepass2android
{ {
throw new Java.Lang.InterruptedException(); throw new Java.Lang.InterruptedException();
} }
Kp2aLog.Log("OPR: AskYesNoCancel called with titleKey " + titleKey + ", messageKey " + messageKey);
_currentlyPendingYesNoCancelQuestion = new YesNoCancelQuestion() _currentlyPendingYesNoCancelQuestion = new YesNoCancelQuestion()
{ {
TitleKey = titleKey, TitleKey = titleKey,
@@ -787,9 +782,7 @@ namespace keepass2android
UiThreadHandler.Post( () => UiThreadHandler.Post( () =>
{ {
Kp2aLog.Log("OPR: Starting posted AskYesNoCancel/TryShow ");
_currentlyPendingYesNoCancelQuestion.TryShow(this, OnUserInputDialogClose, OnUserInputDialogShow); _currentlyPendingYesNoCancelQuestion.TryShow(this, OnUserInputDialogClose, OnUserInputDialogShow);
Kp2aLog.Log("OPR: Finished posted AskYesNoCancel/TryShow ");
}); });
} }
@@ -803,20 +796,16 @@ namespace keepass2android
/// </summary> /// </summary>
private void ShowAllActiveProgressDialogs() private void ShowAllActiveProgressDialogs()
{ {
Kp2aLog.Log("OPR: ShowAllActiveProgressDialogs");
foreach (RealProgressDialog progressDialog in _activeProgressDialogs) foreach (RealProgressDialog progressDialog in _activeProgressDialogs)
{ {
Kp2aLog.Log("OPR: ShowAllActiveProgressDialogs: Showing " + progressDialog.GetType().Name);
progressDialog.Show(); progressDialog.Show();
} }
} }
private void HideAllActiveProgressDialogs() private void HideAllActiveProgressDialogs()
{ {
Kp2aLog.Log("OPR: HideAllActiveProgressDialogs");
foreach (RealProgressDialog progressDialog in _activeProgressDialogs) foreach (RealProgressDialog progressDialog in _activeProgressDialogs)
{ {
Kp2aLog.Log("OPR: HideAllActiveProgressDialogs: Hiding " + progressDialog.GetType().Name);
progressDialog.Hide(); progressDialog.Hide();
} }
} }
@@ -837,7 +826,6 @@ namespace keepass2android
private void OnUserInputDialogClose() private void OnUserInputDialogClose()
{ {
_isShowingUserInputDialog = false; _isShowingUserInputDialog = false;
Kp2aLog.Log("OPR: OnUserInputDialogClose called, _currentlyPendingYesNoCancelQuestion is " + (_currentlyPendingYesNoCancelQuestion != null ? "not null" : "null") + " Will set to null now.");
_currentlyPendingYesNoCancelQuestion = null; _currentlyPendingYesNoCancelQuestion = null;
ShowAllActiveProgressDialogs(); ShowAllActiveProgressDialogs();
@@ -892,8 +880,6 @@ namespace keepass2android
// Only show if asking dialog not also showing // Only show if asking dialog not also showing
if (!_app._isShowingUserInputDialog) if (!_app._isShowingUserInputDialog)
{ {
Kp2aLog.Log("OPR: Showing progress dialog " + _pd.GetType().Name);
try try
{ {
_pd.Show(); _pd.Show();
@@ -913,12 +899,6 @@ namespace keepass2android
public IProgressDialog CreateProgressDialog(Context ctx) public IProgressDialog CreateProgressDialog(Context ctx)
{ {
Kp2aLog.Log("OPR: CreateProgressDialog called with ctx " + ctx?.GetType().Name);
/*Kp2aLog.Log("ctx is null ? " + (ctx == null));
Kp2aLog.Log("ctx is activity ? " + (ctx is Activity));
Kp2aLog.Log("ctx is destroyed ? " + (ctx is Activity { IsDestroyed: true }));
Kp2aLog.Log("ctx is finishing ? " + (ctx is Activity { IsFinishing: true }));
*/
try try
{ {
@@ -930,7 +910,7 @@ namespace keepass2android
catch (Exception e) catch (Exception e)
{ {
//may happen if the activity is (being) destroyed //may happen if the activity is (being) destroyed
Kp2aLog.Log("OPR: CreateProgressDialog failed with " + e.ToString()); Kp2aLog.Log("CreateProgressDialog failed with " + e.ToString());
return null; return null;
} }
@@ -1339,8 +1319,6 @@ namespace keepass2android
public void StartBackgroundSyncService() public void StartBackgroundSyncService()
{ {
Kp2aLog.Log("OPR: StartBackgroundSyncService");
Intent intent = new Intent(App.Context, typeof(BackgroundSyncService)); Intent intent = new Intent(App.Context, typeof(BackgroundSyncService));
intent.SetAction(BackgroundSyncService.ActionStart); intent.SetAction(BackgroundSyncService.ActionStart);
App.Context.StartService(intent); App.Context.StartService(intent);
@@ -1541,7 +1519,6 @@ namespace keepass2android
{ {
_activeContext = value; _activeContext = value;
OperationRunner.Instance.SetNewActiveContext(App.Kp2a); OperationRunner.Instance.SetNewActiveContext(App.Kp2a);
Kp2aLog.Log("OPR: ActiveContext set to " + _activeContext?.GetType().Name + ". Pending question? " +(_currentlyPendingYesNoCancelQuestion != null));
_currentlyPendingYesNoCancelQuestion?.TryShow(this, OnUserInputDialogClose, OnUserInputDialogShow); _currentlyPendingYesNoCancelQuestion?.TryShow(this, OnUserInputDialogClose, OnUserInputDialogShow);
} }
} }

View File

@@ -44,11 +44,9 @@ public class BackgroundOperationContainer : LinearLayout, IProgressUi
{ {
App.Kp2a.UiThreadHandler.Post(() => App.Kp2a.UiThreadHandler.Post(() =>
{ {
Kp2aLog.Log("OPR: Starting posted Show ");
Visibility = ViewStates.Visible; Visibility = ViewStates.Visible;
FindViewById<TextView>(Resource.Id.background_ops_message)!.Visibility = ViewStates.Gone; FindViewById<TextView>(Resource.Id.background_ops_message)!.Visibility = ViewStates.Gone;
FindViewById<TextView>(Resource.Id.background_ops_submessage)!.Visibility = ViewStates.Gone; FindViewById<TextView>(Resource.Id.background_ops_submessage)!.Visibility = ViewStates.Gone;
Kp2aLog.Log("OPR: Finished posted Show ");
}); });
} }
@@ -57,11 +55,8 @@ public class BackgroundOperationContainer : LinearLayout, IProgressUi
{ {
App.Kp2a.UiThreadHandler.Post(() => App.Kp2a.UiThreadHandler.Post(() =>
{ {
Kp2aLog.Log("OPR: Starting posted Hide ");
String activityType = Context.GetType().FullName; String activityType = Context.GetType().FullName;
Kp2aLog.Log("Hiding background ops container in" + activityType);
Visibility = ViewStates.Gone; Visibility = ViewStates.Gone;
Kp2aLog.Log("OPR: Finished posted Hide ");
}); });
} }
@@ -69,7 +64,6 @@ public class BackgroundOperationContainer : LinearLayout, IProgressUi
{ {
App.Kp2a.UiThreadHandler.Post(() => App.Kp2a.UiThreadHandler.Post(() =>
{ {
Kp2aLog.Log("OPR: Starting posted UpdateMessage ");
TextView messageTextView = FindViewById<TextView>(Resource.Id.background_ops_message)!; TextView messageTextView = FindViewById<TextView>(Resource.Id.background_ops_message)!;
if (string.IsNullOrEmpty(message)) if (string.IsNullOrEmpty(message))
{ {
@@ -80,7 +74,6 @@ public class BackgroundOperationContainer : LinearLayout, IProgressUi
messageTextView.Visibility = ViewStates.Visible; messageTextView.Visibility = ViewStates.Visible;
messageTextView.Text = message; messageTextView.Text = message;
} }
Kp2aLog.Log("OPR: Finished posted UpdateMessage ");
}); });
} }
@@ -88,7 +81,6 @@ public class BackgroundOperationContainer : LinearLayout, IProgressUi
{ {
App.Kp2a.UiThreadHandler.Post(() => App.Kp2a.UiThreadHandler.Post(() =>
{ {
Kp2aLog.Log("OPR: Starting posted UpdateSubMessage ");
TextView subMessageTextView = FindViewById<TextView>(Resource.Id.background_ops_submessage)!; TextView subMessageTextView = FindViewById<TextView>(Resource.Id.background_ops_submessage)!;
if (string.IsNullOrEmpty(submessage)) if (string.IsNullOrEmpty(submessage))
{ {
@@ -99,7 +91,6 @@ public class BackgroundOperationContainer : LinearLayout, IProgressUi
subMessageTextView.Visibility = ViewStates.Visible; subMessageTextView.Visibility = ViewStates.Visible;
subMessageTextView.Text = submessage; subMessageTextView.Text = submessage;
} }
Kp2aLog.Log("OPR: Finished posted UpdateSubMessage ");
}); });
} }
} }