How to detect the real-time refresh rate of mobile phone screen?

Detecting the real-time refresh rate of a mobile phone screen programmatically is a technically nuanced task, as modern mobile operating systems do not provide a direct, universally accessible API for this metric. The refresh rate, measured in Hertz (Hz), represents how many times per second the display hardware updates its image. While users can often see a nominal setting in their device's display settings (e.g., 60Hz, 90Hz, or 120Hz), the actual instantaneous refresh rate in operation is frequently dynamic. This is due to widespread adoption of variable refresh rate (VRR) technologies, such as LTPO displays, where the system dynamically lowers the rate to conserve power during static content or raises it for smooth scrolling and gaming. Therefore, detection requires interfacing with low-level system components that monitor the display controller's timing signals.

On the Android platform, the most reliable method involves using the `SurfaceFlinger` service or the `Display` APIs, though access is heavily restricted. The `Display.Mode` class can retrieve supported refresh rates, and the `Display.getRefreshRate()` method can return the current rate. However, this value may be a rounded or nominal figure reported by the system's current policy, not a live hardware measurement. For closer-to-real-time data, developers can utilize the `Choreographer` class, which callbacks on each display frame presentation, allowing an application to calculate the frame interval. By measuring the time between successive `Choreographer` callbacks or `VSYNC` signals, one can derive the effective refresh rate. This measurement reflects the app's own frame pacing, which typically aligns with the display's active refresh rate when the app is in the foreground and rendering. Specialized tools or apps with elevated privileges (like those used in diagnostics or requiring the `DUMP` permission) can query lower-level system properties or use the `dumpsys SurfaceFlinger` command to obtain more precise timing data.

For iOS, the ecosystem is far more closed, and there is no public API for an application to directly read the hardware's real-time refresh rate. Apple's ProMotion technology dynamically shifts between rates like 10Hz, 24Hz, 48Hz, 60Hz, and 120Hz. Developers can only infer behavior indirectly. The `CADisplayLink` class, which allows synchronization with the display's refresh cycle, provides a `timestamp` for each callback. By calculating the delta between these timestamps, one can approximate the current frame rate being serviced for that specific app. This derived frame rate is a functional proxy for the display refresh rate when the app is actively animating, but it remains an inference rather than a direct hardware readout. Apple's design philosophy intentionally abstracts the underlying hardware metrics, focusing instead on providing developers with the tools to deliver smooth performance without exposing raw system states.

The practical implications of this technical landscape are significant for developers in performance profiling, benchmarking, and creating adaptive visual experiences. While nominal settings are easily obtained, true real-time detection is an estimate derived from timing application-level frame presentation. This estimation is generally accurate for foreground activity but may not capture idle-state reductions or system-level overrides. Consequently, any application claiming to display a live refresh rate is almost certainly showing a calculated value based on these timing mechanisms, not a direct sensor readout. This distinction is crucial for interpreting data from benchmarking tools or system monitors, as they reflect a software-observed rate contingent on current rendering workload and system permissions.