diff options
author | Zhomart Mukhamejanov <zhomart@google.com> | 2018-05-31 19:47:09 +0200 |
---|---|---|
committer | Zhomart Mukhamejanov <zhomart@google.com> | 2018-06-05 02:33:16 +0200 |
commit | 16db994fad2b898c542214a3056a790d79e390f2 (patch) | |
tree | 57f989f13a7e32a07698ec09ef5cdeaea060c634 /updater_sample/src/com/example/android/systemupdatersample/UpdateManager.java | |
parent | Merge "updater_sample: Add UI docs to README" (diff) | |
download | android_bootable_recovery-16db994fad2b898c542214a3056a790d79e390f2.tar android_bootable_recovery-16db994fad2b898c542214a3056a790d79e390f2.tar.gz android_bootable_recovery-16db994fad2b898c542214a3056a790d79e390f2.tar.bz2 android_bootable_recovery-16db994fad2b898c542214a3056a790d79e390f2.tar.lz android_bootable_recovery-16db994fad2b898c542214a3056a790d79e390f2.tar.xz android_bootable_recovery-16db994fad2b898c542214a3056a790d79e390f2.tar.zst android_bootable_recovery-16db994fad2b898c542214a3056a790d79e390f2.zip |
Diffstat (limited to '')
-rw-r--r-- | updater_sample/src/com/example/android/systemupdatersample/UpdateManager.java | 28 |
1 files changed, 19 insertions, 9 deletions
diff --git a/updater_sample/src/com/example/android/systemupdatersample/UpdateManager.java b/updater_sample/src/com/example/android/systemupdatersample/UpdateManager.java index e4c09346b..a9783e70a 100644 --- a/updater_sample/src/com/example/android/systemupdatersample/UpdateManager.java +++ b/updater_sample/src/com/example/android/systemupdatersample/UpdateManager.java @@ -198,6 +198,24 @@ public class UpdateManager { } /** + * Suspend running update. + */ + public synchronized void suspend() throws UpdaterState.InvalidTransitionException { + Log.d(TAG, "suspend invoked"); + setUpdaterState(UpdaterState.PAUSED); + mUpdateEngine.cancel(); + } + + /** + * Resume suspended update. + */ + public synchronized void resume() throws UpdaterState.InvalidTransitionException { + Log.d(TAG, "resume invoked"); + setUpdaterState(UpdaterState.RUNNING); + updateEngineReApplyPayload(); + } + + /** * Updates {@link this.mState} and if state is changed, * it also notifies {@link this.mOnStateChangeCallback}. */ @@ -237,10 +255,6 @@ public class UpdateManager { /** * Requests update engine to stop any ongoing update. If an update has been applied, * leave it as is. - * - * <p>Sometimes it's possible that the - * update engine would throw an error when the method is called, and the only way to - * handle it is to catch the exception.</p> */ public synchronized void cancelRunningUpdate() throws UpdaterState.InvalidTransitionException { Log.d(TAG, "cancelRunningUpdate invoked"); @@ -250,10 +264,6 @@ public class UpdateManager { /** * Resets update engine to IDLE state. If an update has been applied it reverts it. - * - * <p>Sometimes it's possible that the - * update engine would throw an error when the method is called, and the only way to - * handle it is to catch the exception.</p> */ public synchronized void resetUpdate() throws UpdaterState.InvalidTransitionException { Log.d(TAG, "resetUpdate invoked"); @@ -506,7 +516,7 @@ public class UpdateManager { synchronizeUpdaterStateWithUpdateEngineStatus(); } - getOnProgressUpdateCallback().ifPresent(callback -> callback.accept(progress)); + getOnProgressUpdateCallback().ifPresent(callback -> callback.accept(mProgress.get())); if (previousStatus != status) { getOnEngineStatusUpdateCallback().ifPresent(callback -> callback.accept(status)); |