2 * Copyright (C) 2005-2018 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
9 #include "CPUInfoAndroid.h"
12 #include "utils/StringUtils.h"
13 #include "utils/Temperature.h"
15 #include "platform/android/activity/AndroidFeatures.h"
19 std::shared_ptr
<CCPUInfo
> CCPUInfo::GetCPUInfo()
21 return std::make_shared
<CCPUInfoAndroid
>();
24 CCPUInfoAndroid::CCPUInfoAndroid()
26 m_posixFile
= std::make_unique
<CPosixFile
>();
28 if (m_posixFile
&& m_posixFile
->Open(CURL("/proc/cpuinfo")))
30 std::array
<char, 2048> buffer
= {};
32 if (0 < m_posixFile
->Read(buffer
.data(), buffer
.size()))
34 for (const auto& line
: StringUtils::Split(buffer
.data(), '\n'))
36 if (line
.find("vendor_id") != std::string::npos
)
37 m_cpuVendor
= line
.substr(line
.find(':') + 2);
39 else if (line
.find("model name") != std::string::npos
)
40 m_cpuModel
= line
.substr(line
.find(':') + 2);
42 else if (line
.find("BogoMIPS") != std::string::npos
)
43 m_cpuBogoMips
= line
.substr(line
.find(':') + 2);
45 else if (line
.find("Hardware") != std::string::npos
)
46 m_cpuHardware
= line
.substr(line
.find(':') + 2);
48 else if (line
.find("Serial") != std::string::npos
)
49 m_cpuSerial
= line
.substr(line
.find(':') + 2);
51 else if (line
.find("Revision") != std::string::npos
)
52 m_cpuRevision
= line
.substr(line
.find(':') + 2);
59 m_cpuCount
= CAndroidFeatures::GetCPUCount();
61 for (int i
= 0; i
< m_cpuCount
; i
++)
65 m_cores
.emplace_back(core
);
68 if (CAndroidFeatures::HasNeon())
69 m_cpuFeatures
|= CPU_FEATURE_NEON
;
72 float CCPUInfoAndroid::GetCPUFrequency()
79 if (m_posixFile
->Open(CURL("/sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq")))
81 std::array
<char, 32> buffer
= {};
83 if (0 < m_posixFile
->Read(buffer
.data(), buffer
.size()))
84 freq
= std::atof(buffer
.data()) / 1000;