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 17 #include "update_engine/omaha_utils.h" 18 19 #include <base/logging.h> 20 21 namespace chromeos_update_engine { 22 23 namespace { 24 25 // The possible string values for the end-of-life status. 26 const char kEolStatusSupported[] = "supported"; 27 const char kEolStatusSecurityOnly[] = "security-only"; 28 const char kEolStatusEol[] = "eol"; 29 30 } // namespace 31 32 const char* EolStatusToString(EolStatus eol_status) { 33 switch (eol_status) { 34 case EolStatus::kSupported: 35 return kEolStatusSupported; 36 case EolStatus::kSecurityOnly: 37 return kEolStatusSecurityOnly; 38 case EolStatus::kEol: 39 return kEolStatusEol; 40 } 41 // Only reached if an invalid number is casted to |EolStatus|. 42 LOG(WARNING) << "Invalid EolStatus value: " << static_cast<int>(eol_status); 43 return kEolStatusSupported; 44 } 45 46 EolStatus StringToEolStatus(const std::string& eol_status) { 47 if (eol_status == kEolStatusSupported || eol_status.empty()) 48 return EolStatus::kSupported; 49 if (eol_status == kEolStatusSecurityOnly) 50 return EolStatus::kSecurityOnly; 51 if (eol_status == kEolStatusEol) 52 return EolStatus::kEol; 53 LOG(WARNING) << "Invalid end-of-life attribute: " << eol_status; 54 return EolStatus::kSupported; 55 } 56 57 } // namespace chromeos_update_engine 58