diff options
author | Roshan Pius <rpius@google.com> | 2017-03-03 11:43:52 -0800 |
---|---|---|
committer | Roshan Pius <rpius@google.com> | 2017-03-03 12:41:12 -0800 |
commit | f42911bc9a921c28ce1614c3513e088e755a55f0 (patch) | |
tree | 87185932d90a4e80c6523df93b8e30d8b47fb3ae /service | |
parent | 60ef62896e60b41a36a73f4a58d1281084b7181a (diff) |
SupplicantHal: Store death recipients
Also, Removed an unused flag from SupplicantStaIface.java.
Bug: 33383725
Test: Unit tests.
Test: Killed wpa_supplicant on the device and ensured the callbacks are
invoked.
Change-Id: I62ec2459ad552bca95c9f9b96032c936c14461fb
Diffstat (limited to 'service')
-rw-r--r-- | service/java/com/android/server/wifi/SupplicantP2pIfaceHal.java | 42 | ||||
-rw-r--r-- | service/java/com/android/server/wifi/SupplicantStaIfaceHal.java | 44 |
2 files changed, 44 insertions, 42 deletions
diff --git a/service/java/com/android/server/wifi/SupplicantP2pIfaceHal.java b/service/java/com/android/server/wifi/SupplicantP2pIfaceHal.java index 8007d3055..19d68c07c 100644 --- a/service/java/com/android/server/wifi/SupplicantP2pIfaceHal.java +++ b/service/java/com/android/server/wifi/SupplicantP2pIfaceHal.java @@ -30,6 +30,7 @@ import android.net.wifi.p2p.WifiP2pConfig; import android.net.wifi.p2p.WifiP2pGroup; import android.net.wifi.p2p.WifiP2pManager; import android.net.wifi.p2p.nsd.WifiP2pServiceInfo; +import android.os.HwRemoteBinder; import android.os.RemoteException; import android.util.Log; @@ -47,6 +48,8 @@ public class SupplicantP2pIfaceHal { private static final int RESULT_NOT_VALID = -1; private static final int DEFAULT_GROUP_OWNER_INTENT = 6; + private Object mLock = new Object(); + // Supplicant HAL HIDL interface objects private IServiceManager mIServiceManager = null; private ISupplicant mISupplicant = null; @@ -69,8 +72,21 @@ public class SupplicantP2pIfaceHal { } } }; - private Object mLock = new Object(); - private boolean mServiceCallbackInstalled = false; + private final HwRemoteBinder.DeathRecipient mServiceManagerDeathRecipient = + cookie -> { + Log.w(TAG, "IServiceManager died: cookie=" + cookie); + synchronized (mLock) { + supplicantServiceDiedHandler(); + mIServiceManager = null; // Will need to register a new ServiceNotification + } + }; + private final HwRemoteBinder.DeathRecipient mSupplicantDeathRecipient = + cookie -> { + Log.w(TAG, "ISupplicant/ISupplicantStaIface died: cookie=" + cookie); + synchronized (mLock) { + supplicantServiceDiedHandler(); + } + }; private final WifiMonitor mMonitor; private SupplicantP2pIfaceCallback mCallback = null; @@ -82,13 +98,7 @@ public class SupplicantP2pIfaceHal { private boolean linkToServiceManagerDeath() { if (mIServiceManager == null) return false; try { - if (!mIServiceManager.linkToDeath(cookie -> { - Log.w(TAG, "IServiceManager died: cookie=" + cookie); - synchronized (mLock) { - supplicantServiceDiedHandler(); - mIServiceManager = null; // Will need to register a new ServiceNotification - } - }, 0)) { + if (!mIServiceManager.linkToDeath(mServiceManagerDeathRecipient, 0)) { Log.wtf(TAG, "Error on linkToDeath on IServiceManager"); supplicantServiceDiedHandler(); mIServiceManager = null; // Will need to register a new ServiceNotification @@ -151,12 +161,7 @@ public class SupplicantP2pIfaceHal { private boolean linkToSupplicantDeath() { if (mISupplicant == null) return false; try { - if (!mISupplicant.linkToDeath(cookie -> { - Log.w(TAG, "ISupplicant died: cookie=" + cookie); - synchronized (mLock) { - supplicantServiceDiedHandler(); - } - }, 0)) { + if (!mISupplicant.linkToDeath(mSupplicantDeathRecipient, 0)) { Log.wtf(TAG, "Error on linkToDeath on ISupplicant"); supplicantServiceDiedHandler(); return false; @@ -190,12 +195,7 @@ public class SupplicantP2pIfaceHal { private boolean linkToSupplicantP2pIfaceDeath() { if (mISupplicantP2pIface == null) return false; try { - if (!mISupplicantP2pIface.linkToDeath(cookie -> { - Log.w(TAG, "ISupplicantP2pIface died: cookie=" + cookie); - synchronized (mLock) { - supplicantServiceDiedHandler(); - } - }, 0)) { + if (!mISupplicantP2pIface.linkToDeath(mSupplicantDeathRecipient, 0)) { Log.wtf(TAG, "Error on linkToDeath on ISupplicantP2pIface"); supplicantServiceDiedHandler(); return false; diff --git a/service/java/com/android/server/wifi/SupplicantStaIfaceHal.java b/service/java/com/android/server/wifi/SupplicantStaIfaceHal.java index 1aa1386cc..a6df07fa5 100644 --- a/service/java/com/android/server/wifi/SupplicantStaIfaceHal.java +++ b/service/java/com/android/server/wifi/SupplicantStaIfaceHal.java @@ -43,6 +43,7 @@ import android.net.IpConfiguration; import android.net.wifi.SupplicantState; import android.net.wifi.WifiConfiguration; import android.net.wifi.WifiSsid; +import android.os.HwRemoteBinder; import android.os.RemoteException; import android.text.TextUtils; import android.util.Log; @@ -80,9 +81,11 @@ public class SupplicantStaIfaceHal { private static final Pattern WPS_DEVICE_TYPE_PATTERN = Pattern.compile("^(\\d{1,2})-([0-9a-fA-F]{8})-(\\d{1,2})$"); + private final Object mLock = new Object(); private boolean mVerboseLoggingEnabled = false; - private IServiceManager mIServiceManager = null; + // Supplicant HAL interface objects + private IServiceManager mIServiceManager = null; private ISupplicant mISupplicant; private ISupplicantStaIface mISupplicantStaIface; private ISupplicantStaIfaceCallback mISupplicantStaIfaceCallback; @@ -103,12 +106,27 @@ public class SupplicantStaIfaceHal { } } }; + private final HwRemoteBinder.DeathRecipient mServiceManagerDeathRecipient = + cookie -> { + Log.w(TAG, "IServiceManager died: cookie=" + cookie); + synchronized (mLock) { + supplicantServiceDiedHandler(); + mIServiceManager = null; // Will need to register a new ServiceNotification + } + }; + private final HwRemoteBinder.DeathRecipient mSupplicantDeathRecipient = + cookie -> { + Log.w(TAG, "ISupplicant/ISupplicantStaIface died: cookie=" + cookie); + synchronized (mLock) { + supplicantServiceDiedHandler(); + } + }; + private String mIfaceName; // Currently configured network in wpa_supplicant private SupplicantStaNetworkHal mCurrentNetwork; // Currently configured network's framework network Id. private int mFrameworkNetworkId = WifiConfiguration.INVALID_NETWORK_ID; - private final Object mLock = new Object(); private final Context mContext; private final WifiMonitor mWifiMonitor; @@ -130,13 +148,7 @@ public class SupplicantStaIfaceHal { private boolean linkToServiceManagerDeath() { if (mIServiceManager == null) return false; try { - if (!mIServiceManager.linkToDeath(cookie -> { - Log.w(TAG, "IServiceManager died: cookie=" + cookie); - synchronized (mLock) { - supplicantServiceDiedHandler(); - mIServiceManager = null; // Will need to register a new ServiceNotification - } - }, 0)) { + if (!mIServiceManager.linkToDeath(mServiceManagerDeathRecipient, 0)) { Log.wtf(TAG, "Error on linkToDeath on IServiceManager"); supplicantServiceDiedHandler(); mIServiceManager = null; // Will need to register a new ServiceNotification @@ -194,12 +206,7 @@ public class SupplicantStaIfaceHal { private boolean linkToSupplicantDeath() { if (mISupplicant == null) return false; try { - if (!mISupplicant.linkToDeath(cookie -> { - Log.w(TAG, "ISupplicant died: cookie=" + cookie); - synchronized (mLock) { - supplicantServiceDiedHandler(); - } - }, 0)) { + if (!mISupplicant.linkToDeath(mSupplicantDeathRecipient, 0)) { Log.wtf(TAG, "Error on linkToDeath on ISupplicant"); supplicantServiceDiedHandler(); return false; @@ -233,12 +240,7 @@ public class SupplicantStaIfaceHal { private boolean linkToSupplicantStaIfaceDeath() { if (mISupplicantStaIface == null) return false; try { - if (!mISupplicantStaIface.linkToDeath(cookie -> { - Log.w(TAG, "ISupplicantStaIface died: cookie=" + cookie); - synchronized (mLock) { - supplicantServiceDiedHandler(); - } - }, 0)) { + if (!mISupplicantStaIface.linkToDeath(mSupplicantDeathRecipient, 0)) { Log.wtf(TAG, "Error on linkToDeath on ISupplicantStaIface"); supplicantServiceDiedHandler(); return false; |