GSCapability

From iPhone Development Wiki
Jump to: navigation, search


GSCapability is a group of C functions that checks the capability of the device. A capability can be anything from a simple boolean value (such as whether the device can take pictures) to a complex structure (such as the screen dimensions).

  • Note: On iOS 7, GSSystemHasCapability (see example below) crashes with _abort unless you query for @'explicitContentRestriction". You should use MGGetBoolAnswer instead.

Contents

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

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.