@@ -153,7 +153,7 @@ private static void createDevicesTable(final SQLiteConnection conn) throws SQLit
153153 "pinnedAppVersion INTEGER NOT NULL,\n " +
154154 "pinnedSecurityLevel INTEGER NOT NULL,\n " +
155155 "userProfileSecure INTEGER NOT NULL CHECK (userProfileSecure in (0, 1)),\n " +
156- "enrolledFingerprints INTEGER NOT NULL CHECK (enrolledFingerprints in (0, 1)),\n " +
156+ "enrolledBiometrics INTEGER NOT NULL CHECK (enrolledBiometrics in (0, 1)),\n " +
157157 "accessibility INTEGER NOT NULL CHECK (accessibility in (0, 1)),\n " +
158158 "deviceAdmin INTEGER NOT NULL CHECK (deviceAdmin in (0, 1, 2)),\n " +
159159 "adbEnabled INTEGER NOT NULL CHECK (adbEnabled in (0, 1)),\n " +
@@ -215,7 +215,7 @@ public static void main(final String[] args) throws Exception {
215215
216216 final SQLiteStatement selectCreated = attestationConn .prepare ("SELECT 1 FROM sqlite_master WHERE type='table' AND name='Configuration'" );
217217 if (!selectCreated .step ()) {
218- attestationConn .exec ("PRAGMA user_version = 3 " );
218+ attestationConn .exec ("PRAGMA user_version = 4 " );
219219 }
220220 selectCreated .dispose ();
221221
@@ -322,6 +322,25 @@ public static void main(final String[] args) throws Exception {
322322 attestationConn .exec ("PRAGMA foreign_keys = ON" );
323323 }
324324
325+ // rename enrolledFingerprints to enrolledBiometrics
326+ if (userVersion == 3 ) {
327+ attestationConn .exec ("PRAGMA foreign_keys = OFF" );
328+ attestationConn .exec ("BEGIN TRANSACTION" );
329+ attestationConn .exec ("ALTER TABLE Devices RENAME TO DevicesOld" );
330+ createDevicesTable (attestationConn );
331+ attestationConn .exec ("INSERT INTO Devices " +
332+ "(fingerprint, pinnedCertificate0, pinnedCertificate1, pinnedCertificate2, pinnedCertificate3, pinnedVerifiedBootKey, verifiedBootHash, pinnedOsVersion, pinnedOsPatchLevel, pinnedVendorPatchLevel, pinnedBootPatchLevel, pinnedAppVersion, pinnedSecurityLevel, userProfileSecure, enrolledBiometrics, accessibility, deviceAdmin, adbEnabled, addUsersWhenLocked, denyNewUsb, oemUnlockAllowed, systemUser, verifiedTimeFirst, verifiedTimeLast, expiredTimeLast, failureTimeLast, userId, deletionTime) " +
333+ "SELECT " +
334+ "fingerprint, pinnedCertificate0, pinnedCertificate1, pinnedCertificate2, pinnedCertificate3, pinnedVerifiedBootKey, verifiedBootHash, pinnedOsVersion, pinnedOsPatchLevel, pinnedVendorPatchLevel, pinnedBootPatchLevel, pinnedAppVersion, pinnedSecurityLevel, userProfileSecure, enrolledFingerprints, accessibility, deviceAdmin, adbEnabled, addUsersWhenLocked, denyNewUsb, oemUnlockAllowed, systemUser, verifiedTimeFirst, verifiedTimeLast, expiredTimeLast, failureTimeLast, userId, deletionTime " +
335+ "FROM DevicesOld" );
336+ attestationConn .exec ("DROP TABLE DevicesOld" );
337+ createDevicesIndices (attestationConn );
338+ attestationConn .exec ("PRAGMA user_version = 4" );
339+ userVersion = 4 ;
340+ attestationConn .exec ("END TRANSACTION" );
341+ attestationConn .exec ("PRAGMA foreign_keys = ON" );
342+ }
343+
325344 logger .info ("New schema version: " + userVersion );
326345
327346 logger .info ("Analyze database" );
@@ -1058,7 +1077,7 @@ private static void writeDevicesJson(final HttpExchange exchange, final long use
10581077 "(SELECT hex(verifiedBootHash) where verifiedBootHash IS NOT NULL), " +
10591078 "pinnedOsVersion, pinnedOsPatchLevel, pinnedVendorPatchLevel, " +
10601079 "pinnedBootPatchLevel, pinnedAppVersion, pinnedSecurityLevel, " +
1061- "userProfileSecure, enrolledFingerprints , accessibility, deviceAdmin, " +
1080+ "userProfileSecure, enrolledBiometrics , accessibility, deviceAdmin, " +
10621081 "adbEnabled, addUsersWhenLocked, denyNewUsb, oemUnlockAllowed, " +
10631082 "systemUser, verifiedTimeFirst, verifiedTimeLast " +
10641083 "FROM Devices WHERE userId is ? AND deletionTime IS NULL " +
0 commit comments