1 // 2 // Copyright 2018 The ANGLE Project Authors. All rights reserved. 3 // Use of this source code is governed by a BSD-style license that can be 4 // found in the LICENSE file. 5 // 6 7 // SystemInfo_android.cpp: implementation of the Android-specific parts of SystemInfo.h 8 9 #include "gpu_info_util/SystemInfo_internal.h" 10 11 #include <sys/system_properties.h> 12 #include <cstdlib> 13 #include <cstring> 14 #include <fstream> 15 #include <string> 16 17 #include "common/angleutils.h" 18 #include "common/debug.h" 19 20 namespace angle 21 { 22 namespace 23 { GetAndroidSystemProperty(const std::string & propertyName,std::string * value)24bool GetAndroidSystemProperty(const std::string &propertyName, std::string *value) 25 { 26 // PROP_VALUE_MAX from <sys/system_properties.h> 27 std::vector<char> propertyBuf(PROP_VALUE_MAX); 28 int len = __system_property_get(propertyName.c_str(), propertyBuf.data()); 29 if (len <= 0) 30 { 31 return false; 32 } 33 *value = std::string(propertyBuf.data()); 34 return true; 35 } 36 } // namespace 37 GetSystemInfo(SystemInfo * info)38bool GetSystemInfo(SystemInfo *info) 39 { 40 bool isFullyPopulated = true; 41 42 isFullyPopulated = 43 GetAndroidSystemProperty("ro.product.manufacturer", &info->machineManufacturer) && 44 isFullyPopulated; 45 isFullyPopulated = 46 GetAndroidSystemProperty("ro.product.model", &info->machineModelName) && isFullyPopulated; 47 48 std::string androidSdkLevel; 49 if (GetAndroidSystemProperty("ro.build.version.sdk", &androidSdkLevel)) 50 { 51 info->androidSdkLevel = std::atoi(androidSdkLevel.c_str()); 52 } 53 else 54 { 55 isFullyPopulated = false; 56 } 57 58 return GetSystemInfoVulkan(info) && isFullyPopulated; 59 } 60 61 } // namespace angle 62