Skip to content

feat(reminder): add Baidu location module and native monitor - #239

Closed
gac0812 wants to merge 4 commits into
1024XEngineer:mainfrom
gac0812:feat/native-baidu-location-wiring
Closed

feat(reminder): add Baidu location module and native monitor#239
gac0812 wants to merge 4 commits into
1024XEngineer:mainfrom
gac0812:feat/native-baidu-location-wiring

Conversation

@gac0812

@gac0812 gac0812 commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

Summary

  • 新增 frontend/modules/timeflow-baidu-location Android 模块与 Expo plugin withTimeflowBaiduLocation
  • 新增 BaiduLocationBridge / NativeLocationMonitor:百度连续定位 + Haversine 进出圈
  • createAppServiceslocation 接到 NativeLocationMonitor
  • 新增 useLocationPermissionsOnLaunch,启动时申请前台/后台定位权限

Merge Order

Scope

  • frontend/modules/timeflow-baidu-location/**
  • frontend/plugins/withTimeflowBaiduLocation.js
  • frontend/react-native.config.js
  • frontend/app.jsonfrontend/package.jsonfrontend/eslint.config.js
  • frontend/src/infrastructure/location/native/BaiduLocationBridge.ts
  • frontend/src/infrastructure/location/NativeLocationMonitor.ts
  • frontend/src/features/reminder/presentation/useLocationPermissionsOnLaunch.ts
  • frontend/src/app/composition/createAppServices.ts(仅 location 接线)
  • frontend/src/app/AppProviders.tsx(启动定位权限)
  • frontend/tests/unit/infrastructure/location/**
  • frontend/tests/unit/features/reminder/useLocationPermissionsOnLaunch.test.ts

Out of scope

Verification

  • npm run check
  • npm ci

Closes #234

Ship the Android Baidu LocationClient bridge and request launch location permissions so place reminders can watch geofences without Google geofencing.
@vercel

vercel Bot commented Aug 13, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
timeflow Ready Ready Preview Aug 14, 2026 1:44am

@fennoai fennoai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Found two functional issues in the native location wiring. The focused Jest run could not execute locally because the repository’s Jest binary is not executable (Permission denied).

Comment thread frontend/app.json
…rvice

Start a location-type FGS with the LocationClient, and document that the AK must match expo.android.package (com.anonymous.timeflow).
@gac0812

gac0812 commented Aug 13, 2026

Copy link
Copy Markdown
Contributor Author

@fennoai /review

@fennoai

fennoai Bot commented Aug 13, 2026

Copy link
Copy Markdown

Review Complete

Submitted a non-blocking PR review with 3 inline findings:

  • P1: Baidu privacy consent is asserted automatically without a Baidu-specific user decision.
  • P1: Native samples use GCJ-02 while reminder centers have no matching conversion or coordinate metadata.
  • P2: Rebuild restarts native location monitoring once per schedule instead of synchronizing once.

Validation: inspected the fixed SHA range and ran git diff --check. Focused tests could not run because the mounted node_modules executables were unavailable/non-executable (vitest: Permission denied; tsc missing).

View job run

@fennoai fennoai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found three issues in the native location wiring: two affect correctness/compliance, and one causes avoidable native restarts during rebuilds.

Comment thread frontend/src/infrastructure/location/native/BaiduLocationBridge.ts
Comment thread frontend/src/infrastructure/location/NativeLocationMonitor.ts Outdated
Gate SDK init on explicit consent, keep samples in WGS84, and rebuild location watches with a single native sync.
@gac0812

gac0812 commented Aug 14, 2026

Copy link
Copy Markdown
Contributor Author

@fennoai /review

@fennoai

fennoai Bot commented Aug 14, 2026

Copy link
Copy Markdown

Review Complete

The previous findings were addressed in 11d6e9c:

  • Baidu privacy consent is now persisted and required before SDK initialization.
  • Native samples now use WGS84.
  • Rebuild installs watches and synchronizes native monitoring once.

The updated review contains 2 remaining P1 findings:

  • First-time consent can race with runtime startup; accepting consent does not resync an already-stopped monitor.
  • Foreground-service startup failures are swallowed while LocationClient still starts, so background reminders can silently lose their required FGS protection.

Validation passed: npm run check (lint, format check, typecheck, Vitest, and 30 Jest suites / 250 tests).

View job run

@fennoai fennoai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The previous findings are addressed. Full frontend validation passes, but two Android lifecycle issues remain in the updated implementation.

}
const agreed = await confirmBaiduPrivacy();
if (!agreed) return;
await persistBaiduPrivacyConsent(true);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 — Re-sync location monitoring after first-time consent. A location runtime can start while this async launch hook is waiting for the foreground/background permission prompts and the Baidu privacy dialog. In that case NativeLocationMonitor.syncMonitoring() sees no persisted consent, baiduInit()/baiduStartUpdating() return false, and the monitor remains stopped. After the user taps 同意, this code only persists consent and sets the SDK flag; it never asks the existing monitor/runtime to retry, so location reminders stay disabled until another rebuild or app-state transition. Trigger a monitor resync (or defer runtime start) after consent succeeds.

if (!updating) {
try {
BaiduLocationForegroundService.start(reactContext.applicationContext)
} catch (error: Exception) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 — Do not continue location updates when the foreground service cannot start. If startForegroundService() throws (for example because Android rejects a background FGS start), this catch only logs the error and the code still calls locationClient.start() and resolves success. The JS monitor then marks itself started even though no location FGS protects the process, so background reminders can silently stop once the app is backgrounded. Propagate the failure and avoid starting the client, or provide an explicit service-start acknowledgement before reporting success.

@gac0812 gac0812 closed this Aug 14, 2026
@gac0812
gac0812 deleted the feat/native-baidu-location-wiring branch August 14, 2026 06:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(reminder): 接入百度定位并接线 NativeLocationMonitor

1 participant