Sensors that measure air quality by detecting various particles in the ether are either too small to be accurate, or too bulky to fit in a smartphone. Samsung, however, has patented a so-called "environmental sensor" that is combining the best of both worlds by creating one that is small enough to get into the next flagship Galaxy phone, yet returns sufficiently credible readings.
How did Samsung achieve this? It flattened the sensor, and managed to incorporate it into the display substrate. Thus, while having a bit larger footprint than stacked sensors, the new one manages to be of a suitable smartphone component height. The contraption can measire different size and amount of harmful particles in the air, though how ecatly air will reach the display's glass or plastic (in the case of flexible AMOLEDs) substrate itself, remains to be seen.
There's no guarantee that we will see an air quality warning system as soon as the Galaxy S9, of course, but usually with Samsung when the patents for these things are posted for public view, their launch in a retail device is not far away. After all, the application for the patent has been done a year and a half ago, and Samsung is no stranger to employing various barometer and UV sensors in its flagships.