问题描述:

I have implemented a daemon that automates clicking on a jailbroken iPhone. It worked on iOS 7.1 before, but when running it on iPhone 5S with iOS 9.1 the daemon throws an exception. I have also enabled the UI Automation in the settings as described here, but this does not solve the issue.

Here is the idevicesyslog output:

Feb 21 15:03:37 iPhone clickerd[4492] <Error>: starting ...

Feb 21 15:03:37 iPhone clickerd[4492] <Warning>: Accessing [UIATarget localTarget]

Feb 21 15:03:37 iPhone backboardd[96] <Notice>: SecTaskLoadEntitlements failed error=22 cs_flags=6001004, task->pid_self=-1

Feb 21 15:03:37 iPhone backboardd[96] <Notice>: SecTaskCopyDebugDescription: clickerd[4492]

Feb 21 15:03:37 iPhone backboardd[96] <Notice>: SecTaskLoadEntitlements failed error=22 cs_flags=6001004, task->pid_self=-1

Feb 21 15:03:37 iPhone backboardd[96] <Notice>: SecTaskCopyDebugDescription: clickerd[4492]

Feb 21 15:03:37 iPhone clickerd[4492] <Warning>: AXError: Could not auto-register for pid status change

Feb 21 15:03:37 iPhone backboardd[96] <Notice>: SecTaskLoadEntitlements failed error=22 cs_flags=6001004, task->pid_self=-1

Feb 21 15:03:37 iPhone backboardd[96] <Notice>: SecTaskCopyDebugDescription: clickerd[4492]

Feb 21 15:03:37 iPhone backboardd[96] <Notice>: SecTaskLoadEntitlements failed error=22 cs_flags=6001004, task->pid_self=-1

Feb 21 15:03:37 iPhone backboardd[96] <Notice>: SecTaskCopyDebugDescription: clickerd[4492]

Feb 21 15:03:37 iPhone clickerd[4492] <Warning>: Failed to enable accessiblity, kAXErrorAPIDisabled

Feb 21 15:03:37 iPhone clickerd[4492] <Warning>: NSException caught

Feb 21 15:03:37 iPhone clickerd[4492] <Warning>: Name: kUIAExeceptionNoAccessibility

Feb 21 15:03:37 iPhone clickerd[4492] <Warning>: Reason: Failed to enable accessiblity, kAXErrorAPIDisabled

Feb 21 15:03:37 iPhone clickerd[4492] <Warning>: CallStackSymbols: (

0 CoreFoundation 0x0000000185bfcf60 <redacted> + 148

1 libobjc.A.dylib 0x000000019a6bff80 objc_exception_throw + 56

2 CoreFoundation 0x0000000185bfce90 <redacted> + 0

3 UIAutomation 0x00000001000e9b20 +[UIAXElement initializeAccessibility] + 600

4 UIAutomation 0x00000001000ec994 +[UIAXElement uiaxSystemWideElement] + 36

5 UIAutomation 0x0000000100100f1c -[UIATarget init] + 396

6 UIAutomation 0x0000000100100d80 +[UIATarget localTarget] + 56

7 clickerd 0x0000000100042948 main + 384

8 libdyld.dylib 0x000000019af0e8b8 <redacted> + 4

)

Feb 21 15:03:37 iPhone clickerd[4492] <Warning>: CallStackReturnAddresses: (0x185bfcf48 0x19a6bff80 0x185bfce90 0x1000e9b20 0x1000ec994 0x100100f1c 0x100100d80 0x100042948 0x19af0e8b8)

Feb 21 15:03:37 iPhone clickerd[4492] <Warning>: UserInfo: (null)

Feb 21 15:03:37 iPhone clickerd[4492] <Alert>: UIAutomation.framework is not working!!!

Here is the corresponding code snippet:

DDLogCInfo(@"starting ...");

// UIAutomation check

BOOL UIAutomationIsWorking = YES;

