Merge "[Provider Model] Fix settings crash issue" into sc-dev
diff --git a/src/com/android/settings/network/InternetUpdater.java b/src/com/android/settings/network/InternetUpdater.java
index dd70cef..cb8d32c 100644
--- a/src/com/android/settings/network/InternetUpdater.java
+++ b/src/com/android/settings/network/InternetUpdater.java
@@ -20,6 +20,7 @@
 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 @@
         mContext.unregisterReceiver(mWifiStateReceiver);
     }
 
+    /** @OnLifecycleEvent(ON_DESTROY) */
+    @OnLifecycleEvent(ON_DESTROY)
+    public void onDestroy() {
+        mAirplaneModeEnabler.close();
+    }
+
     @Override
     public void onAirplaneModeChanged(boolean isAirplaneModeOn) {
         fetchActiveNetwork();
diff --git a/tests/unit/src/com/android/settings/network/InternetUpdaterTest.java b/tests/unit/src/com/android/settings/network/InternetUpdaterTest.java
index d61ca00..5ab2ce0 100644
--- a/tests/unit/src/com/android/settings/network/InternetUpdaterTest.java
+++ b/tests/unit/src/com/android/settings/network/InternetUpdaterTest.java
@@ -108,6 +108,13 @@
     }
 
     @Test
+    public void onDestroy_shouldCloseCallback() {
+        mInternetUpdater.onDestroy();
+
+        verify(mAirplaneModeEnabler).close();
+    }
+
+    @Test
     public void updateInternetAvailable_wifiConnectedAndNoValidated_internetUnavailable() {
         final NetworkCapabilities networkCapabilities = new NetworkCapabilities.Builder()
                 .addTransportType(TRANSPORT_WIFI)