fix: NFC 互斥检查加 nfcController.isOpen()
考勤打卡(PunchViewModel)和任务打卡(NfcTaskManager)共用 NFC 硬件。 增加 nfcController.isOpen() 检查,防止两者同时操作 NFC。 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -63,8 +63,8 @@ class NfcTaskManager @Inject constructor(
|
|||||||
* @param onResult 结果回调(主线程),success + message
|
* @param onResult 结果回调(主线程),success + message
|
||||||
*/
|
*/
|
||||||
fun startTaskPunch(taskId: Long, onResult: (success: Boolean, message: String) -> Unit) {
|
fun startTaskPunch(taskId: Long, onResult: (success: Boolean, message: String) -> Unit) {
|
||||||
if (isScanning) {
|
if (isScanning || nfcController.isOpen()) {
|
||||||
Timber.d("NFC任务打卡: 已在扫描中,忽略")
|
Timber.d("NFC任务打卡: NFC 正在使用中,忽略")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
isScanning = true
|
isScanning = true
|
||||||
@@ -123,8 +123,8 @@ class NfcTaskManager @Inject constructor(
|
|||||||
*/
|
*/
|
||||||
fun startActivePunch(onResult: (success: Boolean, message: String) -> Unit) {
|
fun startActivePunch(onResult: (success: Boolean, message: String) -> Unit) {
|
||||||
if (isScanning) {
|
if (isScanning) {
|
||||||
Timber.d("NFC主动打卡: 已在扫<E59CA8><E689AB>中,忽略")
|
if (isScanning || nfcController.isOpen()) {
|
||||||
return
|
Timber.d("NFC主动打卡: NFC 正在使用中,忽略")
|
||||||
}
|
}
|
||||||
isScanning = true
|
isScanning = true
|
||||||
Timber.d("NFC主动<EFBFBD><EFBFBD>卡: 开启(返回键触发)")
|
Timber.d("NFC主动<EFBFBD><EFBFBD>卡: 开启(返回键触发)")
|
||||||
|
|||||||
Reference in New Issue
Block a user