summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorandroid-build-team Robot <android-build-team-robot@google.com>2018-06-02 11:33:49 +0200
committerandroid-build-team Robot <android-build-team-robot@google.com>2018-06-02 11:33:49 +0200
commit708976b9234a7ef94604e8c28f775597c2d45662 (patch)
treec7afc30dd47d09ca8a7c17995e74dd512dcd71ae
parentSnap for 4816034 from f5f2d8cc13a2a7136f2e6c7eee6975350d72eab7 to qt-release (diff)
parentMerge "updater_sample: validate state only once" am: 02ee7bf29d am: 8bb3085865 (diff)
downloadandroid_bootable_recovery-708976b9234a7ef94604e8c28f775597c2d45662.tar
android_bootable_recovery-708976b9234a7ef94604e8c28f775597c2d45662.tar.gz
android_bootable_recovery-708976b9234a7ef94604e8c28f775597c2d45662.tar.bz2
android_bootable_recovery-708976b9234a7ef94604e8c28f775597c2d45662.tar.lz
android_bootable_recovery-708976b9234a7ef94604e8c28f775597c2d45662.tar.xz
android_bootable_recovery-708976b9234a7ef94604e8c28f775597c2d45662.tar.zst
android_bootable_recovery-708976b9234a7ef94604e8c28f775597c2d45662.zip
-rw-r--r--minui/graphics.cpp15
-rw-r--r--minui/include/minui/minui.h4
-rw-r--r--updater_sample/src/com/example/android/systemupdatersample/UpdateManager.java9
3 files changed, 23 insertions, 5 deletions
diff --git a/minui/graphics.cpp b/minui/graphics.cpp
index 202ce71fd..3b386015a 100644
--- a/minui/graphics.cpp
+++ b/minui/graphics.cpp
@@ -51,12 +51,21 @@ const GRFont* gr_sys_font() {
}
int gr_measure(const GRFont* font, const char* s) {
+ if (font == nullptr) {
+ return -1;
+ }
+
return font->char_width * strlen(s);
}
-void gr_font_size(const GRFont* font, int* x, int* y) {
+int gr_font_size(const GRFont* font, int* x, int* y) {
+ if (font == nullptr) {
+ return -1;
+ }
+
*x = font->char_width;
*y = font->char_height;
+ return 0;
}
// Blends gr_current onto pix value, assumes alpha as most significant byte.
@@ -319,8 +328,8 @@ void gr_flip() {
int gr_init() {
int ret = gr_init_font("font", &gr_font);
if (ret != 0) {
- printf("Failed to init font: %d\n", ret);
- return -1;
+ printf("Failed to init font: %d, continuing graphic backend initialization without font file\n",
+ ret);
}
auto backend = std::unique_ptr<MinuiBackend>{ std::make_unique<MinuiBackendAdf>() };
diff --git a/minui/include/minui/minui.h b/minui/include/minui/minui.h
index f9da19999..e96b7ae08 100644
--- a/minui/include/minui/minui.h
+++ b/minui/include/minui/minui.h
@@ -66,8 +66,10 @@ void gr_texticon(int x, int y, GRSurface* icon);
const GRFont* gr_sys_font();
int gr_init_font(const char* name, GRFont** dest);
void gr_text(const GRFont* font, int x, int y, const char* s, bool bold);
+// Return -1 if font is nullptr.
int gr_measure(const GRFont* font, const char* s);
-void gr_font_size(const GRFont* font, int* x, int* y);
+// Return -1 if font is nullptr.
+int gr_font_size(const GRFont* font, int* x, int* y);
void gr_blit(GRSurface* source, int sx, int sy, int w, int h, int dx, int dy);
unsigned int gr_get_width(GRSurface* surface);
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));