Skip to content
Commit bc8dbe12 authored by Riddle Hsu's avatar Riddle Hsu
Browse files

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
parent 26ef4c4c
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment