Switching from Priority Apps to None would still show the icons of the priority apps. There were several minor things wrong: * We were keeping the AppSession when a mode switches from "priority apps" to "none", and because onResume always fires the callback, we were loading the icons. * Even when deactivating the session, its own onResume lifecycle listener was still firing one extra time, before we had a chance to deactivate it. Also two minor improvements to CircularIconsPreference: * Update mLoadedIcons when we early exit due to mIconSet having no items. Mostly for testing, since the icons wouldn't be visible anyway. * Use notifyChanged() when we get a measured view, instead of holding a reference to the view. Technically the previous code violated the "shouldn't keep references to views outside of onBindViewHolder" (although I didn't see this having an effect in practice). Fixes: 360077747 Test: atest ZenModeAppsLinkPreferenceControllerTest Flag: android.app.modes_ui Change-Id: I6d4b7a344542da46f5ebfcd0774f1af27ed113ac
Running Settings Robolectric tests
The full suite
$ croot
$ atest SettingsRoboTests
Running a single test class
With a filter
$ croot
$ atest SettingsRoboTests:com.android.settings.display.AdaptiveSleepPreferenceControllerTest
You can also run any single test class with atest (it will try to find the correct path)
$ atest AdaptiveSleepPreferenceControllerTest