We use a method called sleep actigraphy and there are several scientific papers which show that it is not as precise as PSG but still provides reasonable data and more over it is more convenient for the user. The phone has an accelerometer sensor build in which is very sensitive and if placed in your bed we have a record of your movement over the nigh. In deep sleep your muscular movements are suppressed (otherwise you would be running or jumping around according to your dreams :)) and thus in this phase the sleep graph gets nearly flat. This is in short how we measure your sleep phases, for more details refer to 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