@try {

DDLogCDebug(@"Accessing [UIATarget localTarget]");

[UIATarget localTarget]; // <-- Throws exception

DDLogCDebug(@"Checking if frontMostApp isVisible");

[[UIATarget localTarget].frontMostApp isVisible];

DDLogCDebug(@"Checking if PID not null");

if (UIAutomationIsWorking &&

[UIATarget localTarget].springboard.pid == nil) {

UIAutomationIsWorking = NO;

}

}

@catch (NSException *exception) {

DDLogCDebug(@"NSException caught");

DDLogCDebug(@"Name: %@", exception.name);

DDLogCDebug(@"Reason: %@", exception.reason);

DDLogCDebug(@"CallStackSymbols: %@", exception.callStackSymbols);

DDLogCDebug(@"CallStackReturnAddresses: %@", exception.callStackReturnAddresses);

DDLogCDebug(@"UserInfo: %@", exception.userInfo);

UIAutomationIsWorking = NO;

}

if (!UIAutomationIsWorking) {

DDLogCError(@"UIAutomation.framework is not working!!!");

exit(1);

}

Here is the corresponding disassembly:

__text:0000000000001A78 loc_1A78 ; CODE XREF: +[UIAXElement initializeAccessibility]+6Cj

__text:0000000000001A78 BL _AXDisableAccessibilityOnTermination

__text:0000000000001A7C MOV X19, X0

__text:0000000000001A80 CBZ W19, loc_1B20

__text:0000000000001A84 ADR X0, cfstr_UiautomationFa ; "UIAutomation failed to load accessibility"

__text:0000000000001A88 NOP

__text:0000000000001A8C BL __UIATargetStackshot

__text:0000000000001A90 MOV W0, #0

__text:0000000000001A94 BL __AXSSetAutomationEnabled

__text:0000000000001A98 NOP

__text:0000000000001A9C LDR X20, =_OBJC_CLASS_$_UIAElement

__text:0000000000001AA0 ADRP X25, #[email protected]

__text:0000000000001AA4 LDR X0, [X25,#[email protected]]

__text:0000000000001AA8 NOP

__text:0000000000001AAC LDR X21, =sel_stringForAXError_ ; "stringForAXError:"

__text:0000000000001AB0 MOV X2, X19

__text:0000000000001AB4 MOV X1, X21

__text:0000000000001AB8 BL _objc_msgSend

__text:0000000000001ABC NOP

__text:0000000000001AC0 LDR X1, =sel__logVerbosity_format_ ; "_logVerbosity:format:"

__text:0000000000001AC4 STR X0, [SP,#0x60+var_60]

__text:0000000000001AC8 ADR X22, cfstr_FailedToEnable ; "Failed to enable accessiblity, %@"

__text:0000000000001ACC NOP

__text:0000000000001AD0 MOV W2, #0x1000

__text:0000000000001AD4 MOV X0, X20

__text:0000000000001AD8 MOV X3, X22

__text:0000000000001ADC BL _objc_msgSend

__text:0000000000001AE0 NOP

__text:0000000000001AE4 LDR X20, =_OBJC_CLASS_$_NSException

__text:0000000000001AE8 ADR X8, _kUIAExceptionNoAccessibility

__text:0000000000001AEC NOP

__text:0000000000001AF0 LDR X23, [X8] ; "kUIAExeceptionNoAccessibility"

__text:0000000000001AF4 LDR X0, [X25,#[email protected]]

__text:0000000000001AF8 MOV X2, X19

__text:0000000000001AFC MOV X1, X21

__text:0000000000001B00 BL _objc_msgSend

__text:0000000000001B04 NOP

__text:0000000000001B08 LDR X1, =sel_raise_format_ ; "raise:format:"

__text:0000000000001B0C STR X0, [SP,#0x60+var_60]

__text:0000000000001B10 MOV X0, X20

__text:0000000000001B14 MOV X2, X23

__text:0000000000001B18 MOV X3, X22

__text:0000000000001B1C BL _objc_msgSend

__text:0000000000001B20 <------ return address

Is there anything I'm missing in order to enable UI Automation? Why do I get the error kAXErrorAPIDisabled? Thanks for any help or suggestions.

相关阅读:
Top