diff options
author | Rebecca Silberstein <silberst@google.com> | 2017-04-29 17:08:05 -0700 |
---|---|---|
committer | Rebecca Silberstein <silberst@google.com> | 2017-05-17 00:24:37 -0700 |
commit | 0c96f88c6d9f031ab76392cdb1255bd249212ad3 (patch) | |
tree | 38440768e91d521616322dd2b4a61652cc23ca78 /service | |
parent | 5420aa3143c2a21ed2b06cd4db2d9d6f5d0af562 (diff) |
WifiServiceImpl: add binder death callback impl
Binder objects for requesting applications are tracked in
LocalOnlyHotspotRequestInfo objects. When a binder death is detected,
this object calls back in to WifiServiceImpl so the request can be
removed and the hotspot can shutdown if there are not any outstanding
requests.
Added a test to verify behavior when there are not any pending requests,
further testing will be added when we start tracking the startLOHS
requests.
Bug: 31466854
Test: frameworks/opt/net/wifi/tests/wifitests/runtests.sh
Change-Id: Ida9cf996683acca03e5478845721501d12ee1a7f
Diffstat (limited to 'service')
-rw-r--r-- | service/java/com/android/server/wifi/WifiServiceImpl.java | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/service/java/com/android/server/wifi/WifiServiceImpl.java b/service/java/com/android/server/wifi/WifiServiceImpl.java index ba82c1d1c..7b76f6d5c 100644 --- a/service/java/com/android/server/wifi/WifiServiceImpl.java +++ b/service/java/com/android/server/wifi/WifiServiceImpl.java @@ -200,6 +200,22 @@ public class WifiServiceImpl extends IWifiManager.Stub { private WifiConfiguration mLocalOnlyHotspotConfig = null; /** + * Callback for use with LocalOnlyHotspot to unregister requesting applications upon death. + * + * @hide + */ + public final class LocalOnlyRequestorCallback + implements LocalOnlyHotspotRequestInfo.RequestingApplicationDeathCallback { + /** + * Called with requesting app has died. + */ + @Override + public void onLocalOnlyHotspotRequestorDeath(LocalOnlyHotspotRequestInfo requestor) { + unregisterCallingAppAndStopLocalOnlyHotspot(requestor); + }; + } + + /** * Handles client connections */ private class ClientHandler extends WifiHandler { @@ -956,6 +972,31 @@ public class WifiServiceImpl extends IWifiManager.Stub { } /** + * Helper method to unregister LocalOnlyHotspot requestors and stop the hotspot if needed. + */ + private void unregisterCallingAppAndStopLocalOnlyHotspot(LocalOnlyHotspotRequestInfo request) { + mLog.trace("unregisterCallingAppAndStopLocalOnlyHotspot uid=%").c(request.getUid()).flush(); + + synchronized (mLocalOnlyHotspotRequests) { + if (mLocalOnlyHotspotRequests.remove(request.getUid()) == null) { + mLog.trace("LocalOnlyHotspotRequestInfo not found to remove"); + return; + } + + if (mLocalOnlyHotspotRequests.isEmpty()) { + mLocalOnlyHotspotConfig = null; + // if that was the last caller, then call stopSoftAp as WifiService + long identity = Binder.clearCallingIdentity(); + try { + stopSoftApInternal(); + } finally { + Binder.restoreCallingIdentity(identity); + } + } + } + } + + /** * see {@link WifiManager#watchLocalOnlyHotspot(LocalOnlyHotspotObserver)} * * @param messenger Messenger to send messages to the corresponding WifiManager. |