Question

According to Are there APIs for custom vibrations in iOS? (that would have been as of iOS 5 / 6), AudioServicesPlaySystemSoundWithVibration() is used internally for vibration on iOS.

However I have tried hooking into on iOS 7, using MobileSubstrate... AudioServicesPlaySystemSoundWithVibration <- Doesn't seem to ever be called AudioServicesPlaySystemSound <- Gets called when silence switch is toggled, but no other vibrations AudioServicesPlayAlertSound <– Doesn't seem to ever be called

So the question is, what function (presumably still in AudioToolkit.framework, but maybe not) is used internally for vibration as of iOS 7?

Was it helpful?

Solution

I recently looked at how SpringBoard plays it's vibrations when you toggle silent switch or connect to power source. It only uses AudioServicesPlaySystemSound with same argument (0x452 for charging, 0x453 for silent switch) regardles of silent switch. Only place where I've seen AudioServicesPlaySystemSoundWithVibration call is when bulletin is added.

That applies to iOS 5-7. Only difference is on iOS 5 bulletins use AudioServicesPlaySoundWithBehavior because AudioServicesPlaySystemSoundWithVibration is only available starting at iOS 6.

UPDATE

Preferences app uses AudioServicesPlaySystemSound with 0x547 or 0x546 as argument. The reason you can't see that with MobileSubstrate is because Preferences app loads AudioToolbox framework at runtime using dlopen and then obtains pointer to AudioServicesPlaySystemSound with dlsym. To hook the function in that case you need to wait until Preferences app obtained the pointer and only then hook it.

UPDATE 2

SpringBoard also uses CoreMedia.framework APIs to play vibrations. All arguments here are just a guess from looking at disassembly. I don't have much experience with C structure arguments and floating-point instructions.

  • FigVibratorPlayVibrationWithDictionary(CFDictionaryRef pattern, BOOL, float). Last two arguments are unknown to me - they are set as NO and 1.0f.
  • FigVibratorPlayVibration(float, CMTime, CMTime, CTime).

Functions above are most likely to be used by iOS but there are some other functions worth hooking:

  • FigVibratorStartOneShot(float, CMTime)
  • FigVibratorStartRepeating. First argument is probably a float but don't know for others - it's some number of CMTime arguments.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top