Skip to content

Commit fedfc38

Browse files
author
Anastasia Senyushina
authored
Merge pull request #1580 from microsoft/v-ankubo/release-4.4.0-patch-1
Patch with fixes after testing release 4.4.0
2 parents 1c75a2a + 8ecdaa3 commit fedfc38

File tree

5 files changed

+69
-4
lines changed

5 files changed

+69
-4
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# App Center SDK for Android Change Log
22

3-
## Version 4.4.0
3+
## Version 4.4.1
44

55
### App Center
66

@@ -19,6 +19,7 @@
1919
* **[Feature]** Remove the download manager task if the download doesn't start within 10 seconds.
2020
* **[Feature]** Replace installing a new release using the deprecated intent action [ACTION_INSTALL_PACKAGE](https://developer.android.com/reference/android/content/Intent#ACTION_INSTALL_PACKAGE) with the `PackageInstaller` API.
2121
* **[Feature]** Add sumcheck on the downloaded file before starting the install process.
22+
* **[Fix]** Fix a crash after discarding the installation if the download of a new release was interrupted in the previous application start and resumed in the current one.
2223

2324
___
2425

apps/sasquatch/src/main/java/com/microsoft/appcenter/sasquatch/activities/ActivityConstants.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,5 @@ final class ActivityConstants {
2020
/**
2121
* Default Analytics transmission interval in seconds.
2222
*/
23-
static final int DEFAULT_TRANSMISSION_INTERVAL_IN_SECONDS = 3;
23+
static final int DEFAULT_TRANSMISSION_INTERVAL_IN_SECONDS = 6;
2424
}

sdk/appcenter-distribute/src/main/java/com/microsoft/appcenter/distribute/Distribute.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1540,7 +1540,7 @@ private synchronized void showUpdateDialog() {
15401540
}
15411541
mUsingDefaultUpdateDialog = !customized;
15421542
}
1543-
if (mUsingDefaultUpdateDialog) {
1543+
if (mUsingDefaultUpdateDialog != null && mUsingDefaultUpdateDialog) {
15441544
if (!shouldRefreshDialog(mUpdateDialog)) {
15451545
return;
15461546
}
@@ -1952,6 +1952,10 @@ synchronized private void installUpdate() {
19521952
* @param totalSize total size of downloaded file.
19531953
*/
19541954
synchronized void showSystemSettingsDialogOrStartInstalling(long downloadId, long totalSize) {
1955+
if (mReleaseInstallerListener == null) {
1956+
AppCenterLog.debug(LOG_TAG, "Installing couldn't start due to the release installer wasn't initialized.");
1957+
return;
1958+
}
19551959
mReleaseInstallerListener.setDownloadId(downloadId);
19561960
mReleaseInstallerListener.setTotalSize(totalSize);
19571961

sdk/appcenter-distribute/src/test/java/com/microsoft/appcenter/distribute/DistributeTest.java

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
import org.junit.Test;
4141
import org.mockito.ArgumentCaptor;
4242
import org.mockito.Matchers;
43+
import org.mockito.Mockito;
4344
import org.mockito.internal.util.reflection.Whitebox;
4445
import org.mockito.invocation.InvocationOnMock;
4546
import org.mockito.stubbing.Answer;
@@ -996,6 +997,65 @@ public void checkInstallProgressState() {
996997
verify(mReleaseInstallerListener, times(2)).hideInstallProgressDialog();
997998
}
998999

1000+
@Test
1001+
public void showSystemSettingsDialogWhenPackageInstallerNull() {
1002+
1003+
/* Try to show dialog. */
1004+
Distribute.getInstance().showSystemSettingsDialogOrStartInstalling(1L, 1L);
1005+
1006+
/* Verify that log was called. */
1007+
verifyStatic();
1008+
AppCenterLog.debug(eq(LOG_TAG), eq("Installing couldn't start due to the release installer wasn't initialized."));
1009+
}
1010+
1011+
@Test
1012+
public void showUpdateDialogAfterShowingInstallReleaseDialogTest() {
1013+
1014+
/* Mock App Center log. */
1015+
mockStatic(AppCenterLog.class);
1016+
1017+
/* Mock system alert settings. */
1018+
mockStatic(InstallerUtils.class);
1019+
when(InstallerUtils.isSystemAlertWindowsEnabled(any(Context.class))).thenReturn(false);
1020+
1021+
/* Mock distribute utils. */
1022+
mockStatic(DistributeUtils.class);
1023+
when(DistributeUtils.getStoredDownloadState()).thenReturn(-1).thenReturn(1);
1024+
1025+
/* Mock that download time is bigger than packageInfo.lastUpdateTime. */
1026+
when(SharedPreferencesManager.getLong(eq(PREFERENCE_KEY_DOWNLOAD_TIME))).thenReturn(3L);
1027+
1028+
/* mReleaseDetails is not null and it's a mandatory update. */
1029+
when(DistributeUtils.loadCachedReleaseDetails()).thenReturn(mReleaseDetails);
1030+
when(mReleaseDetails.isMandatoryUpdate()).thenReturn(true);
1031+
when(mReleaseDownloader.isDownloading()).thenReturn(false);
1032+
1033+
/* Prepare distribute listener. */
1034+
Distribute.setListener(Mockito.mock(DistributeListener.class));
1035+
1036+
/* Show install settings dialog. */
1037+
Distribute.getInstance().startFromBackground(mContext);
1038+
resumeWorkflow(mActivity);
1039+
Distribute.getInstance().showSystemSettingsDialogOrStartInstalling(1L, 1L);
1040+
1041+
/* Emulate that settings was applied. */
1042+
Distribute.getInstance().onActivityPaused(mActivity);
1043+
Distribute.getInstance().onActivityStopped(mActivity);
1044+
resumeWorkflow(mActivity);
1045+
1046+
/* Verify that install progress was started. */
1047+
verify(mReleaseInstallerListener).startInstall();
1048+
1049+
/* Emulate system confirmation dialog about installing new release. */
1050+
Distribute.getInstance().onActivityPaused(mActivity);
1051+
Distribute.getInstance().onActivityStopped(mActivity);
1052+
resumeWorkflow(mActivity);
1053+
1054+
/* Verify that SDK wasn't crash with NPE and don't show dialog. */
1055+
verifyStatic(never());
1056+
AppCenterLog.debug(eq(LOG_TAG), eq("Show default update dialog."));
1057+
}
1058+
9991059
private void firstDownloadNotification(int apiLevel) throws Exception {
10001060
TestUtils.setInternalState(Build.VERSION.class, "SDK_INT", apiLevel);
10011061
mockStatic(DistributeUtils.class);

versions.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
ext {
99
versionCode = 65
10-
versionName = '4.4.0'
10+
versionName = '4.4.1'
1111
minSdkVersion = 21
1212
compileSdkVersion = 30
1313
targetSdkVersion = 30

0 commit comments

Comments
 (0)