Difference between revisions of "GSCapability"

From iPhone Development Wiki
Jump to: navigation, search
m (Extracting the capability dictionary)
m (Default capabilities of various devices)
Line 224: Line 224:
 
| {{No}} || {{No}}
 
| {{No}} || {{No}}
 
|-
 
|-
| kGSVeniceCapability <br /> "<tt>venice</tt>"
+
| kGSVeniceCapability<ref>"Venice" is used to determine if video conferencing is allowed. It is not known what Venice stands for.</ref> <br /> "<tt>venice</tt>"
 
| {{Unk}} || {{Unk}}
 
| {{Unk}} || {{Unk}}
 
|-
 
|-

Revision as of 19:11, 20 April 2010


GSCapability is a group of C functions that checks the capability of the device. A capability can be a simple boolean value, e.g. whether the device can take pictures, to a complex structure e.g. the screen dimensions.

Example code

if (GSSystemHasCapability(kGSMagnetometerCapability)) {
  direction = get_direction();
} else {
  printf("This device has no compass\n");
}

Extracting the capability dictionary

The capabilities are stored as a plist in a shared memory region named "GSCapabilities". You can use this code to extract it:

#include <sys/mman.h>
#include <sys/stat.h>
#include <CoreFoundation/CoreFoundation.h>
static CFDictionaryRef GSCopyCapababilities(void) {
	int shm = shm_open("GSCapabilities", 0);
	assert(shm != -1);
	
	struct stat shm_stat;
	int fstat_ret = fstat(shm, &shm_stat);
	assert(fstat_ret == 0);
	
	void* map = mmap(NULL, shm_stat.st_size, 1, 1, shm, 0);
	assert(map >= 0);
	
	CFIndex len = *(CFIndex*)map;
	CFDataRef data = CFDataCreateWithBytesNoCopy(NULL, (const UInt8*)map + sizeof(len), len, kCFAllocatorNull);
	assert(data != NULL);
	
	CFPropertyListRef propList = CFPropertyListCreateFromXMLData(NULL, data, kCFPropertyListImmutable, NULL);
	CFRelease(data);
	
	munmap(map, len);
	close(shm);
	
	return propList;
}

This shared memory is constructed by the SBPlatformController class in SpringBoard.

Default capabilities of various devices

Capabilities N45AP
(iPod Touch 1G)
M68AP
(iPhone 2G)
kGSTelephonyCapability
"telephony"
No Yes
kGSCellularDataCapability
"cellular-data"
No Unknown
kGSSMSCapability
"sms"
No Yes
kGSCameraCapability
"still-camera"
No Yes
kGSVideoCameraCapability
"video-camera"
No No
kGSAutoFocusCameraCapability
"auto-focus-camera"
No No
kGSH264EncoderCapability
"h264-encoder"
No No
kGSWiFiCapability
"wifi"
Yes Yes
kGSAccelerometerCapability
"accelerometer"
Yes Yes
kGSMagnetometerCapability
"magnetometer"
No No
kGSGPSCapability
"gps"
No Yes
kGSLocationServicesCapability
"location-services"
Yes Yes
kGSMicrophoneCapability
"microphone"
No Yes
kGSPeer2PeerCapability
"peer-peer"
No Unknown
kGSOpenGLES1Capability
"opengles-1"
Yes Yes
kGSOpenGLES2Capability
"opengles-2"
No No
kGSARMV6ExecutionCapability
"armv6"
Yes Yes
kGSARMV7ExecutionCapability
"armv7"
No No
kGSDisplayPortCapability
"display-port"
No Unknown
kGSContainsCellularRadioCapability
"contains-cellular-radio"
No Unknown
kGSVolumeButtonCapability
"volume-buttons"
No Yes
kGSRingerSwitchCapability
"ringer-switch"
No Yes
kGSPiezoClickerCapability
"piezo-clicker"
Yes No
kGSBluetoothCapability
"bluetooth"
No Yes
kGSUnifiedIPodCapability
"unified-ipod"
No Yes
kGSYouTubeCapability
"youtube"
Yes Yes
kGSYouTubePluginCapability
"youtubePlugin"
Yes Yes
kGSGreenTeaDeviceCapability[1]
"green-tea"
No No
kGSNotGreenTeaDeviceCapability[1]
"not-green-tea"
Yes Yes
kGSInternationalSettingsCapability
"international-settings"
Yes Yes
kGSPlatformStandAloneContactsCapability
"stand-alone-contacts"
Yes Yes
kGSDelaySleepForHeadsetClickCapability
"delay-sleep-for-headset-click"
No Unknown
kGSLaunchApplicationsWhileAnimatingCapability
"launch-applications-while-animating"
No Unknown
kGSLoadThumbnailsWhileScrollingCapability
"load-thumbnails-while-scrolling"
No Unknown
kGSSensitiveUICapability
"sensitive-ui"
No Unknown
kGSAppleInternalInstallCapability
"apple-internal-install"
No No
kGSHasAllFeaturesCapability
"all-features"
Yes Yes
kGSNikeIpodCapability
"nike-ipod"
No No
kGSApplicationInstallationCapability
"applicationInstallation"
Yes Yes
kGSVoiceControlCapability
"voice-control"
No No
kGSProximitySensorCapability
"proximity-sensor"
No Yes
kGSGasGaugeBatteryCapability[2]
"gas-gauge-battery"
No Unknown
kGSAccessibilityCapability
"accessibility"
No No
kGSMMSCapability
"mms"
No No
kGSEncryptedDataPartitionCapability
"encrypted-data-partition"
No Unknown
kGSEncodeAACCapability
"encode-aac"
No Unknown
kGS720pPlaybackCapability
"720p"
No No
kGSDisplayFCCLogosViaSoftwareCapability
"fcc-logos-via-software"
No Unknown
kGSHideNonDefaultApplicationsCapability
"hide-non-default-apps"
No Unknown
kGSWildcatCapability[3]
"wildcat"
No No
kGSDataPlanCapability
"data-plan"
No Unknown
kGSCameraFlashCapability
"camera-flash"
No Unknown
kGSCanRasterizeEfficientlyCapability
"can-rasterize-efficiently"
Unknown Unknown
kGSFrontFacingCameraCapability
"front-facing-camera"
No No
kGSHiDPICapability
"horiz"
Unknown Unknown
kGSIOSurfaceBackedImagesCapability
"io-surface-backed-images"
Unknown Unknown
kGSMultitaskingCapability
"multitasking"
No No
kGSVeniceCapability[4]
"venice"
Unknown Unknown
kGSTelephonyMaximumGeneration
"telephony-maximum-generation"
0 2.5
kGSDeviceNameString
"device-name"
iPod iPhone
kGSMarketingNameString
"marketing-name"
iPod Touch iPhone
kGSScreenDimensionsCapability[5]
"screen-dimensions"
320 × 480 320 × 480

References

  1. 1.0 1.1 "Green-Tea" is a code name for devices sold in China. Green-Tea devices have restricted access to various applications e.g. Maps.
  2. Gas-gauge capability allows accurate monitoring of the battery level
  3. "Wildcat" is the codename of iPad.
  4. "Venice" is used to determine if video conferencing is allowed. It is not known what Venice stands for.
  5. This capability is a dictionary with 4 members. Only width and height are shown here.