class TertiaryKeysTable {

    public Map<String, TertiaryKey> getAllKeys(String secondaryKeyAlias)
            throws EncryptionDbException {
        SQLiteDatabase db = mHelper.getReadableDatabaseSafe();
        String[] projection = {
            TertiaryKeysEntry._ID,
            TertiaryKeysEntry.COLUMN_NAME_SECONDARY_KEY_ALIAS,
            TertiaryKeysEntry.COLUMN_NAME_PACKAGE_NAME,
            TertiaryKeysEntry.COLUMN_NAME_WRAPPED_KEY_BYTES
        };
        String selection = TertiaryKeysEntry.COLUMN_NAME_SECONDARY_KEY_ALIAS + " = ?";
        String[] selectionArguments = {secondaryKeyAlias};

        Map<String, TertiaryKey> keysByPackageName = new ArrayMap<>();
        try (Cursor cursor =
                db.query(
                        TertiaryKeysEntry.TABLE_NAME,
                        projection,
                        selection,
                        selectionArguments,
                        /*groupBy=*/ null,
                        /*having=*/ null,
                        /*orderBy=*/ null)) {
            while (cursor.moveToNext()) {
                String packageName =
                        cursor.getString(
                                cursor.getColumnIndexOrThrow(
                                        TertiaryKeysEntry.COLUMN_NAME_PACKAGE_NAME));
                byte[] wrappedKeyBytes =
                        cursor.getBlob(
                                cursor.getColumnIndexOrThrow(
                                        TertiaryKeysEntry.COLUMN_NAME_WRAPPED_KEY_BYTES));
                keysByPackageName.put(
                        packageName,
                        new TertiaryKey(secondaryKeyAlias, packageName, wrappedKeyBytes));
            }
        }
        return Collections.unmodifiableMap(keysByPackageName);
    }

      TertiaryKeysTable(BackupEncryptionDbHelper helper);

}