Check wifi feature before starting wifi service

Otherwise, Wifi service could crash SystemServer;
for example, on emulator system image where wifi
feature is missing, starting wifi will cause boot
failure.

BUG: 70378659

Change-Id: I82546c2c63fb6736e8216a7942fba2d3c9affb13
diff --git a/services/java/com/android/server/SystemServer.java b/services/java/com/android/server/SystemServer.java
index 4c994b9..7aa628a 100644
--- a/services/java/com/android/server/SystemServer.java
+++ b/services/java/com/android/server/SystemServer.java
@@ -1088,14 +1088,17 @@
             }
             traceEnd();
 
-            // Wifi Service must be started first for wifi-related services.
-            traceBeginAndSlog("StartWifi");
-            mSystemServiceManager.startService(WIFI_SERVICE_CLASS);
-            traceEnd();
-            traceBeginAndSlog("StartWifiScanning");
-            mSystemServiceManager.startService(
-                "com.android.server.wifi.scanner.WifiScanningService");
-            traceEnd();
+            if (context.getPackageManager().hasSystemFeature(
+                        PackageManager.FEATURE_WIFI)) {
+                // Wifi Service must be started first for wifi-related services.
+                traceBeginAndSlog("StartWifi");
+                mSystemServiceManager.startService(WIFI_SERVICE_CLASS);
+                traceEnd();
+                traceBeginAndSlog("StartWifiScanning");
+                mSystemServiceManager.startService(
+                    "com.android.server.wifi.scanner.WifiScanningService");
+                traceEnd();
+            }
 
             if (!disableRtt) {
                 traceBeginAndSlog("StartWifiRtt");