Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions definehead.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd.
// SPDX-FileCopyrightText: 2022 - 2026 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: LGPL-3.0-or-later

Expand Down Expand Up @@ -31,7 +31,10 @@ enum EnrollStatus {
FaceEnrollFaceCovered,
FaceEnrollCancel,
FaceEnrollError,
FaceEnrollException
FaceEnrollException = 12,
// 13/14 由 deepin-authentication 内部使用(厂商断开/发起方断开),
// 因此摄像头未开启从 15 开始编号
FaceEnrollCameraNotEnabled = 15 // 摄像头未开启
};

enum VerifyStatus {
Expand All @@ -47,7 +50,10 @@ enum VerifyStatus {
FaceVerifyFaceCovered,
FaceVerifyCancel,
FaceVerifyError,
FaceVerifyException
FaceVerifyException = 12,
// 13/14 由 deepin-authentication 内部使用(厂商断开/发起方断开),
// 因此摄像头未开启从 15 开始编号
FaceVerifyCameraNotEnabled = 15 // 摄像头未开启
};

#endif // DEFINEHEAD_H
8 changes: 6 additions & 2 deletions doc/uos-biometric-authentication-service-interface.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,9 @@ UOS 并不关心实际上的生物特征数据内容,服务程序计算得出
FaceEnrollFaceCovered,
FaceEnrollCancel,
FaceEnrollError, // 认证失败
FaceEnrollException // 发生错误
FaceEnrollException, // 发生错误
// 13/14 由 deepin-authentication 内部使用(厂商断开/发起方断开)
FaceEnrollCameraNotEnabled = 15 // 摄像头未开启
};
```

Expand All @@ -125,7 +127,9 @@ UOS 并不关心实际上的生物特征数据内容,服务程序计算得出
FaceVerifyFaceCovered,
FaceVerifyCancel,
FaceVerifyError,
FaceVerifyException
FaceVerifyException,
// 13/14 由 deepin-authentication 内部使用(厂商断开/发起方断开)
FaceVerifyCameraNotEnabled = 15 // 摄像头未开启
};
```

Expand Down
92 changes: 54 additions & 38 deletions drivermanger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,13 @@

#include "drivermanger.h"
#include "modelmanger.h"
#include <sys/socket.h>

Check warning on line 7 in drivermanger.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <sys/socket.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <sys/types.h>

Check warning on line 8 in drivermanger.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <sys/types.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.

#include <DConfig>

Check warning on line 10 in drivermanger.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <DConfig> not found. Please note: Cppcheck does not need standard library headers to get proper results.

DCORE_USE_NAMESPACE

DriverManger::DriverManger()
: m_spCharaDataManger(new CharaDataManger)
, m_eroll(new QThread(this))
Expand All @@ -23,22 +27,17 @@
}
void DriverManger::init()
{
m_spFileWatch = QSharedPointer<QFileSystemWatcher>(new QFileSystemWatcher(this));
m_spErollthread = QSharedPointer<ErollThread>(new ErollThread());
m_spVerifyThread = QSharedPointer<VerifyThread>(new VerifyThread());
m_spCharaDataManger->loadCharaData();
// 监听相机隐私开关(dde-system-daemon 的 DConfig):FN 键/接口关闭摄像头时
// 第一时间结束正在进行的录入/验证,无需等看门狗轮询或设备从 Qt 列表消失
initCameraPrivacyWatch();
m_bClaim = false;
m_charalist = this->m_spCharaDataManger->getCharaList();
// 人脸能力与摄像头开关状态解耦:摄像头 FN 键关闭(设备消失)时仍上报人脸能力,
// 由控制中心始终展示生物认证(人脸)入口,实际操作时再上报摄像头未开启。
m_charaType = FACECHARATYPE;
m_spFileWatch->addPath("/dev/");

// 暂不支持热插拔
connect(m_spFileWatch.get(),
&QFileSystemWatcher::directoryChanged,
this,
&DriverManger::onDirectoryChanged);

onDirectoryChanged("/dev/");
m_spErollthread->moveToThread(m_eroll);
m_spVerifyThread->moveToThread(m_verify);
connect(m_spErollthread.data(), &ErollThread::processStatus, this, &DriverManger::processStatus);
Expand All @@ -48,6 +47,37 @@
qDebug() << "DriverManger::init thread:" << QThread::currentThreadId();
}

