Files
app_Settings/src/com/android/settings/HotspotOffReceiver.java
Jeremy Klein 8a934767dc Allow TetherService to take a callback to receiver provision results.
See ag/850685 for corresponding framework changes. This is being done
as part of exposing a cleaner tethering API which will be used by
Quick Settings and Settings.

BUG: 26247383
Change-Id: I061b8b8b2b0c5bbe98f50deb051e2bfb8e773d61
2016-01-25 15:09:48 -08:00

35 lines
1.3 KiB
Java

package com.android.settings;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.net.ConnectivityManager;
import android.net.wifi.WifiManager;
import android.util.Log;
import com.android.settingslib.TetherUtil;
/**
* This receiver catches when quick settings turns off the hotspot, so we can
* cancel the alarm in that case. All other cancels are handled in tethersettings.
*/
public class HotspotOffReceiver extends BroadcastReceiver {
private static final String TAG = "HotspotOffReceiver";
private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG);
@Override
public void onReceive(Context context, Intent intent) {
if (WifiManager.WIFI_AP_STATE_CHANGED_ACTION.equals(intent.getAction())) {
WifiManager wifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
if (wifiManager.getWifiApState() == WifiManager.WIFI_AP_STATE_DISABLED) {
if (DEBUG) Log.d(TAG, "TetherService.cancelRecheckAlarmIfNecessary called");
// The hotspot has been turned off, we don't need to recheck tethering.
TetherService.cancelRecheckAlarmIfNecessary(
context, ConnectivityManager.TETHERING_WIFI);
}
}
}
}