R0rt1z2 / realme-ota

Request and download OTA packages from BBK server(s)
GNU General Public License v3.0
150 stars 49 forks source link

Add version 2 request support #46

Closed rapperskull closed 1 year ago

rapperskull commented 1 year ago

This change has a little bit of a story behind. I discovered that there was a new request type when capturing the traffic from my phone. I wanted to know if the reason some updates were not showing up was some missing field in the body. Now I know that's not the case, but at the time I couldn't figure out what was going on. But recently an official tool was released by realme to check for updates on your PC. It uses a companion app that gets installed on the phone to build the request, and then it sends it to the server. Conversely, when it gets the response, it sends it back to the phone to decrypt it. As a side note, turns out that the PC tool still doesn't completely solve the problem of phones not getting updates. Starting from this tool, I decided to reverse engineer the new schema, and here we are.

While I was at it, I also refactored the code a little bit.

The new method works from ColorOS 11 onward (rui_version >= 2). I made it the default, but added an option to use the old one, just in case.

Now some things I discovered about the headers:

Finally a consideration about the URLs (extracted from the desktop tool): there doesn't seem to be a difference in the response with the other ones (they both respond the same on /v1, /v2 and even /v3), except for the change log. The old ones gives a brief description and a link to a page with the details. The new ones gives a link to a change log with the logo, summary and details in one page. Using the --old-method option will of course use the old ones, so I think it's worth keeping both. I haven't tested if they work with OnePlus phones, though.

Of course feel free to ask any question or make changes to the PR.

EDIT: Forgot to specify that the servers of course still accept the old method, but I decided to implement the new one in case realme shuts down the support for the old one.

R0rt1z2 commented 1 year ago

This is truly amazing, I didn't know there was a desktop application to download OTAs. Sorry for not replying until now, I have been looking at all the changes and in theory everything looks good, I don't see any problems with the new implementation. The only thing I noticed is that the README.md would need to be updated as well. Would you mind doing so?

R0rt1z2 commented 1 year ago

On the other hand, given the amount of contributions you have been making lately, would you be interested in being granted permissions on the repository? Just for the sake of convenience (not to be all the time forking the repo).

rapperskull commented 1 year ago

Yes, I will update the README. If you're fine with it, I would like to get permissions on the repo. If you prefer, I can still consult you before committing to master.

R0rt1z2 commented 1 year ago

Great, I'll give you read/write permissions then (you should've received an invitation). As for the consult thing, I guess you can always create a new branch to try things out and then push to master.

rapperskull commented 1 year ago

I updated the README, I will just check for small details later and then merge.