• 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 <dlfcn.h>
10 #include <vulkan/vulkan.h>
11 #include "gpu_info_util/SystemInfo_internal.h"
12 #include "gpu_info_util/SystemInfo_vulkan.h"
13 
14 #include <sys/system_properties.h>
15 #include <cstring>
16 #include <fstream>
17 
18 #include "common/angleutils.h"
19 #include "common/debug.h"
20 
21 namespace angle
22 {
23 
GetAndroidSystemProperty(const std::string & propertyName,std::string * value)24 bool 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 
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     return GetSystemInfoVulkan(info) && isFullyPopulated;
48 }
49 
50 }  // namespace angle
51