diff options
author | Rebecca Silberstein <silberst@google.com> | 2017-05-17 23:36:36 +0000 |
---|---|---|
committer | android-build-merger <android-build-merger@google.com> | 2017-05-17 23:36:36 +0000 |
commit | fd9a6d5607bd6c92045f80046ae344a1275a06d7 (patch) | |
tree | 426af0f53731dbcfb61e7ee98f4d018161df6b63 /service | |
parent | ed0226aa5f8d64617858b20671be7ea51b17e3f3 (diff) | |
parent | 58f2ade07f35ccdbfb2a97367e329447271f6706 (diff) |
WifiServiceImpl: add binder death callback impl am: 0c96f88c6d
am: 58f2ade07f
Change-Id: I9c6734588737e89815d4eba0306d48deee64ef19
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 5a60423b4..2cb72945e 100644 --- a/service/java/com/android/server/wifi/WifiServiceImpl.java +++ b/service/java/com/android/server/wifi/WifiServiceImpl.java @@ -196,6 +196,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 { @@ -952,6 +968,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. |