Skip to content

Commit 66845a3

Browse files
committed
Add more dump info about emergency calls state
Bug: 21549528 Change-Id: Idbd70e2f4b1b3285af283a28dc1933c02ad8d04c
1 parent 8dbd484 commit 66845a3

2 files changed

Lines changed: 33 additions & 2 deletions

File tree

packages/SystemUI/src/com/android/systemui/statusbar/policy/MobileSignalController.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public class MobileSignalController extends SignalController<
5151
@VisibleForTesting
5252
final PhoneStateListener mPhoneStateListener;
5353
// Save entire info for logging, we only use the id.
54-
private final SubscriptionInfo mSubscriptionInfo;
54+
final SubscriptionInfo mSubscriptionInfo;
5555

5656
// @VisibleForDemoMode
5757
final SparseArray<MobileIconGroup> mNetworkToIconLookup;

packages/SystemUI/src/com/android/systemui/statusbar/policy/NetworkControllerImpl.java

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,11 @@ public class NetworkControllerImpl extends BroadcastReceiver
6666
// additional diagnostics, but not logspew
6767
static final boolean CHATTY = Log.isLoggable(TAG + "Chat", Log.DEBUG);
6868

69+
private static final int EMERGENCY_NO_CONTROLLERS = 0;
70+
private static final int EMERGENCY_FIRST_CONTROLLER = 100;
71+
private static final int EMERGENCY_VOICE_CONTROLLER = 200;
72+
private static final int EMERGENCY_NO_SUB = 300;
73+
6974
private final Context mContext;
7075
private final TelephonyManager mPhone;
7176
private final WifiManager mWifiManager;
@@ -118,6 +123,9 @@ public class NetworkControllerImpl extends BroadcastReceiver
118123
// Handler that all callbacks are made on.
119124
private final CallbackHandler mCallbackHandler;
120125

126+
private int mEmergencySource;
127+
private boolean mIsEmergency;
128+
121129
@VisibleForTesting
122130
ServiceState mLastServiceState;
123131

@@ -267,23 +275,28 @@ public boolean isEmergencyOnly() {
267275
if (mMobileSignalControllers.size() == 0) {
268276
// When there are no active subscriptions, determine emengency state from last
269277
// broadcast.
278+
mEmergencySource = EMERGENCY_NO_CONTROLLERS;
270279
return mLastServiceState != null && mLastServiceState.isEmergencyOnly();
271280
}
272281
int voiceSubId = mSubDefaults.getDefaultVoiceSubId();
273282
if (!SubscriptionManager.isValidSubscriptionId(voiceSubId)) {
274283
for (MobileSignalController mobileSignalController :
275284
mMobileSignalControllers.values()) {
276285
if (!mobileSignalController.getState().isEmergency) {
286+
mEmergencySource = EMERGENCY_FIRST_CONTROLLER
287+
+ mobileSignalController.mSubscriptionInfo.getSubscriptionId();
277288
if (DEBUG) Log.d(TAG, "Found emergency " + mobileSignalController.mTag);
278289
return false;
279290
}
280291
}
281292
}
282293
if (mMobileSignalControllers.containsKey(voiceSubId)) {
294+
mEmergencySource = EMERGENCY_VOICE_CONTROLLER + voiceSubId;
283295
if (DEBUG) Log.d(TAG, "Getting emergency from " + voiceSubId);
284296
return mMobileSignalControllers.get(voiceSubId).getState().isEmergency;
285297
}
286298
if (DEBUG) Log.e(TAG, "Cannot find controller for voice sub: " + voiceSubId);
299+
mEmergencySource = EMERGENCY_NO_SUB + voiceSubId;
287300
// Something is wrong, better assume we can't make calls...
288301
return true;
289302
}
@@ -293,7 +306,8 @@ public boolean isEmergencyOnly() {
293306
* so we should recheck and send out the state to listeners.
294307
*/
295308
void recalculateEmergency() {
296-
mCallbackHandler.setEmergencyCallsOnly(isEmergencyOnly());
309+
mIsEmergency = isEmergencyOnly();
310+
mCallbackHandler.setEmergencyCallsOnly(mIsEmergency);
297311
}
298312

299313
public void addSignalCallback(SignalCallback cb) {
@@ -606,6 +620,10 @@ public void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
606620
pw.println(mLocale);
607621
pw.print(" mLastServiceState=");
608622
pw.println(mLastServiceState);
623+
pw.print(" mIsEmergency=");
624+
pw.println(mIsEmergency);
625+
pw.print(" mEmergencySource=");
626+
pw.println(emergencyToString(mEmergencySource));
609627

610628
for (MobileSignalController mobileSignalController : mMobileSignalControllers.values()) {
611629
mobileSignalController.dump(pw);
@@ -617,6 +635,19 @@ public void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
617635
mAccessPoints.dump(pw);
618636
}
619637

638+
private static final String emergencyToString(int emergencySource) {
639+
if (emergencySource > EMERGENCY_NO_SUB) {
640+
return "NO_SUB(" + (emergencySource - EMERGENCY_NO_SUB) + ")";
641+
} else if (emergencySource > EMERGENCY_VOICE_CONTROLLER) {
642+
return "VOICE_CONTROLLER(" + (emergencySource - EMERGENCY_VOICE_CONTROLLER) + ")";
643+
} else if (emergencySource > EMERGENCY_FIRST_CONTROLLER) {
644+
return "FIRST_CONTROLLER(" + (emergencySource - EMERGENCY_FIRST_CONTROLLER) + ")";
645+
} else if (emergencySource == EMERGENCY_NO_CONTROLLERS) {
646+
return "NO_CONTROLLERS";
647+
}
648+
return "UNKNOWN_SOURCE";
649+
}
650+
620651
private boolean mDemoMode;
621652
private boolean mDemoInetCondition;
622653
private WifiSignalController.WifiState mDemoWifiState;

0 commit comments

Comments
 (0)