summaryrefslogtreecommitdiffstats
path: root/updater_sample/src/com/example
diff options
context:
space:
mode:
authorZhomart Mukhamejanov <zhomart@google.com>2018-05-31 21:19:41 +0200
committerZhomart Mukhamejanov <zhomart@google.com>2018-06-01 01:12:43 +0200
commit51cde1e60c43167f649eb62bfaa15429f845dd20 (patch)
tree2a9d8fdf4bddcf0990e11ecdb3f71f023867d30a /updater_sample/src/com/example
parentMerge "updater_sample: Add @GuardedBy" (diff)
downloadandroid_bootable_recovery-51cde1e60c43167f649eb62bfaa15429f845dd20.tar
android_bootable_recovery-51cde1e60c43167f649eb62bfaa15429f845dd20.tar.gz
android_bootable_recovery-51cde1e60c43167f649eb62bfaa15429f845dd20.tar.bz2
android_bootable_recovery-51cde1e60c43167f649eb62bfaa15429f845dd20.tar.lz
android_bootable_recovery-51cde1e60c43167f649eb62bfaa15429f845dd20.tar.xz
android_bootable_recovery-51cde1e60c43167f649eb62bfaa15429f845dd20.tar.zst
android_bootable_recovery-51cde1e60c43167f649eb62bfaa15429f845dd20.zip
Diffstat (limited to 'updater_sample/src/com/example')
-rw-r--r--updater_sample/src/com/example/android/systemupdatersample/UpdateManager.java9
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));