Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes Crash on App Resume after Session Expiration #2799

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion app/src/org/commcare/activities/HomeButtons.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
7 changes: 7 additions & 0 deletions app/src/org/commcare/services/CommCareSessionService.java
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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;
}

Expand Down
Loading