Skip to content

Latest commit

 

History

History
31 lines (17 loc) · 8.95 KB

Code__android__README.md

File metadata and controls

31 lines (17 loc) · 8.95 KB

Android local run — M01–M05 pilot flows

Open this directory in Android Studio, or build from a terminal with ./gradlew :app:assembleDebug.

Debug builds use the synthetic demo-safarsaathi Firebase Auth and Functions emulators by default, including a normal Android Studio Debug Run. For the application and evidence workflow, start all four local services from ../cloud-functions with npm run emulators:android. This uses the ports expected by the Android emulator (10.0.2.2:9099 for Auth and 10.0.2.2:5001 for Functions), starts Firestore and Storage, and uses a stable synthetic registration key for local submission. The startup script selects Android Studio's JDK when it is installed. It imports the last saved Auth, Firestore and Storage data from Code/emulator-data and exports them there when the emulator is stopped cleanly with Control-C. Keep that directory when you want test data to survive; delete it only for an intentional reset. The isolated M02 smoke-test config uses different ports and does not connect to the default Android debug build. Run ./gradlew :app:connectedDebugAndroidTest with an Android emulator for connected tests. Use -PuseFirebaseEmulators=false only for an intentional live development-project test. Release builds do not use emulators.

Physical phone on the same Wi-Fi

  1. Stop any running Firebase Emulator Suite cleanly with Control-C, then run npm run emulators:phone from Code/cloud-functions. This binds Auth (9099) and Functions (5001) to the Mac's network interface; Firestore, Storage and Emulator UI remain local to the Mac. Use this only on a trusted local network with synthetic data.
  2. Find the Mac's Wi-Fi IPv4 address with ifconfig en0 (the inet address). Make sure the phone and Mac are on the same network and that the Mac firewall allows incoming connections to the emulator process.
  3. Put firebaseEmulatorHost=<MAC_WIFI_IP> in Code/android/local.properties for Android Studio Run, or build from Code/android with ./gradlew :app:assembleDebug -PfirebaseEmulatorHost=<MAC_WIFI_IP>. The -P option takes priority over local.properties. Install app/build/outputs/apk/debug/app-debug.apk on the phone. Rebuild if the Mac's address changes. Without either setting, the default 10.0.2.2 serves Android Virtual Devices.

The physical phone connects to the Firebase emulators running on the Mac. It does not connect to an Android Virtual Device. The LAN setting applies only to debug builds; release builds use the normal Firebase project configuration.

For M05 driver push testing, a Google APIs/Play-services Android emulator obtains an FCM token from the Firebase project in app/google-services.json while the debug app continues using synthetic Auth, Functions and Firestore emulators. The Firebase Emulator Suite has no FCM emulator. To test a passenger request from a second device without deploying, start the local suite with SAFARSAATHI_EMULATOR_FCM=1 npm run emulators:phone from Code/cloud-functions after configuring Application Default Credentials for safarsaathi-ridepooling. Use emulators:android instead of emulators:phone only when no physical phone needs the suite. In this opt-in mode, the local request-creation trigger reads only local request and token records and sends a real FCM message only to tokens registered by an Android emulator. Keep the driver app signed in and on duty on the Android emulator; connect the passenger debug app on the phone to the same local suite. No Firebase deployment or production ride data is involved. The push contains only request ID, driver ID and deadline; tapping it re-fetches current request state from the local suite. A Firebase Console notification-composer message follows a different background display path and does not verify this receiver.

The current app includes S01, S02, S03 and S09, P01–P05 passenger discovery and request screens, S05 server-checked driver routing, D02–D06 driver application/correction/renewal, D01/D07/D10 Free pass and duty, and D11 incoming requests. An approved driver can obtain a 12-hour Free pass, choose an approved e-rickshaw, start a separate 12-hour shift inside an enabled town, take a break, resume or end. Foreground GPS heartbeat publishes only approximate public markers through a server callable; missing updates hide them after 60 seconds. Add Vehicle accepts bike, car and e-rickshaw, with a future RC expiry. D01 and D06 show licence/RC expiry warnings. The app can save drafts and upload private synthetic evidence without a retention-policy record for developer testing; production submission still needs the vehicle registration HMAC secret. Do not collect real documents or deploy this flow to production until the release checklist is complete. Carpool and fare negotiation remain later modules. English, Hindi and draft Assamese strings cover the implemented screens; native-speaker approval remains open. See the M01, M02, Free pass/duty, and M05 records.

M05 map setup

P01–P05 use Google Maps SDK for Android when mapsApiKey=<ANDROID_RESTRICTED_KEY> is set in the ignored Code/android/local.properties, or supplied as -PmapsApiKey=<ANDROID_RESTRICTED_KEY> for a build. Enable Maps SDK for Android and Places API (New) on the key's Google Cloud project, and restrict the key to the Android package and signing certificate. Keep the key out of source control. Without a configured key the route screens offer a coordinate-entry development fallback; configure a key before a user-facing pilot. The Maps SDK version and API requirements follow Google's Android setup guide.

The passenger can search Indian cities through Places autocomplete. Selecting a city inside a fresh enabled e-rickshaw town boundary centers its map and sets the pickup; other cities show a service-unavailable page. P01 presents a full-height location permission gate on entry; the map and bottom sheet remain hidden until permission and device location service are available. The Android permission dialog opens only when the passenger taps Grant access; blocked permission and disabled location offer a device-settings action. After access is granted, the map and bottom sheet appear. On P01, map gestures collapse the bottom sheet and a floating control restores it. When no driver is available, the route card is hidden and a disabled search button appears while the visible home refreshes discovery every 15 seconds. When drivers are available, pickup and destination rows open route selection; P02 supports place search, map taps, current location for pickup, and manual coordinates. The passenger chooses a fresh public driver within 3 km or expands to 5 km, and sends a selected-driver request. The request status polls the participant-scoped server state and resumes after app restart. On-duty drivers see incoming requests on D01 and can open D11 to accept or decline before the server deadline. M06 will add fare discussion after acceptance.

Map vehicle icons come from the supplied 48/96 px bike, auto-rickshaw and car PNGs. P01 renders them only for fresh drivers returned by listPublicDrivers; there are no sample vehicle markers. The callable includes each driver's vehicleType, and NearbyDriver.vehicleType chooses the icon. Older e-rickshaw-only M05 responses without that field remain compatible; unknown values are skipped. Nearby drivers group only with others of the same type. M05VehicleMarkerMotion.glide animates a retained live marker to its next fresh coordinate and turns it along the shortest angle toward travel direction. Future bike/car discovery can pass their vehicle types through the same marker path.

Recovery now rechecks current account and driver access after restart, language save or return from permission setup. Android accepts the application link safarsaathi://app/driver-application/{ownerUid}; it opens only the signed-in owner's current D02/D05 state. Other link types return safely to passenger home until their record resolvers exist. P01 shows the passenger location gate on entry and requests permission after Grant access is tapped; D10 requests precise GPS before starting duty. Notification permission support is present for future alerts and is not prompted at launch. See the M01/M14 recovery record.

If Firestore port 8080 is occupied while testing this path, the recovery emulator config uses port 18080 while keeping Android's Auth and Functions ports at 9099 and 5001. From ../cloud-functions, run firebase emulators:start --project demo-safarsaathi --only auth,functions,firestore --config ../firebase.recovery-test.json with JDK 21 or newer.

S01 and S02 bundle Inter Regular and SemiBold from the Inter 4.1 release. Its redistribution terms are in Inter-OFL.txt.