From 85392343fa393054ddd3446aa38c3be941eb02c5 Mon Sep 17 00:00:00 2001 From: Linus Torvalds Date: Sat, 18 Sep 2021 18:52:50 -0700 Subject: Re-do the libdivecomputer fingerprint save/load code This tries to make our fingerprinting code work better, by avoiding using the "deviceid" field that has always been unreliable because we've calculated it multiple different ways, and even for the same version of subsurface, it ends up changing in the middle (ie we calculate one value initially, then re-calculate it when we have a proper serial number string). So instead, the fingerprinting code will look up and save the fingerprint file using purely "stable" information that is available early during the download: - the device model name (which is a string with vendor and product name separated by a space) - the DC_EVENT_DEVINFO 32-bit 'serial' number (which is not necessarily a real serial number at all, but hopefully at least a unique number for the particular product) but because the model name is not necessarily a good filename (think slashes and other possibly invalid characters), we hash that model name and use the resulting hex number in the fingerprint file name. This way the fingerprint file is unambiguous at load and save time, and depends purely on libdivecomputer data. But because we also need to verify that we have the actual _dive_ associated with that fingerprint, we also need to save the final deviceid and diveid when saving the fingerprint file, so that when we load it again we can look up the dive and verify that we have it before we use the fingerprint data. To do that, the fingerprint file itself contains not just the fingerprint data from libdivecomputer, but the last 8 bytes of the file are the (subsurface) deviceid and the diveid of the dive that is associated with the fingerprint. Signed-off-by: Linus Torvalds --- mobile-widgets/qmlmanager.cpp | 10 ---------- mobile-widgets/qmlmanager.h | 4 ---- 2 files changed, 14 deletions(-) (limited to 'mobile-widgets') diff --git a/mobile-widgets/qmlmanager.cpp b/mobile-widgets/qmlmanager.cpp index 313e3fcb5..41be77f59 100644 --- a/mobile-widgets/qmlmanager.cpp +++ b/mobile-widgets/qmlmanager.cpp @@ -1892,16 +1892,6 @@ bool QMLManager::DC_saveDump() const return DCDeviceData::instance()->saveDump(); } -int QMLManager::DC_deviceId() const -{ - return DCDeviceData::instance()->deviceId(); -} - -void QMLManager::DC_setDeviceId(int deviceId) -{ - DCDeviceData::instance()->setDeviceId(deviceId); -} - void QMLManager::DC_setVendor(const QString& vendor) { DCDeviceData::instance()->setVendor(vendor); diff --git a/mobile-widgets/qmlmanager.h b/mobile-widgets/qmlmanager.h index 89fdce323..e43c666ec 100644 --- a/mobile-widgets/qmlmanager.h +++ b/mobile-widgets/qmlmanager.h @@ -48,7 +48,6 @@ class QMLManager : public QObject { Q_PROPERTY(bool DC_forceDownload READ DC_forceDownload WRITE DC_setForceDownload NOTIFY DC_ForceDownloadChanged) Q_PROPERTY(bool DC_bluetoothMode READ DC_bluetoothMode WRITE DC_setBluetoothMode) Q_PROPERTY(bool DC_saveDump READ DC_saveDump WRITE DC_setSaveDump) - Q_PROPERTY(int DC_deviceId READ DC_deviceId WRITE DC_setDeviceId) Q_PROPERTY(QString pluggedInDeviceName MEMBER m_pluggedInDeviceName NOTIFY pluggedInDeviceNameChanged) Q_PROPERTY(bool showNonDiveComputers MEMBER m_showNonDiveComputers WRITE setShowNonDiveComputers NOTIFY showNonDiveComputersChanged) Q_PROPERTY(qPrefCloudStorage::cloud_status oldStatus MEMBER m_oldStatus WRITE setOldStatus NOTIFY oldStatusChanged) @@ -101,9 +100,6 @@ public: bool DC_saveDump() const; void DC_setSaveDump(bool dumpMode); - int DC_deviceId() const; - void DC_setDeviceId(int deviceId); - QString getUndoText() const; QString getRedoText() const; -- cgit v1.2.3-70-g09d2