Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1387)

Unified Diff: webrtc/modules/utility/source/helpers_ios.mm

Issue 1746023002: Modifies SDK and iOS detection for helper method that needs iOS 9+ (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Improvements proposed by tkchin@ Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: webrtc/modules/utility/source/helpers_ios.mm
diff --git a/webrtc/modules/utility/source/helpers_ios.mm b/webrtc/modules/utility/source/helpers_ios.mm
index a312f032d13f6bd8460f04b8df904ef1a42dc316..3d7567b7f0f6362c1931f3ca286358801fb8e58c 100644
--- a/webrtc/modules/utility/source/helpers_ios.mm
+++ b/webrtc/modules/utility/source/helpers_ios.mm
@@ -23,6 +23,10 @@
namespace webrtc {
namespace ios {
+bool isOperatingSystemAtLeastVersion(double version) {
+ return GetSystemVersion() >= version;
+}
+
// Internal helper method used by GetDeviceName() to return device name.
const char* LookUpRealName(const char* raw_name) {
// Lookup table which maps raw device names to real (human readable) names.
@@ -126,14 +130,18 @@ std::string GetSystemName() {
return StdStringFromNSString(osName);
}
-std::string GetSystemVersion() {
+std::string GetSystemVersionAsString() {
NSString* osVersion = [[UIDevice currentDevice] systemVersion];
return StdStringFromNSString(osVersion);
}
-float GetSystemVersionAsFloat() {
- NSString* osVersion = [[UIDevice currentDevice] systemVersion];
- return osVersion.floatValue;
+double GetSystemVersion() {
+ static dispatch_once_t once_token;
+ static double system_version;
+ dispatch_once(&once_token, ^{
+ system_version = [UIDevice currentDevice].systemVersion.doubleValue;
+ });
+ return system_version;
}
std::string GetDeviceType() {
@@ -169,14 +177,17 @@ int GetProcessorCount() {
return [NSProcessInfo processInfo].processorCount;
}
+#if defined(__IPHONE_9_0) && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_9_0
bool GetLowPowerModeEnabled() {
- NSProcessInfo* info = [NSProcessInfo processInfo];
- // lowPoweredModeEnabled is only available on iOS9+.
- if ([info respondsToSelector:@selector(lowPoweredModeEnabled)]) {
- return info.lowPowerModeEnabled;
+ if (isOperatingSystemAtLeastVersion(9.0)) {
+ // lowPoweredModeEnabled is only available on iOS9+.
+ return [NSProcessInfo processInfo].lowPowerModeEnabled;
}
+ LOG(LS_WARNING) << "webrtc::ios::GetLowPowerModeEnabled() is not "
+ "supported. Requires at least iOS 9.0";
return false;
}
+#endif
} // namespace ios
} // namespace webrtc

Powered by Google App Engine
This is Rietveld 408576698