• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #ifndef BASE_IOS_DEVICE_UTIL_H_
6 #define BASE_IOS_DEVICE_UTIL_H_
7 
8 #include <stdint.h>
9 
10 #include <string>
11 
12 namespace ios {
13 namespace device_util {
14 
15 // Returns the hardware version of the device the app is running on.
16 //
17 // The returned string is the string returned by sysctlbyname() with name
18 // "hw.machine". Possible (known) values include:
19 //
20 // iPhone7,1 -> iPhone 6 Plus
21 // iPhone7,2 -> iPhone 6
22 // iPhone8,1 -> iPhone 6s
23 // iPhone8,2 -> iPhone 6s Plus
24 // iPhone8,4 -> iPhone SE (GSM)
25 // iPhone9,1 -> iPhone 7
26 // iPhone9,2 -> iPhone 7 Plus
27 // iPhone9,3 -> iPhone 7
28 // iPhone9,4 -> iPhone 7 Plus
29 // iPhone10,1 -> iPhone 8
30 // iPhone10,2 -> iPhone 8 Plus
31 // iPhone10,3 -> iPhone X Global
32 // iPhone10,4 -> iPhone 8
33 // iPhone10,5 -> iPhone 8 Plus
34 // iPhone10,6 -> iPhone X GSM
35 // iPhone11,2 -> iPhone XS
36 // iPhone11,4 -> iPhone XS Max
37 // iPhone11,6 -> iPhone XS Max Global
38 // iPhone11,8 -> iPhone XR
39 // iPhone12,1 -> iPhone 11
40 // iPhone12,3 -> iPhone 11 Pro
41 // iPhone12,5 -> iPhone 11 Pro Max
42 // iPhone12,8 -> iPhone SE 2nd Gen
43 // iPhone13,1 -> iPhone 12 Mini
44 // iPhone13,2 -> iPhone 12
45 // iPhone13,3 -> iPhone 12 Pro
46 // iPhone13,4 -> iPhone 12 Pro Max
47 // iPhone14,2 -> iPhone 13 Pro
48 // iPhone14,3 -> iPhone 13 Pro Max
49 // iPhone14,4 -> iPhone 13 Mini
50 // iPhone14,5 -> iPhone 13
51 // iPhone14,6 -> iPhone SE 3rd Gen
52 // iPhone14,7 -> iPhone 14
53 // iPhone14,8 -> iPhone 14 Plus
54 // iPhone15,2 -> iPhone 14 Pro
55 // iPhone15,3 -> iPhone 14 Pro Max
56 //
57 // iPad3,4 -> 4th Gen iPad
58 // iPad3,5 -> 4th Gen iPad GSM+LTE
59 // iPad3,6 -> 4th Gen iPad CDMA+LTE
60 // iPad4,1 -> iPad Air (WiFi)
61 // iPad4,2 -> iPad Air (GSM+CDMA)
62 // iPad4,3 -> 1st Gen iPad Air (China)
63 // iPad4,4 -> iPad mini Retina (WiFi)
64 // iPad4,5 -> iPad mini Retina (GSM+CDMA)
65 // iPad4,6 -> iPad mini Retina (China)
66 // iPad4,7 -> iPad mini 3 (WiFi)
67 // iPad4,8 -> iPad mini 3 (GSM+CDMA)
68 // iPad4,9 -> iPad Mini 3 (China)
69 // iPad5,1 -> iPad mini 4 (WiFi)
70 // iPad5,2 -> 4th Gen iPad mini (WiFi+Cellular)
71 // iPad5,3 -> iPad Air 2 (WiFi)
72 // iPad5,4 -> iPad Air 2 (Cellular)
73 // iPad6,3 -> iPad Pro (9.7 inch, WiFi)
74 // iPad6,4 -> iPad Pro (9.7 inch, WiFi+LTE)
75 // iPad6,7 -> iPad Pro (12.9 inch, WiFi)
76 // iPad6,8 -> iPad Pro (12.9 inch, WiFi+LTE)
77 // iPad6,11 -> iPad (2017)
78 // iPad6,12 -> iPad (2017)
79 // iPad7,1 -> iPad Pro 2nd Gen (WiFi)
80 // iPad7,2 -> iPad Pro 2nd Gen (WiFi+Cellular)
81 // iPad7,3 -> iPad Pro 10.5-inch 2nd Gen
82 // iPad7,4 -> iPad Pro 10.5-inch 2nd Gen
83 // iPad7,5 -> iPad 6th Gen (WiFi)
84 // iPad7,6 -> iPad 6th Gen (WiFi+Cellular)
85 // iPad7,11 -> iPad 7th Gen 10.2-inch (WiFi)
86 // iPad7,12 -> iPad 7th Gen 10.2-inch (WiFi+Cellular)
87 // iPad8,1 -> iPad Pro 11 inch 3rd Gen (WiFi)
88 // iPad8,2 -> iPad Pro 11 inch 3rd Gen (1TB, WiFi)
89 // iPad8,3 -> iPad Pro 11 inch 3rd Gen (WiFi+Cellular)
90 // iPad8,4 -> iPad Pro 11 inch 3rd Gen (1TB, WiFi+Cellular)
91 // iPad8,5 -> iPad Pro 12.9 inch 3rd Gen (WiFi)
92 // iPad8,6 -> iPad Pro 12.9 inch 3rd Gen (1TB, WiFi)
93 // iPad8,7 -> iPad Pro 12.9 inch 3rd Gen (WiFi+Cellular)
94 // iPad8,8 -> iPad Pro 12.9 inch 3rd Gen (1TB, WiFi+Cellular)
95 // iPad8,9 -> iPad Pro 11 inch 4th Gen (WiFi)
96 // iPad8,10 -> iPad Pro 11 inch 4th Gen (WiFi+Cellular)
97 // iPad8,11 -> iPad Pro 12.9 inch 4th Gen (WiFi)
98 // iPad8,12 -> iPad Pro 12.9 inch 4th Gen (WiFi+Cellular)
99 // iPad11,1 -> iPad mini 5th Gen (WiFi)
100 // iPad11,2 -> iPad mini 5th Gen
101 // iPad11,3 -> iPad Air 3rd Gen (WiFi)
102 // iPad11,4 -> iPad Air 3rd Gen
103 // iPad11,6 -> iPad 8th Gen (WiFi)
104 // iPad11,7 -> iPad 8th Gen (WiFi+Cellular)
105 // iPad12,1 -> iPad 9th Gen (WiFi)
106 // iPad12,2 -> iPad 9th Gen (WiFi+Cellular)
107 // iPad14,1 -> iPad mini 6th Gen (WiFi)
108 // iPad14,2 -> iPad mini 6th Gen (WiFi+Cellular)
109 // iPad13,1 -> iPad Air 4th Gen (WiFi)
110 // iPad13,2 -> iPad Air 4th Gen (WiFi+Cellular)
111 // iPad13,4 -> iPad Pro 11 inch 5th Gen
112 // iPad13,5 -> iPad Pro 11 inch 5th Gen
113 // iPad13,6 -> iPad Pro 11 inch 5th Gen
114 // iPad13,7 -> iPad Pro 11 inch 5th Gen
115 // iPad13,8 -> iPad Pro 12.9 inch 5th Gen
116 // iPad13,9 -> iPad Pro 12.9 inch 5th Gen
117 // iPad13,10 -> iPad Pro 12.9 inch 5th Gen
118 // iPad13,11 -> iPad Pro 12.9 inch 5th Gen
119 // iPad13,16 -> iPad Air 5th Gen (WiFi)
120 // iPad13,17 -> iPad Air 5th Gen (WiFi+Cellular)
121 //
122 // AppleTV2,1 -> AppleTV 2
123 std::string GetPlatform();
124 
125 // Returns true if the application is running on a device with 512MB or more
126 // RAM.
127 bool RamIsAtLeast512Mb();
128 
129 // Returns true if the application is running on a device with 1024MB or more
130 // RAM.
131 bool RamIsAtLeast1024Mb();
132 
133 // Returns true if the application is running on a device with |ram_in_mb| MB or
134 // more RAM.
135 // Use with caution! Actual RAM reported by devices is less than the commonly
136 // used powers-of-two values. For example, a 512MB device may report only 502MB
137 // RAM. The convenience methods above should be used in most cases because they
138 // correctly handle this issue.
139 bool RamIsAtLeast(uint64_t ram_in_mb);
140 
141 // Returns true if the device has only one core.
142 bool IsSingleCoreDevice();
143 
144 // Returns the MAC address of the interface with name |interface_name|.
145 std::string GetMacAddress(const std::string& interface_name);
146 
147 // Returns a random UUID.
148 std::string GetRandomId();
149 
150 // Returns an identifier for the device, using the given |salt|. A global
151 // identifier is generated the first time this method is called, and the salt
152 // is used to be able to generate distinct identifiers for the same device. If
153 // |salt| is NULL, a default value is used. Unless you are using this value for
154 // something that should be anonymous, you should probably pass NULL.
155 std::string GetDeviceIdentifier(const char* salt);
156 
157 // Returns the iOS Vendor ID for this device. Using this value can have privacy
158 // implications.
159 std::string GetVendorId();
160 
161 // Returns a hashed version of |in_string| using |salt| (which must not be
162 // zero-length). Different salt values should result in differently hashed
163 // strings.
164 std::string GetSaltedString(const std::string& in_string,
165                             const std::string& salt);
166 
167 }  // namespace device_util
168 }  // namespace ios
169 
170 #endif  // BASE_IOS_DEVICE_UTIL_H_
171