I expanded the trigger SQL a bit. The app that checks the attestation state (GMS toolbox by
@Freshek) is looking at a different table in a different db (Wallets in android_pay) as opposed to the method by
@BostonDan which is looking at main in dg.db.
So I created triggers for both tables. There's 2 sql files in the attached zip file. One will set any non-zero attestation values to zero and also create both insert and update triggers for both tables.
The second file drops (removes) the triggers from both tables, but doesn't change any values.
This solution doesn't need any permission changes and should, in theory, be good for any updates going forward - unless they change the table structure. If it works it's apply and forget.
I strongly recommend using the Magisk Mod for SQLite. To apply these files feed them into the sqlite3 binary. Assuming you have them in the root of sdcard, and using attest.sql as the example just run, as root
Code:
sqlite3 < /sdcard/attest.sql
If you've already applied the previous files I posted these won't hurt anything, you can apply these over those with no problems. Contents of attest.sql
Code:
.open /data/data/com.google.android.gms/databases/dg.db
UPDATE main SET c='0' WHERE a LIKE '%attest%';
CREATE TRIGGER IF NOT EXISTS attestation_insert AFTER INSERT
ON main WHEN (NEW.a LIKE '%attest%' AND NEW.c <> 0)
BEGIN
UPDATE main SET c = 0 WHERE ROWID = NEW.ROWID;
END;
CREATE TRIGGER IF NOT EXISTS attestation_update AFTER UPDATE OF c
ON main WHEN (OLD.a LIKE '%attest%' AND NEW.c <> 0)
BEGIN
UPDATE main SET c = 0 WHERE ROWID = OLD.ROWID;
END;
.schema main
.open /data/data/com.google.android.gms/databases/android_pay
UPDATE Wallets SET fails_attestation=0 WHERE fails_attestation <> 0;
CREATE TRIGGER IF NOT EXISTS fails_attestation_insert AFTER INSERT
ON Wallets WHEN (NEW.fails_attestation <> 0)
BEGIN
UPDATE Wallets SET fails_attestation = 0 WHERE ROWID = NEW.ROWID;
END;
CREATE TRIGGER IF NOT EXISTS fails_attestation_update AFTER UPDATE OF fails_attestation
ON Wallets WHEN (NEW.fails_attestation <> 0)
BEGIN
UPDATE Wallets SET fails_attestation = 0 WHERE ROWID = OLD.ROWID;
END;
.schema Wallets
.quit
Contents of drop_attest.sql
Code:
.open /data/data/com.google.android.gms/databases/dg.db
DROP TRIGGER IF EXISTS attestation_insert;
DROP TRIGGER IF EXISTS attestation_update;
.schema main
.open /data/data/com.google.android.gms/databases/android_pay
DROP TRIGGER IF EXISTS fails_attestation_insert;
DROP TRIGGER IF EXISTS fails_attestation_update;
.schema Wallets
.quit