diff options
author | Zhomart Mukhamejanov <zhomart@google.com> | 2018-06-01 21:03:06 +0200 |
---|---|---|
committer | android-build-merger <android-build-merger@google.com> | 2018-06-01 21:03:06 +0200 |
commit | 8bb30858650b088e8327d094a2a278015ddfc0bc (patch) | |
tree | e402df3bc47ee20ee6c3ccf4c9410180f1b9877e | |
parent | Merge "Let gr_init proceed even if we failed to load a font file" (diff) | |
parent | Merge "updater_sample: validate state only once" (diff) | |
download | android_bootable_recovery-8bb30858650b088e8327d094a2a278015ddfc0bc.tar android_bootable_recovery-8bb30858650b088e8327d094a2a278015ddfc0bc.tar.gz android_bootable_recovery-8bb30858650b088e8327d094a2a278015ddfc0bc.tar.bz2 android_bootable_recovery-8bb30858650b088e8327d094a2a278015ddfc0bc.tar.lz android_bootable_recovery-8bb30858650b088e8327d094a2a278015ddfc0bc.tar.xz android_bootable_recovery-8bb30858650b088e8327d094a2a278015ddfc0bc.tar.zst android_bootable_recovery-8bb30858650b088e8327d094a2a278015ddfc0bc.zip |
-rw-r--r-- | updater_sample/src/com/example/android/systemupdatersample/UpdateManager.java | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/updater_sample/src/com/example/android/systemupdatersample/UpdateManager.java b/updater_sample/src/com/example/android/systemupdatersample/UpdateManager.java index 145cc83b1..2fe04bdde 100644 --- a/updater_sample/src/com/example/android/systemupdatersample/UpdateManager.java +++ b/updater_sample/src/com/example/android/systemupdatersample/UpdateManager.java @@ -64,6 +64,9 @@ public class UpdateManager { private AtomicBoolean mManualSwitchSlotRequired = new AtomicBoolean(true); + /** Validate state only once when app binds to UpdateEngine. */ + private AtomicBoolean mStateValidityEnsured = new AtomicBoolean(false); + @GuardedBy("mLock") private UpdateData mLastUpdateData = null; @@ -90,6 +93,7 @@ public class UpdateManager { * Binds to {@link UpdateEngine}. */ public void bind() { + mStateValidityEnsured.set(false); this.mUpdateEngine.bind(mUpdateEngineCallback); } @@ -468,7 +472,10 @@ public class UpdateManager { mUpdateEngineStatus.set(status); mProgress.set(progress); - ensureCorrectUpdaterState(); + if (!mStateValidityEnsured.getAndSet(true)) { + // We ensure correct state once only when sample app is bound to UpdateEngine. + ensureCorrectUpdaterState(); + } getOnProgressUpdateCallback().ifPresent(callback -> callback.accept(progress)); |