6161import android .widget .EditText ;
6262
6363import com .android .internal .R ;
64+ import com .android .internal .telephony .TelephonyIntents ;
6465import com .android .internal .util .AsyncChannel ;
6566import com .android .internal .util .Protocol ;
6667import com .android .internal .util .State ;
@@ -134,6 +135,8 @@ public class WifiP2pService extends IWifiP2pManager.Stub {
134135
135136 /* Airplane mode changed */
136137 private static final int AIRPLANE_MODE_CHANGED = BASE + 6 ;
138+ /* Emergency callback mode */
139+ private static final int EMERGENCY_CALLBACK_MODE = BASE + 7 ;
137140
138141 private final boolean mP2pSupported ;
139142 private final String mDeviceType ;
@@ -172,6 +175,7 @@ public WifiP2pService(Context context) {
172175 IntentFilter filter = new IntentFilter ();
173176 filter .addAction (WifiManager .WIFI_STATE_CHANGED_ACTION );
174177 filter .addAction (Intent .ACTION_AIRPLANE_MODE_CHANGED );
178+ filter .addAction (TelephonyIntents .ACTION_EMERGENCY_CALLBACK_MODE_CHANGED );
175179 filter .addAction (WifiManager .WIFI_AP_STATE_CHANGED_ACTION );
176180 mContext .registerReceiver (new WifiStateReceiver (), filter );
177181
@@ -185,14 +189,19 @@ public void connectivityServiceReady() {
185189 private class WifiStateReceiver extends BroadcastReceiver {
186190 @ Override
187191 public void onReceive (Context context , Intent intent ) {
188- if (intent .getAction ().equals (WifiManager .WIFI_STATE_CHANGED_ACTION )) {
192+ String action = intent .getAction ();
193+ if (action .equals (WifiManager .WIFI_STATE_CHANGED_ACTION )) {
189194 mWifiState = intent .getIntExtra (WifiManager .EXTRA_WIFI_STATE ,
190195 WifiManager .WIFI_STATE_DISABLED );
191- } else if (intent . getAction () .equals (WifiManager .WIFI_AP_STATE_CHANGED_ACTION )) {
196+ } else if (action .equals (WifiManager .WIFI_AP_STATE_CHANGED_ACTION )) {
192197 mWifiApState = intent .getIntExtra (WifiManager .EXTRA_WIFI_AP_STATE ,
193198 WifiManager .WIFI_AP_STATE_DISABLED );
194- } else if (intent . getAction () .equals (Intent .ACTION_AIRPLANE_MODE_CHANGED )) {
199+ } else if (action .equals (Intent .ACTION_AIRPLANE_MODE_CHANGED )) {
195200 mP2pStateMachine .sendMessage (AIRPLANE_MODE_CHANGED );
201+ } else if (action .equals (TelephonyIntents .ACTION_EMERGENCY_CALLBACK_MODE_CHANGED )) {
202+ if (intent .getBooleanExtra ("phoneinECMState" , false ) == true ) {
203+ mP2pStateMachine .sendMessage (EMERGENCY_CALLBACK_MODE );
204+ }
196205 }
197206 }
198207 }
@@ -361,6 +370,9 @@ public boolean processMessage(Message message) {
361370 case AIRPLANE_MODE_CHANGED :
362371 if (isAirplaneModeOn ()) sendMessage (WifiP2pManager .DISABLE_P2P );
363372 break ;
373+ case EMERGENCY_CALLBACK_MODE :
374+ sendMessage (WifiP2pManager .DISABLE_P2P );
375+ break ;
364376 // Ignore
365377 case WIFI_DISABLE_USER_ACCEPT :
366378 case WIFI_DISABLE_USER_REJECT :
0 commit comments