|
4 | 4 |
|
5 | 5 | import com.google.firebase.perf.metrics.Trace; |
6 | 6 |
|
| 7 | +import org.commcare.CommCareApplication; |
7 | 8 | import org.commcare.android.logging.ForceCloseLogger; |
8 | 9 | import org.commcare.cases.entity.Entity; |
9 | 10 | import org.commcare.cases.entity.EntityLoadingProgressListener; |
|
12 | 13 | import org.commcare.suite.model.Detail; |
13 | 14 | import org.commcare.suite.model.EntityDatum; |
14 | 15 | import org.commcare.tasks.templates.ManagedAsyncTask; |
| 16 | +import org.commcare.util.LogTypes; |
15 | 17 | import org.javarosa.core.model.condition.EvaluationContext; |
16 | 18 | import org.javarosa.core.model.instance.TreeReference; |
17 | 19 | import org.javarosa.core.services.Logger; |
18 | 20 | import org.javarosa.xpath.XPathException; |
19 | 21 |
|
| 22 | +import java.util.Date; |
20 | 23 | import java.util.HashMap; |
21 | 24 | import java.util.List; |
22 | 25 | import java.util.Map; |
@@ -79,9 +82,29 @@ protected Pair<List<Entity<TreeReference>>, List<TreeReference>> doInBackground( |
79 | 82 | Logger.exception("Error during EntityLoaderTask: " + ForceCloseLogger.getStackTrace(xe), xe); |
80 | 83 | mException = xe; |
81 | 84 | return null; |
| 85 | + } catch (RuntimeException e) { |
| 86 | + Logger.log(LogTypes.SOFT_ASSERT, "Loading entities failed for " + getSessionShortDetail() + |
| 87 | + "; session expiring at: " + getSessionExpirationTime()); |
| 88 | + throw e; |
82 | 89 | } |
83 | 90 | } |
84 | 91 |
|
| 92 | + private Date getSessionExpirationTime() { |
| 93 | + if (CommCareApplication.isSessionActive()) { |
| 94 | + try { |
| 95 | + return CommCareApplication.instance().getSession().getSessionExpireDate(); |
| 96 | + } catch (Exception e) { |
| 97 | + return null; |
| 98 | + } |
| 99 | + } |
| 100 | + return null; |
| 101 | + } |
| 102 | + |
| 103 | + private String getSessionShortDetail() { |
| 104 | + return (entityLoaderHelper != null && entityLoaderHelper.getSessionDatum() != null) ? |
| 105 | + entityLoaderHelper.getSessionDatum().getShortDetail() : "null"; |
| 106 | + } |
| 107 | + |
85 | 108 | @Override |
86 | 109 | protected void onPostExecute(Pair<List<Entity<TreeReference>>, List<TreeReference>> result) { |
87 | 110 | super.onPostExecute(result); |
|
0 commit comments