omaha_utils.cc 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. //
  2. // Copyright (C) 2016 The Android Open Source Project
  3. //
  4. // Licensed under the Apache License, Version 2.0 (the "License");
  5. // you may not use this file except in compliance with the License.
  6. // You may obtain a copy of the License at
  7. //
  8. // http://www.apache.org/licenses/LICENSE-2.0
  9. //
  10. // Unless required by applicable law or agreed to in writing, software
  11. // distributed under the License is distributed on an "AS IS" BASIS,
  12. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. // See the License for the specific language governing permissions and
  14. // limitations under the License.
  15. //
  16. #include "update_engine/omaha_utils.h"
  17. #include <base/logging.h>
  18. namespace chromeos_update_engine {
  19. namespace {
  20. // The possible string values for the end-of-life status.
  21. const char kEolStatusSupported[] = "supported";
  22. const char kEolStatusSecurityOnly[] = "security-only";
  23. const char kEolStatusEol[] = "eol";
  24. } // namespace
  25. const char* EolStatusToString(EolStatus eol_status) {
  26. switch (eol_status) {
  27. case EolStatus::kSupported:
  28. return kEolStatusSupported;
  29. case EolStatus::kSecurityOnly:
  30. return kEolStatusSecurityOnly;
  31. case EolStatus::kEol:
  32. return kEolStatusEol;
  33. }
  34. // Only reached if an invalid number is casted to |EolStatus|.
  35. LOG(WARNING) << "Invalid EolStatus value: " << static_cast<int>(eol_status);
  36. return kEolStatusSupported;
  37. }
  38. EolStatus StringToEolStatus(const std::string& eol_status) {
  39. if (eol_status == kEolStatusSupported || eol_status.empty())
  40. return EolStatus::kSupported;
  41. if (eol_status == kEolStatusSecurityOnly)
  42. return EolStatus::kSecurityOnly;
  43. if (eol_status == kEolStatusEol)
  44. return EolStatus::kEol;
  45. LOG(WARNING) << "Invalid end-of-life attribute: " << eol_status;
  46. return EolStatus::kSupported;
  47. }
  48. } // namespace chromeos_update_engine