// 监听 dde-system-daemon 持久化的相机隐私开关(SetCameraPrivacy 写入的
// org.deepin.dde.daemon / org.deepin.dde.daemon.system / cameraPrivacyEnabled)。
// 开关打开时立即按“摄像头未开启”结束当前操作;DConfig 不可用(旧版本系统)时
// 静默跳过,仍由 GetCameraPrivacy 查询与运行期看门狗兜底。
void DriverManger::initCameraPrivacyWatch()
{
auto *config = DConfig::create(QStringLiteral("org.deepin.dde.daemon"),
QStringLiteral("org.deepin.dde.daemon.system"),
QString(), this);
if (!config || !config->isValid()) {
qWarning() << "camera privacy dconfig unavailable, fallback to watchdog";
return;
}

connect(config, &DConfig::valueChanged, this, [this, config](const QString &key) {
if (key != QStringLiteral("cameraPrivacyEnabled"))
return;
if (!config->value(key).toBool())
return;

qWarning() << "camera privacy switch on, abort active face action";
const auto actionIds = m_actionMap.keys();
for (const auto &actionId : actionIds) {
const auto actionType = m_actionMap.value(actionId).actionType;
const qint32 status = (actionType == Enroll) ? FaceEnrollCameraNotEnabled
: FaceVerifyCameraNotEnabled;
processStatus(actionId, status);
}
});
}

QDBusUnixFileDescriptor DriverManger::enrollStart(QString chara,
qint32 charaType,
QString actionId,
Expand Down Expand Up @@ -236,6 +266,14 @@
return;
}
auto &actionInfo = m_actionMap[actionId];
// DConfig 开关事件、看门狗与设备检测可能同时上报“摄像头未开启”,
// 每个操作只上报一次,避免重复结束同一操作
if (status == FaceEnrollCameraNotEnabled || status == FaceVerifyCameraNotEnabled) {
if (actionInfo.cameraNotEnabledReported) {
return;
}
actionInfo.cameraNotEnabledReported = true;
}
actionInfo.status = status;
if (faceChara != nullptr) {
actionInfo.faceChara = static_cast<float *>(
Expand Down Expand Up @@ -281,34 +319,6 @@
QDBusConnection::systemBus().send(signal);
}

void DriverManger::onDirectoryChanged(const QString &path)
{
qDebug() << "HandleFileChanged" << path;

QDir dir(path);
if (!dir.exists()) {
qDebug() << "dir " << path << "not exist";
return;
}

//获取filePath下所有系统文件
dir.setFilter(QDir::System);
QFileInfoList filelist = dir.entryInfoList();
bool bFound = false;
for (int i = 0; i < filelist.size(); i++) {
if (filelist[i].fileName().contains("video")) {
bFound = true;
break;
}
}

if (bFound) {
setCharaType(FACECHARATYPE);
} else {
setCharaType(EMPTYCHARATYPE);
}
}

QString DriverManger::getStatusMsg(ActionType actionType, qint32 status)
{
QString retMsg;
Expand Down Expand Up @@ -354,6 +364,9 @@
case FaceEnrollException:
retMsg = "Enroll Exception";
break;
case FaceEnrollCameraNotEnabled:
retMsg = "Enroll Camera Not Enabled";
break;
}
} else if (actionType == Verify) {
VerifyStatus tempStatus = VerifyStatus(status);
Expand Down Expand Up @@ -397,6 +410,9 @@
case FaceVerifyException:
retMsg = "Verify Exception";
break;
case FaceVerifyCameraNotEnabled:
retMsg = "Verify Camera Not Enabled";
break;
}
}

Expand Down
9 changes: 3 additions & 6 deletions drivermanger.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd.
// SPDX-FileCopyrightText: 2022 - 2026 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: LGPL-3.0-or-later

Expand All @@ -14,12 +14,11 @@
#include "seeta/FaceRecognizer.h"
#include "seeta/FaceTracker.h"
#include "seeta/QualityAssessor.h"
#include "seeta/QualityOfPoseEx.h"

Check warning on line 17 in drivermanger.h

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: "seeta/QualityOfPoseEx.h" not found.
#include "workmodule.h"

#include <QFileSystemWatcher>
#include <QSharedPointer>

Check warning on line 20 in drivermanger.h

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QSharedPointer> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QtDBus/QtDBus>

Check warning on line 21 in drivermanger.h

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QtDBus/QtDBus> not found. Please note: Cppcheck does not need standard library headers to get proper results.

#include <memory>

Expand All @@ -29,6 +28,7 @@
ActionType actionType;
float *faceChara;
int size;
bool cameraNotEnabledReported = false; // “摄像头未开启”是否已上报(DConfig 事件与看门狗去重)
};

struct ErrMsgInfo {
Expand Down Expand Up @@ -64,13 +64,11 @@
QStringList getCharaList();
void setCharaList(QStringList lCharaList);

private Q_SLOTS:
void onDirectoryChanged(const QString &path);

private:
QString getStatusMsg(ActionType actionType, qint32 status);
void emitPropertiesChanged(QVariantMap &qVariantMap);
void emitStatus(ActionType action, QString actionId, qint32 status, QString msg);
void initCameraPrivacyWatch();

private:
QSharedPointer<ErollThread> m_spErollthread;
Expand All @@ -80,7 +78,6 @@
bool m_bClaim; //是否被占用
qint32 m_charaType;
QStringList m_charalist;
QSharedPointer<QFileSystemWatcher> m_spFileWatch;
QThread *m_eroll;
QThread *m_verify;
};
Expand Down
Loading
Loading