Skip to content
Browse files

Added capability string array feedback

  • Loading branch information...
1 parent 4689bc7 commit cc0baa1758f6357fa1c6392abf443a78d569fb95 Erica Sadun committed Aug 4, 2009
Showing with 52 additions and 1 deletion.
  1. +7 −0 UIDevice-Hardware.h
  2. +45 −1 UIDevice-Hardware.m
View
7 UIDevice-Hardware.h
@@ -66,6 +66,8 @@ enum {
+ (NSString *) platformString;
+ (NSString *) platformCode;
++ (NSArray *) capabilityArray;
+
+ (NSUInteger) cpuFrequency;
+ (NSUInteger) busFrequency;
+ (NSUInteger) totalMemory;
@@ -83,3 +85,8 @@ enum {
@property (nonatomic, readonly) NSString *orientationString;
@end
+/*
+@interface UIDevice (ClassAccess)
++ (NSString *) uniqueIdentifier;
+@end
+*/
View
46 UIDevice-Hardware.m
@@ -145,6 +145,7 @@ + (NSUInteger) platformCapabilities
UIDeviceSupportsBrightnessSensor;
case UIDevice3GiPhone:
+ return
UIDeviceSupportsTelephony ||
UIDeviceSupportsSMS ||
UIDeviceSupportsStillCamera ||
@@ -166,6 +167,7 @@ + (NSUInteger) platformCapabilities
UIDeviceSupportsBrightnessSensor;
case UIDevice3GSiPhone:
+ return
UIDeviceSupportsTelephony ||
UIDeviceSupportsSMS ||
UIDeviceSupportsStillCamera ||
@@ -185,9 +187,11 @@ + (NSUInteger) platformCapabilities
UIDeviceSupportsAccessibility ||
UIDeviceSupportsVoiceControl ||
UIDeviceSupportsBrightnessSensor;
+
case UIDeviceUnknowniPhone: return 0;
case UIDevice1GiPod:
+ return
// UIDeviceSupportsTelephony ||
// UIDeviceSupportsSMS ||
// UIDeviceSupportsStillCamera ||
@@ -207,7 +211,9 @@ + (NSUInteger) platformCapabilities
// UIDeviceSupportsAccessibility ||
// UIDeviceSupportsVoiceControl ||
UIDeviceSupportsBrightnessSensor;
+
case UIDevice2GiPod:
+ return
// UIDeviceSupportsTelephony ||
// UIDeviceSupportsSMS ||
// UIDeviceSupportsStillCamera ||
@@ -231,6 +237,7 @@ + (NSUInteger) platformCapabilities
case UIDeviceUnknowniPod: return 0;
case UIDeviceiPhoneSimulator:
+ return
// UIDeviceSupportsTelephony ||
// UIDeviceSupportsSMS ||
// UIDeviceSupportsStillCamera ||
@@ -250,11 +257,39 @@ + (NSUInteger) platformCapabilities
// UIDeviceSupportsAccessibility ||
// UIDeviceSupportsVoiceControl ||
// UIDeviceSupportsBrightnessSensor;
-
+
default: return 0;
}
}
++ (NSArray *) capabilityArray
+{
+ NSUInteger flags = [self platformCapabilities];
+ NSMutableArray *array = [NSMutableArray array];
+
+ if (flags & UIDeviceSupportsTelephony) [array addObject:@"Telephony"];
+ if (flags & UIDeviceSupportsSMS) [array addObject:@"SMS"];
+ if (flags & UIDeviceSupportsStillCamera) [array addObject:@"Still Camera"];
+ if (flags & UIDeviceSupportsVideoCamera) [array addObject:@"Video Camera"];
+ if (flags & UIDeviceSupportsWifi) [array addObject:@"WiFi"];
+ if (flags & UIDeviceSupportsAccelerometer) [array addObject:@"Accelerometer"];
+ if (flags & UIDeviceSupportsLocationServices) [array addObject:@"Location Services"];
+ if (flags & UIDeviceSupportsGPS) [array addObject:@"GPS"];
+ if (flags & UIDeviceSupportsMagnetometer) [array addObject:@"Magnetometer"];
+ if (flags & UIDeviceSupportsBuiltInMicrophone) [array addObject:@"Built-in Microphone"];
+ if (flags & UIDeviceSupportsExternalMicrophone) [array addObject:@"External Microphone Support"];
+ if (flags & UIDeviceSupportsOPENGLES1) [array addObject:@"OpenGL ES 1.x"];
+ if (flags & UIDeviceSupportsOPENGLES2) [array addObject:@"OpenGL ES 2.x"];
+ if (flags & UIDeviceBuiltInSpeaker) [array addObject:@"Built-in Speaker"];
+ if (flags & UIDeviceSupportsVibration) [array addObject:@"Vibration"];
+ if (flags & UIDeviceBuiltInProximitySensor) [array addObject:@"Proximity Sensor"];
+ if (flags & UIDeviceSupportsAccessibility) [array addObject:@"Accessibility"];
+ if (flags & UIDeviceSupportsVoiceControl) [array addObject:@"Voice Control"];
+ if (flags & UIDeviceSupportsBrightnessSensor) [array addObject:@"Brightness Sensor"];
+
+ return array;
+}
+
#pragma mark MAC addy
// Return the local MAC addy
// Courtesy of FreeBSD hackers email list
@@ -349,3 +384,12 @@ - (NSString *) orientationString
return nil;
}
@end
+
+/*
+@interface UIDevice (ClassAccess)
++ (float) batteryLevel {return [[UIDevice currentDevice] batteryLevel];}
++ (NSString *) uniqueIdentifier {return [[UIDevice currentDevice] uniqueIdentifier];}
++ (UIDeviceBatteryState) batteryState {return [[UIDevice currentDevice] batteryState];}
++
+@end
+*/

0 comments on commit cc0baa1

Please sign in to comment.
Something went wrong with that request. Please try again.