simtap 0.0.0-stage → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (179) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +186 -2
  3. package/THIRD_PARTY_LICENSES +61 -0
  4. package/bin/simtap.js +4 -0
  5. package/dist/act/diff.js +67 -0
  6. package/dist/act/resolve.js +49 -0
  7. package/dist/act/steps.js +188 -0
  8. package/dist/cli.js +123 -0
  9. package/dist/engine/apps.js +153 -0
  10. package/dist/engine/axe.js +107 -0
  11. package/dist/engine/exec.js +36 -0
  12. package/dist/engine/jobs.js +95 -0
  13. package/dist/engine/logs.js +115 -0
  14. package/dist/engine/simctl.js +191 -0
  15. package/dist/engine/state.js +30 -0
  16. package/dist/engine/xcode.js +253 -0
  17. package/dist/engine/xcresult.js +95 -0
  18. package/dist/errors.js +11 -0
  19. package/dist/look/read.js +50 -0
  20. package/dist/look/snapshot.js +455 -0
  21. package/dist/mcp.js +108 -0
  22. package/dist/registry.js +65 -0
  23. package/dist/tools/app-control.js +127 -0
  24. package/dist/tools/app-logs.js +128 -0
  25. package/dist/tools/app-run.js +94 -0
  26. package/dist/tools/device-use.js +68 -0
  27. package/dist/tools/devices.js +26 -0
  28. package/dist/tools/jobs.js +55 -0
  29. package/dist/tools/launch-app.js +68 -0
  30. package/dist/tools/screen-record.js +79 -0
  31. package/dist/tools/tests-run.js +81 -0
  32. package/dist/tools/types.js +2 -0
  33. package/dist/tools/ui-act.js +435 -0
  34. package/dist/tools/ui-look.js +40 -0
  35. package/package.json +45 -4
  36. package/skill/SKILL.md +23 -0
  37. package/vendor/axe/.version +1 -0
  38. package/vendor/axe/AXe_AXe.bundle/skills/axe/SKILL.md +87 -0
  39. package/vendor/axe/Frameworks/FBControlCore.framework/Versions/A/FBControlCore +0 -0
  40. package/vendor/axe/Frameworks/FBControlCore.framework/Versions/A/Headers/FBAccessibilityTraits.h +23 -0
  41. package/vendor/axe/Frameworks/FBControlCore.framework/Versions/A/Headers/FBArchitecture.h +20 -0
  42. package/vendor/axe/Frameworks/FBControlCore.framework/Versions/A/Headers/FBArchiveOperations.h +136 -0
  43. package/vendor/axe/Frameworks/FBControlCore.framework/Versions/A/Headers/FBBinaryDescriptor.h +73 -0
  44. package/vendor/axe/Frameworks/FBControlCore.framework/Versions/A/Headers/FBControlCore-Swift.h +3232 -0
  45. package/vendor/axe/Frameworks/FBControlCore.framework/Versions/A/Headers/FBControlCore-SwiftImport.h +28 -0
  46. package/vendor/axe/Frameworks/FBControlCore.framework/Versions/A/Headers/FBControlCore.h +47 -0
  47. package/vendor/axe/Frameworks/FBControlCore.framework/Versions/A/Headers/FBControlCoreFrameworkLoader.h +104 -0
  48. package/vendor/axe/Frameworks/FBControlCore.framework/Versions/A/Headers/FBControlCoreLogger+OSLog.h +30 -0
  49. package/vendor/axe/Frameworks/FBControlCore.framework/Versions/A/Headers/FBControlCoreLogger.h +107 -0
  50. package/vendor/axe/Frameworks/FBControlCore.framework/Versions/A/Headers/FBCrashLog.h +20 -0
  51. package/vendor/axe/Frameworks/FBControlCore.framework/Versions/A/Headers/FBDataBuffer.h +75 -0
  52. package/vendor/axe/Frameworks/FBControlCore.framework/Versions/A/Headers/FBDataConsumer.h +173 -0
  53. package/vendor/axe/Frameworks/FBControlCore.framework/Versions/A/Headers/FBFileContainer.h +46 -0
  54. package/vendor/axe/Frameworks/FBControlCore.framework/Versions/A/Headers/FBFileReader.h +25 -0
  55. package/vendor/axe/Frameworks/FBControlCore.framework/Versions/A/Headers/FBFourCharCode.h +30 -0
  56. package/vendor/axe/Frameworks/FBControlCore.framework/Versions/A/Headers/FBFuture+Sync.h +104 -0
  57. package/vendor/axe/Frameworks/FBControlCore.framework/Versions/A/Headers/FBFuture.h +580 -0
  58. package/vendor/axe/Frameworks/FBControlCore.framework/Versions/A/Headers/FBFutureContextManager.h +61 -0
  59. package/vendor/axe/Frameworks/FBControlCore.framework/Versions/A/Headers/FBInstalledApplication.h +30 -0
  60. package/vendor/axe/Frameworks/FBControlCore.framework/Versions/A/Headers/FBInstrumentsCommands.h +29 -0
  61. package/vendor/axe/Frameworks/FBControlCore.framework/Versions/A/Headers/FBInstrumentsOperation.h +83 -0
  62. package/vendor/axe/Frameworks/FBControlCore.framework/Versions/A/Headers/FBObjCExceptionGuard.h +59 -0
  63. package/vendor/axe/Frameworks/FBControlCore.framework/Versions/A/Headers/FBProcessBuilder.h +272 -0
  64. package/vendor/axe/Frameworks/FBControlCore.framework/Versions/A/Headers/FBProcessFetcher.h +128 -0
  65. package/vendor/axe/Frameworks/FBControlCore.framework/Versions/A/Headers/FBProcessIO.h +126 -0
  66. package/vendor/axe/Frameworks/FBControlCore.framework/Versions/A/Headers/FBProcessStream.h +175 -0
  67. package/vendor/axe/Frameworks/FBControlCore.framework/Versions/A/Headers/FBProcessTerminationStrategy.h +25 -0
  68. package/vendor/axe/Frameworks/FBControlCore.framework/Versions/A/Headers/FBScreenshotCommands.h +15 -0
  69. package/vendor/axe/Frameworks/FBControlCore.framework/Versions/A/Headers/FBSettingsCommands.h +22 -0
  70. package/vendor/axe/Frameworks/FBControlCore.framework/Versions/A/Headers/FBSocketServer.h +63 -0
  71. package/vendor/axe/Frameworks/FBControlCore.framework/Versions/A/Headers/FBSubprocess.h +131 -0
  72. package/vendor/axe/Frameworks/FBControlCore.framework/Versions/A/Headers/FBVideoStream.h +255 -0
  73. package/vendor/axe/Frameworks/FBControlCore.framework/Versions/A/Headers/FBVideoStreamConfiguration.h +51 -0
  74. package/vendor/axe/Frameworks/FBControlCore.framework/Versions/A/Headers/FBXCTraceOperation.h +13 -0
  75. package/vendor/axe/Frameworks/FBControlCore.framework/Versions/A/Headers/FBiOSTarget.h +69 -0
  76. package/vendor/axe/Frameworks/FBControlCore.framework/Versions/A/Headers/FBiOSTargetConfiguration.h +322 -0
  77. package/vendor/axe/Frameworks/FBControlCore.framework/Versions/A/Headers/FBiOSTargetConstants.h +48 -0
  78. package/vendor/axe/Frameworks/FBControlCore.framework/Versions/A/Headers/FBiOSTargetOperation.h +18 -0
  79. package/vendor/axe/Frameworks/FBControlCore.framework/Versions/A/Modules/FBControlCore.swiftmodule/Project/arm64-apple-macos.swiftsourceinfo +0 -0
  80. package/vendor/axe/Frameworks/FBControlCore.framework/Versions/A/Modules/FBControlCore.swiftmodule/Project/x86_64-apple-macos.swiftsourceinfo +0 -0
  81. package/vendor/axe/Frameworks/FBControlCore.framework/Versions/A/Modules/FBControlCore.swiftmodule/arm64-apple-macos.abi.json +51890 -0
  82. package/vendor/axe/Frameworks/FBControlCore.framework/Versions/A/Modules/FBControlCore.swiftmodule/arm64-apple-macos.private.swiftinterface +1341 -0
  83. package/vendor/axe/Frameworks/FBControlCore.framework/Versions/A/Modules/FBControlCore.swiftmodule/arm64-apple-macos.swiftdoc +0 -0
  84. package/vendor/axe/Frameworks/FBControlCore.framework/Versions/A/Modules/FBControlCore.swiftmodule/arm64-apple-macos.swiftinterface +1341 -0
  85. package/vendor/axe/Frameworks/FBControlCore.framework/Versions/A/Modules/FBControlCore.swiftmodule/arm64-apple-macos.swiftmodule +0 -0
  86. package/vendor/axe/Frameworks/FBControlCore.framework/Versions/A/Modules/FBControlCore.swiftmodule/x86_64-apple-macos.abi.json +51890 -0
  87. package/vendor/axe/Frameworks/FBControlCore.framework/Versions/A/Modules/FBControlCore.swiftmodule/x86_64-apple-macos.private.swiftinterface +1341 -0
  88. package/vendor/axe/Frameworks/FBControlCore.framework/Versions/A/Modules/FBControlCore.swiftmodule/x86_64-apple-macos.swiftdoc +0 -0
  89. package/vendor/axe/Frameworks/FBControlCore.framework/Versions/A/Modules/FBControlCore.swiftmodule/x86_64-apple-macos.swiftinterface +1341 -0
  90. package/vendor/axe/Frameworks/FBControlCore.framework/Versions/A/Modules/FBControlCore.swiftmodule/x86_64-apple-macos.swiftmodule +0 -0
  91. package/vendor/axe/Frameworks/FBControlCore.framework/Versions/A/Modules/module.modulemap +10 -0
  92. package/vendor/axe/Frameworks/FBControlCore.framework/Versions/A/Resources/Info.plist +50 -0
  93. package/vendor/axe/Frameworks/FBControlCore.framework/Versions/A/_CodeSignature/CodeResources +492 -0
  94. package/vendor/axe/Frameworks/FBDeviceControl.framework/Versions/A/FBDeviceControl +0 -0
  95. package/vendor/axe/Frameworks/FBDeviceControl.framework/Versions/A/Headers/FBAFCConnection.h +135 -0
  96. package/vendor/axe/Frameworks/FBDeviceControl.framework/Versions/A/Headers/FBAMDServiceConnection.h +239 -0
  97. package/vendor/axe/Frameworks/FBDeviceControl.framework/Versions/A/Headers/FBAMDefines.h +256 -0
  98. package/vendor/axe/Frameworks/FBDeviceControl.framework/Versions/A/Headers/FBAMDevice.h +105 -0
  99. package/vendor/axe/Frameworks/FBDeviceControl.framework/Versions/A/Headers/FBAMDeviceManager.h +59 -0
  100. package/vendor/axe/Frameworks/FBDeviceControl.framework/Versions/A/Headers/FBAMRestorableDevice.h +72 -0
  101. package/vendor/axe/Frameworks/FBDeviceControl.framework/Versions/A/Headers/FBAMRestorableDeviceManager.h +32 -0
  102. package/vendor/axe/Frameworks/FBDeviceControl.framework/Versions/A/Headers/FBDevice.h +89 -0
  103. package/vendor/axe/Frameworks/FBDeviceControl.framework/Versions/A/Headers/FBDeviceCommands.h +147 -0
  104. package/vendor/axe/Frameworks/FBDeviceControl.framework/Versions/A/Headers/FBDeviceControl-Swift.h +1500 -0
  105. package/vendor/axe/Frameworks/FBDeviceControl.framework/Versions/A/Headers/FBDeviceControl.h +24 -0
  106. package/vendor/axe/Frameworks/FBDeviceControl.framework/Versions/A/Headers/FBDeviceControlFrameworkLoader.h +25 -0
  107. package/vendor/axe/Frameworks/FBDeviceControl.framework/Versions/A/Headers/FBDeviceDebugSymbolsCommands.h +29 -0
  108. package/vendor/axe/Frameworks/FBDeviceControl.framework/Versions/A/Headers/FBDeviceManager.h +118 -0
  109. package/vendor/axe/Frameworks/FBDeviceControl.framework/Versions/A/Headers/FBInstrumentsClient.h +49 -0
  110. package/vendor/axe/Frameworks/FBDeviceControl.framework/Versions/A/Modules/FBDeviceControl.swiftmodule/Project/arm64-apple-macos.swiftsourceinfo +0 -0
  111. package/vendor/axe/Frameworks/FBDeviceControl.framework/Versions/A/Modules/FBDeviceControl.swiftmodule/Project/x86_64-apple-macos.swiftsourceinfo +0 -0
  112. package/vendor/axe/Frameworks/FBDeviceControl.framework/Versions/A/Modules/FBDeviceControl.swiftmodule/arm64-apple-macos.abi.json +16073 -0
  113. package/vendor/axe/Frameworks/FBDeviceControl.framework/Versions/A/Modules/FBDeviceControl.swiftmodule/arm64-apple-macos.private.swiftinterface +398 -0
  114. package/vendor/axe/Frameworks/FBDeviceControl.framework/Versions/A/Modules/FBDeviceControl.swiftmodule/arm64-apple-macos.swiftdoc +0 -0
  115. package/vendor/axe/Frameworks/FBDeviceControl.framework/Versions/A/Modules/FBDeviceControl.swiftmodule/arm64-apple-macos.swiftinterface +398 -0
  116. package/vendor/axe/Frameworks/FBDeviceControl.framework/Versions/A/Modules/FBDeviceControl.swiftmodule/arm64-apple-macos.swiftmodule +0 -0
  117. package/vendor/axe/Frameworks/FBDeviceControl.framework/Versions/A/Modules/FBDeviceControl.swiftmodule/x86_64-apple-macos.abi.json +16073 -0
  118. package/vendor/axe/Frameworks/FBDeviceControl.framework/Versions/A/Modules/FBDeviceControl.swiftmodule/x86_64-apple-macos.private.swiftinterface +398 -0
  119. package/vendor/axe/Frameworks/FBDeviceControl.framework/Versions/A/Modules/FBDeviceControl.swiftmodule/x86_64-apple-macos.swiftdoc +0 -0
  120. package/vendor/axe/Frameworks/FBDeviceControl.framework/Versions/A/Modules/FBDeviceControl.swiftmodule/x86_64-apple-macos.swiftinterface +398 -0
  121. package/vendor/axe/Frameworks/FBDeviceControl.framework/Versions/A/Modules/FBDeviceControl.swiftmodule/x86_64-apple-macos.swiftmodule +0 -0
  122. package/vendor/axe/Frameworks/FBDeviceControl.framework/Versions/A/Modules/module.modulemap +10 -0
  123. package/vendor/axe/Frameworks/FBDeviceControl.framework/Versions/A/Resources/Info.plist +50 -0
  124. package/vendor/axe/Frameworks/FBDeviceControl.framework/Versions/A/_CodeSignature/CodeResources +324 -0
  125. package/vendor/axe/Frameworks/FBSimulatorControl.framework/Versions/A/FBSimulatorControl +0 -0
  126. package/vendor/axe/Frameworks/FBSimulatorControl.framework/Versions/A/Headers/FBFramebuffer.h +24 -0
  127. package/vendor/axe/Frameworks/FBSimulatorControl.framework/Versions/A/Headers/FBPeriodicStatsTimer.h +43 -0
  128. package/vendor/axe/Frameworks/FBSimulatorControl.framework/Versions/A/Headers/FBSimDeviceWrapper.h +86 -0
  129. package/vendor/axe/Frameworks/FBSimulatorControl.framework/Versions/A/Headers/FBSimulator.h +160 -0
  130. package/vendor/axe/Frameworks/FBSimulatorControl.framework/Versions/A/Headers/FBSimulatorBootConfiguration.h +18 -0
  131. package/vendor/axe/Frameworks/FBSimulatorControl.framework/Versions/A/Headers/FBSimulatorControl-Swift.h +2270 -0
  132. package/vendor/axe/Frameworks/FBSimulatorControl.framework/Versions/A/Headers/FBSimulatorControl.h +21 -0
  133. package/vendor/axe/Frameworks/FBSimulatorControl.framework/Versions/A/Headers/FBSimulatorControlFrameworkLoader.h +45 -0
  134. package/vendor/axe/Frameworks/FBSimulatorControl.framework/Versions/A/Headers/FBSimulatorVideoStream.h +153 -0
  135. package/vendor/axe/Frameworks/FBSimulatorControl.framework/Versions/A/Modules/FBSimulatorControl.swiftmodule/Project/arm64-apple-macos.swiftsourceinfo +0 -0
  136. package/vendor/axe/Frameworks/FBSimulatorControl.framework/Versions/A/Modules/FBSimulatorControl.swiftmodule/Project/x86_64-apple-macos.swiftsourceinfo +0 -0
  137. package/vendor/axe/Frameworks/FBSimulatorControl.framework/Versions/A/Modules/FBSimulatorControl.swiftmodule/arm64-apple-macos.abi.json +46980 -0
  138. package/vendor/axe/Frameworks/FBSimulatorControl.framework/Versions/A/Modules/FBSimulatorControl.swiftmodule/arm64-apple-macos.private.swiftinterface +1072 -0
  139. package/vendor/axe/Frameworks/FBSimulatorControl.framework/Versions/A/Modules/FBSimulatorControl.swiftmodule/arm64-apple-macos.swiftdoc +0 -0
  140. package/vendor/axe/Frameworks/FBSimulatorControl.framework/Versions/A/Modules/FBSimulatorControl.swiftmodule/arm64-apple-macos.swiftinterface +1072 -0
  141. package/vendor/axe/Frameworks/FBSimulatorControl.framework/Versions/A/Modules/FBSimulatorControl.swiftmodule/arm64-apple-macos.swiftmodule +0 -0
  142. package/vendor/axe/Frameworks/FBSimulatorControl.framework/Versions/A/Modules/FBSimulatorControl.swiftmodule/x86_64-apple-macos.abi.json +46980 -0
  143. package/vendor/axe/Frameworks/FBSimulatorControl.framework/Versions/A/Modules/FBSimulatorControl.swiftmodule/x86_64-apple-macos.private.swiftinterface +1072 -0
  144. package/vendor/axe/Frameworks/FBSimulatorControl.framework/Versions/A/Modules/FBSimulatorControl.swiftmodule/x86_64-apple-macos.swiftdoc +0 -0
  145. package/vendor/axe/Frameworks/FBSimulatorControl.framework/Versions/A/Modules/FBSimulatorControl.swiftmodule/x86_64-apple-macos.swiftinterface +1072 -0
  146. package/vendor/axe/Frameworks/FBSimulatorControl.framework/Versions/A/Modules/FBSimulatorControl.swiftmodule/x86_64-apple-macos.swiftmodule +0 -0
  147. package/vendor/axe/Frameworks/FBSimulatorControl.framework/Versions/A/Modules/module.modulemap +10 -0
  148. package/vendor/axe/Frameworks/FBSimulatorControl.framework/Versions/A/Resources/Info.plist +50 -0
  149. package/vendor/axe/Frameworks/FBSimulatorControl.framework/Versions/A/Resources/README.md +124 -0
  150. package/vendor/axe/Frameworks/FBSimulatorControl.framework/Versions/A/_CodeSignature/CodeResources +293 -0
  151. package/vendor/axe/Frameworks/XCTestBootstrap.framework/Versions/A/Headers/FBActivityRecord.h +33 -0
  152. package/vendor/axe/Frameworks/XCTestBootstrap.framework/Versions/A/Headers/FBAttachment.h +25 -0
  153. package/vendor/axe/Frameworks/XCTestBootstrap.framework/Versions/A/Headers/FBCodeCoverageConfiguration.h +15 -0
  154. package/vendor/axe/Frameworks/XCTestBootstrap.framework/Versions/A/Headers/FBTestBundleConnection.h +37 -0
  155. package/vendor/axe/Frameworks/XCTestBootstrap.framework/Versions/A/Headers/FBTestConfiguration.h +74 -0
  156. package/vendor/axe/Frameworks/XCTestBootstrap.framework/Versions/A/Headers/FBTestManagerAPIMediator.h +46 -0
  157. package/vendor/axe/Frameworks/XCTestBootstrap.framework/Versions/A/Headers/FBTestManagerResultSummary.h +19 -0
  158. package/vendor/axe/Frameworks/XCTestBootstrap.framework/Versions/A/Headers/FBTestReporterAdapter.h +27 -0
  159. package/vendor/axe/Frameworks/XCTestBootstrap.framework/Versions/A/Headers/FBXCTestConfiguration.h +30 -0
  160. package/vendor/axe/Frameworks/XCTestBootstrap.framework/Versions/A/Headers/XCTestBootstrap-Swift.h +1570 -0
  161. package/vendor/axe/Frameworks/XCTestBootstrap.framework/Versions/A/Headers/XCTestBootstrap.h +22 -0
  162. package/vendor/axe/Frameworks/XCTestBootstrap.framework/Versions/A/Headers/XCTestBootstrapError.h +25 -0
  163. package/vendor/axe/Frameworks/XCTestBootstrap.framework/Versions/A/Modules/XCTestBootstrap.swiftmodule/Project/arm64-apple-macos.swiftsourceinfo +0 -0
  164. package/vendor/axe/Frameworks/XCTestBootstrap.framework/Versions/A/Modules/XCTestBootstrap.swiftmodule/Project/x86_64-apple-macos.swiftsourceinfo +0 -0
  165. package/vendor/axe/Frameworks/XCTestBootstrap.framework/Versions/A/Modules/XCTestBootstrap.swiftmodule/arm64-apple-macos.abi.json +15972 -0
  166. package/vendor/axe/Frameworks/XCTestBootstrap.framework/Versions/A/Modules/XCTestBootstrap.swiftmodule/arm64-apple-macos.private.swiftinterface +397 -0
  167. package/vendor/axe/Frameworks/XCTestBootstrap.framework/Versions/A/Modules/XCTestBootstrap.swiftmodule/arm64-apple-macos.swiftdoc +0 -0
  168. package/vendor/axe/Frameworks/XCTestBootstrap.framework/Versions/A/Modules/XCTestBootstrap.swiftmodule/arm64-apple-macos.swiftinterface +397 -0
  169. package/vendor/axe/Frameworks/XCTestBootstrap.framework/Versions/A/Modules/XCTestBootstrap.swiftmodule/arm64-apple-macos.swiftmodule +0 -0
  170. package/vendor/axe/Frameworks/XCTestBootstrap.framework/Versions/A/Modules/XCTestBootstrap.swiftmodule/x86_64-apple-macos.abi.json +15972 -0
  171. package/vendor/axe/Frameworks/XCTestBootstrap.framework/Versions/A/Modules/XCTestBootstrap.swiftmodule/x86_64-apple-macos.private.swiftinterface +397 -0
  172. package/vendor/axe/Frameworks/XCTestBootstrap.framework/Versions/A/Modules/XCTestBootstrap.swiftmodule/x86_64-apple-macos.swiftdoc +0 -0
  173. package/vendor/axe/Frameworks/XCTestBootstrap.framework/Versions/A/Modules/XCTestBootstrap.swiftmodule/x86_64-apple-macos.swiftinterface +397 -0
  174. package/vendor/axe/Frameworks/XCTestBootstrap.framework/Versions/A/Modules/XCTestBootstrap.swiftmodule/x86_64-apple-macos.swiftmodule +0 -0
  175. package/vendor/axe/Frameworks/XCTestBootstrap.framework/Versions/A/Modules/module.modulemap +13 -0
  176. package/vendor/axe/Frameworks/XCTestBootstrap.framework/Versions/A/Resources/Info.plist +50 -0
  177. package/vendor/axe/Frameworks/XCTestBootstrap.framework/Versions/A/XCTestBootstrap +0 -0
  178. package/vendor/axe/Frameworks/XCTestBootstrap.framework/Versions/A/_CodeSignature/CodeResources +303 -0
  179. package/vendor/axe/axe +0 -0
