Skip to content

Commit 45caa44

Browse files
isheriffAndroid (Google) Code Review
authored andcommitted
Merge "Emergency callback mode handling"
2 parents 76eb1a2 + 616f317 commit 45caa44

File tree

2 files changed

+28
-4
lines changed

2 files changed

+28
-4
lines changed

services/java/com/android/server/WifiService.java

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@
6969
import java.io.PrintWriter;
7070

7171
import com.android.internal.app.IBatteryStats;
72+
import com.android.internal.telephony.TelephonyIntents;
7273
import com.android.internal.util.AsyncChannel;
7374
import com.android.server.am.BatteryStatsService;
7475
import com.android.internal.R;
@@ -96,6 +97,7 @@ public class WifiService extends IWifiManager.Stub {
9697
private static final int IDLE_REQUEST = 0;
9798
private boolean mScreenOff;
9899
private boolean mDeviceIdle;
100+
private boolean mEmergencyCallbackMode = false;
99101
private int mPluggedType;
100102

101103
/* Chipset supports background scan */
@@ -996,6 +998,9 @@ public void onReceive(Context context, Intent intent) {
996998
int state = intent.getIntExtra(BluetoothAdapter.EXTRA_CONNECTION_STATE,
997999
BluetoothAdapter.STATE_DISCONNECTED);
9981000
mWifiStateMachine.sendBluetoothAdapterStateChange(state);
1001+
} else if (action.equals(TelephonyIntents.ACTION_EMERGENCY_CALLBACK_MODE_CHANGED)) {
1002+
mEmergencyCallbackMode = intent.getBooleanExtra("phoneinECMState", false);
1003+
updateWifiState();
9991004
}
10001005
}
10011006

@@ -1057,7 +1062,13 @@ private synchronized void reportStartWorkSource() {
10571062
private void updateWifiState() {
10581063
boolean lockHeld = mLocks.hasLocks();
10591064
int strongestLockMode = WifiManager.WIFI_MODE_FULL;
1060-
boolean wifiShouldBeStarted = !mDeviceIdle || lockHeld;
1065+
boolean wifiShouldBeStarted;
1066+
1067+
if (mEmergencyCallbackMode) {
1068+
wifiShouldBeStarted = false;
1069+
} else {
1070+
wifiShouldBeStarted = !mDeviceIdle || lockHeld;
1071+
}
10611072

10621073
if (lockHeld) {
10631074
strongestLockMode = mLocks.getStrongestLockMode();
@@ -1097,6 +1108,7 @@ private void registerForBroadcasts() {
10971108
intentFilter.addAction(Intent.ACTION_BATTERY_CHANGED);
10981109
intentFilter.addAction(ACTION_DEVICE_IDLE);
10991110
intentFilter.addAction(BluetoothAdapter.ACTION_CONNECTION_STATE_CHANGED);
1111+
intentFilter.addAction(TelephonyIntents.ACTION_EMERGENCY_CALLBACK_MODE_CHANGED);
11001112
mContext.registerReceiver(mReceiver, intentFilter);
11011113
}
11021114

wifi/java/android/net/wifi/p2p/WifiP2pService.java

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@
6161
import android.widget.EditText;
6262

6363
import com.android.internal.R;
64+
import com.android.internal.telephony.TelephonyIntents;
6465
import com.android.internal.util.AsyncChannel;
6566
import com.android.internal.util.Protocol;
6667
import 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

Comments
 (0)