Fix bucket change issues.

1. Prevent invalid state when tests call a method written for tests. The
   test method (forceIdleState) would force the app into the RARE
   bucket, regardless of the app's exemption status. However, on actual
   devices, the app's min bucket is taken into account before the bucket
   is changed. Change the test method to also consider the min bucket
   before changing the app's bucket.
2. Actually notify app standby listeners when the bucket changes in all
   instances.
3. Tell batterystats when an app is forced into idle. Previously, we
   were only ever telling batterystats when an app is no longer idle, so
   batterystats was never told when an app became idle.

Bug: 162862794
Bug: 227993380
Test: atest --rerun-until-failure 100 com.android.cts.net.HostsideRestrictBackgroundNetworkTests --use-modules-in
Change-Id: If517c1b3063af6758ab7a7a4cf7f1f67decba90c
2 files changed