From 674aa6c6110717fdeba3f50a7a6d00dd3eb03886 Mon Sep 17 00:00:00 2001 From: Zhomart Mukhamejanov Date: Fri, 25 May 2018 17:00:11 -0700 Subject: updater_sample: add UpdaterState - Add UpdaterState - atomic class, handles proper state changes. - Remove util.UpdaterStates. Test: compiled and ran on the device Change-Id: I7fa87bbf09f8289632e8de1f26654365f4891700 Signed-off-by: Zhomart Mukhamejanov --- .../example/android/systemupdatersample/ui/MainActivity.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'updater_sample/src/com/example/android/systemupdatersample/ui/MainActivity.java') diff --git a/updater_sample/src/com/example/android/systemupdatersample/ui/MainActivity.java b/updater_sample/src/com/example/android/systemupdatersample/ui/MainActivity.java index 9983fe316..0b571cc81 100644 --- a/updater_sample/src/com/example/android/systemupdatersample/ui/MainActivity.java +++ b/updater_sample/src/com/example/android/systemupdatersample/ui/MainActivity.java @@ -33,11 +33,11 @@ import android.widget.TextView; import com.example.android.systemupdatersample.R; import com.example.android.systemupdatersample.UpdateConfig; import com.example.android.systemupdatersample.UpdateManager; +import com.example.android.systemupdatersample.UpdaterState; import com.example.android.systemupdatersample.util.PayloadSpecs; import com.example.android.systemupdatersample.util.UpdateConfigs; import com.example.android.systemupdatersample.util.UpdateEngineErrorCodes; import com.example.android.systemupdatersample.util.UpdateEngineStatuses; -import com.example.android.systemupdatersample.util.UpdaterStates; import java.util.List; @@ -192,7 +192,7 @@ public class MainActivity extends Activity { /** * Invoked when SystemUpdaterSample app state changes. * Value of {@code state} will be one of the - * values from {@link UpdaterStates}. + * values from {@link UpdaterState}. */ private void onUpdaterStateChange(int state) { Log.i(TAG, "onUpdaterStateChange invoked state=" + state); @@ -233,8 +233,8 @@ public class MainActivity extends Activity { runOnUiThread(() -> { Log.i(TAG, "Completed - errorCode=" - + UpdateEngineErrorCodes.getCodeName(errorCode) + "/" + errorCode - + " " + completionState); + + UpdateEngineErrorCodes.getCodeName(errorCode) + "/" + errorCode + + " " + completionState); setUiEngineErrorCode(errorCode); if (errorCode == UpdateEngineErrorCodes.UPDATED_BUT_NOT_ACTIVE) { // if update was successfully applied. @@ -323,7 +323,7 @@ public class MainActivity extends Activity { * @param state updater sample state */ private void setUiUpdaterState(int state) { - String stateText = UpdaterStates.getStateText(state); + String stateText = UpdaterState.getStateText(state); mTextViewUpdaterState.setText(stateText + "/" + state); } -- cgit v1.2.3 From 7671f68ab858a75f269fbddefb4840b87078a425 Mon Sep 17 00:00:00 2001 From: Zhomart Mukhamejanov Date: Thu, 24 May 2018 09:11:47 -0700 Subject: updater_sample: Improve update completion handling Currently sample app relies on onPayloadApplicationComplete callback. It might not get invoked when app is unbound and update is complete. On the other hand, onStatusUpdate gets invoked always (except when update_engine fails to init). It's good to rely on onStatusUpdate callback to reapply the update if it's IDLE but sample app state is RUNNING. - Add methods to ensure correct updater state. - Update README.md. BUG: 80205922 Test: on the device Change-Id: Ic2f390e85af43556e227362321ab69f0ff146188 Signed-off-by: Zhomart Mukhamejanov --- .../src/com/example/android/systemupdatersample/ui/MainActivity.java | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'updater_sample/src/com/example/android/systemupdatersample/ui/MainActivity.java') diff --git a/updater_sample/src/com/example/android/systemupdatersample/ui/MainActivity.java b/updater_sample/src/com/example/android/systemupdatersample/ui/MainActivity.java index 0b571cc81..1de72c2d6 100644 --- a/updater_sample/src/com/example/android/systemupdatersample/ui/MainActivity.java +++ b/updater_sample/src/com/example/android/systemupdatersample/ui/MainActivity.java @@ -108,12 +108,16 @@ public class MainActivity extends Activity { @Override protected void onResume() { super.onResume(); + // TODO(zhomart) load saved states + // Binding to UpdateEngine invokes onStatusUpdate callback, + // persisted updater state has to be loaded and prepared beforehand. this.mUpdateManager.bind(); } @Override protected void onPause() { this.mUpdateManager.unbind(); + // TODO(zhomart) save state super.onPause(); } -- cgit v1.2.3