1// Copyright 2012 The Chromium Authors 2// Use of this source code is governed by a BSD-style license that can be 3// found in the LICENSE file. 4 5#include "partition_alloc/partition_alloc_base/ios/ios_util.h" 6 7#include <array> 8 9#include "partition_alloc/partition_alloc_base/system/sys_info.h" 10 11namespace partition_alloc::internal::base::ios { 12 13bool IsRunningOnIOS12OrLater() { 14 static const bool is_running_on_or_later = IsRunningOnOrLater(12, 0, 0); 15 return is_running_on_or_later; 16} 17 18bool IsRunningOnIOS13OrLater() { 19 static const bool is_running_on_or_later = IsRunningOnOrLater(13, 0, 0); 20 return is_running_on_or_later; 21} 22 23bool IsRunningOnIOS14OrLater() { 24 static const bool is_running_on_or_later = IsRunningOnOrLater(14, 0, 0); 25 return is_running_on_or_later; 26} 27 28bool IsRunningOnIOS15OrLater() { 29 static const bool is_running_on_or_later = IsRunningOnOrLater(15, 0, 0); 30 return is_running_on_or_later; 31} 32 33bool IsRunningOnOrLater(int32_t major, int32_t minor, int32_t bug_fix) { 34 static const class OSVersion { 35 public: 36 OSVersion() { 37 SysInfo::OperatingSystemVersionNumbers( 38 ¤t_version_[0], ¤t_version_[1], ¤t_version_[2]); 39 } 40 41 bool IsRunningOnOrLater(int32_t version[3]) const { 42 for (size_t i = 0; i < std::size(current_version_); ++i) { 43 if (current_version_[i] != version[i]) { 44 return current_version_[i] > version[i]; 45 } 46 } 47 return true; 48 } 49 50 private: 51 int32_t current_version_[3]; 52 } kOSVersion; 53 54 int32_t version[3] = {major, minor, bug_fix}; 55 return kOSVersion.IsRunningOnOrLater(version); 56} 57 58} // namespace partition_alloc::internal::base::ios 59