Detecting Color of iPhone/iPad/iPod touch? - ios

Is there any way or hack to detect on what color (black / white) iPhone, iPad or iPod touch the iOS is installed?
I want to load corresponding UI skins in case of Black or White devices.

There's a private API to retrieve both the DeviceColor and the DeviceEnclosureColor.
UIDevice *device = [UIDevice currentDevice];
SEL selector = NSSelectorFromString(#"deviceInfoForKey:");
if (![device respondsToSelector:selector]) {
selector = NSSelectorFromString(#"_deviceInfoForKey:");
}
if ([device respondsToSelector:selector]) {
NSLog(#"DeviceColor: %# DeviceEnclosureColor: %#", [device performSelector:selector withObject:#"DeviceColor"], [device performSelector:selector withObject:#"DeviceEnclosureColor"]);
}
I've blogged about this and provide a sample app:
http://www.futuretap.com/blog/device-colors/
Warning: As mentioned, this is a private API. Don't use this in App Store builds.

The answer to the question is NO (as of now) and personally I don't think it's worth much, because what if the end-user uses a skin or an additional casing for his iPhone?
I'd suggest to initially ask the user "Hey, what's the color of your phone?" and then do accordingly.
Additionally, a research provided me with this information, I'm not sure if it's TRUE or if is going to help you.
The serial number is the key :)
If aabccdddeef is the serial number of the iPhone 4, ee represents the Color, (A4=black). I hope some of you here check this information with yours to see if this is true.

Just my 2 cents worth - if anyone is looking for the iPhone 5c colors, the colors below are picked from the apple website.
Hope it is of use to anyone:-)
iPhone 5c Colors:
Green
R 179
G 243
B 142
HEX #B3F38E
Blue
R 123
G 195
B 252
HEX #7BC3FC
Yellow
R 255
G 243
B 141
HEX #FFF38D
Red
R 252
G 132
B 142
HEX #FF848E
White
R 239
G 239
B 239
HEX #EFEFEF

According to information sprinkled around the web, the color of the device is encoded in the serial number. iFixit's blog indicates that the third- and second-to-last positions hold the information: xxxxxxxxCCx For an iPhone 4, A4 indicates black. No one seems to have the code for a white iPhone 4, which is strange. One forum posting indicates that it might be DZ. Everyone seems to be just parroting everyone else's information here.
Another site, mydigitallife.com, has an article listing the color codes for various older models. In some cases, the three positions have to be read together in order to determine the color. According to this site, all iPhone 3Gs models have 3N in the color code position; 3NP indicates "Black 16GB 3Gs", and 3NQ indicates "White 16GB 3Gs". The original (2G) iPhone also uses all three positions to indicate size (there were no color options).
There are already a number of questions here on SO that will help you to get the device's serial number.

For debugging purposes I compiled a more comprehensive list of of possible deviceInfoForKey: keys.
Interesting keys to note (for this question) are DeviceRGBColor DeviceEnclosureRGBColor. The values appear to be an integer that represent the RGB value in the form 0x00rrggbb.
Here, for reference, are all the keys I found:
ActiveWirelessTechnology
AirplaneMode
assistant
BasebandCertId
BasebandChipId
BasebandPostponementStatus
BasebandStatus
BatteryCurrentCapacity
BatteryIsCharging
BluetoothAddress
BoardId
BootNonce
BuildVersion
CertificateProductionStatus
CertificateSecurityMode
ChipID
CompassCalibrationDictionary
CPUArchitecture
DeviceClass
DeviceColor
DeviceEnclosureColor
DeviceEnclosureRGBColor
DeviceName
DeviceRGBColor
DeviceSupportsFaceTime
DeviceVariant
DeviceVariantGuess
DiagData
dictation
DiskUsage
EffectiveProductionStatus
EffectiveProductionStatusAp
EffectiveProductionStatusSEP
EffectiveSecurityMode
EffectiveSecurityModeAp
EffectiveSecurityModeSEP
FirmwarePreflightInfo
FirmwareVersion
FrontFacingCameraHFRCapability
HardwarePlatform
HasSEP
HWModelStr
Image4Supported
InternalBuild
InverseDeviceID
ipad
MixAndMatchPrevention
MLBSerialNumber
MobileSubscriberCountryCode
MobileSubscriberNetworkCode
ModelNumber
PartitionType
PasswordProtected
ProductName
ProductType
ProductVersion
ProximitySensorCalibrationDictionary
RearFacingCameraHFRCapability
RegionCode
RegionInfo
SDIOManufacturerTuple
SDIOProductInfo
SerialNumber
SIMTrayStatus
SoftwareBehavior
SoftwareBundleVersion
SupportedDeviceFamilies
SupportedKeyboards
telephony
UniqueChipID
UniqueDeviceID
UserAssignedDeviceName
wifi
WifiVendor

As others have noted, no, there is no official way of getting this information. Apple clearly knows (look in iTunes when you sync), so they could make it available. Might be worth raising a Radar.

Related

Is there a way to know the color (white, black, rose gold, etc) of an iOS device in Swift? [duplicate]

Is there any way or hack to detect on what color (black / white) iPhone, iPad or iPod touch the iOS is installed?
I want to load corresponding UI skins in case of Black or White devices.
There's a private API to retrieve both the DeviceColor and the DeviceEnclosureColor.
UIDevice *device = [UIDevice currentDevice];
SEL selector = NSSelectorFromString(#"deviceInfoForKey:");
if (![device respondsToSelector:selector]) {
selector = NSSelectorFromString(#"_deviceInfoForKey:");
}
if ([device respondsToSelector:selector]) {
NSLog(#"DeviceColor: %# DeviceEnclosureColor: %#", [device performSelector:selector withObject:#"DeviceColor"], [device performSelector:selector withObject:#"DeviceEnclosureColor"]);
}
I've blogged about this and provide a sample app:
http://www.futuretap.com/blog/device-colors/
Warning: As mentioned, this is a private API. Don't use this in App Store builds.
The answer to the question is NO (as of now) and personally I don't think it's worth much, because what if the end-user uses a skin or an additional casing for his iPhone?
I'd suggest to initially ask the user "Hey, what's the color of your phone?" and then do accordingly.
Additionally, a research provided me with this information, I'm not sure if it's TRUE or if is going to help you.
The serial number is the key :)
If aabccdddeef is the serial number of the iPhone 4, ee represents the Color, (A4=black). I hope some of you here check this information with yours to see if this is true.
Just my 2 cents worth - if anyone is looking for the iPhone 5c colors, the colors below are picked from the apple website.
Hope it is of use to anyone:-)
iPhone 5c Colors:
Green
R 179
G 243
B 142
HEX #B3F38E
Blue
R 123
G 195
B 252
HEX #7BC3FC
Yellow
R 255
G 243
B 141
HEX #FFF38D
Red
R 252
G 132
B 142
HEX #FF848E
White
R 239
G 239
B 239
HEX #EFEFEF
According to information sprinkled around the web, the color of the device is encoded in the serial number. iFixit's blog indicates that the third- and second-to-last positions hold the information: xxxxxxxxCCx For an iPhone 4, A4 indicates black. No one seems to have the code for a white iPhone 4, which is strange. One forum posting indicates that it might be DZ. Everyone seems to be just parroting everyone else's information here.
Another site, mydigitallife.com, has an article listing the color codes for various older models. In some cases, the three positions have to be read together in order to determine the color. According to this site, all iPhone 3Gs models have 3N in the color code position; 3NP indicates "Black 16GB 3Gs", and 3NQ indicates "White 16GB 3Gs". The original (2G) iPhone also uses all three positions to indicate size (there were no color options).
There are already a number of questions here on SO that will help you to get the device's serial number.
For debugging purposes I compiled a more comprehensive list of of possible deviceInfoForKey: keys.
Interesting keys to note (for this question) are DeviceRGBColor DeviceEnclosureRGBColor. The values appear to be an integer that represent the RGB value in the form 0x00rrggbb.
Here, for reference, are all the keys I found:
ActiveWirelessTechnology
AirplaneMode
assistant
BasebandCertId
BasebandChipId
BasebandPostponementStatus
BasebandStatus
BatteryCurrentCapacity
BatteryIsCharging
BluetoothAddress
BoardId
BootNonce
BuildVersion
CertificateProductionStatus
CertificateSecurityMode
ChipID
CompassCalibrationDictionary
CPUArchitecture
DeviceClass
DeviceColor
DeviceEnclosureColor
DeviceEnclosureRGBColor
DeviceName
DeviceRGBColor
DeviceSupportsFaceTime
DeviceVariant
DeviceVariantGuess
DiagData
dictation
DiskUsage
EffectiveProductionStatus
EffectiveProductionStatusAp
EffectiveProductionStatusSEP
EffectiveSecurityMode
EffectiveSecurityModeAp
EffectiveSecurityModeSEP
FirmwarePreflightInfo
FirmwareVersion
FrontFacingCameraHFRCapability
HardwarePlatform
HasSEP
HWModelStr
Image4Supported
InternalBuild
InverseDeviceID
ipad
MixAndMatchPrevention
MLBSerialNumber
MobileSubscriberCountryCode
MobileSubscriberNetworkCode
ModelNumber
PartitionType
PasswordProtected
ProductName
ProductType
ProductVersion
ProximitySensorCalibrationDictionary
RearFacingCameraHFRCapability
RegionCode
RegionInfo
SDIOManufacturerTuple
SDIOProductInfo
SerialNumber
SIMTrayStatus
SoftwareBehavior
SoftwareBundleVersion
SupportedDeviceFamilies
SupportedKeyboards
telephony
UniqueChipID
UniqueDeviceID
UserAssignedDeviceName
wifi
WifiVendor
As others have noted, no, there is no official way of getting this information. Apple clearly knows (look in iTunes when you sync), so they could make it available. Might be worth raising a Radar.

Convert UIColor to 24 bit value

I have a bluetooth device (led light) to which I can send different commands to. By now everything works fine and all the commands work. Now I want to send a custom command. The documentation says the following:
[0X99] + [24 bit colorimetric value (R=?,G=?,B=?)] + [8bit speed value] + ...
Now I don't know how to get the 24 bit colorimetric value from an UIColor.
Refer to this SO Post. This shows how to convert uicolor to its rgb component values.The values are returned as a float ratio. You can convert this ration to base 8 color and send to the device.
Hope this helps.

iOS iBeacon: How to get all of proximityUUID programmatically?

I want to see all of proximityUUID of advertising packets programmatically. Some articles say that it is impossible on iOS but Android is possible. But I cannot believe it because I found the fantastic app "BLExplr" has the feature. I need to implement the function into my app. Does anyone knows how to do it or good examples? Any help will be appreciated.
(UPDATE 2014/1/17)
I believe #davidgyoung answer is right. Estimote beacon's proximityUUID is "B9407F30-F5F8-466E-AFF9-25556B57FE6D" but displayed my Estimote beacon's UUID on BLExplr app is another ID.
Unfortunately, you cannot to this on iOS. When you say that BLExplr and LightBlue can do this, you are confusing the Bluetooth service UUID with the iBeacon Proximity UUID. These are two very different things.
The Bluetooth service UUID is visible to iOS, but has nothing to do with an iBeacon's identifiers, and is useless for working with iBeacons. The service UUID is generated by iOS each time a bluetooth device is seen, and stays the same only for the duration of time the bluetooth device is in range. If you take a bluetooth device away and bring it back later, it will have a different service UUID.
An iBeacon's identifiers (ProximityUUID, Major, Minor) are embedded inside the body of the Bluetooth advertisement. The problem on iOS devices is that Apple's CoreBluetooth APIs disallow access to the raw advertisement body, so no third-party app is able to read these identifiers. Apple only allows access to these identifiers using the special iBeacon CoreLocation APIs, but these APIs require you to know the Proximity UUID up front.
Sorry, I know this is not the answer you want to hear! (I'm sorry about it, too!) For what it's worth, you can do this on Android, on OSX Mavericks and Linux.
See details here.
davidgyoung is partially wrong about not being able to get iBeacon info. You actually can get the proximity UUID on OS X, but not iOS.
In a CBPeripheral's advertisingData, there should be a key called kCBAdvDataManufacturerData; It is an NSData representing the iBeacon advertising information. This key is only available on OS X.
Check that the 2nd byte is equal to 0x02, the 1st two bytes are equal to 0x004c (76 in decimal), and the 4th byte (in decimal) + 4 equals the data's length (should be 25).
NSRanges (sorry for Mac syntax)
Proximity UUID: NSMakeRange(4, 16)
Major: NSMakeRange(20,2)
Minor: NSMakeRange(22,2)
To make sure you're doing it right, you can log the values as hex (use the format string %x) and make sure they match the description of the NSData from whence they came.
NSRange uuidRange = NSMakeRange(4, 16);
NSRange majorRange = NSMakeRange(20, 2);
NSRange minorRange = NSMakeRange(22, 2);
NSRange powerRange = NSMakeRange(24, 1);
Byte uuidBytes[16];
[data getBytes:&uuidBytes range:uuidRange];
NSUUID *uuid = [[NSUUID alloc] initWithUUIDBytes:uuidBytes];
int16_t majorBytes;
[data getBytes:&majorBytes range:majorRange];
int16_t majorBytesBig = (majorBytes >> 8) | (majorBytes << 8);
int16_t minorBytes;
[data getBytes:&minorBytes range:minorRange];
int16_t minorBytesBig = (minorBytes >> 8) | (minorBytes << 8);
int8_t powerByte;
[data getBytes:&powerByte range:powerRange];
return #{ #"uuid" : uuid,
#"major" : #(majorBytesBig),
#"minor" : #(minorBytesBig),
#"power" : #(powerByte)
};
but the uuid is the DeviceUUID, not the ProximityUUID

Scapy - retrieving RSSI from WiFi packets

I'm trying to get RSSI or signal strength from WiFi packets.
I want also RSSI from 'WiFi probe requests' (when somebody is searching for a WiFi hotspots).
I managed to see it from kismet logs but that was only to make sure it is possible - I don't want to use kismet all the time.
For 'full time scanning' I'm using scapy. Does anybody know where can I find the RSSI or signal strength (in dBm) from the packets sniffed with scapy? I don't know how is the whole packet built - and there are a lot of 'hex' values which I don't know how to parse/interpret.
I'm sniffing on both interfaces - wlan0 (detecting when somebody connects to my hotspot), and mon.wlan0 (detecting when somebody is searching for hotspots).
Hardware (WiFi card) I use is based on Prism chipset (ISL3886). However test with Kismet was ran on Atheros (AR2413) and Intel iwl4965.
Edit1:
Looks like I need to access somehow information stored in PrismHeader:
http://trac.secdev.org/scapy/browser/scapy/layers/dot11.py
line 92 ?
Anybody knows how to enter this information?
packet.show() and packet.show2() don't show anything from this Class/Layer
Edit2:
After more digging it appears that the interface just isn't set correctly and that's why it doesn't collect all necessary headers.
If I run kismet and then sniff packets from that interface with scapy there is more info in the packet:
###[ RadioTap dummy ]###
version= 0
pad= 0
len= 26
present= TSFT+Flags+Rate+Channel+dBm_AntSignal+Antenna+b14
notdecoded= '8`/\x08\x00\x00\x00\x00\x10\x02\x94\t\xa0\x00\xdb\x01\x00\x00'
...
Now I only need to set the interface correctly without using kismet.
Here is a valuable scapy extension that improves scapy.layers.dot11.Packet's parsing of present not decoded fields.
https://github.com/ivanlei/airodump-iv/blob/master/airoiv/scapy_ex.py
Just use:
import scapy_ex
And:
packet.show()
It'll look like this:
###[ 802.11 RadioTap ]###
version = 0
pad = 0
RadioTap_len= 18
present = Flags+Rate+Channel+dBm_AntSignal+Antenna+b14
Flags = 0
Rate = 2
Channel = 1
Channel_flags= 160
dBm_AntSignal= -87
Antenna = 1
RX_Flags = 0
To summarize:
signal strength was not visible because something was wrong in the way that 'monitor mode' was set (not all headers were passed/parsed by sniffers). This monitor interface was created by hostapd.
now I'm setting monitor mode on interface with airmon-ng - tcpdump, scapy show theese extra headers.
Edited: use scapy 2.4.1+ (or github dev version). Most recent versions now correctly decode the « notdecoded » part
For some reason the packet structure has changed. Now dBm_AntSignal is the first element in notdecoded.
I am not 100% sure of this solution but I used sig_str = -(256 - ord(packet.notdecoded[-2:-1])) to reach first element and I get values that seems to be dBm_AntSignal.
I am using OpenWRT in a TP-Link MR3020 with extroot and Edward Keeble Passive Wifi Monitoring project with some modifications.
I use scapy_ex.py and I had this information:
802.11 RadioTap
version = 0
pad = 0
RadioTap_len= 36
present = dBm_AntSignal+Lock_Quality+b22+b24+b25+b26+b27+b29
dBm_AntSignal= 32
Lock_Quality= 8
If someone still has the same issue, I think I have found the solution:
I believe this is the right cut for the RSSI value:
sig_str = -(256-ord(packet.notdecoded[-3:-2]))
and this one is for the noise level:
noise_str = -(256-ord(packet.notdecoded[-2:-1]))
The fact that it says "RadioTap" suggests that the device may supply Radiotap headers, not Prism headers, even though it has a Prism chipset. The p54 driver appears to be a "SoftMAC driver", in which case it'll probably supply Radiotap headers; are you using the p54 driver or the older prism54 driver?
I have similar problem, I set up the monitor mode with airmon-ng and I can see the dBm level in tcpdump but whenever I try the sig_str = -(256-ord(packet.notdecoded[-4:-3])) I get -256 because the returned value from notdecoded in 0. Packet structure looks like this.
version = 0
pad = 0
len = 36
present = TSFT+Flags+Rate+Channel+dBm_AntSignal+b14+b29+Ext
notdecoded= ' \x08\x00\x00\x00\x00\x00\x00\x1f\x02\xed\x07\x05
.......

Best technique for iPad 1 vs iPad 2 GPU determination?

The performance of the iPad 2 GPU is way better than the iPad 1. I'd like to switch in my app and add some extra nice graphical subtlety when I know the GPU can handle it.
So I'd like to be able to detect essentially the distinction between the iPad 1 and 2 (and later), ideally using as close to a capability detection as I can. There are plenty of unrelated things I could switch on (presence of camera, etc), but ideally I'd like to find something, maybe an OpenGL capability, that distinguishes the GPU more directly.
This Apple page doesn't list anything useful for iPad 1 vs 2, and this article talks about benchmarking and GPU arch differences but doesn't pinpoint anything that looks like I can query directly (e.g. number of texture units or whatever).
Anyone have any thoughts on how to do this, or am I missing something obvious? Thanks.
One distinction you can query for is maximum texture size. On iPad 2 and iPhone 4S, the maximum texture size is 4096 x 4096, where on all other iOS devices it's 2048 x 2048. It would seem to me to be a safe assumption that future, more powerful iOS devices would also have a maximum texture size at least this large.
To query for the maximum texture size, first create your OpenGL ES context, then set it as the current context and run the following query:
GLint maxTextureSize;
glGetIntegerv(GL_MAX_TEXTURE_SIZE, &maxTextureSize);
On my iPhone 4, this returns 2048 in maxTextureSize, but on my iPad 2 and iPhone 4S this gives back the value of 4096.
You can also test for the presence of some new extensions that the iPad 2 supports, such as EXT_shadow_samplers (more are documented in "What's New in iOS: iOS 5.0"), but those tests will only work on iOS 5.0. Stragglers still on iOS 4.x won't have those capabilities register.
Today with more GPU's available, here is what I came up with for my own needs.
enum GpuClass {
kGpuA5 = 0,
kGpuA6,
kGpuA7,
kGpuA8,
kGpuUnknown,
} ;
- (enum GpuClass)reportGpuClass {
NSString *glVersion = [NSString stringWithUTF8String:(char *)glGetString(GL_VERSION)];
if ([glVersion containsString:#"Apple A5"] || [glVersion containsString:#"S5L8"]) {
NSLog(#"Running on a A5 GPU");
return kGpuA5;
}
if ([glVersion containsString:#"Apple A6"] || [glVersion containsString:#"IMGSGX5"]) {
NSLog(#"Running on a A6 GPU");
return kGpuA6;
}
if ([glVersion containsString:#"Apple A7"] || [glVersion containsString:#"G6430"]) {
NSLog(#"Running on a A7 GPU");
return kGpuA7;
}
if ([glVersion containsString:#"Apple A8"] || [glVersion containsString:#"GXA6850"]) {
NSLog(#"Running on a A8 GPU");
return kGpuA8;
}
return kGpuUnknown;
}
You may further differentiate between specific chips by specifying more full version numbers. e.g. specify IMGSGX543 instead of just IMGSGX5.

Resources