@Test public void onCompleteNotify() throws Exception { boolean mandatoryUpdate = false; ReleaseDetails mockReleaseDetails = mockReleaseDetails(mandatoryUpdate); when(mDistribute.notifyDownload(mockReleaseDetails, mInstallIntent)).thenReturn(true); ReleaseDownloadListener releaseDownloadListener = new ReleaseDownloadListener(mContext, mockReleaseDetails); assertTrue(releaseDownloadListener.onComplete(mUri)); verify(mContext, never()).startActivity(any(Intent.class)); verify(mDistribute, never()).setInstalling(mockReleaseDetails); }
@WorkerThread @Override public boolean onComplete(@NonNull Uri localUri) { Intent intent = getInstallIntent(localUri); if (intent.resolveActivity(mContext.getPackageManager()) == null) { AppCenterLog.debug(LOG_TAG, "Cannot resolve install intent for " + localUri); return false; } AppCenterLog.debug(LOG_TAG, String.format(Locale.ENGLISH, "Download %s (%d) update completed.", mReleaseDetails.getShortVersion(), mReleaseDetails.getVersion())); if (!Distribute.getInstance().notifyDownload(mReleaseDetails, intent)) { AppCenterLog.info(LOG_TAG, "Show install UI for " + localUri); mContext.startActivity(intent); Distribute.getInstance().setInstalling(mReleaseDetails); } return true; }
ReleaseDownloadListener implements ReleaseDownloader.Listener { @WorkerThread @Override public boolean onComplete(@NonNull Uri localUri) { Intent intent = getInstallIntent(localUri); if (intent.resolveActivity(mContext.getPackageManager()) == null) { AppCenterLog.debug(LOG_TAG, "Cannot resolve install intent for " + localUri); return false; } AppCenterLog.debug(LOG_TAG, String.format(Locale.ENGLISH, "Download %s (%d) update completed.", mReleaseDetails.getShortVersion(), mReleaseDetails.getVersion())); if (!Distribute.getInstance().notifyDownload(mReleaseDetails, intent)) { AppCenterLog.info(LOG_TAG, "Show install UI for " + localUri); mContext.startActivity(intent); Distribute.getInstance().setInstalling(mReleaseDetails); } return true; } }
ReleaseDownloadListener implements ReleaseDownloader.Listener { @WorkerThread @Override public boolean onComplete(@NonNull Uri localUri) { Intent intent = getInstallIntent(localUri); if (intent.resolveActivity(mContext.getPackageManager()) == null) { AppCenterLog.debug(LOG_TAG, "Cannot resolve install intent for " + localUri); return false; } AppCenterLog.debug(LOG_TAG, String.format(Locale.ENGLISH, "Download %s (%d) update completed.", mReleaseDetails.getShortVersion(), mReleaseDetails.getVersion())); if (!Distribute.getInstance().notifyDownload(mReleaseDetails, intent)) { AppCenterLog.info(LOG_TAG, "Show install UI for " + localUri); mContext.startActivity(intent); Distribute.getInstance().setInstalling(mReleaseDetails); } return true; } ReleaseDownloadListener(@NonNull Context context, @NonNull ReleaseDetails releaseDetails); }
ReleaseDownloadListener implements ReleaseDownloader.Listener { @WorkerThread @Override public boolean onComplete(@NonNull Uri localUri) { Intent intent = getInstallIntent(localUri); if (intent.resolveActivity(mContext.getPackageManager()) == null) { AppCenterLog.debug(LOG_TAG, "Cannot resolve install intent for " + localUri); return false; } AppCenterLog.debug(LOG_TAG, String.format(Locale.ENGLISH, "Download %s (%d) update completed.", mReleaseDetails.getShortVersion(), mReleaseDetails.getVersion())); if (!Distribute.getInstance().notifyDownload(mReleaseDetails, intent)) { AppCenterLog.info(LOG_TAG, "Show install UI for " + localUri); mContext.startActivity(intent); Distribute.getInstance().setInstalling(mReleaseDetails); } return true; } ReleaseDownloadListener(@NonNull Context context, @NonNull ReleaseDetails releaseDetails); @WorkerThread @Override void onStart(long enqueueTime); @WorkerThread @Override synchronized boolean onProgress(final long currentSize, final long totalSize); @WorkerThread @Override boolean onComplete(@NonNull Uri localUri); @WorkerThread @Override void onError(@Nullable String errorMessage); }
ReleaseDownloadListener implements ReleaseDownloader.Listener { @WorkerThread @Override public boolean onComplete(@NonNull Uri localUri) { Intent intent = getInstallIntent(localUri); if (intent.resolveActivity(mContext.getPackageManager()) == null) { AppCenterLog.debug(LOG_TAG, "Cannot resolve install intent for " + localUri); return false; } AppCenterLog.debug(LOG_TAG, String.format(Locale.ENGLISH, "Download %s (%d) update completed.", mReleaseDetails.getShortVersion(), mReleaseDetails.getVersion())); if (!Distribute.getInstance().notifyDownload(mReleaseDetails, intent)) { AppCenterLog.info(LOG_TAG, "Show install UI for " + localUri); mContext.startActivity(intent); Distribute.getInstance().setInstalling(mReleaseDetails); } return true; } ReleaseDownloadListener(@NonNull Context context, @NonNull ReleaseDetails releaseDetails); @WorkerThread @Override void onStart(long enqueueTime); @WorkerThread @Override synchronized boolean onProgress(final long currentSize, final long totalSize); @WorkerThread @Override boolean onComplete(@NonNull Uri localUri); @WorkerThread @Override void onError(@Nullable String errorMessage);  }