Optimize DeviceFoldStateProvider#onHingeAngle

isClosingThresholdMet calculation turn out to cause some binder transaction to know if the current top task is home activity. As it is very rarely used, it is now moved to the last position of the AND chain.

Instead of querying ActivityManager each time, now a listener is registered for top task changes.

This removes many useless binder transactions (but adds a binder transaction when DeviceFoldStateProvider is initialized)

Test: DeviceFoldStateProviderTest
Bug: 265666399
Change-Id: I9b44d7409261882a3b72ad5d7f5eb44a2eb3c2b1
3 files changed