in sdk/appcenter-distribute/src/main/java/com/microsoft/appcenter/distribute/Distribute.java [1272:1345]
private synchronized void handleApiCallSuccess(Object releaseCallId, String rawReleaseDetails, @NonNull ReleaseDetails releaseDetails, String sourceDistributionId) {
String lastDownloadedReleaseHash = SharedPreferencesManager.getString(PREFERENCE_KEY_DOWNLOADED_RELEASE_HASH);
if (!TextUtils.isEmpty(lastDownloadedReleaseHash)) {
if (isCurrentReleaseWasUpdated(lastDownloadedReleaseHash)) {
AppCenterLog.debug(LOG_TAG, "Successfully reported app update for downloaded release hash (" + lastDownloadedReleaseHash + "), removing from store..");
SharedPreferencesManager.remove(PREFERENCE_KEY_DOWNLOADED_RELEASE_HASH);
SharedPreferencesManager.remove(PREFERENCE_KEY_DOWNLOADED_RELEASE_ID);
} else {
AppCenterLog.debug(LOG_TAG, "Stored release hash doesn't match current installation, probably downloaded but not installed yet, keep in store");
}
}
/* Check if state did not change. */
if (mCheckReleaseCallId == releaseCallId) {
/* Reset state. */
mCheckReleaseApiCall = null;
/* If we didn't know what distribution group we were originally tied to (public track). */
if (sourceDistributionId == null) {
processDistributionGroupId(releaseDetails.getDistributionGroupId());
}
/* Check minimum Android API level. */
if (Build.VERSION.SDK_INT >= releaseDetails.getMinApiLevel()) {
/* Check version code is equals or higher and hash is different. */
AppCenterLog.debug(LOG_TAG, "Check if latest release is more recent.");
boolean moreRecent = isMoreRecent(releaseDetails);
if (!moreRecent) {
if (mListener != null && mForegroundActivity != null) {
AppCenterLog.debug(LOG_TAG, "Calling listener.onNoReleaseAvailable.");
mListener.onNoReleaseAvailable(mForegroundActivity);
}
} else if (canUpdateNow(releaseDetails)) {
/* Load last known release to see if we need to prepare a cleanup. */
if (mReleaseDetails == null) {
updateReleaseDetails(DistributeUtils.loadCachedReleaseDetails());
}
/* Update cache. */
SharedPreferencesManager.putString(PREFERENCE_KEY_RELEASE_DETAILS, rawReleaseDetails);
/* If previous release is mandatory and still processing, don't do anything right now. */
if (mReleaseDetails != null && mReleaseDetails.isMandatoryUpdate()) {
if (mReleaseDetails.getId() != releaseDetails.getId()) {
AppCenterLog.debug(LOG_TAG, "Latest release is more recent than the previous mandatory.");
SharedPreferencesManager.putInt(PREFERENCE_KEY_DOWNLOAD_STATE, DOWNLOAD_STATE_AVAILABLE);
} else {
AppCenterLog.debug(LOG_TAG, "The latest release is mandatory and already being processed.");
}
return;
}
/* Prepare download and cleanup older files if needed. */
updateReleaseDetails(releaseDetails);
/* Show update dialog. */
AppCenterLog.debug(LOG_TAG, "Latest release is more recent.");
SharedPreferencesManager.putInt(PREFERENCE_KEY_DOWNLOAD_STATE, DOWNLOAD_STATE_AVAILABLE);
if (mForegroundActivity != null) {
showUpdateDialog();
}
return;
}
} else {
AppCenterLog.info(LOG_TAG, "This device is not compatible with the latest release.");
}
/* If update dialog was not shown or scheduled, complete workflow. */
completeWorkflow();
}
}