update_engine: Reorder enum values in UpdateStatus

A new enum NEED_PERMISSION_TO_UPDATE was added in the middle of UpdateStatus
enum and this caused problems with Java interfaces in Android. This patch does
these things:

- Eliminates range based comparisons on UpdateStatus in the code.
- Moves the newly added NEED_PERMISSION_TO_UPDATE to the end of the enum.
- Assigns explicit values enum values in UpdateStatus.

Original CL: aosp/647793

BUG=b:62842358
TEST=unit tests

Change-Id: I1fd3ef0171e46250c68cf2ceada06ec815b725a6
Reviewed-on: https://chromium-review.googlesource.com/978676
Commit-Ready: Amin Hassani <ahassani@chromium.org>
Tested-by: Amin Hassani <ahassani@chromium.org>
Reviewed-by: Tianjie Xu <xunchang@google.com>
Reviewed-by: Nicolas Norvez <norvez@chromium.org>
Reviewed-by: Ben Chan <benchan@chromium.org>
diff --git a/update_attempter.cc b/update_attempter.cc
index 13bc098..ebf7fb0 100644
--- a/update_attempter.cc
+++ b/update_attempter.cc
@@ -1076,9 +1076,23 @@
     // If the current state is at or past the download phase, count the failure
     // in case a switch to full update becomes necessary. Ignore network
     // transfer timeouts and failures.
-    if (status_ >= UpdateStatus::DOWNLOADING &&
-        code != ErrorCode::kDownloadTransferError) {
-      MarkDeltaUpdateFailure();
+    if (code != ErrorCode::kDownloadTransferError) {
+      switch (status_) {
+        case UpdateStatus::IDLE:
+        case UpdateStatus::CHECKING_FOR_UPDATE:
+        case UpdateStatus::UPDATE_AVAILABLE:
+        case UpdateStatus::NEED_PERMISSION_TO_UPDATE:
+          break;
+        case UpdateStatus::DOWNLOADING:
+        case UpdateStatus::VERIFYING:
+        case UpdateStatus::FINALIZING:
+        case UpdateStatus::UPDATED_NEED_REBOOT:
+        case UpdateStatus::REPORTING_ERROR_EVENT:
+        case UpdateStatus::ATTEMPTING_ROLLBACK:
+        case UpdateStatus::DISABLED:
+          MarkDeltaUpdateFailure();
+          break;
+      }
     }
     // On failure, schedule an error event to be sent to Omaha.
     CreatePendingErrorEvent(action, code);