The appearance of being closed/open is a light trick; light reflecting off the tiny transparent window of the missile launch detector.
This detector typically sees in IR and would detect the plume of a heat-seeking missile. According to Wikipedia, the model used on the F-22 is AN/AAR-56 (IR based). (There are videos available on YouTube for its output; example.)
In the below cutaway, it's label number 7. Note it says windows, so I suppose there's more than one for the different angles (after some eye strain I couldn't find another 7).

Source: pinterest.com
The F-35 uses the AN/AAQ-37, below are the various locations:

Source: daumcdn.net (Korean)