Compare commits
No commits in common. "b21a91bb9e417eb7e1d981697c6f09af4064b173" and "41bb6fcd2dc0999d212ceab0c9a6b6b64fe07cce" have entirely different histories.
b21a91bb9e
...
41bb6fcd2d
7 changed files with 30 additions and 153 deletions
|
|
@ -2,15 +2,6 @@
|
|||
|
||||
All notable changes to this project will be documented in this file. See [commit-and-tag-version](https://github.com/absolute-version/commit-and-tag-version) for commit guidelines.
|
||||
|
||||
## [1.16.6](https://github.com/alerte-secours/as-app/compare/v1.16.5...v1.16.6) (2026-01-22)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* permissions screen ([6c8153b](https://github.com/alerte-secours/as-app/commit/6c8153bdb114582f9a597a50fd2604f7b90dd181))
|
||||
* **track-location:** try 3 ([41bb6fc](https://github.com/alerte-secours/as-app/commit/41bb6fcd2dc0999d212ceab0c9a6b6b64fe07cce))
|
||||
* **track-location:** try 4 ([c7d0b36](https://github.com/alerte-secours/as-app/commit/c7d0b36f1bd3e700ad15bbc3ecff987e61aadbd9))
|
||||
|
||||
## [1.16.5](https://github.com/alerte-secours/as-app/compare/v1.16.4...v1.16.5) (2026-01-20)
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -83,8 +83,8 @@ android {
|
|||
applicationId 'com.alertesecours'
|
||||
minSdkVersion rootProject.ext.minSdkVersion
|
||||
targetSdkVersion rootProject.ext.targetSdkVersion
|
||||
versionCode 237
|
||||
versionName "1.16.6"
|
||||
versionCode 236
|
||||
versionName "1.16.5"
|
||||
multiDexEnabled true
|
||||
testBuildType System.getProperty('testBuildType', 'debug')
|
||||
testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@
|
|||
<key>CFBundlePackageType</key>
|
||||
<string>$(PRODUCT_BUNDLE_PACKAGE_TYPE)</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>1.16.6</string>
|
||||
<string>1.16.5</string>
|
||||
<key>CFBundleSignature</key>
|
||||
<string>????</string>
|
||||
<key>CFBundleURLTypes</key>
|
||||
|
|
@ -48,7 +48,7 @@
|
|||
</dict>
|
||||
</array>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>237</string>
|
||||
<string>236</string>
|
||||
<key>ITSAppUsesNonExemptEncryption</key>
|
||||
<false/>
|
||||
<key>LSApplicationQueriesSchemes</key>
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "alerte-secours",
|
||||
"version": "1.16.6",
|
||||
"version": "1.16.5",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"start": "expo start --dev-client --private-key-path ./keys/private-key.pem",
|
||||
|
|
@ -53,8 +53,8 @@
|
|||
"screenshot:android": "scripts/screenshot-android.sh"
|
||||
},
|
||||
"customExpoVersioning": {
|
||||
"versionCode": 237,
|
||||
"buildNumber": 237
|
||||
"versionCode": 236,
|
||||
"buildNumber": 236
|
||||
},
|
||||
"commit-and-tag-version": {
|
||||
"scripts": {
|
||||
|
|
|
|||
|
|
@ -74,10 +74,7 @@ export const BASE_GEOLOCATION_CONFIG = {
|
|||
method: "POST",
|
||||
httpRootProperty: "location",
|
||||
batchSync: false,
|
||||
// We intentionally disable autoSync and perform controlled uploads from explicit triggers
|
||||
// (startup, identity-change, moving-edge, active-alert). This prevents stationary "ghost"
|
||||
// uploads from low-quality locations produced by some Android devices.
|
||||
autoSync: false,
|
||||
autoSync: true,
|
||||
|
||||
// Persistence: keep enough records for offline catch-up.
|
||||
// (The SDK already constrains with maxDaysToPersist; records are deleted after successful upload.)
|
||||
|
|
@ -104,7 +101,6 @@ export const BASE_GEOLOCATION_INVARIANTS = {
|
|||
speedJumpFilter: 100,
|
||||
method: "POST",
|
||||
httpRootProperty: "location",
|
||||
autoSync: false,
|
||||
maxRecordsToPersist: 1000,
|
||||
maxDaysToPersist: 7,
|
||||
};
|
||||
|
|
@ -117,9 +113,10 @@ export const TRACKING_PROFILES = {
|
|||
// only periodic fixes (several times/hour). Note many config options like
|
||||
// `distanceFilter` / `stationaryRadius` are documented as having little/no
|
||||
// effect in this mode.
|
||||
// Some devices / OEMs can be unreliable with significant-change only.
|
||||
// Use standard motion tracking for reliability, with conservative distanceFilter.
|
||||
useSignificantChangesOnly: false,
|
||||
// Some iOS devices / user settings can result in unreliable significant-change wakeups.
|
||||
// We keep SLC for Android (battery), but fall back to standard motion tracking on iOS
|
||||
// with a conservative distanceFilter.
|
||||
useSignificantChangesOnly: Platform.OS !== "ios",
|
||||
|
||||
// Defensive: if some devices/platform conditions fall back to standard tracking,
|
||||
// keep the distanceFilter conservative to avoid battery drain.
|
||||
|
|
|
|||
|
|
@ -50,46 +50,12 @@ export default function trackLocation() {
|
|||
let didDisableUploadsForAnonymous = false;
|
||||
let didSyncAfterAuth = false;
|
||||
let didSyncAfterStartupFix = false;
|
||||
let lastMovingEdgeAt = 0;
|
||||
const MOVING_EDGE_COOLDOWN_MS = 5 * 60 * 1000;
|
||||
|
||||
const BAD_ACCURACY_THRESHOLD_M = 200;
|
||||
|
||||
// Track identity so we can force a first geopoint when the effective user changes.
|
||||
let lastSessionUserId = null;
|
||||
|
||||
const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
||||
|
||||
const pruneBadLocations = async () => {
|
||||
try {
|
||||
const locations = await BackgroundGeolocation.getLocations();
|
||||
if (!Array.isArray(locations) || !locations.length) return 0;
|
||||
|
||||
let deleted = 0;
|
||||
// Defensive: only scan a bounded amount to avoid heavy work.
|
||||
const toScan = locations.slice(-200);
|
||||
for (const loc of toScan) {
|
||||
const acc = loc?.coords?.accuracy;
|
||||
const uuid = loc?.uuid;
|
||||
if (
|
||||
typeof acc === "number" &&
|
||||
acc > BAD_ACCURACY_THRESHOLD_M &&
|
||||
uuid
|
||||
) {
|
||||
try {
|
||||
await BackgroundGeolocation.destroyLocation(uuid);
|
||||
deleted++;
|
||||
} catch (e) {
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
}
|
||||
return deleted;
|
||||
} catch (e) {
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
|
||||
const safeSync = async (reason) => {
|
||||
// Sync can fail transiently (SDK busy, network warming up, etc). Retry a few times.
|
||||
for (let attempt = 1; attempt <= 3; attempt++) {
|
||||
|
|
@ -99,8 +65,6 @@ export default function trackLocation() {
|
|||
BackgroundGeolocation.getCount(),
|
||||
]);
|
||||
|
||||
const pruned = await pruneBadLocations();
|
||||
|
||||
locationLogger.info("Attempting BGGeo sync", {
|
||||
reason,
|
||||
attempt,
|
||||
|
|
@ -108,7 +72,6 @@ export default function trackLocation() {
|
|||
isMoving: state?.isMoving,
|
||||
trackingMode: state?.trackingMode,
|
||||
pendingBefore,
|
||||
pruned,
|
||||
});
|
||||
|
||||
const records = await BackgroundGeolocation.sync();
|
||||
|
|
@ -458,7 +421,7 @@ export default function trackLocation() {
|
|||
} catch (e) {
|
||||
currentSessionUserId = null;
|
||||
}
|
||||
if (!userToken && !currentSessionUserId) {
|
||||
if (!userToken) {
|
||||
// Pre-login mode: keep tracking enabled but disable uploads.
|
||||
// Also applies to logout: keep tracking on (per product requirement: track all the time),
|
||||
// but stop sending anything to server without auth.
|
||||
|
|
@ -528,7 +491,7 @@ export default function trackLocation() {
|
|||
locationLogger.debug("Updating background geolocation config");
|
||||
await BackgroundGeolocation.setConfig({
|
||||
url: env.GEOLOC_SYNC_URL, // Update the sync URL for when it's changed for staging
|
||||
autoSync: false,
|
||||
autoSync: true,
|
||||
headers: {
|
||||
Authorization: `Bearer ${userToken}`,
|
||||
},
|
||||
|
|
@ -655,30 +618,6 @@ export default function trackLocation() {
|
|||
// The final persisted location will arrive with sample=false.
|
||||
if (location.sample) return;
|
||||
|
||||
// Quality gate: delete very poor-accuracy locations to prevent them from being synced
|
||||
// and ignore them for UI/state.
|
||||
const acc = location?.coords?.accuracy;
|
||||
if (typeof acc === "number" && acc > BAD_ACCURACY_THRESHOLD_M) {
|
||||
locationLogger.info("Ignoring poor-accuracy location", {
|
||||
accuracy: acc,
|
||||
uuid: location?.uuid,
|
||||
});
|
||||
if (location?.uuid) {
|
||||
try {
|
||||
await BackgroundGeolocation.destroyLocation(location.uuid);
|
||||
locationLogger.debug("Destroyed poor-accuracy location", {
|
||||
uuid: location.uuid,
|
||||
});
|
||||
} catch (e) {
|
||||
locationLogger.warn("Failed to destroy poor-accuracy location", {
|
||||
uuid: location?.uuid,
|
||||
error: e?.message,
|
||||
});
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (
|
||||
location.coords &&
|
||||
location.coords.latitude &&
|
||||
|
|
@ -742,46 +681,6 @@ export default function trackLocation() {
|
|||
isMoving: event?.isMoving,
|
||||
location: event?.location?.coords,
|
||||
});
|
||||
|
||||
// Moving-edge strategy: when we enter moving state, force one persisted high-quality
|
||||
// point + sync so the server gets a quick update.
|
||||
//
|
||||
// IMPORTANT: Restrict this to ACTIVE tracking only. On Android, motion detection can
|
||||
// produce false-positive moving transitions while the device is stationary (screen-off),
|
||||
// which would otherwise trigger unwanted background uploads.
|
||||
// Cooldown to avoid repeated work due to motion jitter.
|
||||
if (event?.isMoving && authReady && currentProfile === "active") {
|
||||
const now = Date.now();
|
||||
if (now - lastMovingEdgeAt >= MOVING_EDGE_COOLDOWN_MS) {
|
||||
lastMovingEdgeAt = now;
|
||||
(async () => {
|
||||
try {
|
||||
const fix = await BackgroundGeolocation.getCurrentPosition({
|
||||
samples: 1,
|
||||
persist: true,
|
||||
timeout: 30,
|
||||
maximumAge: 0,
|
||||
desiredAccuracy: 50,
|
||||
extras: {
|
||||
moving_edge: true,
|
||||
},
|
||||
});
|
||||
locationLogger.info("Moving-edge fix acquired", {
|
||||
accuracy: fix?.coords?.accuracy,
|
||||
latitude: fix?.coords?.latitude,
|
||||
longitude: fix?.coords?.longitude,
|
||||
timestamp: fix?.timestamp,
|
||||
});
|
||||
} catch (e) {
|
||||
locationLogger.warn("Moving-edge fix failed", {
|
||||
error: e?.message,
|
||||
stack: e?.stack,
|
||||
});
|
||||
}
|
||||
await safeSync("moving-edge");
|
||||
})();
|
||||
}
|
||||
}
|
||||
},
|
||||
onActivityChange: (event) => {
|
||||
locationLogger.info("Activity change", {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import React, { useEffect, useCallback, useMemo, useRef } from "react";
|
||||
import React, { useEffect, useCallback, useRef } from "react";
|
||||
import {
|
||||
View,
|
||||
TouchableOpacity,
|
||||
|
|
@ -309,10 +309,8 @@ const PermissionItem = ({
|
|||
};
|
||||
|
||||
export default function Permissions() {
|
||||
// IMPORTANT: keep a stable permissions list across renders.
|
||||
// If this array changes identity each render, it re-creates callbacks and can
|
||||
// trigger a re-render loop via permission checks + store updates.
|
||||
const permissionsList = useMemo(() => {
|
||||
// Create permissions list based on platform
|
||||
const getPermissionsList = () => {
|
||||
const basePermissions = [
|
||||
"fcm",
|
||||
"phoneCall",
|
||||
|
|
@ -321,31 +319,29 @@ export default function Permissions() {
|
|||
"motion",
|
||||
"readContacts",
|
||||
];
|
||||
return Platform.OS === "android"
|
||||
? [...basePermissions, "batteryOptimizationDisabled"]
|
||||
: basePermissions;
|
||||
}, []);
|
||||
|
||||
// Add battery optimization only on Android
|
||||
if (Platform.OS === "android") {
|
||||
return [...basePermissions, "batteryOptimizationDisabled"];
|
||||
}
|
||||
|
||||
return basePermissions;
|
||||
};
|
||||
|
||||
const permissionsList = getPermissionsList();
|
||||
const permissionsState = usePermissionsState(permissionsList);
|
||||
|
||||
const titleRef = useRef(null);
|
||||
const lastAnnouncementRef = useRef({});
|
||||
const lastSetPermissionRef = useRef({});
|
||||
const lastBlockedMapRef = useRef(null);
|
||||
|
||||
// We keep a minimal, best-effort blocked map for a11y/UX.
|
||||
const [blockedMap, setBlockedMap] = React.useState({});
|
||||
|
||||
// Memoize the check permissions function.
|
||||
// NOTE: Do NOT depend on permissionsState here (it changes on each store update),
|
||||
// or we can re-run effects and create a log spam loop.
|
||||
// Memoize the check permissions function
|
||||
const checkAllPermissions = useCallback(async () => {
|
||||
// Update store only when values actually change, to avoid churn.
|
||||
for (const permission of permissionsList) {
|
||||
const status = await checkPermissionStatus(permission);
|
||||
if (lastSetPermissionRef.current[permission] !== status) {
|
||||
lastSetPermissionRef.current[permission] = status;
|
||||
setPermissions[permission](status);
|
||||
}
|
||||
setPermissions[permission](status);
|
||||
}
|
||||
|
||||
// Also refresh "blocked" state used for a11y guidance.
|
||||
|
|
@ -354,13 +350,7 @@ export default function Permissions() {
|
|||
const meta = await getPermissionA11yMeta(permission);
|
||||
nextBlocked[permission] = !!meta.blocked;
|
||||
}
|
||||
|
||||
// Avoid re-setting state if unchanged (prevents extra re-renders).
|
||||
const nextBlockedKey = JSON.stringify(nextBlocked);
|
||||
if (lastBlockedMapRef.current !== nextBlockedKey) {
|
||||
lastBlockedMapRef.current = nextBlockedKey;
|
||||
setBlockedMap(nextBlocked);
|
||||
}
|
||||
setBlockedMap(nextBlocked);
|
||||
}, [permissionsList]);
|
||||
|
||||
// Check all permissions when component mounts
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue