diff --git a/index.js b/index.js index 20848d7..72bc41a 100644 --- a/index.js +++ b/index.js @@ -1,7 +1,8 @@ import { default as Usbmux } from './lib/usbmux'; import * as utilities from './lib/utilities'; import * as services from './lib/services'; +import { INSTRUMENT_CHANNEL } from './lib/instrument'; -export { Usbmux, utilities, services }; +export { Usbmux, utilities, services, INSTRUMENT_CHANNEL }; export default Usbmux; diff --git a/lib/instrument/index.js b/lib/instrument/index.js index 1735b3c..35537ee 100644 --- a/lib/instrument/index.js +++ b/lib/instrument/index.js @@ -17,7 +17,7 @@ const CHANNEL_OFFSET = 2 ** 32; const INSTRUMENT_SERVICE_NAME_VERSION_14 = 'com.apple.instruments.remoteserver.DVTSecureSocketProxy'; const INSTRUMENT_SERVICE_NAME = 'com.apple.instruments.remoteserver'; -export const SERVICE = Object.freeze({ +export const INSTRUMENT_CHANNEL = Object.freeze({ DEVICE_INFO: 'com.apple.instruments.server.services.deviceinfo', PROCESS_CONTROL: 'com.apple.instruments.server.services.processcontrol', SYSMONTAP: 'com.apple.instruments.server.services.sysmontap', @@ -84,9 +84,9 @@ class InstrumentService extends BaseServiceSocket { } /** - * If the event is registered, this channel {SERVICE} messages will be returned to event. refer to this._handleData + * If the event is registered, this channel {CHANNEL} messages will be returned to event. refer to this._handleData * It's actually listening for int channelCode. In this._channel object to record channel key and int value - * @param {string} channel instruments service channel e.g: SERVICE.DEVICE_INFO. + * @param {string} channel instruments service channel e.g: INSTRUMENT_CHANNEL.DEVICE_INFO. * @param {DTXCallback} event */ async registerChannelCallback (channel, event) { @@ -96,7 +96,7 @@ class InstrumentService extends BaseServiceSocket { /** * Create a service channel, data transmission of the service will use this channelCode - * @param {string} channel instruments service channel e.g: SERVICE.DEVICE_INFO + * @param {string} channel instruments service channel e.g: INSTRUMENT_CHANNEL.DEVICE_INFO * @returns {Promise} instruments service channel code for data transmission */ async makeChannel (channel) { @@ -111,12 +111,12 @@ class InstrumentService extends BaseServiceSocket { /** * In general, we call this method to start the instrument dtx service - * @param {string} channel instrument dtx service e.g: SERVICE.DEVICE_INFO + * @param {string} channel instrument dtx service e.g: INSTRUMENT_CHANNEL.DEVICE_INFO * @param {string} selector instrument service method name (reflection calls) * @param {...any} auxiliaries parameters required by selector * @returns {Promise} * example: - * instrumentService.callChannel(SERVICE.PROCESS_CONTROL, + * instrumentService.callChannel(INSTRUMENT_CHANNEL.PROCESS_CONTROL, 'launchSuspendedProcessWithDevicePath:bundleIdentifier:environment:arguments:options:', '', bundleID, {}, [], {'StartSuspendedKey': 0, 'KillExisting': 1} */ diff --git a/test/instrument/instrument-service-specs.js b/test/instrument/instrument-service-specs.js index a7c39c8..55da25c 100644 --- a/test/instrument/instrument-service-specs.js +++ b/test/instrument/instrument-service-specs.js @@ -1,5 +1,5 @@ import chai from 'chai'; -import {InstrumentService, SERVICE} from '../../lib/instrument'; +import {InstrumentService, INSTRUMENT_CHANNEL} from '../../lib/instrument'; import { getServerWithFixtures, fixtures } from '../fixtures'; import B from 'bluebird'; @@ -25,7 +25,7 @@ describe('instrument', function () { ({server, socket} = await getServerWithFixtures(fixtures.INSTRUMENTS_LAUNCH_APP)); const bundleID = 'com.apple.mobilesafari'; instrumentService = new InstrumentService(socket); - const data = await instrumentService.callChannel(SERVICE.PROCESS_CONTROL, + const data = await instrumentService.callChannel(INSTRUMENT_CHANNEL.PROCESS_CONTROL, 'launchSuspendedProcessWithDevicePath:bundleIdentifier:environment:arguments:options:', '', bundleID, {}, [], {'StartSuspendedKey': 0, 'KillExisting': 1}); data.selector.should.be.equal(pid); @@ -34,7 +34,7 @@ describe('instrument', function () { it('should ios device kill app ', async function () { ({server, socket} = await getServerWithFixtures(fixtures.INSTRUMENTS_LAUNCH_APP)); instrumentService = new InstrumentService(socket); - await instrumentService.callChannel(SERVICE.PROCESS_CONTROL, 'killPid:', pid.toString()); + await instrumentService.callChannel(INSTRUMENT_CHANNEL.PROCESS_CONTROL, 'killPid:', pid.toString()); }); it('should ios device get fps', async function () { @@ -46,7 +46,7 @@ describe('instrument', function () { } instrumentService = new InstrumentService(socket, message); const data = []; - await instrumentService.callChannel(SERVICE.GRAPHICS_OPENGL, 'startSamplingAtTimeInterval:', 0); + await instrumentService.callChannel(INSTRUMENT_CHANNEL.GRAPHICS_OPENGL, 'startSamplingAtTimeInterval:', 0); await new B((resolve) => { setTimeout(() => { resolve(data);