R0rt1z2 / realme-ota

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

~~Update for OnePlus~~ Add --language argument #51

Closed chouex closed 1 year ago

chouex commented 1 year ago

Example: python main.py OnePlus8T_CH -v 5 KB2000_11.F.00_0000_000000000000 4 --region 1

Update: since the component-otapc-cn endpoint is working again, the new changes is meaningless now, I rollback the changes of ota-server.

chouex commented 1 year ago

Note: seem this model will not work region other than 1, since it has an suffix _CH in its model name.

chouex commented 1 year ago

Add --language example python main.py OnePlus8T_CH -v 5 KB2000_11.F.00_0000_000000000000 4 --region 1 -l zh-CN python main.py OnePlus8T_CH -v 5 KB2000_11.F.00_0000_000000000000 4 --region 1 -l zh-HK

rapperskull commented 1 year ago

I tried the command in the first post and I get a response even without your changes, so I don't understand the reasoning behind this PR.

First of all, the OnePlus detection is currently "wrong", as you noticed and fixed, since it only matches literally OnePlus, oneplus or Oneplus. I don't know why it was like that in the first place¹, but it means that your request uses the same endpoints of Realme models.

Speaking of endpoints, we already have the one you added, it's just component-otapc-cn instead of component-ota-cn, because it's the one used in the PC update tool, and v1 instead of v2, but AFAIK there's no difference between them. They are used by default if RealmeUI version is >= 2, and carry update info for Realme, OPPO and OnePlus devices. I also tried the --old-method option and I still get a response, so the OnePlus special case truly affects only older devices on the equivalent of RUI 1.

Also there's no problem with client_auto since, again, it works from my side.

The language option could be a nice addition, in case you want the changelog in your language², but other than that, that's irrelevant.

¹ Probably early OnePlus devices were all called just OnePlus? ² What I've noticed in my experience is that the changelog is not always translated in all languages anyways.

chouex commented 1 year ago

I just confirm the server response data successfully without my changes. but the reason I start this PR is because my phone can get the response but realme-ota got server error yesterday, and the host is different, this make me think the ota-url for Oneplus is outdated, then I try to reverse my phone to see what is the different.

The phone and realme-ota use different ota server, probably the misbehaving of component-otapc-cn yesterday confuses me. I will pay attention to the server side see If It reproduce the issue later.

another strange thing is the OTA response rollback to F.64 now, but version of yesterday was F.67 the response capture just now: image Here is the response from yesterday's new code.

{"aid":"KB2000NV97_11.F","androidVersion":"Android 13","colorOSVersion":"ColorOS 13.1","componentAssembleType":true,"components":[{"componentId":"my_manifest_KB2000_11.F.67_2670_202305111850.97.08512094","componentName":"my_manifest","componentPackets":{"id":"domestic_my_manifest_KB2000_11.F.67_2670_202305111850.97.08512094_1_d845174c36690c94932793a6a778e30f","manualUrl":"https://gauss-componentotacostmanual-cn.allawnfs.com/remove-9c8965262d7447c5bcebde1e32bbe0bf/component-ota/23/05/11/43a3edd905ee4ceebbb838f6354cf09b.zip","md5":"d845174c36690c94932793a6a778e30f","size":"6280203107","type":"1","url":"https://gauss-compotacostauto-cn.allawnfs.com/remove-9c8965262d7447c5bcebde1e32bbe0bf/component-ota/23/05/11/43a3edd905ee4ceebbb838f6354cf09b.zip","vabInfo":{"data":{"extra_params":"metadata_hash:bb889772b2d6f79987b40e89091c7481be3c5637f60aad578d8764400fea61e7","header":["FILE_HASH=1QLhg4eMVWhgwbpgdyVlTNL+44CAt8/6k0RbROV599Q=","FILE_SIZE=6280197042","METADATA_HASH=aGIYbTjfhh+Akhx6zj09bojYvPgqRk8zjxIw0xxlPAk=","METADATA_SIZE=237367","oplus_separate_soft=20806","oplus_rom_version=V13.1.0","security_patch=2023-04-05","security_patch_vendor=2023-04-05","oplus_update_engine_verify_disable=0","ota_target_version=KB2000_11.F.67_2670_202305111850"],"otaStreamingProperty":"payload_metadata.bin:2592:237634,payload.bin:2592:6280197042,payload_properties.txt:6280199692:356,metadata:69:1016,metadata.pb:1153:1372","vab_package_hash":"d845174c36690c94932793a6a778e30f"}}},"componentVersion":"KB2000_11.F.67_2670_202305111850.97.08512094"}],"decentralize":{"offset":6770,"round":28800,"strategyVersion":"8"},"description":{"firstTitle":"檢測到最新的系統版本。是次升級至 ColorOS 13.1,重點新增 ColorOS 狀態互通服務,帶來更貼心的智慧服務。新增 ColorOS 智慧跨裝置服務,提供更無縫的裝置互通體驗。推薦進行更新。","panelUrl":"https://gauss-compotacostauto-cn.allawnfs.com/remove-9c8965262d7447c5bcebde1e32bbe0bf/component-ota/23/05/23/2196d936e5f34fa69ab1d9a881b96767.html","share":".","url":"https://h5fs.coloros.com/d31a3e6937404b7198a51f99cc033e08/static/index.html#/about"},"googlePatchInfo":"0","id":"646c869766c9610115c2916e","isNvDescription":true,"isRecruit":false,"isSecret":false,"noticeType":0,"nvId16":"NV97","osVersion":"ColorOS 13.1","otaVersion":"KB2000_11.F.67_2670_202305111850","paramFlag":1,"parent":"ota","realAndroidVersion":"Android 13","realOsVersion":"ColorOS 13.1.0","reminderType":0,"rid":"5fd12f55-7ee6-496e-a3f2-6abba6e4b864","securityPatch":"2023-04-05","securityPatchVendor":"2023-04-05","silenceUpdate":0,"status":"published","versionCode":2670,"versionName":"KB2000_13.1.0.121(CN01)","versionTypeH5":"正式版"}

since we prove the changes is pointless now. I will rollback the changes.

I keep oneplus check condition because I found my OnePlus devices not called just OnePlus. Oneplus device with ColorOS can not use otag.h2os.com because it return HTTP 204. work fine if self.url not changed.

The language option is not important, its just a feature in case someone need.

The only change remain is the language flag now.

rapperskull commented 1 year ago

In my experience, the Chinese server often returns an error, you just have to retry. As for the returned version, probably OnePlus halted the rollout of the new version. ColorOS 13.1 is known to have some bugs, and also Realme halted the rollout for the GT2 Pro.

Finally, I'll let @R0rt1z2 have the final word on the language addition.

R0rt1z2 commented 1 year ago

In my experience, the Chinese server often returns an error, you just have to retry. As for the returned version, probably OnePlus halted the rollout of the new version. ColorOS 13.1 is known to have some bugs, and also Realme halted the rollout for the GT2 Pro.

Finally, I'll let @R0rt1z2 have the final word on the language addition.

If it doesn't break anything else, I see no reason against it. Can either of you confirm whether this won't cause any other problems? I'm currently away from my computer, so I can't really test myself.

rapperskull commented 1 year ago

The code looks good, and I tested it a bit, finding no obvious problems.