Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to enable developer mode #303

Closed
JJTech0130 opened this issue Jul 21, 2022 · 6 comments
Closed

Unable to enable developer mode #303

JJTech0130 opened this issue Jul 21, 2022 · 6 comments

Comments

@JJTech0130
Copy link

Test environment

  • macOS 12.4
  • iPhone 8 Plus on iOS Developer Beta 3 (B)

Describe the bug
When enabling developer mode with pymobiledevice3 amfi enable-developer-mode, it is unable to enable developer mode.

To Reproduce
Steps to reproduce the behavior:

  1. Pair device (pymobiledevice3 lockdown pair)
  2. Try and enable developer mode with above command
  3. Get error

Expected behavior
Developer mode should be enabled

Logs
If applicable, add logs including backtraces for the given error that help explain your problem.

Traceback (most recent call last):
  File "/Users/jjtech/pymobiledevice3/pymobiledevice3/./__main__.py", line 74, in <module>
    cli()
  File "/Users/jjtech/pymobiledevice3/pymobiledevice3/./__main__.py", line 54, in cli
    cli_commands()
  File "/usr/local/lib/python3.9/site-packages/click/core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python3.9/site-packages/click/core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.9/site-packages/click/core.py", line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python3.9/site-packages/click/core.py", line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python3.9/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python3.9/site-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "/usr/local/lib/python3.9/site-packages/pymobiledevice3/cli/amfi.py", line 26, in enable_developer_mode
    AmfiService(lockdown).enable_developer_mode()
  File "/usr/local/lib/python3.9/site-packages/pymobiledevice3/services/amfi.py", line 32, in enable_developer_mode
    if not resp['success']:
KeyError: 'success'

Additional context
I added a print() statement before the if not resp['success'] line, and resp is equal to {'Error': 'Device has a passcode set'}

@JJTech0130
Copy link
Author

JJTech0130 commented Jul 21, 2022

That error handling is a little sus. Shouldn't it be:

if not 'success' in resp:
    raise PyMobileDevice3Exception(f'enable_developer_mode(): {resp}')

instead of

if not resp['success']:
    raise PyMobileDevice3Exception(f'enable_developer_mode(): {resp}')

@JJTech0130
Copy link
Author

Also, why is it not a proper subclass of BaseService?

@JJTech0130
Copy link
Author

Wait a moment. I just realized, it might be an intended feature.... I saw something saying they mentioned at WWDC that only devices without a passcode can have it enabled automatically

doronz88 added a commit that referenced this issue Jul 21, 2022
@doronz88
Copy link
Owner

doronz88 commented Jul 21, 2022

Thanks for the very explained bug report 😎

AmfiService isn't a subclass of BaseService specifically because it doesn't act as other service are and should.
BaseService expects an active TCP connection and allows proper closing using a context manager or a close() method.

This service just closes the connection after every single message is received.

Also, I've just verified that amfid indeed prevent this automatic opt-in when a passcode is set. A proper error is now raised.

@doronz88
Copy link
Owner

Latest version with this fix is now on pypi so you can try it out:

https://github.com/doronz88/pymobiledevice3/releases/tag/v1.26.1

@JJTech0130
Copy link
Author

lgtm. Can't actually test the functionality, as my device has a passcode, but the errors look good.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants