Class ComparableBackup

  • All Implemented Interfaces:
    org.signal.libsignal.internal.NativeHandleGuard.Owner

    
    public class ComparableBackup
    extends NativeHandleGuard.SimpleOwner
                        

    An in-memory representation of a backup file used to compare contents.

    When comparing the contents of two backups:

    • Create a `ComparableBackup` instance for each of the inputs.
    • Check the `unknownFields()` value; if it's not empty, some parts of the backup weren't parsed and won't be compared.
    • Produce a canonical string for each backup with `comparableString()`.
    Compare the canonical string representations. The diff of the canonical strings (which may be rather large) will show the differences between the logical content of the input backup files.
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
    • Field Summary

      Fields 
      Modifier and Type Field Description
    • Constructor Summary

      Constructors 
      Constructor Description
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
    • Method Summary

      Modifier and Type Method Description
      static ComparableBackup readUnencrypted(MessageBackup.Purpose purpose, InputStream input, long streamLength) Reads an unencrypted message backup bundle into memory for comparison.
      String getComparableString() Produces a string representation of the contents.
      Array<String> getUnknownFieldMessages() Returns the unrecognized protobuf fields present in the backup.
      • Methods inherited from class org.signal.libsignal.internal.NativeHandleGuard.SimpleOwner

        unsafeNativeHandleWithoutGuard
      • Methods inherited from class org.signal.libsignal.internal.NativeHandleGuard.Owner

        guard, guardedMap, guardedMapChecked, guardedRun, guardedRunChecked
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

    • Method Detail

      • readUnencrypted

         static ComparableBackup readUnencrypted(MessageBackup.Purpose purpose, InputStream input, long streamLength)

        Reads an unencrypted message backup bundle into memory for comparison.

        Returns an error if the input cannot be read or if validation fails.

        Parameters:
        purpose - whether the input was created for device-to-device transfer or remote backup
        input - an InputStream that produces the input
        streamLength - the number of bytes each InputStream will produce
      • getComparableString

         String getComparableString()

        Produces a string representation of the contents.

        The returned strings for two backups will be equal if the backups contain the same logical content. If two backups' strings are not equal, the diff will show what is different between them.

        Returns:

        a canonical string representation of the backup

      • getUnknownFieldMessages

         Array<String> getUnknownFieldMessages()

        Returns the unrecognized protobuf fields present in the backup.

        If the returned array is not empty, some parts of the backup were not recognized and won't be present in the string representation.

        Returns:

        information about each unknown field found in the backup