I just wanna begin by saying that I have no real knowledge of cameras, so this might be a stupid question. But how do smartphone cameras know they are in focus? I would assume that if you told a camera to focus on a point in space, that it would need to know how far away that point is from the camera. Is this true? And if so, how do smartphones focus? Do they use depth sensors? If im completely wrong in my assumption then what methods do smartphones use to focus?
The vast majority of smartphones that can change the focus distance use contrast detection autofocus.
With contrast detection AF: The focus is moved and the camera compares the amount of contrast on the selected portions of the imaging sensor at the first position to the amount contrast at the second position. It continues to do this until it finds the point at which it moves past greatest contrast and the contrast begins to be reduced by further travel in the same direction. It then returns the focus position to the point of greatest contrast.