Add lazy evaluation for getWindowInsets()
It is very common that apps call windowManager.getCurrentWindowMetrics().getBounds(); windowManager.getMaximumWindowMetrics().getBounds(); without calling WindowMetrics#getWindowInsets(). Then the heavy operations IWindowManager#getWindowInsets and InsetsState#calculateInsets are wasteful. This change makes the calculation only be called if WindowMetrics#getWindowInsets() is called. Though it may make the result invalid if the interval between creating WindowMetrics and calling getWindowInsets() is long, the common usage should get the result immediately instead of storing the WindowMetrics and get the outdated state later. Bug: 151908239 Test: atest android.view.WindowMetricsTest Change-Id: I28230adcdf004eed60a9fcd4481639f5c04b7c2c
Loading
Please register or sign in to comment