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..b16c51e1e6cafd7648c22135243cf25884a26beb 100644 |
--- a/webrtc/modules/utility/source/helpers_ios.mm |
+++ b/webrtc/modules/utility/source/helpers_ios.mm |
@@ -23,6 +23,27 @@ |
namespace webrtc { |
namespace ios { |
+#define SYSTEM_VERSION_EQUAL_TO(v) \ |
+ ([[[UIDevice currentDevice] systemVersion] \ |
tkchin_webrtc
2016/03/01 21:51:34
can just use doubleValue to make these comparisons
henrika_webrtc
2016/03/02 14:49:50
Great idea, thanks!
|
+ compare:v \ |
+ options:NSNumericSearch] == NSOrderedSame) |
+#define SYSTEM_VERSION_GREATER_THAN(v) \ |
+ ([[[UIDevice currentDevice] systemVersion] \ |
+ compare:v \ |
+ options:NSNumericSearch] == NSOrderedDescending) |
+#define SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(v) \ |
+ ([[[UIDevice currentDevice] systemVersion] \ |
+ compare:v \ |
+ options:NSNumericSearch] != NSOrderedAscending) |
+#define SYSTEM_VERSION_LESS_THAN(v) \ |
+ ([[[UIDevice currentDevice] systemVersion] \ |
+ compare:v \ |
+ options:NSNumericSearch] == NSOrderedAscending) |
+#define SYSTEM_VERSION_LESS_THAN_OR_EQUAL_TO(v) \ |
+ ([[[UIDevice currentDevice] systemVersion] \ |
+ compare:v \ |
+ options:NSNumericSearch] != NSOrderedDescending) |
+ |
// 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. |
@@ -169,14 +190,23 @@ 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; |
- } |
- return false; |
+ if |
+ SYSTEM_VERSION_LESS_THAN(@"9.0.0") { |
tkchin_webrtc
2016/03/01 21:51:33
Wouldn't use macros. Instead have a bunch of funct
henrika_webrtc
2016/03/02 14:49:50
Done.
|
+ LOG(LS_WARNING) << "webrtc::ios::GetLowPowerModeEnabled() is not " |
+ "supported. Requires at least iOS 9.0"; |
+ return false; |
+ } |
+ NSProcessInfo* info = [NSProcessInfo processInfo]; |
+ return info.lowPowerModeEnabled; |
} |
+#else |
+// TODO(henrika): can't use iOS 9 APIs as the SDK version doesn't support |
tkchin_webrtc
2016/03/01 21:51:34
If it's unavailable we should just not use it. Tha
henrika_webrtc
2016/03/02 14:49:50
Done.
|
+// them. What is the best thing to do here? User will get linker error; |
+// should be sufficient, right? |
+#endif |
} // namespace ios |
} // namespace webrtc |