@@ -0,0 +1,239 @@
1
+ /*
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+
8
+ #import <Foundation/Foundation.h>
9
+
10
+ #import <FBControlCore/FBControlCore.h>
11
+ #import <FBDeviceControl/FBAMDefines.h>
12
+
13
+ @class FBAFCConnection;
14
+ @protocol FBControlCoreLogger;
15
+
16
+ /**
17
+ Wraps the AMDServiceConnection.
18
+ An AMDServiceConnection represents a connection to a "lockdown" service over USB.
19
+ */
20
+ @interface FBAMDServiceConnection : NSObject
21
+
22
+ #pragma mark Initializers
23
+
24
+ /**
25
+ The Designated Initializer.
26
+ Data transfer uses raw sockets.
27
+
28
+ @param name the name of the service connection.
29
+ @param connection the underlying AMDevice Service Connection to wrap.
30
+ @param device the device to use.
31
+ @param calls the calls to use.
32
+ @param logger the logger to use.
33
+ @return a FBAMDServiceConnection instance.
34
+ */
35
+ + (nonnull instancetype)connectionWithName:(nonnull NSString *)name connection:(AMDServiceConnectionRef _Nonnull)connection device:(AMDeviceRef _Nonnull)device calls:(AMDCalls)calls logger:(nullable id<FBControlCoreLogger>)logger;
36
+
37
+ #pragma mark plist Messaging
38
+
39
+ // There's a common protocol that is commonly used with AMDServiceConnections (otherwise known as lockdown services).
40
+ // As this is used by a number of different services, there's library code for this protocol in MobileDevice.framework
41
+ // This format is built on top of sending and receiving from the AMDServiceConnection socket.
42
+ // It's implemented in the AMDServiceConnectionSendMessage/AMDServiceConnectionReceiveMessage calls, but can also be implemented manually.
43
+ // One reason for using these calls instead of sending raw bytes is that these library functions send encrypted traffic if there's an SSL context on the AMDServiceConnection.
44
+ // Over the course of iOS releases, the requirement to send data using SSL has become more strictly enforced.
45
+ //
46
+ // The send-side of the protocol is as follows:
47
+ // 1) Any packet has a device-endian 32-bit unsigned integer that encodes the length of a packet. This is used for both the sending and receiving side.
48
+ // 2) The data after this is a binary-plist of the payload itself. This means that any plist-serializable data can be transmitted.
49
+ // 3) There is no trailer for a packet, the header defines when the end of the packet is.
50
+ // 4) The header (#1) and the binary plist (#2) are then sent over the socket. If there's an SSL context then any data that is transmitted is encrypted. When encryption is enabled, all data on the channel is encrypted, including the header
51
+ //
52
+ // The receive side is just the same, but in reverse:
53
+ // 1) The header is read, it's of a fixed size so the socket receive call can be provided with a fixed value
54
+ // 2) The header gives the size of the plist-packet read length. Once the read side has read up to the size of the payload, it is ready to be deserialized.
55
+ // 3) As with the write side, if there's an SSL context the data will be decrypted through this context.
56
+
57
+ /**
58
+ Synchronously send a plist-based packet used by lockdown.
59
+
60
+ @param message the message to send.
61
+ @param error an error out for any error that occurs.
62
+ @return YES if the message was sent, NO otherwise.
63
+ */
64
+ - (BOOL)sendMessage:(nonnull id)message error:(NSError * _Nullable * _Nullable)error;
65
+
66
+ /**
67
+ Synchronously receive a plist-based packet used by lockdown.
68
+
69
+ @param error an error out for any error that occurs.
70
+ @return the read plist on success, nil on error.
71
+ */
72
+ - (nullable id)receiveMessageWithError:(NSError * _Nullable * _Nullable)error;
73
+
74
+ /**
75
+ Send then receive a plist.
76
+
77
+ @param message the message to send.
78
+ @param error an error out for any error that occurs.
79
+ @return the message received, if successful.
80
+ */
81
+ - (nullable id)sendAndReceiveMessage:(nonnull id)message error:(NSError * _Nullable * _Nullable)error;
82
+
83
+ #pragma mark Raw Bytes Read/Write
84
+ /**
85
+ Synchronously send bytes on the connection.
86
+
87
+ @param data the data to send
88
+ @param error an error out for any error that occurs.
89
+ @return YES if the bytes were sent, NO otherwise.
90
+ */
91
+ - (BOOL)send:(nonnull NSData *)data error:(NSError * _Nullable * _Nullable)error;
92
+
93
+ /**
94
+ Synchronously send bytes on the connection, prefixed with a length packet.
95
+
96
+ @param data the data to send>
97
+ @param error an error out for any error that occurs.
98
+ @return YES if the bytes were sent, NO otherwise.
99
+ */
100
+ - (BOOL)sendWithLengthHeader:(nonnull NSData *)data error:(NSError * _Nullable * _Nullable)error;
101
+
102
+ /**
103
+ Sends a uint32_t over the connection.
104
+
105
+ @param value the value to send.
106
+ @param error an error out for any error that occurs.
107
+ @return YES if successful, NO otherwise.
108
+ */
109
+ - (BOOL)sendUnsignedInt32:(uint32_t)value error:(NSError * _Nullable * _Nullable)error;
110
+
111
+ /**
112
+ Synchronously receive bytes from the connection.
113
+ This call will block until 'size' is met.
114
+ If a read fails before the 'size' is met, this call will fail.
115
+
116
+ @param size the number of bytes to read.
117
+ @param error an error out for any error that occurs.
118
+ @return the data.
119
+ */
120
+ - (nullable NSData *)receive:(size_t)size error:(NSError * _Nullable * _Nullable)error;
121
+
122
+ /**
123
+ Synchronously receive up to 'size' bytes in the connection
124
+ This call will return an empty NSData when end of file is reached.
125
+
126
+ @param size the number of bytes to read up to.
127
+ @param error an error out for any error that occurs.
128
+ @return the data.
129
+ */
130
+ - (nullable NSData *)receiveUpTo:(size_t)size error:(NSError * _Nullable * _Nullable)error;
131
+
132
+ /**
133
+ Synchronously receive bytes from the connection, writing to a file handle.
134
+
135
+ @param size the number of bytes to read.
136
+ @param fileHandle the file handle to write to.
137
+ @param error an error out for any error that occurs.
138
+ @return the data.
139
+ */
140
+ - (BOOL)receive:(size_t)size toFile:(nonnull NSFileHandle *)fileHandle error:(NSError * _Nullable * _Nullable)error;
141
+
142
+ /**
143
+ Synchronously receive bytes into a buffer.
144
+
145
+ @param destination the destination to write into.
146
+ @param size the number of bytes to read.
147
+ @param error an error out for any error that occurs.
148
+ @return YES if all bytes read, NO otherwise.
149
+ */
150
+ - (BOOL)receive:(void * _Nonnull)destination ofSize:(size_t)size error:(NSError * _Nullable * _Nullable)error;
151
+
152
+ /**
153
+ Receives a uint32_t a from the connection.
154
+
155
+ @param valueOut the value to pull.
156
+ @param error an error out for any error that occurs.
157
+ @return YES if successful, NO otherwise.
158
+ */
159
+ - (BOOL)receiveUnsignedInt32:(uint32_t * _Nonnull)valueOut error:(NSError * _Nullable * _Nullable)error;
160
+
161
+ /**
162
+ Receives a uint64_t a from the connection.
163
+
164
+ @param valueOut the value to pull.
165
+ @param error an error out for any error that occurs.
166
+ @return YES if successful, NO otherwise.
167
+ */
168
+ - (BOOL)receiveUnsignedInt64:(uint64_t * _Nonnull)valueOut error:(NSError * _Nullable * _Nullable)error;
169
+
170
+ #pragma mark Streams
171
+
172
+ /**
173
+ Reads the stream on the given queue, until exhausted.
174
+
175
+ @param consumer the consumer to use.
176
+ @param queue the queue to consume on.
177
+ @return the FBFileReader instance, this can be used to start reading the receiver's connection.
178
+ */
179
+ - (nonnull id<FBFileReaderProtocol>)readFromConnectionWritingToConsumer:(nonnull id<FBDataConsumer>)consumer onQueue:(nonnull dispatch_queue_t)queue;
180
+
181
+ /**
182
+ Constructs a data consumer that writes to the underlying connection.
183
+
184
+ @param queue the queue to perform writes on.
185
+ @return a consumer that writes to the receiver's connection.
186
+ */
187
+ - (nonnull id<FBDataConsumer, FBDataConsumerLifecycle>)writeWithConsumerWritingOnQueue:(nonnull dispatch_queue_t)queue;
188
+
189
+ #pragma mark Lifecycle
190
+
191
+ /**
192
+ Invalidates the Service connection.
193
+ After this is called, this object is no longer valid.
194
+
195
+ @param error an error out for any error that occurs.
196
+ @return YES if successful, NO otherwise.
197
+ */
198
+ - (BOOL)invalidateWithError:(NSError * _Nullable * _Nullable)error;
199
+
200
+ #pragma mark AFC
201
+
202
+ /**
203
+ Constructs an AFC Connection from the underlying connection
204
+
205
+ @param calls calls, the calls to use.
206
+ @param callback the callback to use for progress.
207
+ @param logger the logger to use for logging.
208
+ @return a new FBAFCConnection wrapper instance.
209
+ */
210
+ - (nonnull FBAFCConnection *)asAFCConnectionWithCalls:(AFCCalls)calls callback:(AFCNotificationCallback _Nonnull)callback logger:(nonnull id<FBControlCoreLogger>)logger;
211
+
212
+ #pragma mark Properties
213
+
214
+ /**
215
+ The name of the service.
216
+ */
217
+ @property (nonnull, nonatomic, readonly, copy) NSString *name;
218
+
219
+ /**
220
+ The Wrapped Connection.
221
+ */
222
+ @property (nullable, nonatomic, readonly, assign) AMDServiceConnectionRef connection;
223
+
224
+ /**
225
+ The Device to use.
226
+ */
227
+ @property (nonatomic, readonly, assign) AMDeviceRef _Nonnull device;
228
+
229
+ /**
230
+ The Calls to use.
231
+ */
232
+ @property (nonatomic, readonly, assign) AMDCalls calls;
233
+
234
+ /**
235
+ The Logger to use.
236
+ */
237
+ @property (nullable, nonatomic, readonly, strong) id<FBControlCoreLogger> logger;
238
+
239
+ @end
@@ -0,0 +1,256 @@
1
+ /*
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+
8
+ #import <Foundation/Foundation.h>
9
+
10
+ #pragma mark - AMDevice API
11
+
12
+ /**
13
+ An Alias AMDeviceRef Type.
14
+ */
15
+ typedef CFTypeRef AMDeviceRef;
16
+
17
+ /**
18
+ The Connection Reference as is typically passed around between functions.
19
+ */
20
+ typedef CFTypeRef AFCConnectionRef;
21
+
22
+ /**
23
+ The Connection Reference as is typically passed around between functions.
24
+ */
25
+ typedef CFTypeRef AMDServiceConnectionRef;
26
+
27
+ /**
28
+ Used inside AFC Operations.
29
+ */
30
+ typedef CFTypeRef AFCOperationRef;
31
+
32
+ /**
33
+ An Alias for the AMRestorableDeviceRef Type.
34
+ */
35
+ typedef CFTypeRef AMRestorableDeviceRef;
36
+
37
+ /**
38
+ An Alias for the "Recovery Mode Device"
39
+ */
40
+ typedef CFTypeRef AMRecoveryModeDeviceRef;
41
+
42
+ /**
43
+ An Alias for a "Secure IO Context"
44
+ */
45
+ typedef void *AMSecureIOContext;
46
+
47
+ /**
48
+ An Alias for the MISProfileRef Type.
49
+ */
50
+ typedef CFTypeRef MISProfileRef;
51
+
52
+ /**
53
+ An opaque handle to a notification subscription.
54
+ */
55
+ typedef void *AMDNotificationSubscription;
56
+
57
+ /**
58
+ An enum for read modes.
59
+ */
60
+ typedef enum : uint64_t {
61
+ FBAFCReadOnlyMode = 1,
62
+ FBAFCreateReadAndWrite = 3
63
+ } FBAFCReadMode;
64
+
65
+ /**
66
+ AMDevice Notification Types.
67
+ */
68
+ typedef NS_ENUM(int, AMDeviceNotificationType) {
69
+ AMDeviceNotificationTypeConnected = 1,
70
+ AMDeviceNotificationTypeDisconnected = 2,
71
+ AMDeviceNotificationTypeUnsubscribed = 3,
72
+ AMDeviceNotificationTypePaired = 4,
73
+ };
74
+
75
+ typedef NS_ENUM(int, AMRestorableDeviceNotificationType) {
76
+ AMRestorableDeviceNotificationTypeConnected = 0,
77
+ AMRestorableDeviceNotificationTypeDisconnected = 1,
78
+ };
79
+
80
+ /**
81
+ Aliases for AMRestorableDeviceState
82
+ */
83
+ typedef NS_ENUM(int, AMRestorableDeviceState) {
84
+ AMRestorableDeviceStateDFU = 0,
85
+ AMRestorableDeviceStateRecovery = 1,
86
+ AMRestorableDeviceStateRestoreOS = 2,
87
+ AMRestorableDeviceStateBootedOS = 4,
88
+ AMRestorableDeviceStateUnknown = 5,
89
+ };
90
+
91
+ /**
92
+ A Notification structure.
93
+ */
94
+ typedef struct {
95
+ AMDeviceRef _Nonnull amDevice;
96
+ AMDeviceNotificationType status;
97
+ } AMDeviceNotification;
98
+
99
+ #pragma clang diagnostic push
100
+ #pragma clang diagnostic ignored "-Wnullability-completeness"
101
+
102
+ /**
103
+ Defines the "Progress Callback" function signature.
104
+ */
105
+ typedef void (*AMDeviceProgressCallback)(NSDictionary<NSString *, id> *progress, void *_Nullable context);
106
+
107
+ /**
108
+ Defines the "Notification Callback" AMDeviceRef instances.
109
+ */
110
+ typedef void (*AMDeviceNotificationCallback)(AMDeviceNotification *notification, void *_Nullable context);
111
+
112
+ /**
113
+ Defines the "Notification Callback" for AMRestorableDeviceRef instances.
114
+ */
115
+ typedef void (*AMRestorableDeviceNotificationCallback)(AMRestorableDeviceRef eventData, AMRestorableDeviceNotificationType status, void *context);
116
+
117
+ /**
118
+ Defines the "Notification Callback" for AFCConnectionCreate call.
119
+ */
120
+ typedef void (*AFCNotificationCallback)(void *connectionRefPtr, void *arg1, void *afcOperationPtr);
121
+
122
+ /**
123
+ Defines the callback for "AMSEraseDevice".
124
+ */
125
+ typedef int (*AMSEraseDeviceCallback)(NSString *identifier, int progress, void *_Nullable context);
126
+
127
+ /**
128
+ A Structure that references to the AMDevice APIs we use.
129
+ */
130
+ typedef struct {
131
+ // Managing Connections & Sessions.
132
+ int (*Connect)(AMDeviceRef device);
133
+ int (*Disconnect)(AMDeviceRef device);
134
+ int (*IsPaired)(AMDeviceRef device);
135
+ int (*Pair)(AMDeviceRef device);
136
+ int (*StartSession)(AMDeviceRef device);
137
+ int (*StopSession)(AMDeviceRef device);
138
+ int (*ValidatePairing)(AMDeviceRef device);
139
+
140
+ // Memory Management
141
+ void (*Retain)(AMDeviceRef device);
142
+ void (*Release)(AMDeviceRef device);
143
+
144
+ // Getting Properties of a Device.
145
+ _Nullable CFStringRef(*_Nonnull CopyDeviceIdentifier)(AMDeviceRef device);
146
+ _Nullable CFStringRef(*_Nonnull CopyValue)(AMDeviceRef device, _Nullable CFStringRef domain, CFStringRef name);
147
+
148
+ // Obtaining Devices.
149
+ _Nullable CFArrayRef (*CreateDeviceList)(void);
150
+ int (*NotificationSubscribe)(AMDeviceNotificationCallback callback, int arg0, int arg1, void *context, AMDNotificationSubscription *subscriptionOut);
151
+ int (*NotificationUnsubscribe)(AMDNotificationSubscription subscription);
152
+
153
+ // Using Connections.
154
+ int (*ServiceConnectionGetSocket)(CFTypeRef connection);
155
+ int (*ServiceConnectionInvalidate)(CFTypeRef connection);
156
+ int32_t (*ServiceConnectionReceive)(CFTypeRef connection, void *buffer, size_t bytes);
157
+ int (*ServiceConnectionReceiveMessage)(CFTypeRef connection, CFPropertyListRef *messageOut, CFPropertyListFormat *formatOut, void *unknown0, void *unknown1, void *unknown2);
158
+ int32_t (*ServiceConnectionSend)(CFTypeRef connection, const void *buffer, size_t bytes);
159
+ int (*ServiceConnectionSendMessage)(CFTypeRef connection, CFPropertyListRef propertyList, CFPropertyListFormat format, void *unknown0, CFDictionaryKeyCallBacks *keyCallbacks, CFDictionaryValueCallBacks *valueCallbacks);
160
+ AMSecureIOContext (*ServiceConnectionGetSecureIOContext)(CFTypeRef connection);
161
+
162
+ // Managing device recovery.
163
+ int (*EnterRecovery)(AMDeviceRef device);
164
+ AMRecoveryModeDeviceRef (*RestorableDeviceGetRecoveryModeDevice)(AMRestorableDeviceRef device);
165
+ int (*RecoveryModeDeviceSetAutoBoot)(AMRecoveryModeDeviceRef device, int enableAutoBoot);
166
+ int (*RecoveryDeviceReboot)(AMRecoveryModeDeviceRef device);
167
+
168
+ // Services
169
+ int (*CreateHouseArrestService)(AMDeviceRef device, CFStringRef bundleID, void *_Nullable unused, AFCConnectionRef *connectionOut);
170
+ int (*LookupApplications)(AMDeviceRef device, CFDictionaryRef _Nullable options, CFDictionaryRef _Nonnull * _Nonnull attributesOut);
171
+ int (*SecureInstallApplication)(_Nullable AMDServiceConnectionRef connection, AMDeviceRef device, CFURLRef arg2, CFDictionaryRef arg3, _Nullable AMDeviceProgressCallback callback, void *_Nullable context);
172
+ int (*SecureInstallApplicationBundle)(AMDeviceRef device, CFURLRef hostAppURL, CFDictionaryRef _Nullable options, _Nullable AMDeviceProgressCallback callback, void *_Nullable context);
173
+ int (*SecureStartService)(AMDeviceRef device, CFStringRef service_name, _Nullable CFDictionaryRef userinfo, CFTypeRef *serviceOut);
174
+ int (*SecureTransferPath)(_Nullable AMDServiceConnectionRef connection, AMDeviceRef device, CFURLRef arg2, CFDictionaryRef arg3, _Nullable AMDeviceProgressCallback callback, void *_Nullable context);
175
+ int (*SecureUninstallApplication)(_Nullable AMDServiceConnectionRef connection, AMDeviceRef device, CFStringRef arg2, int arg3, _Nullable AMDeviceProgressCallback callback, void *_Nullable context);
176
+
177
+ // Developer Images
178
+ int (*MountImage)(AMDeviceRef device, CFStringRef image, CFDictionaryRef options, _Nullable AMDeviceProgressCallback callback, void *_Nullable context);
179
+
180
+ // Provisioning Profiles
181
+ CFArrayRef (*CopyProvisioningProfiles)(AMDeviceRef device);
182
+ CFDictionaryRef (*ProvisioningProfileCopyPayload)(CFTypeRef profile);
183
+ MISProfileRef (*ProvisioningProfileCreateWithData)(CFDataRef data);
184
+ int (*InstallProvisioningProfile)(AMDeviceRef device, MISProfileRef profile);
185
+ int (*RemoveProvisioningProfile)(AMDeviceRef device, CFStringRef profileUUID);
186
+ CFStringRef (*ProvisioningProfileGetUUID)(MISProfileRef profile);
187
+ CFStringRef (*ProvisioningProfileCopyErrorStringForCode)(int code);
188
+
189
+ // Restorable Devices: Notifications
190
+ int (*RestorableDeviceRegisterForNotifications)(AMRestorableDeviceNotificationCallback callback, void *context, int arg2, int arg3);
191
+ int (*RestorableDeviceUnregisterForNotifications)(int registrationID);
192
+
193
+ // Restorable Devices: Getting and Copying Values.
194
+ CFStringRef (*RestorableDeviceCopyBoardConfig)(AMRestorableDeviceRef device);
195
+ CFStringRef (*RestorableDeviceCopyProductString)(AMRestorableDeviceRef device);
196
+ CFStringRef (*RestorableDeviceCopySerialNumber)(AMRestorableDeviceRef device);
197
+ CFStringRef (*RestorableDeviceCopyUserFriendlyName)(AMRestorableDeviceRef device);
198
+ int (*RestorableDeviceGetBoardID)(AMRestorableDeviceRef device);
199
+ int (*RestorableDeviceGetChipID)(AMRestorableDeviceRef device);
200
+ int (*RestorableDeviceGetDeviceClass)(AMRestorableDeviceRef device);
201
+ unsigned long (*RestorableDeviceGetECID)(AMRestorableDeviceRef device);
202
+ int (*RestorableDeviceGetLocationID)(AMRestorableDeviceRef device);
203
+ int (*RestorableDeviceGetProductType)(AMRestorableDeviceRef device);
204
+ int (*RestorableDeviceGetState)(AMRestorableDeviceRef device);
205
+
206
+ // AppleMobileSync
207
+ int (*AMSInitialize)(int arg0);
208
+ int (*AMSEraseDevice)(CFStringRef udid, AMSEraseDeviceCallback callback, void *context);
209
+
210
+ // USBMux
211
+ int (*GetConnectionID)(AMDeviceRef device);
212
+ int (*USBMuxConnectByPort)(int connectionID, int remotePort, int *socket);
213
+
214
+ // Debugging
215
+ void (*InitializeMobileDevice)(void);
216
+ void (*SetLogLevel)(int32_t level);
217
+ _Nullable CFStringRef (*CopyErrorText)(int status);
218
+ } AMDCalls;
219
+
220
+ /**
221
+ A Structure holding references to the 'Apple File Conduit' APIs we use.
222
+ */
223
+ typedef struct {
224
+ // Creating a Connection
225
+ AFCConnectionRef (*Create)(void *_Nullable unknown0, int socket, void *_Nullable unknown1, AFCNotificationCallback callback, void *_Nullable unknown3);
226
+ int (*ConnectionOpen)(CFTypeRef handle, uint32_t io_timeout, CFTypeRef _Nullable *_Nullable conn);
227
+ int (*ConnectionClose)(AFCConnectionRef connection);
228
+ int (*ConnectionIsValid)(AFCConnectionRef connection);
229
+ void (*SetSecureContext)(AFCConnectionRef connection, AMSecureIOContext ioContext);
230
+
231
+ // Individual Operations
232
+ int (*DirectoryOpen)(AFCConnectionRef connection, const char *path, CFTypeRef _Nullable * _Nullable dir);
233
+ int (*DirectoryRead)(AFCConnectionRef connection, CFTypeRef dir, char *_Nullable *_Nullable dirent);
234
+ int (*DirectoryClose)(AFCConnectionRef connection, CFTypeRef dir);
235
+ int (*DirectoryCreate)(AFCConnectionRef connection, const char *dir);
236
+ int (*FileRefOpen)(AFCConnectionRef connection, const char *_Nonnull path, FBAFCReadMode mode, CFTypeRef *_Nonnull ref);
237
+ int (*FileRefClose)(AFCConnectionRef connection, CFTypeRef ref);
238
+ int (*FileRefSeek)(AFCConnectionRef connection, CFTypeRef ref, int64_t offset, uint64_t mode);
239
+ int (*FileRefTell)(AFCConnectionRef connection, CFTypeRef ref, uint64_t *_Nonnull offset);
240
+ int (*FileRefRead)(AFCConnectionRef connection, CFTypeRef ref, void *_Nonnull buf, uint64_t *_Nonnull len);
241
+ int (*FileRefWrite)(AFCConnectionRef connection, CFTypeRef ref, const void *_Nonnull buf, uint64_t len);
242
+ int (*RenamePath)(AFCConnectionRef connection, const char *_Nonnull path, const char *_Nonnull toPath);
243
+ int (*RemovePath)(AFCConnectionRef connection, const char *_Nonnull path);
244
+
245
+ // Batch Operations
246
+ int (*ConnectionProcessOperation)(AFCConnectionRef connection, CFTypeRef operation);
247
+ int (*OperationGetResultStatus)(CFTypeRef operation);
248
+ CFTypeRef (*OperationCreateRemovePathAndContents)(CFTypeRef allocator, CFStringRef path, void *_Nullable unknown_callback_maybe);
249
+ CFTypeRef (*OperationGetResultObject)(CFTypeRef operation);
250
+
251
+ // Errors
252
+ char *(*ErrorString)(int errorCode);
253
+ CFDictionaryRef (*ConnectionCopyLastErrorInfo)(AFCConnectionRef connection);
254
+ } AFCCalls;
255
+
256
+ #pragma clang diagnostic pop
@@ -0,0 +1,105 @@
1
+ /*
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+
8
+ #import <Foundation/Foundation.h>
9
+
10
+ #import <FBControlCore/FBControlCore.h>
11
+ #import <FBDeviceControl/FBAMDefines.h>
12
+ #import <FBDeviceControl/FBDeviceCommands.h>
13
+
14
+ @class FBAFCConnection;
15
+ @class FBAMDServiceConnection;
16
+ @class FBAMDeviceServiceManager;
17
+ @class FBDeviceType;
18
+ @class FBOSVersion;
19
+
20
+ /**
21
+ An Object Wrapper for AMDevice.
22
+ AMDevice is a Core Foundation Type in the MobileDevice.framework.
23
+ Some important things that we've learned about AMDevice from experimentation and looking at other open source projects:
24
+ - AMDevice sessions should be short-lived. They will timeout after 60 seconds causing subsequent usages (e.g. starting house_arrest service) to fail with:
25
+ 0xe800002d (Could not send a message to the device.)
26
+ - The AMDevice session only needs to be open long enough to initiate the operation that requires the AMDevice object. It can be closed immediately after
27
+ without waiting for the subsequent operation to finish. E.g. the right sequence of operations for using a service like com.apple.syslog_relay is:
28
+ AMDeviceConnect
29
+ AMDeviceStartSession
30
+ AMDeviceSecureStartService(amdevice, "com.apple.syslog_relay")
31
+ AMDeviceStopSession
32
+ AMDeviceDisconnect
33
+ // Do stuff with syslog service
34
+ AMDServiceConnectionInvalidate
35
+ Previously we were keeping the AMDevice session open for the duration of the service operation, which could hit the 60 second timeout for long operations,
36
+ causing the next operation to use the AMDevice session to fail.
37
+ - Only one AMDevice session should be open at once. Trying to open another will result in an error that the session is already active. To handle this we
38
+ let concurrent operations share the AMDevice session and only close it when there are no waiting consumers.
39
+ - Interestingly, trying to open a session a third time succeeds, so it seems the second attempt might kill off the first session
40
+ - Starting / stopping the same service on the phone (e.g. house_arrest) many times in a short period will cause the error 0xe800005b (Too many instances of this service are already running.)
41
+ Because of this, we pool service connections with a short cooldown to avoid reopening the same service repeatedly during bursts of operations using that service (e.g. recursively enumerating a directory)
42
+ */
43
+ @interface FBAMDevice : NSObject <FBiOSTargetInfo, FBDeviceCommands, FBFutureContextManagerDelegate>
44
+
45
+ #pragma mark - FBiOSTargetInfo Protocol Members
46
+ // These are implemented in FBAMDevice.m but must be declared explicitly for Swift visibility
47
+ // since the FBiOSTargetInfo protocol is Swift-defined.
48
+ @property (nonnull, nonatomic, readonly, copy) NSString *uniqueIdentifier;
49
+ @property (nonnull, nonatomic, readonly, copy) NSString *udid;
50
+ @property (nonnull, nonatomic, readonly, copy) NSString *name;
51
+ @property (nonnull, nonatomic, readonly, strong) FBDeviceType *deviceType;
52
+ @property (nonnull, nonatomic, readonly, copy) NSArray<FBArchitecture> *architectures;
53
+ @property (nonnull, nonatomic, readonly, strong) FBOSVersion *osVersion;
54
+ @property (nonnull, nonatomic, readonly, copy) NSDictionary<NSString *, id> *extendedInformation;
55
+ @property (nonatomic, readonly, assign) FBiOSTargetType targetType;
56
+ @property (nonatomic, readonly, assign) FBiOSTargetState state;
57
+
58
+ /**
59
+ The queue on which work should be serialized.
60
+ */
61
+ @property (nonnull, nonatomic, readonly, strong) dispatch_queue_t workQueue;
62
+
63
+ /**
64
+ The queue on which asynchronous work can be performed sequentially.
65
+ */
66
+ @property (nonnull, nonatomic, readonly, strong) dispatch_queue_t asyncQueue;
67
+
68
+ #pragma mark - Should be marked private when converting to Swift
69
+
70
+ /**
71
+ The underyling AMDeviceRef.
72
+ May be NULL.
73
+ */
74
+ @property (nonatomic, readwrite, assign) AMDeviceRef _Nullable amDeviceRef;
75
+
76
+ /**
77
+ All of the Device Values available.
78
+ */
79
+ @property (nonnull, nonatomic, readwrite, copy) NSDictionary<NSString *, id> *allValues;
80
+
81
+ /**
82
+ The Context Manager for the Connection
83
+ */
84
+ @property (nonnull, nonatomic, readonly, strong) FBFutureContextManager<FBAMDevice *> *connectionContextManager;
85
+
86
+ /**
87
+ The Service Manager.
88
+ */
89
+ @property (nonnull, nonatomic, readonly, strong) FBAMDeviceServiceManager *serviceManager;
90
+
91
+ /**
92
+ The Designated Initializer
93
+
94
+ @param allValues the values from the AMDevice.
95
+ @param calls the calls to use.
96
+ @param connectionReuseTimeout the time to wait before releasing a connection
97
+ @param serviceReuseTimeout the time to wait before releasing a service
98
+ @param workQueue the queue on which work should be serialized.
99
+ @param asyncQueue the queue on which asynchronous work can be performed sequentially.
100
+ @param logger the logger to use.
101
+ @return a new FBAMDevice instance.
102
+ */
103
+ - (nonnull instancetype)initWithAllValues:(nonnull NSDictionary<NSString *, id> *)allValues calls:(AMDCalls)calls connectionReuseTimeout:(nullable NSNumber *)connectionReuseTimeout serviceReuseTimeout:(nullable NSNumber *)serviceReuseTimeout workQueue:(nonnull dispatch_queue_t)workQueue asyncQueue:(nonnull dispatch_queue_t)asyncQueue logger:(nonnull id<FBControlCoreLogger>)logger;
104
+
105
+ @end
@@ -0,0 +1,59 @@
1
+ /*
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+
8
+ #import <Foundation/Foundation.h>
9
+
10
+ #import <FBDeviceControl/FBAMDefines.h>
11
+ #import <FBDeviceControl/FBDeviceManager.h>
12
+
13
+ @class FBAMDevice;
14
+
15
+ /**
16
+ Class for obtaining FBAMDevice instances.
17
+ */
18
+ @interface FBAMDeviceManager : FBDeviceManager <FBAMDevice *>
19
+
20
+ /**
21
+ The Designated Initializer
22
+
23
+ @param calls the AMDCalls to use.
24
+ @param workQueue the queue on which work should be serialized.
25
+ @param asyncQueue the queue on which asynchronous work can be performed sequentially.
26
+ @param ecidFilter an ECID filter to apply, or `nil` to accept all devices.
27
+ @param logger the logger to use.
28
+ @return a new FBAMDeviceManager instance
29
+ */
30
+ - (nonnull instancetype)initWithCalls:(AMDCalls)calls workQueue:(nonnull dispatch_queue_t)workQueue asyncQueue:(nonnull dispatch_queue_t)asyncQueue ecidFilter:(nullable NSString *)ecidFilter logger:(nonnull id<FBControlCoreLogger>)logger;
31
+
32
+ /**
33
+ Starts using the AMDeviceRef by doing the following:
34
+ - Starts a Connection with the device
35
+ - Performing and validating pairing.
36
+ - Starts a session.
37
+
38
+ @param device the device to use.
39
+ @param calls the calls to use.
40
+ @param logger the logger to use.
41
+ @param error an error out for any error that occurs.
42
+ @return YES if successful, NO otherwise.
43
+ */
44
+ + (BOOL)startUsing:(AMDeviceRef _Nonnull)device calls:(AMDCalls)calls logger:(nonnull id<FBControlCoreLogger>)logger error:(NSError * _Nullable * _Nullable)error;
45
+
46
+ /**
47
+ Stops using the AMDeviceRef connections.
48
+ - Stops the session with the device.
49
+ - Stops the connection with the device.
50
+
51
+ @param device the device to use.
52
+ @param calls the calls to use.
53
+ @param logger the logger to use.
54
+ @param error an error out for any error that occurs.
55
+ @return YES if successful, NO otherwise.
56
+ */
57
+ + (BOOL)stopUsing:(AMDeviceRef _Nonnull)device calls:(AMDCalls)calls logger:(nonnull id<FBControlCoreLogger>)logger error:(NSError * _Nullable * _Nullable)error;
58
+
59
+ @end