Fix issue where NOT_VISIBLE state is sometimes not logged
This happens because ActivityMetricsLogger#notifyActivityRemoved is sometimes called before ActivityMetricsLogger#logAppCompatState is called from ActivityRecord#setVisibleRequested. The solution is to keep the correct lastLoggedState and just mark the lastLoggedActivity as null when the activity is removed.
In addition, avoid logging the same state twice when an activity becomes invisible while there is another visible activity with the same state for the same package UID.
Note that these changes will be tested in a CTS test that will be added
in a follow up.
Fix: 203417779
Fix: 203506108
Test: atest WmTests:SizeCompatTests
Change-Id: I056584fc234a605bc0d39ac24f430e969ffc86ee
1 file changed