1 2 package com.android.settings; 3 4 import android.content.BroadcastReceiver; 5 import android.content.Context; 6 import android.content.Intent; 7 import android.net.wifi.WifiManager; 8 9 import com.android.settingslib.TetherUtil; 10 11 /** 12 * This receiver catches when quick settings turns off the hotspot, so we can 13 * cancel the alarm in that case. All other cancels are handled in tethersettings. 14 */ 15 public class HotspotOffReceiver extends BroadcastReceiver { 16 17 @Override 18 public void onReceive(Context context, Intent intent) { 19 if (WifiManager.WIFI_AP_STATE_CHANGED_ACTION.equals(intent.getAction())) { 20 WifiManager wifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE); 21 if (wifiManager.getWifiApState() == WifiManager.WIFI_AP_STATE_DISABLED) { 22 // The hotspot has been turned off, we don't need to recheck tethering. 23 TetherService.cancelRecheckAlarmIfNecessary(context, TetherUtil.TETHERING_WIFI); 24 } 25 } 26 } 27 } 28