From 0b83bfa9a4bc3e59e3015675660a528944e0fedf Mon Sep 17 00:00:00 2001 From: Fahim Salam Chowdhury Date: Tue, 2 May 2023 18:58:18 +0600 Subject: [PATCH] 6765-fix_account_switch_break_functionality_issue issue: https://gitlab.e.foundation/e/backlog/-/issues/6765 --- .../e/drive/receivers/AccountRemoveCallbackReceiver.java | 3 +++ .../java/foundation/e/drive/services/InitializerService.java | 2 ++ .../java/foundation/e/drive/utils/DavClientProvider.java | 5 +++++ 3 files changed, 10 insertions(+) diff --git a/app/src/main/java/foundation/e/drive/receivers/AccountRemoveCallbackReceiver.java b/app/src/main/java/foundation/e/drive/receivers/AccountRemoveCallbackReceiver.java index 339507d8..c4b08a69 100644 --- a/app/src/main/java/foundation/e/drive/receivers/AccountRemoveCallbackReceiver.java +++ b/app/src/main/java/foundation/e/drive/receivers/AccountRemoveCallbackReceiver.java @@ -30,6 +30,7 @@ import foundation.e.drive.services.InitializerService; import foundation.e.drive.services.ObserverService; import foundation.e.drive.services.SynchronizationService; import foundation.e.drive.utils.AppConstants; +import foundation.e.drive.utils.DavClientProvider; import foundation.e.drive.utils.ViewUtils; import timber.log.Timber; @@ -54,6 +55,8 @@ public class AccountRemoveCallbackReceiver extends BroadcastReceiver { cleanSharedPreferences(applicationContext, preferences); removeCachedFiles(applicationContext); + DavClientProvider.getInstance().cleanUp(); + ViewUtils.updateWidgetView(applicationContext); } diff --git a/app/src/main/java/foundation/e/drive/services/InitializerService.java b/app/src/main/java/foundation/e/drive/services/InitializerService.java index ecf74702..93ddb453 100644 --- a/app/src/main/java/foundation/e/drive/services/InitializerService.java +++ b/app/src/main/java/foundation/e/drive/services/InitializerService.java @@ -23,6 +23,7 @@ import java.util.List; import foundation.e.drive.models.SyncedFolder; import foundation.e.drive.utils.AppConstants; import foundation.e.drive.utils.CommonUtils; +import foundation.e.drive.utils.DavClientProvider; import foundation.e.drive.utils.RootSyncedFolderProvider; import timber.log.Timber; @@ -48,6 +49,7 @@ public class InitializerService extends Service { @Override public int onStartCommand(@NonNull Intent intent, int flags, int startId) { Timber.i("onStartCommand()"); + DavClientProvider.getInstance().cleanUp(); CommonUtils.setServiceUnCaughtExceptionHandler(this); //Get account diff --git a/app/src/main/java/foundation/e/drive/utils/DavClientProvider.java b/app/src/main/java/foundation/e/drive/utils/DavClientProvider.java index 70514ae3..deb1974f 100644 --- a/app/src/main/java/foundation/e/drive/utils/DavClientProvider.java +++ b/app/src/main/java/foundation/e/drive/utils/DavClientProvider.java @@ -90,6 +90,11 @@ public class DavClientProvider { return ncClientInstance; } + public void cleanUp() { + ncClientInstance = null; + ocClientInstance = null; + } + @Nullable private static String getAcountPwd(Account account, Context ctx) throws AccountUtils.AccountNotFoundException { return AccountManager.get(ctx).getPassword(account); -- GitLab