하교 처리 후 무단반출 오탐 버그 수정 + 앱 버전 1.1.3
- 조도 센서가 폰 반출을 감지하면, 위반 경고를 울리기 전에 서버에 반출 허용 상태(하교/허용시간대)를 먼저 확인 - 허용된 상태면 위반 경고 없이 조용히 정상 회수로 처리
This commit is contained in:
@@ -112,6 +112,30 @@ void onPocketWatchServiceStart(ServiceInstance service) {
|
||||
}
|
||||
}
|
||||
|
||||
/// 하교 처리/반출 허용 시간대라면 조용히 감시만 종료하고, 아니면 위반으로 경고한다.
|
||||
Future<void> handlePhoneRemoved() async {
|
||||
bool isPermitted = false;
|
||||
try {
|
||||
final res = await http.get(
|
||||
Uri.parse("$baseUrl/api/permissions/check?studentId=$studentId"),
|
||||
);
|
||||
if (res.statusCode == 200) {
|
||||
final data = jsonDecode(utf8.decode(res.bodyBytes));
|
||||
isPermitted = data['permitted'] == true;
|
||||
}
|
||||
} catch (_) {
|
||||
isPermitted = false; // 네트워크 오류 시엔 안전하게 위반으로 처리
|
||||
}
|
||||
|
||||
if (isPermitted) {
|
||||
updateNotification("✅ 폰 회수 완료", "[$pocketNumber] 주머니에서 정상적으로 회수되었습니다.");
|
||||
service.invoke('checked_out', {"pocketNumber": pocketNumber});
|
||||
service.stopSelf();
|
||||
} else {
|
||||
reportViolation();
|
||||
}
|
||||
}
|
||||
|
||||
void onLightReading(int luxValue) {
|
||||
if (violated) return;
|
||||
|
||||
@@ -129,7 +153,7 @@ void onPocketWatchServiceStart(ServiceInstance service) {
|
||||
if (luxValue > baselineLux! + _luxJumpThreshold) {
|
||||
violated = true;
|
||||
lightSub?.cancel();
|
||||
reportViolation();
|
||||
handlePhoneRemoved();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user