Repository navigation
fix: let the device plugin of the Android app load the map - #292
Conversation
The device plugin starts with fetchCountryInfo. It gets countryCode and serverCode from the app. The app takes them from the stored login answer: "country" becomes RRUser.countryIso and "region" becomes RRUser.region, which is the serverCode. If serverCode is empty, the plugin reads areaServerMap[countryCode].code. No entry of that map has a code, so the call throws. The catch block calls fetchCountryInfo again at once, so the plugin loops forever and sends no request. Without a cloud snapshot, the login answer had no "region", and its "country" was "EU". So the a307 plugin never got to the agreement check or the map. Send "region" in lower case, as the cloud does, and send "DE" as the country of the EU region. The EU cloud answers "region": "eu", "country": "DE" and "countrycode": "49".
The device plugin checks the privacy agreements before it asks for the
map. It reads the latest versions of its product with
getProductAgreements. The app fills them from "agreements" in
/api/v5/product. It reads the signed versions with getPluginAgreements.
The app fills them from userPluginAgreementList in
/api/v1/checkAppAgreement. The check passes only if both lists hold
USER_AGREEMENT and PRIVACY_POLICY and no signed version is lower than
the latest one.
The route sent "agreements": [], so the check always failed. The plugin
then took its privacy dialog path instead of going on to
app_get_init_status and the map.
Send both agreement types with the version that /api/v1/checkAppAgreement
reports as signed. The entries use the cloud's shape, for example
{"type": "PRIVACY_POLICY", "version": 36, "minorVersion": 0} for the
a307.
The local login answer names "DE" as the country of the EU region, but /api/v1/getUrlByEmail and /api/v1/userInfo still answered "EU". So one account showed two countries. All three routes now take the country from REGION_COUNTRY in shared/constants.py, and a country from the cloud snapshot still wins in /api/v1/userInfo.
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues block the login geography and product agreement compatibility changes.
No open issues 🎉
What changed in this PR
This PR fixes two response mismatches that prevent the Android device plugin from loading maps against the local server: missing login geography and empty product agreement metadata.
Changes:
- Adds lowercase login regions and maps EU app-facing country values to
DE, while preserving cloud snapshot values and vacuum/locationbehavior. - Aligns product agreement versions with signed plugin agreements through the shared v4/v5 product response builder.
- Adds regression coverage for login geography, country consistency, snapshot precedence, and agreement compatibility.
| File | Description |
|---|---|
tests/test_protocol_auth.py |
Tests regional login fields, country consistency, and snapshot precedence. |
tests/test_product_response.py |
Verifies required agreement types and compatible signed versions. |
tests/conftest.py |
Adds a region option to the release configuration helper. |
src/roborock_local_server/server.py |
Adds region and mapped country fields to local login identities. |
src/roborock_local_server/bundled_backend/shared/constants.py |
Defines the shared EU-to-DE country mapping. |
src/roborock_local_server/bundled_backend/https_server/routes/api/v1/user.py |
Applies consistent country defaults to discovery and user-info responses. |
src/roborock_local_server/bundled_backend/https_server/routes/api/v1/agreement.py |
Provides product agreement metadata using shared signed-version constants. |
src/roborock_local_server/bundled_backend/https_server/routes/api/product_service.py |
Replaces empty product agreements with the shared metadata. |
Review effort: Balanced
Lash-L
left a comment
There was a problem hiding this comment.
Automated review: passed (nits)
Now that this has passed the automated review, I'll do a human review and then either request changes or merge it.
Confirmed:
- Without
region, the plugin loops.- It uses
serverCode || areaServerMap[countryCode].codeand calls itself again on any exception (tanos0.js:479-507; refreshed Saros 20 Flowmodule_0.js:2476-2537). areaServerMaphasdebut noeu, so"country":"EU"throws andDEresolves.
- It uses
- The app reads both fields.
RRUserhasregionand maps JSONcountrytocountryIso. The cloud sendsregionin lower case (python-roborock mock data). - Agreements:
hasSignLastestPluginPrivacyAgreementneeds both PRIVACY_POLICY and USER_AGREEMENT with signed version ≥ latest. The PR's entries pass, and shared devices are covered too. - Scope: no new routes and no auth changes. B01 bundles don't run the agreement check.
Unverifiable:
- The native mapping from
/api/v5/productagreementstogetProductAgreements. - Where
serverCodeis derived. - What the EU cloud really sends as
country. - iOS behaviour.
Conflicts:
- #208: conflicts in
product_service.py; keep both, as your body says. - #295: trivial conflict in
constants.py; keepREGION_COUNTRY. - #288, #293 and #294 merge cleanly.
Nits:
- The region-to-country logic is now in three places (
server.py:71,routes/api/v1/user.py:14,server.py:602). Move the dialing-code table and one helper next toREGION_COUNTRY. - The comment at
product_service.py:60creditsgetProductAgreements, which the decompiled APK can't confirm.
Checks: all 508 tests pass.
This is an automated review by Claude Code, checked against the decompiled Roborock app (APK + device plugin bundles, refreshed 2026-11-21), python-roborock and a vacuum firmware dump. It can be incorrect, so please reply if any finding looks wrong.
…lace server.py and routes/api/v1/user.py each had a table of dialing codes and a helper, and REGION_COUNTRY in shared.constants named the country. One table in shared.constants now holds both, and region_country returns them. The login, getUrlByEmail and userInfo answers use it, and a test checks that all three name the same dialing code.
|
Lash-L
left a comment
There was a problem hiding this comment.
Automated review: passed (nits)
Now that this has passed the automated review, I'll do a human review and then either request changes or merge it.
What changed since the reviewed commit (d91aacb):
- 5b4eae2 moves the region-to-country logic into one place, as the last review asked.
REGION_COUNTRYnow maps each region to(country, dialing code), andregion_country()(shared/constants.py:138-149) serves the login answer (server.py:617),getUrlByEmail(routes/api/v1/user.py:38) anduserInfo(user.py:70). Both old_REGION_COUNTRY_CODEtables and their helpers are gone, and nothing else still calls them. The outputs for us/cn/eu/ru and for unknown regions match the old code (unknown regions still fall back to dialing code"1"). The test attests/test_protocol_auth.py:265now checks the dialing code as well. - 8ece039 merges main (#179, #251, #253, #282, #288) with no conflicts. Against main, the diff is still limited to the eight files this PR names.
Claims re-checked:
- Confirmed: the plugin loops when
regionis missing.fetchCountryInfocomputest.serverCode || areaServerMap[countryCode].codeand calls itself again in its catch block (nonhermes/com.roborock.tanos/output/0.js:479-507). Withregionpresent,serverCodeis never empty, so the country lookup isn't reached for us/cn/ru/sg either. - Confirmed: the app maps JSON
countrytoRRUser.countryIsoand keepsregion(jadx/.../sdk/bean/RRUser.java:19-31).isCN()checkscountrycode == "86"orcountryIso == "CN"(RRUser.java:171-176), and both still hold for the CN region. python-roborock'sUserDatahasregiontoo (roborock/data/containers.py:232). - Confirmed: the agreement code hasn't changed since the last review.
product_agreements()(routes/api/v1/agreement.py:42-52) andplugin_agreements()use the same types and versions. It is wired in atproduct_service.py:64. - Unverifiable: the native mapping from
agreementstogetProductAgreements, whereserverCodecomes from natively (serverCodedoesn't appear in the APK's Java sources), iOS, and what the EU cloud really sends ascountry.
Concerns from the brief:
- Existing users: the login answer is built fresh on each login, but phones already logged in keep a stored
RRUserwithoutregion.userInfodoesn't sendregion, so those phones probably need to log out and back in. - Snapshot users:
_protocol_login_identity(server.py:630-645) returns the clouduser_data. That data has the cloud's ownregion, so this PR doesn't change their path. - B01 and mower bundles: they don't run this agreement check (same finding as last time). Adding the field to their product entries is harmless.
Overlaps (git merge-tree):
- main: merges cleanly.
- #295: conflict in
constants.py. #295 deletesMODEL_PRODUCT_ID_OVERRIDES, which sits next toREGION_COUNTRY. Drop the overrides and keepREGION_COUNTRYandregion_country(). - #208: two hunks in
product_service.py. Keep both imports (product_agreements,card_spec_for_category), and keep"agreements": product_agreements()next to #208'sproductTags.
Nits:
- In the PR body or the release notes, tell users who are already logged in to log out and back in on the phone. Otherwise the fix won't reach them.
region_country()(constants.py:149) gives an unknown region such assgthe dialing code"1". That behaviour existed before this PR, but now that the table is in one place,"SG": ("SG", "65")is a one-line addition ifsgis meant to be supported.
Checks: uv run --extra dev pytest -q on 8ece039: 791 passed.
This is an automated review by Claude Code, checked against the decompiled Roborock app (APK + device plugin bundles), python-roborock and a vacuum firmware dump. It can be incorrect, so please reply if any finding looks wrong.
What does this PR do?
With these changes, the device plugin of the Android app (4.60.06) loads the map from a local server. Before, it stayed on its map loading screen. It needs both:
"region"(for example"eu") and a real country ("DE"for the EU region). Before, it had no"region"and answered"country": "EU", so the plugin's country lookup failed./api/v5/productnow answers"agreements"withUSER_AGREEMENTandPRIVACY_POLICY, at the versions that/api/v1/checkAppAgreementreports as signed. Before, it answered[], so the plugin's agreement check failed.Problem: the region
The app stores
"region"and"country"of the login answer. The device plugin reads them asserverCodeandcountryCodeinfetchCountryInfo.Without
"region", the plugin looks up its own area table by the country code."eu"is not in that table, so the lookup throws. The plugin retries at once and loops without sending any request.#240 described the same symptom with a different cause: identical MQTT client ids.
Problem: the agreements
The device plugin compares two lists:
"agreements"in/api/v5/product.userPluginAgreementListin/api/v1/checkAppAgreement.The check passes only if both lists hold
USER_AGREEMENTandPRIVACY_POLICY, and no signed version is lower than the latest one.The route answered
"agreements": [], so the check failed on every open. The plugin then took its privacy dialog path.#207 added the empty
agreementsfield and #209 added/api/v1/checkAppAgreement. This PR connects the two.Change
"region"in lower case, as the cloud sends it."country"is"DE"for the EU region, which fits the"countrycode": "49"that the server already sends. Other regions keep their upper-case region as the country./api/v1/getUrlByEmailand/api/v1/userInfoname the same country and dialing code as the login answer. All three take them from the newregion_country()inshared/constants.py. Its table replaces the two dialing-code tables inserver.pyandroutes/api/v1/user.py. A country from the cloud snapshot still wins in/api/v1/userInfo. The vacuum's/locationroute keeps its"EU".product_agreements()inroutes/api/v1/agreement.py. It returns one entry per agreement type, with the same version that/api/v1/checkAppAgreementreports as signed, for example{"type": "PRIVACY_POLICY", "version": 1, "minorVersion": 0}./api/v5/productuses it for"agreements"instead of[].tests/conftest.py:write_release_configtakes aregionoption.With a cloud import, the login answer comes from the snapshot, so the cloud's own
regionandcountryapply. This PR changes only the local answer.A phone that is already logged in keeps its stored user without
region, because/api/v1/userInfodoes not send it. So after the update, log out of the app and back in once.Home Assistant reads the region through python-roborock. There, only
cnchanges the behavior (inget_clean_routes), so EU and US servers behave as before. A CN server now gets the CN clean routes, as with the cloud.Related
/api/v1/product/agreementAndPolicy, the plugin stayed on its map loading screen. This PR lets the plugin skip that path.product_service.py, so this PR may cover part of it. I have not tested iOS.product_service.py. Whichever lands second needs a small rebase there, which keeps both theproductTagsof feat(api): enable scene tiles via productTags and category cardSpec #208 andproduct_agreements().Before you open this PR (optional, but very helpful)
PRs I reviewed:
Proof that it works
Tested on:
roborock.vacuum.a307)02.17.50a307-pluginbranch. That build is upstream main 32608dd plus the first two commits of this PR, feat(api): enable scene tiles via productTags and category cardSpec #208 and my other fixes for the a307. The tests ran on this branch, on upstream main 2069fc7.What I did and what happened:
Before: the device plugin stayed on its map loading screen. Without the agreements, it failed its agreement check and took its privacy dialog path. Without the region, it looped in its country lookup, and the server got no request from it.
After the deploy, the plugin still hung at first, because the app keeps the login answer of its last login. I deleted the app's data and logged in again. Then the map loaded.
Tests:
test_local_pin_login_names_the_region_and_country_of_the_configlogs in without a cloud snapshot, foreu(regioneu,countryDE,countrycode49) and forus(regionus,countryUS,countrycode1).test_url_and_user_info_routes_name_the_country_of_the_login_answerchecks thatgetUrlByEmailanduserInfoname the country and dialing code of the login answer, foreuandus. Newtest_user_info_prefers_the_country_of_the_cloud_snapshotchecks that a snapshot country still wins.test_product_entry_carries_rriotid_category_id_and_agreementsnow expects both agreement types.test_product_agreements_are_signed_in_plugin_agreementschecks that for both types, the signed version of the device in/api/v1/checkAppAgreementis at least the latest version in/api/v5/product.uv run --extra dev pytest -qpasses (508 tests).Screenshots (required for any UI change)
No UI changes.