From 098b10987ed4cb19e7ed2a2693eb5eb168be9515 Mon Sep 17 00:00:00 2001 From: Mohit Date: Thu, 13 Aug 2020 14:19:15 +0530 Subject: [PATCH] Fix bug when eDrive doesn't detect user account on os update in Nougat --- .../drive/receivers/BootCompleteReceiver.java | 34 +++++++++---------- 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/app/src/main/java/foundation/e/drive/receivers/BootCompleteReceiver.java b/app/src/main/java/foundation/e/drive/receivers/BootCompleteReceiver.java index bdab453b..a996fe1c 100644 --- a/app/src/main/java/foundation/e/drive/receivers/BootCompleteReceiver.java +++ b/app/src/main/java/foundation/e/drive/receivers/BootCompleteReceiver.java @@ -23,12 +23,10 @@ public class BootCompleteReceiver extends BroadcastReceiver { Log.i(TAG, "onReceive"); String intentAction = intent.getAction(); - SharedPreferences prefs = context.getSharedPreferences(AppConstants.SHARED_PREFERENCE_NAME, Context.MODE_PRIVATE); - if (intentAction == null) { Log.e(TAG, "intent Action is null"); } else if (intent.getAction().equals(Intent.ACTION_BOOT_COMPLETED)) { - + SharedPreferences prefs = context.getSharedPreferences(AppConstants.SHARED_PREFERENCE_NAME, Context.MODE_PRIVATE); if (prefs.getString(AccountManager.KEY_ACCOUNT_NAME, null) != null) { //If user account is registered prefs.edit().putBoolean(AppConstants.KEY_OMS_IS_WORKING, false).commit(); @@ -37,25 +35,25 @@ public class BootCompleteReceiver extends BroadcastReceiver { //scanner job isn't registered then register it JobUtils.scheduleScannerJob(context); } - } - } else { - Account mAccount = CommonUtils.getAccount(context.getString(R.string.eelo_account_type), AccountManager.get(context)); + } else { - if (mAccount != null) { - - String accountName = mAccount.name; - String accountType = mAccount.type; + Account mAccount = CommonUtils.getAccount(context.getString(R.string.eelo_account_type), AccountManager.get(context)); - //If data come from intent, store them into pref because there aren't stored - prefs.edit().putString(AccountManager.KEY_ACCOUNT_NAME, accountName) - .putBoolean(AppConstants.KEY_OMS_IS_WORKING, false) - .putString(AccountManager.KEY_ACCOUNT_TYPE, accountType) - .apply(); + if (mAccount != null) { + String accountName = mAccount.name; + String accountType = mAccount.type; - if (!JobUtils.isScannerJobRegistered(context)) { - //scanner job isn't registered then register it - JobUtils.scheduleScannerJob(context); + //If data come from intent, store them into pref because there aren't stored + prefs.edit().putString(AccountManager.KEY_ACCOUNT_NAME, accountName) + .putBoolean(AppConstants.KEY_OMS_IS_WORKING, false) + .putString(AccountManager.KEY_ACCOUNT_TYPE, accountType) + .apply(); + + if (!JobUtils.isScannerJobRegistered(context)) { + //scanner job isn't registered then register it + JobUtils.scheduleScannerJob(context); + } } } } -- GitLab