[Provider Model] Fix settings crash issue

- The GlobalSettingsChangeListener needs to be closed after the life
cycle is destroyed

Bug: 185756174
Bug: 186404332
Bug: 186591527
Test: manual test
atest -c InternetUpdaterTest

Change-Id: I9fbad3b303055c6c7a61ccad8efe69cefef56c58
This commit is contained in:
Weng Su
2021-05-06 05:48:20 +08:00
parent b4a9916adf
commit 88cafbaa24
2 changed files with 14 additions and 0 deletions

View File

@@ -20,6 +20,7 @@ import static android.net.NetworkCapabilities.TRANSPORT_CELLULAR;
import static android.net.NetworkCapabilities.TRANSPORT_ETHERNET;
import static android.net.NetworkCapabilities.TRANSPORT_WIFI;
import static androidx.lifecycle.Lifecycle.Event.ON_DESTROY;
import static androidx.lifecycle.Lifecycle.Event.ON_PAUSE;
import static androidx.lifecycle.Lifecycle.Event.ON_RESUME;
@@ -191,6 +192,12 @@ public class InternetUpdater implements AirplaneModeEnabler.OnAirplaneModeChange
mContext.unregisterReceiver(mWifiStateReceiver);
}
/** @OnLifecycleEvent(ON_DESTROY) */
@OnLifecycleEvent(ON_DESTROY)
public void onDestroy() {
mAirplaneModeEnabler.close();
}
@Override
public void onAirplaneModeChanged(boolean isAirplaneModeOn) {
fetchActiveNetwork();