private void InitiateRequest(AppUpdateRequestImpl request, AppUpdateInfo appUpdateInfo, AppUpdateOptions appUpdateOptions) { if (appUpdateInfo.UpdateAvailability == UpdateAvailability.DeveloperTriggeredUpdateInProgress) { // If an update is already in progress, it would skip user confirmation dialog and // the ActivityResult for user confirmation should be set to ResultOk. request.SetUpdateActivityResult(ActivityResult.ResultOk); } if (request.IsDone && appUpdateOptions.AppUpdateType == AppUpdateType.Flexible) { request.OnUpdateDownloaded(); } else { var requestFlowTask = _appUpdateManagerPlayCore.StartUpdateFlow(appUpdateInfo, appUpdateOptions); requestFlowTask.RegisterOnSuccessCallback(resultCode => { // Set user confirmation dialog result for the update request. request.SetUpdateActivityResult(resultCode); requestFlowTask.Dispose(); }); requestFlowTask.RegisterOnFailureCallback((reason, errorCode) => { Debug.LogErrorFormat("Update flow request failed: {0}", errorCode); request.OnErrorOccurred(AppUpdatePlayCoreTranslator.TranslatePlayCoreErrorCode(errorCode)); requestFlowTask.Dispose(); }); } }
private void AppUpdateRequest(AppUpdateRequestImpl request, AppUpdateState newState) { if (AppUpdatePlayCoreTranslator.TranslatePlayCoreErrorCode(newState.ErrorCode) != AppUpdateErrorCode.NoError) { request.OnErrorOccurred(request.Error); return; } request.UpdateState(AppUpdatePlayCoreTranslator.TranslatePlayCoreUpdateStatus(newState.Status), newState.BytesDownloaded, newState.TotalBytesToDownload); }
/// <summary> /// An internal implementation that obtains an <see cref="AndroidJavaObject"/> of AppUpdateInfo from Play Core /// Java's getAppUpdateInfo() method and converts it to an internal <see cref="AppUpdateInfo"/>. /// </summary> /// <returns> /// A <see cref="PlayAsyncOperation{AppUpdateInfo, AppUpdateErrorCode}"/> that /// returns <see cref="AppUpdateInfo"/> on successful callback /// or returns <see cref="AppUpdateErrorCode"/> on failure callback. /// </returns> public PlayAsyncOperation <AppUpdateInfo, AppUpdateErrorCode> GetAppUpdateInfoInternal() { var appUpdateAsyncOperation = new AppUpdateAsyncOperation <AppUpdateInfo>(); var appUpdateInfoTask = GetAppUpdateInfo(); appUpdateInfoTask.RegisterOnSuccessCallback(javaUpdateInfo => { appUpdateAsyncOperation.SetResult(new AppUpdateInfo(javaUpdateInfo)); appUpdateInfoTask.Dispose(); }); appUpdateInfoTask.RegisterOnFailureCallback((reason, errorCode) => { appUpdateAsyncOperation.SetError(AppUpdatePlayCoreTranslator.TranslatePlayCoreErrorCode(errorCode)); appUpdateInfoTask.Dispose(); }); return(appUpdateAsyncOperation); }
/// <summary> /// An internal implementation that wraps Play Core Java's completeUpdate() method that triggers the completion /// of the update for a flexible update flow. /// </summary> /// <returns> /// A <see cref="PlayAsyncOperation{VoidResult, AppUpdateErrorCode}"/> that returns an /// <see cref="AppUpdateErrorCode"/> on failure. /// If the update succeeds, the app restarts and this callback never fires. /// </returns> public PlayAsyncOperation <VoidResult, AppUpdateErrorCode> CompleteUpdateInternal() { var completeUpdateAsyncOperation = new AppUpdateAsyncOperation <VoidResult>(); var completeUpdateTask = _appUpdateManagerPlayCore.CompleteUpdate(); completeUpdateTask.RegisterOnSuccessCallback(voidResult => { completeUpdateAsyncOperation.SetResult(voidResult); completeUpdateTask.Dispose(); }); completeUpdateTask.RegisterOnFailureCallback((reason, errorCode) => { completeUpdateAsyncOperation.SetError( AppUpdatePlayCoreTranslator.TranslatePlayCoreErrorCode(errorCode)); completeUpdateTask.Dispose(); }); return(completeUpdateAsyncOperation); }
/// <summary> /// Set request Status to a corresponding AppUpdateStatus which maps to the ActivityResult code returned from /// an update user confirmation dialog. /// </summary> /// <param name="resultCode">The ActivityResult code returned by user confirmation dialog.</param> public void SetUpdateActivityResult(int resultCode) { Status = AppUpdatePlayCoreTranslator.TranslateUpdateActivityResult(resultCode); switch (Status) { case AppUpdateStatus.Pending: break; case AppUpdateStatus.Canceled: OnErrorOccurred(AppUpdateErrorCode.ErrorUserCanceled); break; case AppUpdateStatus.Failed: OnErrorOccurred(AppUpdateErrorCode.ErrorUpdateFailed); break; default: OnErrorOccurred(AppUpdateErrorCode.ErrorUnknown); break; } }