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/ui/MainActivity.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/ui/MainActivity.java | 34 |
1 files changed, 34 insertions, 0 deletions
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 6c71cb6f4..fc9fddd70 100644 --- a/updater_sample/src/com/example/android/systemupdatersample/ui/MainActivity.java +++ b/updater_sample/src/com/example/android/systemupdatersample/ui/MainActivity.java @@ -55,6 +55,8 @@ public class MainActivity extends Activity { private Button mButtonApplyConfig; private Button mButtonStop; private Button mButtonReset; + private Button mButtonSuspend; + private Button mButtonResume; private ProgressBar mProgressBar; private TextView mTextViewUpdaterState; private TextView mTextViewEngineStatus; @@ -79,6 +81,8 @@ public class MainActivity extends Activity { this.mButtonApplyConfig = findViewById(R.id.buttonApplyConfig); this.mButtonStop = findViewById(R.id.buttonStop); this.mButtonReset = findViewById(R.id.buttonReset); + this.mButtonSuspend = findViewById(R.id.buttonSuspend); + this.mButtonResume = findViewById(R.id.buttonResume); this.mProgressBar = findViewById(R.id.progressBar); this.mTextViewUpdaterState = findViewById(R.id.textViewUpdaterState); this.mTextViewEngineStatus = findViewById(R.id.textViewEngineStatus); @@ -209,9 +213,34 @@ public class MainActivity extends Activity { } /** + * suspend button clicked + */ + public void onSuspendClick(View view) { + try { + mUpdateManager.suspend(); + } catch (UpdaterState.InvalidTransitionException e) { + Log.e(TAG, "Failed to suspend running update", e); + } + } + + /** + * resume button clicked + */ + public void onResumeClick(View view) { + try { + uiResetWidgets(); + uiResetEngineText(); + mUpdateManager.resume(); + } catch (UpdaterState.InvalidTransitionException e) { + Log.e(TAG, "Failed to resume running update", e); + } + } + + /** * switch slot button clicked */ public void onSwitchSlotClick(View view) { + uiResetWidgets(); mUpdateManager.setSwitchSlotOnReboot(); } @@ -289,6 +318,8 @@ public class MainActivity extends Activity { mButtonApplyConfig.setEnabled(false); mButtonStop.setEnabled(false); mButtonReset.setEnabled(false); + mButtonSuspend.setEnabled(false); + mButtonResume.setEnabled(false); mProgressBar.setEnabled(false); mProgressBar.setVisibility(ProgressBar.INVISIBLE); mButtonSwitchSlot.setEnabled(false); @@ -303,6 +334,7 @@ public class MainActivity extends Activity { private void uiStateIdle() { uiResetWidgets(); + mButtonReset.setEnabled(true); mSpinnerConfigs.setEnabled(true); mButtonReload.setEnabled(true); mButtonApplyConfig.setEnabled(true); @@ -314,6 +346,7 @@ public class MainActivity extends Activity { mProgressBar.setEnabled(true); mProgressBar.setVisibility(ProgressBar.VISIBLE); mButtonStop.setEnabled(true); + mButtonSuspend.setEnabled(true); } private void uiStatePaused() { @@ -321,6 +354,7 @@ public class MainActivity extends Activity { mButtonReset.setEnabled(true); mProgressBar.setEnabled(true); mProgressBar.setVisibility(ProgressBar.VISIBLE); + mButtonResume.setEnabled(true); } private void uiStateSlotSwitchRequired() { |