am 184044e4: am 42caf399: am e648ccbb: am 157ad64d: Merge "Fix emergency only when no sims" into mnc-dev
* commit '184044e499a36297e01ce6d3bd55b7c9026be178':
Fix emergency only when no sims
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/NetworkControllerImpl.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/NetworkControllerImpl.java
index 7cd94d7..57dfff5 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/NetworkControllerImpl.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/NetworkControllerImpl.java
@@ -31,6 +31,7 @@
import android.os.Handler;
import android.os.Looper;
import android.provider.Settings;
+import android.telephony.ServiceState;
import android.telephony.SubscriptionInfo;
import android.telephony.SubscriptionManager;
import android.telephony.SubscriptionManager.OnSubscriptionsChangedListener;
@@ -117,6 +118,9 @@
// Handler that all callbacks are made on.
private final CallbackHandler mCallbackHandler;
+ @VisibleForTesting
+ ServiceState mLastServiceState;
+
/**
* Construct this controller object and register for updates.
*/
@@ -194,6 +198,7 @@
filter.addAction(TelephonyIntents.ACTION_SIM_STATE_CHANGED);
filter.addAction(TelephonyIntents.ACTION_DEFAULT_DATA_SUBSCRIPTION_CHANGED);
filter.addAction(TelephonyIntents.ACTION_DEFAULT_VOICE_SUBSCRIPTION_CHANGED);
+ filter.addAction(TelephonyIntents.ACTION_SERVICE_STATE_CHANGED);
filter.addAction(TelephonyIntents.SPN_STRINGS_UPDATED_ACTION);
filter.addAction(ConnectivityManager.CONNECTIVITY_ACTION);
filter.addAction(ConnectivityManager.INET_CONDITION_ACTION);
@@ -259,6 +264,11 @@
}
public boolean isEmergencyOnly() {
+ if (mMobileSignalControllers.size() == 0) {
+ // When there are no active subscriptions, determine emengency state from last
+ // broadcast.
+ return mLastServiceState != null && mLastServiceState.isEmergencyOnly();
+ }
int voiceSubId = mSubDefaults.getDefaultVoiceSubId();
if (!SubscriptionManager.isValidSubscriptionId(voiceSubId)) {
for (MobileSignalController mobileSignalController :
@@ -353,6 +363,13 @@
} else if (action.equals(TelephonyIntents.ACTION_SIM_STATE_CHANGED)) {
// Might have different subscriptions now.
updateMobileControllers();
+ } else if (action.equals(TelephonyIntents.ACTION_SERVICE_STATE_CHANGED)) {
+ mLastServiceState = ServiceState.newFromBundle(intent.getExtras());
+ if (mMobileSignalControllers.size() == 0) {
+ // If none of the subscriptions are active, we might need to recalculate
+ // emergency state.
+ recalculateEmergency();
+ }
} else {
int subId = intent.getIntExtra(PhoneConstants.SUBSCRIPTION_KEY,
SubscriptionManager.INVALID_SUBSCRIPTION_ID);
@@ -587,6 +604,8 @@
pw.println(mAirplaneMode);
pw.print(" mLocale=");
pw.println(mLocale);
+ pw.print(" mLastServiceState=");
+ pw.println(mLastServiceState);
for (MobileSignalController mobileSignalController : mMobileSignalControllers.values()) {
mobileSignalController.dump(pw);
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/NetworkControllerSignalTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/NetworkControllerSignalTest.java
index 52dea40..d9b9063 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/NetworkControllerSignalTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/NetworkControllerSignalTest.java
@@ -21,6 +21,7 @@
import android.net.ConnectivityManager;
import android.net.NetworkCapabilities;
import android.os.Looper;
+import android.telephony.ServiceState;
import android.telephony.SignalStrength;
import android.telephony.SubscriptionInfo;
import android.telephony.TelephonyManager;
@@ -70,11 +71,20 @@
public void testEmergencyOnlyNoSubscriptions() {
setupDefaultSignal();
+ setSubscriptions();
+ mNetworkController.mLastServiceState = new ServiceState();
+ mNetworkController.mLastServiceState.setEmergencyOnly(true);
+ mNetworkController.recalculateEmergency();
+ verifyEmergencyOnly(true);
+ }
+
+ public void testNoEmengencyNoSubscriptions() {
+ setupDefaultSignal();
+ setSubscriptions();
+ mNetworkController.mLastServiceState = new ServiceState();
+ mNetworkController.mLastServiceState.setEmergencyOnly(false);
mNetworkController.recalculateEmergency();
verifyEmergencyOnly(false);
-
- setSubscriptions();
- verifyEmergencyOnly(true);
}
public void testNoSimlessIconWithoutMobile() {