diff --git a/app/src/org/commcare/activities/HomeButtons.java b/app/src/org/commcare/activities/HomeButtons.java index 2fe104c47b..ca6cb6957f 100644 --- a/app/src/org/commcare/activities/HomeButtons.java +++ b/app/src/org/commcare/activities/HomeButtons.java @@ -130,7 +130,14 @@ private static View.OnClickListener getSyncButtonSubTextListener(final StandardH private static TextSetter getSyncButtonTextSetter(final StandardHomeActivity activity) { return (cardDisplayData, squareButtonViewHolder, context, notificationText) -> { - SyncDetailCalculations.updateSubText(activity, squareButtonViewHolder, cardDisplayData, notificationText); + try { + SyncDetailCalculations.updateSubText(activity, squareButtonViewHolder, cardDisplayData, + notificationText); + } catch (SessionUnavailableException e) { + // stop button setup, since redirection to login is imminent + return; + } + squareButtonViewHolder.subTextView.setBackgroundColor(activity.getResources().getColor(cardDisplayData.subTextBgColor)); squareButtonViewHolder.textView.setTextColor(context.getResources().getColor(cardDisplayData.textColor)); squareButtonViewHolder.textView.setText(cardDisplayData.text); diff --git a/app/src/org/commcare/services/CommCareSessionService.java b/app/src/org/commcare/services/CommCareSessionService.java index 24dd9b87e8..1ed06a1e51 100644 --- a/app/src/org/commcare/services/CommCareSessionService.java +++ b/app/src/org/commcare/services/CommCareSessionService.java @@ -350,9 +350,14 @@ private void timeToExpireSession() { // timeout then wrap-up the process. if (logoutStartedAt != -1 && currentTime > (logoutStartedAt + LOGOUT_TIMEOUT)) { + Logger.log(LogTypes.TYPE_USER, + "Crossed threshold to save form session state during scheduled session expiration. Passed " + ( + currentTime - logoutStartedAt) + "ms"); // Try and grab the logout lock, aborting if synchronization is in // progress. if (!CommCareSessionService.sessionAliveLock.tryLock()) { + Logger.log(LogTypes.TYPE_USER, + "Unabled to get session lock during scheduled session expiration"); return; } try { @@ -371,6 +376,8 @@ private void timeToExpireSession() { // Try and grab the logout lock, aborting if synchronization is in // progress. if (!CommCareSessionService.sessionAliveLock.tryLock()) { + Logger.log(LogTypes.TYPE_USER, + "Unabled to get session lock during scheduled session expiration"); return; }