Skip to content

Conversation

@shubham1g5
Copy link
Contributor

@shubham1g5 shubham1g5 commented Feb 27, 2019

Does 5 things-

  1. Corrects the dispatch to offline install activity (Jira). This was a silly mistake on my part and was affecting APP_REINSTALL_AND_UPDATE measure which allows user to choose between offline and online install.

  2. Handles the case when user returns to the Recovery Screen without selecting any file.

  3. Tries to handle the NPE. I have not been able to repro it so unsure why it's happening.

  4. Error handling: Catch any exceptions in async calls , Logs complete stack trace for an exception during install.

  5. In case we lost result of last recovery call and there is no task currently in progress, trigger the measures again.

  6. Fixes another silly mistake where update was not getting called for offline_reinstall_and_update_measure.

if (resultCode == Activity.RESULT_OK) {
mPresenter.doOfflineAppInstall(intent.getStringExtra(InstallArchiveActivity.ARCHIVE_JR_REFERENCE));
} else {
mPresenter.OnOfflineInstallCancelled();
Copy link
Contributor Author

@shubham1g5 shubham1g5 Feb 27, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Happens when user returns to the Recovery Screen without selecting any file.

Logger.log(LogTypes.TYPE_MAINTENANCE, String.format(
"%s failed with %s for recovery measure %s", mCurrentMeasure.getType(), reason, mCurrentMeasure.getSequenceNumber()));
if (mActivity != null) {
Logger.log(LogTypes.TYPE_MAINTENANCE, String.format(
Copy link
Contributor Author

@shubham1g5 shubham1g5 Feb 27, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is to fix the NPE linked in PR description. I am not sure how mCurrentMeasure is getting null though I am hoping it's because actvity is no longer alive and hence hoping moving the log under activity not null check might fix it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just double chekcing, you mean how "mActivity is getting through null", right? not mCurrentMeasure? Or is mCurrentMeasure coming through null when mActivity is null?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we are getting a crash report because of mCurrentMeasure being null. Though I have not been able to repro it on my end.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have now reverted this change and wrapped the whole thing inside a try catch block to not crash the app in case of any errors here but log the exception and show user a failure message.

@shubham1g5 shubham1g5 requested a review from ctsims February 27, 2019 17:38
@shubham1g5 shubham1g5 changed the title Corrects offline dispatch Fixes CCZ Install during Recovery Feb 27, 2019
@shubham1g5 shubham1g5 added this to the 2.45 milestone Feb 27, 2019
if (mLastExecutionStatus == STATUS_FAILED) {
mActivity.enableRetry();
updateStatus(mLastDisplayStatus);
} else if (!(connectToUpdateTask() || mActivity.aTaskInProgress()) && mLastExecutionStatus != STATUS_WAITING) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed mLastExecutionStatus != STATUS_WAITING condition here since in case we don't have an exisiting task to connect to and mLastExecutionStatus is STATUS_WAITING means that we have lost result of the last async task. So the only resonable thing to do in this case is to trigger the measures again.

} else {
return STATUS_EXECUTED;
}
} catch (Exception e) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is only change in L140 - L190. Moved this exception handling to the top level function start

@shubham1g5
Copy link
Contributor Author

shubham1g5 commented Feb 28, 2019

@ctsims Made some more changes here specifically #4, #5 and #6 in PR description. Can you take a re-look.

@shubham1g5 shubham1g5 merged commit 5598772 into commcare_2.45 Mar 1, 2019
@shubham1g5 shubham1g5 deleted the recoveryBugs branch March 1, 2019 19:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants