diff options
author | Robert Greenwalt <robdroid@android.com> | 2009-10-08 21:15:52 -0700 |
---|---|---|
committer | Robert Greenwalt <robdroid@android.com> | 2009-10-09 00:54:31 -0700 |
commit | 98e0b146b80670b52805b4b210ef5582dad6bb68 (patch) | |
tree | ea52741b3360ca06cd1d5697c38cd0c50be9e0f4 /telephony | |
parent | 1184313cbea3b34a4596a90be7081551d36f251a (diff) | |
download | frameworks_base-98e0b146b80670b52805b4b210ef5582dad6bb68.zip frameworks_base-98e0b146b80670b52805b4b210ef5582dad6bb68.tar.gz frameworks_base-98e0b146b80670b52805b4b210ef5582dad6bb68.tar.bz2 |
Make PhoneStateListeners not call TelephonyManager
Since the StatusBarPolicy is run in the System Process and shouldn't therefore call into
the Telephony process we decided to make sure all the needed info was passed along with the
original notifications.
bug: 2173053
Diffstat (limited to 'telephony')
6 files changed, 68 insertions, 5 deletions
diff --git a/telephony/java/android/telephony/PhoneStateListener.java b/telephony/java/android/telephony/PhoneStateListener.java index 73e7baa5..ea6593e 100644 --- a/telephony/java/android/telephony/PhoneStateListener.java +++ b/telephony/java/android/telephony/PhoneStateListener.java @@ -206,6 +206,13 @@ public class PhoneStateListener { } /** + * @hide + * same as above, but with the network type. Both called. + */ + public void onDataConnectionStateChanged(int state, int networkType) { + } + + /** * Callback invoked when data activity state changes. * * @see TelephonyManager#DATA_ACTIVITY_NONE @@ -264,8 +271,9 @@ public class PhoneStateListener { Message.obtain(mHandler, LISTEN_CALL_STATE, state, 0, incomingNumber).sendToTarget(); } - public void onDataConnectionStateChanged(int state) { - Message.obtain(mHandler, LISTEN_DATA_CONNECTION_STATE, state, 0, null).sendToTarget(); + public void onDataConnectionStateChanged(int state, int networkType) { + Message.obtain(mHandler, LISTEN_DATA_CONNECTION_STATE, state, networkType, null). + sendToTarget(); } public void onDataActivity(int direction) { @@ -299,6 +307,7 @@ public class PhoneStateListener { PhoneStateListener.this.onCallStateChanged(msg.arg1, (String)msg.obj); break; case LISTEN_DATA_CONNECTION_STATE: + PhoneStateListener.this.onDataConnectionStateChanged(msg.arg1, msg.arg2); PhoneStateListener.this.onDataConnectionStateChanged(msg.arg1); break; case LISTEN_DATA_ACTIVITY: diff --git a/telephony/java/android/telephony/ServiceState.java b/telephony/java/android/telephony/ServiceState.java index 06b5c26..48a40fa 100644 --- a/telephony/java/android/telephony/ServiceState.java +++ b/telephony/java/android/telephony/ServiceState.java @@ -120,6 +120,8 @@ public class ServiceState implements Parcelable { private int mSystemId; private int mCdmaRoamingIndicator; private int mCdmaDefaultRoamingIndicator; + private int mCdmaEriIconIndex; + private int mCdmaEriIconMode; /** * Create a new ServiceState from a intent notifier Bundle @@ -166,6 +168,8 @@ public class ServiceState implements Parcelable { mSystemId = s.mSystemId; mCdmaRoamingIndicator = s.mCdmaRoamingIndicator; mCdmaDefaultRoamingIndicator = s.mCdmaDefaultRoamingIndicator; + mCdmaEriIconIndex = s.mCdmaEriIconIndex; + mCdmaEriIconMode = s.mCdmaEriIconMode; } /** @@ -184,6 +188,8 @@ public class ServiceState implements Parcelable { mSystemId = in.readInt(); mCdmaRoamingIndicator = in.readInt(); mCdmaDefaultRoamingIndicator = in.readInt(); + mCdmaEriIconIndex = in.readInt(); + mCdmaEriIconMode = in.readInt(); } public void writeToParcel(Parcel out, int flags) { @@ -199,6 +205,8 @@ public class ServiceState implements Parcelable { out.writeInt(mSystemId); out.writeInt(mCdmaRoamingIndicator); out.writeInt(mCdmaDefaultRoamingIndicator); + out.writeInt(mCdmaEriIconIndex); + out.writeInt(mCdmaEriIconMode); } public int describeContents() { @@ -254,6 +262,20 @@ public class ServiceState implements Parcelable { } /** + * @hide + */ + public int getCdmaEriIconIndex() { + return this.mCdmaEriIconIndex; + } + + /** + * @hide + */ + public int getCdmaEriIconMode() { + return this.mCdmaEriIconMode; + } + + /** * Get current registered operator name in long alphanumeric format * * In GSM/UMTS, long format can be upto 16 characters long @@ -412,8 +434,11 @@ public class ServiceState implements Parcelable { mSystemId = -1; mCdmaRoamingIndicator = -1; mCdmaDefaultRoamingIndicator = -1; + mCdmaEriIconIndex = -1; + mCdmaEriIconMode = -1; } + // TODO - can't this be combined with the above func.. public void setStateOff() { mState = STATE_POWER_OFF; mRoaming = false; @@ -427,6 +452,8 @@ public class ServiceState implements Parcelable { mSystemId = -1; mCdmaRoamingIndicator = -1; mCdmaDefaultRoamingIndicator = -1; + mCdmaEriIconIndex = -1; + mCdmaEriIconMode = -1; } public void setState(int state) { @@ -451,6 +478,20 @@ public class ServiceState implements Parcelable { this.mCdmaDefaultRoamingIndicator = roaming; } + /** + * @hide + */ + public void setCdmaEriIconIndex(int index) { + this.mCdmaEriIconIndex = index; + } + + /** + * @hide + */ + public void setCdmaEriIconMode(int mode) { + this.mCdmaEriIconMode = mode; + } + public void setOperatorName(String longName, String shortName, String numeric) { mOperatorAlphaLong = longName; mOperatorAlphaShort = shortName; diff --git a/telephony/java/com/android/internal/telephony/DefaultPhoneNotifier.java b/telephony/java/com/android/internal/telephony/DefaultPhoneNotifier.java index 00d7c72..4da4b6a 100644 --- a/telephony/java/com/android/internal/telephony/DefaultPhoneNotifier.java +++ b/telephony/java/com/android/internal/telephony/DefaultPhoneNotifier.java @@ -93,13 +93,16 @@ public class DefaultPhoneNotifier implements PhoneNotifier { } public void notifyDataConnection(Phone sender, String reason) { + TelephonyManager telephony = TelephonyManager.getDefault(); try { mRegistry.notifyDataConnection( convertDataState(sender.getDataConnectionState()), sender.isDataConnectivityPossible(), reason, sender.getActiveApn(), sender.getActiveApnTypes(), - sender.getInterfaceName(null)); + sender.getInterfaceName(null), + ((telephony!=null) ? telephony.getNetworkType() : + TelephonyManager.NETWORK_TYPE_UNKNOWN)); } catch (RemoteException ex) { // system process is dead } diff --git a/telephony/java/com/android/internal/telephony/IPhoneStateListener.aidl b/telephony/java/com/android/internal/telephony/IPhoneStateListener.aidl index 0202ec8..856d663 100644 --- a/telephony/java/com/android/internal/telephony/IPhoneStateListener.aidl +++ b/telephony/java/com/android/internal/telephony/IPhoneStateListener.aidl @@ -29,7 +29,7 @@ oneway interface IPhoneStateListener { // we use bundle here instead of CellLocation so it can get the right subclass void onCellLocationChanged(in Bundle location); void onCallStateChanged(int state, String incomingNumber); - void onDataConnectionStateChanged(int state); + void onDataConnectionStateChanged(int state, int networkType); void onDataActivity(int direction); void onSignalStrengthsChanged(in SignalStrength signalStrength); } diff --git a/telephony/java/com/android/internal/telephony/ITelephonyRegistry.aidl b/telephony/java/com/android/internal/telephony/ITelephonyRegistry.aidl index 6b42e6b..5bf8e58 100644 --- a/telephony/java/com/android/internal/telephony/ITelephonyRegistry.aidl +++ b/telephony/java/com/android/internal/telephony/ITelephonyRegistry.aidl @@ -32,7 +32,7 @@ interface ITelephonyRegistry { void notifyCallForwardingChanged(boolean cfi); void notifyDataActivity(int state); void notifyDataConnection(int state, boolean isDataConnectivityPossible, - String reason, String apn, in String[] apnTypes, String interfaceName); + String reason, String apn, in String[] apnTypes, String interfaceName, int networkType); void notifyDataConnectionFailed(String reason); void notifyCellLocation(in Bundle cellLocation); } diff --git a/telephony/java/com/android/internal/telephony/cdma/CDMAPhone.java b/telephony/java/com/android/internal/telephony/cdma/CDMAPhone.java index 6dcfcd9..22fbe8b 100755 --- a/telephony/java/com/android/internal/telephony/cdma/CDMAPhone.java +++ b/telephony/java/com/android/internal/telephony/cdma/CDMAPhone.java @@ -257,6 +257,12 @@ public class CDMAPhone extends PhoneBase { } public ServiceState getServiceState() { + int roamInd = mSST.ss.getCdmaRoamingIndicator(); + int defRoamInd = mSST.ss.getCdmaDefaultRoamingIndicator(); + + mSST.ss.setCdmaEriIconIndex(mEriManager.getCdmaEriIconIndex(roamInd, defRoamInd)); + mSST.ss.setCdmaEriIconMode(mEriManager.getCdmaEriIconMode(roamInd, defRoamInd)); + return mSST.ss; } @@ -798,6 +804,10 @@ public class CDMAPhone extends PhoneBase { } void notifyServiceStateChanged(ServiceState ss) { + // TODO this seems really inefficient. Can't we calc this when the fundamentals change and store in the + // service state? + ss.setCdmaEriIconIndex(this.getCdmaEriIconIndex()); + ss.setCdmaEriIconMode(this.getCdmaEriIconMode()); super.notifyServiceStateChangedP(ss); } |