OSDN Git Service

Wifi details: minor ordering fixes.
authorLorenzo Colitti <lorenzo@google.com>
Sun, 4 Jun 2017 14:15:40 +0000 (23:15 +0900)
committerLorenzo Colitti <lorenzo@google.com>
Tue, 6 Jun 2017 02:39:17 +0000 (11:39 +0900)
commit088215d8772c5129de299076f093cc7f0143e327
tree79352513ec57cde4dc9eb12a074955b97b6a684b
parent2561df808328f78f18b3fa0c936fa09ffc91e2c2
Wifi details: minor ordering fixes.

1. Set mNetwork before the NetworkCallbacks can be delivered.
   Previously, the code would set mNetwork in updateInfo, relying
   on the fact that the BroadcastReceiver registered in onResume
   is immediately invoked. However, this races with the
   callbacks, which are also immediately invoked. If the
   callbacks won the race, mNetwork would not be set and they
   would be ignored.

2. Call updateInfo in onResume instead of in displayPreference.
   This ensures that it's always called exactly once before the
   activity starts running, regardless of whether it's being
   displayed the first time (i.e., after onStart) or resumed
   by switching from another app. displayPreference is only
   called in the former case.

3. Don't call getLinkProperties and getNetworkCapabilities in
   updateInfo. These calls are superfluous, because this
   information is update by the NetworkCallbacks, and they can
   cause jank because updateInfo is called on the UI thread.

This requires that the tests be changed so they always call
onResume, since no UI elements are populated until onResume is
called.

Bug: 62209358
Test: make -j64 RunSettingsRoboTests
Change-Id: Iccb1b9ae51188755d890a6df83004dbe9bec565e
src/com/android/settings/wifi/details/WifiDetailPreferenceController.java
tests/robotests/src/com/android/settings/wifi/details/WifiDetailPreferenceControllerTest.java