device_util.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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.
  4. #ifndef BASE_IOS_DEVICE_UTIL_H_
  5. #define BASE_IOS_DEVICE_UTIL_H_
  6. #include <stdint.h>
  7. #include <string>
  8. namespace ios {
  9. namespace device_util {
  10. // Returns the hardware version of the device the app is running on.
  11. //
  12. // The returned string is the string returned by sysctlbyname() with name
  13. // "hw.machine". Possible (known) values include:
  14. //
  15. // iPhone1,1 -> iPhone 1G
  16. // iPhone1,2 -> iPhone 3G
  17. // iPhone2,1 -> iPhone 3GS
  18. // iPhone3,1 -> iPhone 4/AT&T
  19. // iPhone3,2 -> iPhone 4/Other Carrier?
  20. // iPhone3,3 -> iPhone 4/Other Carrier?
  21. // iPhone4,1 -> iPhone 4S
  22. //
  23. // iPod1,1 -> iPod touch 1G
  24. // iPod2,1 -> iPod touch 2G
  25. // iPod2,2 -> ?
  26. // iPod3,1 -> iPod touch 3G
  27. // iPod4,1 -> iPod touch 4G
  28. // iPod5,1 -> ?
  29. //
  30. // iPad1,1 -> iPad 1G, WiFi
  31. // iPad1,? -> iPad 1G, 3G <- needs 3G owner to test
  32. // iPad2,1 -> iPad 2G, WiFi
  33. //
  34. // AppleTV2,1 -> AppleTV 2
  35. //
  36. // i386 -> Simulator
  37. // x86_64 -> Simulator
  38. std::string GetPlatform();
  39. // Returns true if the application is running on a device with 512MB or more
  40. // RAM.
  41. bool RamIsAtLeast512Mb();
  42. // Returns true if the application is running on a device with 1024MB or more
  43. // RAM.
  44. bool RamIsAtLeast1024Mb();
  45. // Returns true if the application is running on a device with |ram_in_mb| MB or
  46. // more RAM.
  47. // Use with caution! Actual RAM reported by devices is less than the commonly
  48. // used powers-of-two values. For example, a 512MB device may report only 502MB
  49. // RAM. The convenience methods above should be used in most cases because they
  50. // correctly handle this issue.
  51. bool RamIsAtLeast(uint64_t ram_in_mb);
  52. // Returns true if the device has only one core.
  53. bool IsSingleCoreDevice();
  54. // Returns the MAC address of the interface with name |interface_name|.
  55. std::string GetMacAddress(const std::string& interface_name);
  56. // Returns a random UUID.
  57. std::string GetRandomId();
  58. // Returns an identifier for the device, using the given |salt|. A global
  59. // identifier is generated the first time this method is called, and the salt
  60. // is used to be able to generate distinct identifiers for the same device. If
  61. // |salt| is NULL, a default value is used. Unless you are using this value for
  62. // something that should be anonymous, you should probably pass NULL.
  63. std::string GetDeviceIdentifier(const char* salt);
  64. // Returns the iOS Vendor ID for this device. Using this value can have privacy
  65. // implications.
  66. std::string GetVendorId();
  67. // Returns a hashed version of |in_string| using |salt| (which must not be
  68. // zero-length). Different salt values should result in differently hashed
  69. // strings.
  70. std::string GetSaltedString(const std::string& in_string,
  71. const std::string& salt);
  72. } // namespace device_util
  73. } // namespace ios
  74. #endif // BASE_IOS_DEVICE_UTIL_H_