Features / Onboarding & setup

Device registration and remote actions

Checks for admin commands sent to the user (such as forced logout or data wipe) and, when enabled, binds the user to a single device. A user logged in on another device is blocked until they resolve the conflict.

FactsheetOnboarding & setup
Who uses it
CadreUnit In-Charge / FMT L1
How you get here
Opens on top of Home on every start in release builds; also before Village selection when device binding is on.
APIs
5 calls today, 11 App Service operations
Offline
Skipped when offline; the user continues without any check.

Screens

ScreenWhat it doesSource
Device RegistrationStatus text, progress and Retry while remote actions and device binding are checked.app/src/main/java/org/platformcommons/urvi/view/deviceregistration/DeviceRegistrationActivity.kt

Rules

Conditions from the code, rewritten as plain decision rules.

WhenThen
The screen opensA full-screen "Checking remote app actions..." lock shows while remote actions are fetched for today.
Remote actions fail or none existContinue to device binding if enabled, otherwise close.
One or more remote actions existShow the first action's message with only an OK button.
The action is ACTION_TYPE.LOGOUT or ACTION_TYPE.CLEAR_APP_DATAIf unsynced items have been attempted, zip and upload app data; report the action as EXECUTION_STATUS.COMPLETED; log out. CLEAR_APP_DATA also wipes the app.
The action is any other typeMark it executed, then continue to device binding or close.
DEVICE_BINDING_EXTERNAL_SWITCH is not 1Skip device binding.
Binding is on and there is no internetThe screen closes and the user continues without a check.
The server has no session for this userRegister this device (status DEVICE_STATUS.LIVE), store the returned id and continue.
The server says deviceMatchStatus = trueContinue.
The server says deviceMatchStatus = falseShow a non-dismissable "Device Session Conflict" dialog listing the other device's brand, model and login time.
In the conflict dialog, setup is completeShow Check Sync, which opens Pending Sync with a cleared back stack.
In the conflict dialog, REMOVE_DEVICE_BINDING_ON_NEW_DEVICE_EXTERNAL_SWITCH = 1Show Login Here, which removes the old binding (remark BINDING_REMOVED) and registers this device.
In the conflict dialog, the user taps LogoutAll data is cleared.
An HTTP or network error occurs during bindingShow "Registration Error" with Retry / Cancel; Cancel closes the screen and the user continues.
The user logs out and REMOVE_DEVICE_BINDING_ON_LOGOUT_EXTERNAL_SWITCH = 1The binding is expired with remark USER_LOGOUT.

API contracts

Each call opens to its use case, headers, request and response bodies, and errors.

App Service v2: operationUse
POST /auth/logoutLog out and revoke tokens
GET /session/bootstrapSession bootstrap after login and on cold start
GET /configTyped config bundle (ETag)
POST /filesCreate a file upload (resumable or single-shot)
PATCH /files/{fileId}Append a chunk to a resumable upload
HEAD /files/{fileId}Current offset of a resumable upload
PUT /devices/{deviceId}Register or update this device
PUT /devices/{deviceId}/push-tokenStore or rotate the FCM push token
POST /devices/{deviceId}/binding/takeover"Login here": move the binding to this device
GET /devices/{deviceId}/actionsPending remote actions for this device
POST /devices/{deviceId}/actions/{actionId}/completeReport a remote action as executed

Behaviour notes

  • Device id is ANDROID_ID. Registration sends device type, brand, manufacturer, model, fingerprint, MAC, IP, OS, OS version, app version and login time.
  • The returned session id is stored in private prefs device_registration_prefs.
  • Possible bug · unverified binding can be bypassed by going offline or pressing Cancel on the error dialog; it only blocks when online.
  • Possible bug · unverified Check Sync opens Pending Sync with a cleared task, so Back exits the app and Home is not reachable until relaunch.
  • Only runs in release builds when opened from Home.

Improve in the rewrite

  • Enforce device binding on the server if it is a security control.
  • Use a feature flag instead of build type so debug and release behave the same.
  • Combine blocking issues (device conflict, automatic time, session expired) into one blocking-issues screen.