feat(android): warm voice interface and custom sampling up to one day v0.1.51

This commit is contained in:
Codex
2026-10-19 01:19:28 +08:00
parent e3afb2e07f
commit 0a7c4d9b96
28 changed files with 401 additions and 107 deletions
+7 -5
View File
@@ -27,13 +27,15 @@ class Sync:
'(id TEXT PRIMARY KEY,share_id TEXT,family TEXT,member TEXT,started REAL,ended REAL,expires REAL,grant_json TEXT)')
self.a.DB.execute('CREATE INDEX IF NOT EXISTS collection_share ON location_collection_sessions(share_id)')
self.a.DB.execute('CREATE TABLE IF NOT EXISTS location_upload_timing (share_id TEXT PRIMARY KEY,started REAL,last_received REAL)')
if 'last_sample' not in {r[1] for r in self.a.DB.execute('PRAGMA table_info(location_upload_timing)')}:
self.a.DB.execute('ALTER TABLE location_upload_timing ADD COLUMN last_sample REAL NOT NULL DEFAULT 0')
def close(self, sid):
self.a.DB.execute('UPDATE location_collection_sessions SET ended=? WHERE share_id=? AND ended IS NULL', (time.time(), sid))
def start(self, row, grant):
self.close(row['id'])
self.a.DB.execute('INSERT OR REPLACE INTO location_upload_timing VALUES (?,?,0)', (row['id'], time.time()))
self.a.DB.execute('INSERT OR REPLACE INTO location_upload_timing VALUES (?,?,0,0)', (row['id'], time.time()))
if not grant.get('historyEnabled'):
return dict(historyEnabled=False, collectionId='')
key = secrets.token_hex(16)
@@ -42,12 +44,12 @@ class Sync:
(key, row['id'], row['family_id'], row['member_id'], now, row['expires'], json.dumps(grant)))
return dict(historyEnabled=True, collectionId=key, collectionStartedAt=now)
def seen(self, sid, started, now):
self.a.DB.execute('INSERT OR REPLACE INTO location_upload_timing VALUES (?,?,?)', (sid, started, now))
def seen(self, sid, started, now, sample_at=0):
self.a.DB.execute('INSERT OR REPLACE INTO location_upload_timing VALUES (?,?,?,?)', (sid, started, now, sample_at))
def timing(self, sid):
row=self.a.DB.execute('SELECT started,last_received FROM location_upload_timing WHERE share_id=?', (sid,)).fetchone()
return dict(started=row['started'],seen=row['last_received']) if row else {}
row=self.a.DB.execute('SELECT started,last_received,last_sample FROM location_upload_timing WHERE share_id=?', (sid,)).fetchone()
return dict(started=row['started'],seen=row['last_received'],sampleAt=row['last_sample']) if row else {}
def batch(self, token, body):
a = self.a