The question presupposes that there are only two options—that he was talking to the real Samuel or to a demon. We don’t know the answer to that question. All we know clearly from Scripture is that what Saul was doing was absolutely forbidden by God because it was an example of the act of necromancy, of trying to communicate with the dead.
It is not clear whether the witch of En-dor was a magician like some people who do séances today and imitate the voices and figures of those who have passed on, whether it was a demon doing a false work that the devil does of lying signs and wonders, or whether it was actually Samuel who was called up from the dead in opposition to the explicit prohibition of God. We don’t know the answer.