Add missing null check to prevent system server crash
This bug was introduced in aosp/3342195 and can occur when calling
setEthernetEnabled() while ethernet tethering is enabled and the
tethering interface has disappeared.
Bug: 392912047
Test: TH
Change-Id: I4c4c2144558ad9057195ddcf30c055227f3fc62a
diff --git a/service-t/src/com/android/server/ethernet/EthernetTracker.java b/service-t/src/com/android/server/ethernet/EthernetTracker.java
index eedf427..bb7963e 100644
--- a/service-t/src/com/android/server/ethernet/EthernetTracker.java
+++ b/service-t/src/com/android/server/ethernet/EthernetTracker.java
@@ -958,7 +958,7 @@
new ArrayList<>(
List.of(mFactory.getAvailableInterfaces(/* includeRestricted */ true)));
- if (mTetheringInterfaceMode == INTERFACE_MODE_SERVER) {
+ if (mTetheringInterfaceMode == INTERFACE_MODE_SERVER && mTetheringInterface != null) {
interfaces.add(mTetheringInterface);
}