Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0c7e1645 authored by Irfan Sheriff's avatar Irfan Sheriff
Browse files

Fix soft Ap handling on system restart

When system server restarts, a soft AP
start can fail. Fix it by doing a stop
and start through netd.

Bug: 3236625
Change-Id: I95f31eb34a03b64cb7e2b6b8bdd56fc2119b605b
parent ec7c9ff0
Loading
Loading
Loading
Loading
+18 −8
Original line number Diff line number Diff line
@@ -61,7 +61,6 @@ import android.os.WorkSource;
import android.provider.Settings;
import android.util.EventLog;
import android.util.Log;
import android.util.Slog;
import android.app.backup.IBackupManager;
import android.bluetooth.BluetoothAdapter;
import android.content.BroadcastReceiver;
@@ -1672,10 +1671,18 @@ public class WifiStateMachine extends HierarchicalStateMachine {
                                    mInterfaceName,
                                    SOFTAP_IFACE);
                    } catch (Exception e) {
                        Log.e(TAG, "Exception in startAccessPoint()");
                        Log.e(TAG, "Exception in softap start " + e);
                        try {
                            nwService.stopAccessPoint();
                            nwService.startAccessPoint((WifiConfiguration) message.obj,
                                    mInterfaceName,
                                    SOFTAP_IFACE);
                        } catch (Exception ee) {
                            Log.e(TAG, "Exception during softap restart : " + ee);
                            sendMessage(obtainMessage(CMD_UNLOAD_DRIVER, WIFI_AP_STATE_FAILED, 0));
                            break;
                        }
                    }
                    Log.d(TAG, "Soft AP start successful");
                    setWifiApState(WIFI_AP_STATE_ENABLED);
                    transitionTo(mSoftApStartedState);
@@ -2824,14 +2831,17 @@ public class WifiStateMachine extends HierarchicalStateMachine {
                                    mInterfaceName,
                                    SOFTAP_IFACE);
                    } catch(Exception e) {
                        Log.e(TAG, "Exception in nwService during soft AP set");
                        Log.e(TAG, "Exception in softap set " + e);
                        try {
                            nwService.stopAccessPoint();
                            nwService.startAccessPoint((WifiConfiguration) message.obj,
                                    mInterfaceName,
                                    SOFTAP_IFACE);
                        } catch (Exception ee) {
                            Slog.e(TAG, "Could not stop AP, :" + ee);
                        }
                            Log.e(TAG, "Could not restart softap after set failed " + ee);
                            sendMessage(obtainMessage(CMD_UNLOAD_DRIVER, WIFI_AP_STATE_FAILED, 0));
                        }
                    }
                    break;
                /* Fail client mode operation when soft AP is enabled */
                case CMD_START_SUPPLICANT: