• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 <cstring>
13 #include <fstream>
14 #include <string>
15 
16 #include "common/angleutils.h"
17 #include "common/debug.h"
18 
19 namespace angle
20 {
21 namespace
22 {
GetAndroidSystemProperty(const std::string & propertyName,std::string * value)23 bool GetAndroidSystemProperty(const std::string &propertyName, std::string *value)
24 {
25     // PROP_VALUE_MAX from <sys/system_properties.h>
26     std::vector<char> propertyBuf(PROP_VALUE_MAX);
27     int len = __system_property_get(propertyName.c_str(), propertyBuf.data());
28     if (len <= 0)
29     {
30         return false;
31     }
32     *value = std::string(propertyBuf.data());
33     return true;
34 }
35 }  // namespace
36 
GetSystemInfo(SystemInfo * info)37 bool GetSystemInfo(SystemInfo *info)
38 {
39     bool isFullyPopulated = true;
40 
41     isFullyPopulated =
42         GetAndroidSystemProperty("ro.product.manufacturer", &info->machineManufacturer) &&
43         isFullyPopulated;
44     isFullyPopulated =
45         GetAndroidSystemProperty("ro.product.model", &info->machineModelName) && isFullyPopulated;
46 
47     std::string androidSdkLevel;
48     isFullyPopulated =
49         GetAndroidSystemProperty("ro.build.version.sdk", &androidSdkLevel) && isFullyPopulated;
50     info->androidSdkLevel = std::stoi(androidSdkLevel);
51 
52     return GetSystemInfoVulkan(info) && isFullyPopulated;
53 }
54 
55 }  // namespace angle
56