1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef BASE_IOS_DEVICE_UTIL_H_
6 #define BASE_IOS_DEVICE_UTIL_H_
11 namespace device_util
{
13 // Returns the hardware version of the device the app is running on.
15 // The returned string is the string returned by sysctlbyname() with name
16 // "hw.machine". Possible (known) values include:
18 // iPhone1,1 -> iPhone 1G
19 // iPhone1,2 -> iPhone 3G
20 // iPhone2,1 -> iPhone 3GS
21 // iPhone3,1 -> iPhone 4/AT&T
22 // iPhone3,2 -> iPhone 4/Other Carrier?
23 // iPhone3,3 -> iPhone 4/Other Carrier?
24 // iPhone4,1 -> iPhone 4S
26 // iPod1,1 -> iPod touch 1G
27 // iPod2,1 -> iPod touch 2G
29 // iPod3,1 -> iPod touch 3G
30 // iPod4,1 -> iPod touch 4G
33 // iPad1,1 -> iPad 1G, WiFi
34 // iPad1,? -> iPad 1G, 3G <- needs 3G owner to test
35 // iPad2,1 -> iPad 2G, WiFi
37 // AppleTV2,1 -> AppleTV 2
40 // x86_64 -> Simulator
41 std::string
GetPlatform();
43 // Returns true if the application is running on a device with 512MB or more
45 bool RamIsAtLeast512Mb();
47 // Returns true if the application is running on a device with 1024MB or more
49 bool RamIsAtLeast1024Mb();
51 // Returns true if the application is running on a device with |ram_in_mb| MB or
53 // Use with caution! Actual RAM reported by devices is less than the commonly
54 // used powers-of-two values. For example, a 512MB device may report only 502MB
55 // RAM. The convenience methods above should be used in most cases because they
56 // correctly handle this issue.
57 bool RamIsAtLeast(uint64_t ram_in_mb
);
59 // Returns true if the device has only one core.
60 bool IsSingleCoreDevice();
62 // Returns the MAC address of the interface with name |interface_name|.
63 std::string
GetMacAddress(const std::string
& interface_name
);
65 // Returns a random UUID.
66 std::string
GetRandomId();
68 // Returns an identifier for the device, using the given |salt|. A global
69 // identifier is generated the first time this method is called, and the salt
70 // is used to be able to generate distinct identifiers for the same device. If
71 // |salt| is NULL, a default value is used. Unless you are using this value for
72 // something that should be anonymous, you should probably pass NULL.
73 std::string
GetDeviceIdentifier(const char* salt
);
75 // Returns a hashed version of |in_string| using |salt| (which must not be
76 // zero-length). Different salt values should result in differently hashed
78 std::string
GetSaltedString(const std::string
& in_string
,
79 const std::string
& salt
);
81 } // namespace device_util
84 #endif // BASE_IOS_DEVICE_UTIL_H_