We use a method called sleep actigraphy and there are several scientific papers that show that it is not as accurate as PSG but still provides reasonable data and moreover it is more convenient for the user (no need for expensive devices). The phone has an accelerometer sensor built in which is very sensitive and when placed in your bed we have a record of your movements over the night. In deep sleep your muscular movements are suppressed and so in this phase the sleep graph becomes almost flat. This is in short how we measure your sleep phases, for more details see How it works.
This is a companion discussion topic for the original entry at https://docs.sleep.urbandroid.org/faqs/how_sleep_phases_estimation_work.html