feat(android): warm voice interface and custom sampling up to one day v0.1.51
This commit is contained in:
+9
-4
@@ -167,7 +167,7 @@ class Locations:
|
||||
interval=body.get('intervalSeconds',300)
|
||||
if not interval_valid(interval):raise a.Problem('上传周期可选 10 秒、1/5 分钟,或 1 至 720 小时(最多 30 天)')
|
||||
sample=body.get('sampleIntervalSeconds',60)
|
||||
if type(sample) is not int or sample not in (10,60,300):raise a.Problem('采集周期可选 10 秒、1 分钟或 5 分钟')
|
||||
if type(sample) is not int or not 10 <= sample <= 86400:raise a.Problem('采集间隔可自定义 10 秒至 1 天,不支持一周等更长间隔')
|
||||
if not any(chosen.values()):raise a.Problem('至少选择一位查看人;只查看家人无需开启自己的共享')
|
||||
history=body.get('historyEnabled',False)
|
||||
if type(history) is not bool or history and body.get('historyConsent') is not True:raise a.Problem('长期保存轨迹需要本人单独同意',403)
|
||||
@@ -198,7 +198,7 @@ class Locations:
|
||||
if not fix or pos['at']>fix['at']:fix={k:pos[k] for k in ('latitude','longitude','accuracy','at')}
|
||||
if signal in ('permission_denied','location_disabled'):fix=None
|
||||
self.latest[sid]=dict(started=old['started'],seen=now,fix=fix,signal=signal)
|
||||
self.sync.seen(sid,old['started'],now)
|
||||
self.sync.seen(sid,old['started'],now,fix['at'] if fix else 0)
|
||||
return dict(ok=True,expires=row['expires'])
|
||||
|
||||
def listing(self, family, user=None, display_id=None, phone_id=None):
|
||||
@@ -225,13 +225,18 @@ class Locations:
|
||||
if phone_id and phone_id!=row['id'] and phone_id not in {v['id'] for v in grant.get('phones',[])}:continue
|
||||
recent=self.latest.get(row['id']) or self.sync.timing(row['id']);fix=recent.get('fix');seen=recent.get('seen',0)
|
||||
age=now-(fix['at'] if fix else recent.get('started',row['created']))
|
||||
scheduled=grant.get('intervalSeconds',300)>900 and now-(seen or recent.get('started',row['created']))<=grant['intervalSeconds']+900
|
||||
upload=grant.get('intervalSeconds',300);sample=grant.get('sampleIntervalSeconds',60)
|
||||
next_upload=(seen or recent.get('started',row['created']))+upload
|
||||
next_sample=(fix['at'] if fix else recent.get('sampleAt') or recent.get('started',row['created']))+sample
|
||||
sampling=sample>900 and now<=next_sample+900
|
||||
scheduled=sampling or upload>900 and now<=next_upload+900
|
||||
stale=age>900 or seen and now-seen>900
|
||||
state='scheduled' if stale and scheduled else 'stale' if stale else 'live' if fix else 'waiting'
|
||||
position=fix if fix and state=='live' else None
|
||||
items.append(dict(id=row['member_id'],personId=valid[1]['id'],name=valid[1]['name'],status=state,
|
||||
signal=recent.get('signal','waiting'),lastSeen=seen or None,position=position,expires=row['expires'],
|
||||
intervalSeconds=grant.get('intervalSeconds',300),nextUploadAt=(seen or recent.get('started',row['created']))+grant.get('intervalSeconds',300)))
|
||||
intervalSeconds=upload,sampleIntervalSeconds=sample,scheduleReason='sampling' if sampling and sample>upload else 'upload',
|
||||
nextSampleAt=next_sample,nextUploadAt=next_upload))
|
||||
return items
|
||||
|
||||
def snapshot(self,user):
|
||||
|
||||
Reference in New Issue
Block a user