code: static int compareSignature(Signature[] signatures1, Signature[] signatures2) {
      if (signatures1 == null) {
        return (signatures2 == null) ? SIGNATURE_NEITHER_SIGNED : SIGNATURE_FIRST_NOT_SIGNED;
      }
      if (signatures2 == null) {
        return SIGNATURE_SECOND_NOT_SIGNED;
      }
      if (signatures1.length != signatures2.length) {
        return SIGNATURE_NO_MATCH;
      }
      HashSet<Signature> signatures1set = new HashSet<>(asList(signatures1));
      HashSet<Signature> signatures2set = new HashSet<>(asList(signatures2));
      return signatures1set.equals(signatures2set) ? SIGNATURE_MATCH : SIGNATURE_NO_MATCH;
    }
docs: From com.android.server.pm.PackageManagerService.compareSignatures().