am a2267451: Don\'t ever report a null ServiceState
* commit 'a2267451ddf91cc330f4c283e86811e38328915b':
Don't ever report a null ServiceState
diff --git a/telephony/java/android/telephony/ServiceState.java b/telephony/java/android/telephony/ServiceState.java
index fce7cdc..2f010e5 100644
--- a/telephony/java/android/telephony/ServiceState.java
+++ b/telephony/java/android/telephony/ServiceState.java
@@ -473,8 +473,8 @@
+ " EmergOnly=" + mIsEmergencyOnly);
}
- public void setStateOutOfService() {
- mState = STATE_OUT_OF_SERVICE;
+ private void setNullState(int state) {
+ mState = state;
mRoaming = false;
mOperatorAlphaLong = null;
mOperatorAlphaShort = null;
@@ -491,23 +491,12 @@
mIsEmergencyOnly = false;
}
- // TODO - can't this be combined with the above method?
+ public void setStateOutOfService() {
+ setNullState(STATE_OUT_OF_SERVICE);
+ }
+
public void setStateOff() {
- mState = STATE_POWER_OFF;
- mRoaming = false;
- mOperatorAlphaLong = null;
- mOperatorAlphaShort = null;
- mOperatorNumeric = null;
- mIsManualNetworkSelection = false;
- mRadioTechnology = 0;
- mCssIndicator = false;
- mNetworkId = -1;
- mSystemId = -1;
- mCdmaRoamingIndicator = -1;
- mCdmaDefaultRoamingIndicator = -1;
- mCdmaEriIconIndex = -1;
- mCdmaEriIconMode = -1;
- mIsEmergencyOnly = false;
+ setNullState(STATE_POWER_OFF);
}
public void setState(int state) {
diff --git a/telephony/java/com/android/internal/telephony/DefaultPhoneNotifier.java b/telephony/java/com/android/internal/telephony/DefaultPhoneNotifier.java
index 910905a..aa7568b 100644
--- a/telephony/java/com/android/internal/telephony/DefaultPhoneNotifier.java
+++ b/telephony/java/com/android/internal/telephony/DefaultPhoneNotifier.java
@@ -21,6 +21,7 @@
import android.os.Bundle;
import android.os.RemoteException;
import android.os.ServiceManager;
+import android.telephony.ServiceState;
import android.telephony.TelephonyManager;
import android.util.Log;
@@ -55,8 +56,13 @@
}
public void notifyServiceState(Phone sender) {
+ ServiceState ss = sender.getServiceState();
+ if (ss == null) {
+ ss = new ServiceState();
+ ss.setStateOutOfService();
+ }
try {
- mRegistry.notifyServiceState(sender.getServiceState());
+ mRegistry.notifyServiceState(ss);
} catch (RemoteException ex) {
// system process is dead
}