diff options
Diffstat (limited to 'src/java')
14 files changed, 315 insertions, 80 deletions
diff --git a/src/java/com/android/internal/telephony/DefaultPhoneNotifier.java b/src/java/com/android/internal/telephony/DefaultPhoneNotifier.java index 4d16443..157fee6 100644 --- a/src/java/com/android/internal/telephony/DefaultPhoneNotifier.java +++ b/src/java/com/android/internal/telephony/DefaultPhoneNotifier.java @@ -28,6 +28,8 @@ import android.util.Log; import com.android.internal.telephony.ITelephonyRegistry; +import java.util.List; + /** * broadcast intents */ @@ -157,7 +159,7 @@ public class DefaultPhoneNotifier implements PhoneNotifier { } } - public void notifyCellInfo(Phone sender, CellInfo cellInfo) { + public void notifyCellInfo(Phone sender, List<CellInfo> cellInfo) { try { mRegistry.notifyCellInfo(cellInfo); } catch (RemoteException ex) { diff --git a/src/java/com/android/internal/telephony/IccCard.java b/src/java/com/android/internal/telephony/IccCard.java index 648b73e..060bff5 100644 --- a/src/java/com/android/internal/telephony/IccCard.java +++ b/src/java/com/android/internal/telephony/IccCard.java @@ -29,6 +29,7 @@ import android.os.Message; import android.os.PowerManager; import android.os.Registrant; import android.os.RegistrantList; +import android.os.UserHandle; import android.util.Log; import android.view.WindowManager; @@ -638,7 +639,7 @@ public class IccCard { intent.putExtra(IccCardConstants.INTENT_KEY_LOCKED_REASON, reason); if(mDbg) log("Broadcasting intent ACTION_SIM_STATE_CHANGED " + value + " reason " + reason); - ActivityManagerNative.broadcastStickyIntent(intent, READ_PHONE_STATE); + ActivityManagerNative.broadcastStickyIntent(intent, READ_PHONE_STATE, UserHandle.USER_ALL); } protected Handler mHandler = new Handler() { diff --git a/src/java/com/android/internal/telephony/Phone.java b/src/java/com/android/internal/telephony/Phone.java index 34aa96c..00a4554 100644 --- a/src/java/com/android/internal/telephony/Phone.java +++ b/src/java/com/android/internal/telephony/Phone.java @@ -22,6 +22,7 @@ import android.net.LinkProperties; import android.os.Handler; import android.os.Message; import android.os.SystemProperties; +import android.telephony.CellInfo; import android.telephony.CellLocation; import android.telephony.PhoneStateListener; import android.telephony.ServiceState; @@ -176,6 +177,11 @@ public interface Phone { CellLocation getCellLocation(); /** + * @return all available cell information or null if none. + */ + public List<CellInfo> getAllCellInfo(); + + /** * Get the current for the default apn DataState. No change notification * exists at this interface -- use * {@link android.telephony.PhoneStateListener} instead. diff --git a/src/java/com/android/internal/telephony/PhoneBase.java b/src/java/com/android/internal/telephony/PhoneBase.java index 7c2f2e0..a50724b 100755..100644 --- a/src/java/com/android/internal/telephony/PhoneBase.java +++ b/src/java/com/android/internal/telephony/PhoneBase.java @@ -32,7 +32,9 @@ import android.os.RegistrantList; import android.os.SystemProperties; import android.preference.PreferenceManager; import android.provider.Settings; +import android.telephony.CellInfo; import android.telephony.ServiceState; +import android.telephony.SignalStrength; import android.text.TextUtils; import android.util.Log; @@ -45,6 +47,7 @@ import com.android.internal.telephony.gsm.SIMRecords; import java.io.FileDescriptor; import java.io.PrintWriter; +import java.util.List; import java.util.Locale; import java.util.concurrent.atomic.AtomicReference; @@ -192,9 +195,10 @@ public abstract class PhoneBase extends Handler implements Phone { /** * Constructs a PhoneBase in normal (non-unit test) mode. * - * @param context Context object from hosting application * @param notifier An instance of DefaultPhoneNotifier, + * @param context Context object from hosting application * unless unit testing. + * @param ci the CommandsInterface */ protected PhoneBase(PhoneNotifier notifier, Context context, CommandsInterface ci) { this(notifier, context, ci, false); @@ -203,9 +207,10 @@ public abstract class PhoneBase extends Handler implements Phone { /** * Constructs a PhoneBase in normal (non-unit test) mode. * - * @param context Context object from hosting application * @param notifier An instance of DefaultPhoneNotifier, + * @param context Context object from hosting application * unless unit testing. + * @param ci is CommandsInterface * @param unitTestMode when true, prevents notifications * of state change events */ @@ -577,11 +582,6 @@ public abstract class PhoneBase extends Handler implements Phone { mNotifier.notifyServiceState(this); } - /* package */void - notifySignalStrength() { - mNotifier.notifySignalStrength(this); - } - // Inherited documentation suffices. public SimulatedRadioControl getSimulatedRadioControl() { return mSimulatedRadioControl; @@ -696,6 +696,14 @@ public abstract class PhoneBase extends Handler implements Phone { return (r != null) ? r.getRecordsLoaded() : false; } + /** + * @return all available cell information or null if none. + */ + @Override + public List<CellInfo> getAllCellInfo() { + return getServiceStateTracker().getAllCellInfo(); + } + @Override public boolean getMessageWaitingIndicator() { IccRecords r = mIccRecords.get(); @@ -716,6 +724,19 @@ public abstract class PhoneBase extends Handler implements Phone { } /** + * Get the signal strength + */ + @Override + public SignalStrength getSignalStrength() { + ServiceStateTracker sst = getServiceStateTracker(); + if (sst == null) { + return new SignalStrength(); + } else { + return sst.getSignalStrength(); + } + } + + /** * Set the status of the CDMA roaming preference */ public void setCdmaRoamingPreference(int cdmaRoamingType, Message response) { @@ -815,6 +836,14 @@ public abstract class PhoneBase extends Handler implements Phone { mNotifier.notifyOtaspChanged(this, otaspMode); } + public void notifySignalStrength() { + mNotifier.notifySignalStrength(this); + } + + public void notifyCellInfo(List<CellInfo> cellInfo) { + mNotifier.notifyCellInfo(this, cellInfo); + } + /** * @return true if a mobile originating emergency call is active */ diff --git a/src/java/com/android/internal/telephony/PhoneNotifier.java b/src/java/com/android/internal/telephony/PhoneNotifier.java index efc7a13..0a4a05d 100644 --- a/src/java/com/android/internal/telephony/PhoneNotifier.java +++ b/src/java/com/android/internal/telephony/PhoneNotifier.java @@ -18,6 +18,8 @@ package com.android.internal.telephony; import android.telephony.CellInfo; +import java.util.List; + /** * {@hide} */ @@ -45,6 +47,5 @@ public interface PhoneNotifier { public void notifyOtaspChanged(Phone sender, int otaspMode); - // TODO - trigger notifyCellInfo from ServiceStateTracker - public void notifyCellInfo(Phone sender, CellInfo cellInfo); + public void notifyCellInfo(Phone sender, List<CellInfo> cellInfo); } diff --git a/src/java/com/android/internal/telephony/PhoneProxy.java b/src/java/com/android/internal/telephony/PhoneProxy.java index 77135d4..7fc2cea 100644 --- a/src/java/com/android/internal/telephony/PhoneProxy.java +++ b/src/java/com/android/internal/telephony/PhoneProxy.java @@ -26,6 +26,8 @@ import android.os.AsyncResult; import android.os.Handler; import android.os.Message; import android.os.SystemProperties; +import android.os.UserHandle; +import android.telephony.CellInfo; import android.telephony.CellLocation; import android.telephony.ServiceState; import android.telephony.SignalStrength; @@ -202,7 +204,7 @@ public class PhoneProxy extends Handler implements Phone { Intent intent = new Intent(TelephonyIntents.ACTION_RADIO_TECHNOLOGY_CHANGED); intent.addFlags(Intent.FLAG_RECEIVER_REPLACE_PENDING); intent.putExtra(PhoneConstants.PHONE_NAME_KEY, mActivePhone.getPhoneName()); - ActivityManagerNative.broadcastStickyIntent(intent, null); + ActivityManagerNative.broadcastStickyIntent(intent, null, UserHandle.USER_ALL); } @@ -256,6 +258,14 @@ public class PhoneProxy extends Handler implements Phone { return mActivePhone.getCellLocation(); } + /** + * @return all available cell information or null if none. + */ + @Override + public List<CellInfo> getAllCellInfo() { + return mActivePhone.getAllCellInfo(); + } + public PhoneConstants.DataState getDataConnectionState() { return mActivePhone.getDataConnectionState(PhoneConstants.APN_TYPE_DEFAULT); } diff --git a/src/java/com/android/internal/telephony/RIL.java b/src/java/com/android/internal/telephony/RIL.java index c359652..b64ec0d 100755..100644 --- a/src/java/com/android/internal/telephony/RIL.java +++ b/src/java/com/android/internal/telephony/RIL.java @@ -197,7 +197,6 @@ class RILRequest { /** * RIL implementation of the CommandsInterface. - * FIXME public only for testing * * {@hide} */ diff --git a/src/java/com/android/internal/telephony/ServiceStateTracker.java b/src/java/com/android/internal/telephony/ServiceStateTracker.java index 1628a3d..5975b15 100755..100644 --- a/src/java/com/android/internal/telephony/ServiceStateTracker.java +++ b/src/java/com/android/internal/telephony/ServiceStateTracker.java @@ -22,12 +22,15 @@ import android.os.Looper; import android.os.Message; import android.os.Registrant; import android.os.RegistrantList; +import android.os.SystemClock; +import android.telephony.CellInfo; import android.telephony.ServiceState; import android.telephony.SignalStrength; import android.util.TimeUtils; import java.io.FileDescriptor; import java.io.PrintWriter; +import java.util.List; import com.android.internal.telephony.uicc.UiccController; @@ -41,12 +44,20 @@ public abstract class ServiceStateTracker extends Handler { protected IccCard mIccCard = null; protected IccRecords mIccRecords = null; - public ServiceState ss; - protected ServiceState newSS; + protected PhoneBase mPhoneBase; - public SignalStrength mSignalStrength; + public ServiceState ss = new ServiceState(); + protected ServiceState newSS = new ServiceState(); - // TODO - this should not be public + protected CellInfo mLastCellInfo = null; + + // This is final as subclasses alias to a more specific type + // so we don't want the reference to change. + protected final CellInfo mCellInfo; + + protected SignalStrength mSignalStrength = new SignalStrength(); + + // TODO - this should not be public, right now used externally GsmConnetion. public RestrictedState mRestrictedState = new RestrictedState(); /* The otaspMode passed to PhoneStateListener#onOtaspChanged */ @@ -127,7 +138,7 @@ public abstract class ServiceStateTracker extends Handler { protected static final int EVENT_GET_SIGNAL_STRENGTH_CDMA = 29; protected static final int EVENT_NETWORK_STATE_CHANGED_CDMA = 30; protected static final int EVENT_GET_LOC_DONE_CDMA = 31; - protected static final int EVENT_SIGNAL_STRENGTH_UPDATE_CDMA = 32; + //protected static final int EVENT_UNUSED = 32; protected static final int EVENT_NV_LOADED = 33; protected static final int EVENT_POLL_STATE_CDMA_SUBSCRIPTION = 34; protected static final int EVENT_NV_READY = 35; @@ -174,16 +185,40 @@ public abstract class ServiceStateTracker extends Handler { protected static final String REGISTRATION_DENIED_GEN = "General"; protected static final String REGISTRATION_DENIED_AUTH = "Authentication Failure"; - public ServiceStateTracker(PhoneBase p, CommandsInterface ci) { + protected ServiceStateTracker(PhoneBase phoneBase, CommandsInterface ci, CellInfo cellInfo) { + mPhoneBase = phoneBase; + mCellInfo = cellInfo; cm = ci; mUiccController = UiccController.getInstance(); mUiccController.registerForIccChanged(this, EVENT_ICC_CHANGED, null); + cm.setOnSignalStrengthUpdate(this, EVENT_SIGNAL_STRENGTH_UPDATE, null); + } + + public void dispose() { + cm.unSetOnSignalStrengthUpdate(this); } public boolean getDesiredPowerState() { return mDesiredPowerState; } + private SignalStrength mLastSignalStrength = null; + protected boolean notifySignalStrength() { + boolean notified = false; + synchronized(mCellInfo) { + if (!mSignalStrength.equals(mLastSignalStrength)) { + try { + mPhoneBase.notifySignalStrength(); + notified = true; + } catch (NullPointerException ex) { + loge("updateSignalStrength() Phone already destroyed: " + ex + + "SignalStrength not notified"); + } + } + } + return notified; + } + /** * Registration point for combined roaming on * combined roaming is true when roaming is true and ONS differs SPN @@ -470,8 +505,10 @@ public abstract class ServiceStateTracker extends Handler { /** * send signal-strength-changed notification if changed Called both for * solicited and unsolicited signal strength updates + * + * @return true if the signal strength changed and a notification was sent. */ - protected void onSignalStrengthResult(AsyncResult ar, PhoneBase phone, boolean isGsm) { + protected boolean onSignalStrengthResult(AsyncResult ar, boolean isGsm) { SignalStrength oldSignalStrength = mSignalStrength; // This signal is used for both voice and data radio signal so parse @@ -486,17 +523,7 @@ public abstract class ServiceStateTracker extends Handler { mSignalStrength = new SignalStrength(isGsm); } - if (!mSignalStrength.equals(oldSignalStrength)) { - try { - // This takes care of delayed EVENT_POLL_SIGNAL_STRENGTH - // (scheduled after POLL_PERIOD_MILLIS) during Radio Technology - // Change) - phone.notifySignalStrength(); - } catch (NullPointerException ex) { - log("onSignalStrengthResult() Phone already destroyed: " + ex - + "SignalStrength not notified"); - } - } + return notifySignalStrength(); } /** @@ -567,11 +594,27 @@ public abstract class ServiceStateTracker extends Handler { return retVal; } + /** + * @return all available cell information or null if none. + */ + public List<CellInfo> getAllCellInfo() { + return null; + } + + /** + * @return signal strength + */ + public SignalStrength getSignalStrength() { + synchronized(mCellInfo) { + return mSignalStrength; + } + } + public void dump(FileDescriptor fd, PrintWriter pw, String[] args) { pw.println("ServiceStateTracker:"); pw.println(" ss=" + ss); pw.println(" newSS=" + newSS); - pw.println(" mSignalStrength=" + mSignalStrength); + pw.println(" mCellInfo=" + mCellInfo); pw.println(" mRestrictedState=" + mRestrictedState); pw.println(" pollingContext=" + pollingContext); pw.println(" mDesiredPowerState=" + mDesiredPowerState); diff --git a/src/java/com/android/internal/telephony/cdma/CDMAPhone.java b/src/java/com/android/internal/telephony/cdma/CDMAPhone.java index 227b406..3e966f4 100755 --- a/src/java/com/android/internal/telephony/cdma/CDMAPhone.java +++ b/src/java/com/android/internal/telephony/cdma/CDMAPhone.java @@ -31,6 +31,7 @@ import android.os.PowerManager.WakeLock; import android.os.Registrant; import android.os.RegistrantList; import android.os.SystemProperties; +import android.os.UserHandle; import android.preference.PreferenceManager; import android.provider.Telephony; import android.telephony.CellLocation; @@ -363,10 +364,6 @@ public class CDMAPhone extends PhoneBase { throw new CallStateException("Sending UUS information NOT supported in CDMA!"); } - public SignalStrength getSignalStrength() { - return mSST.mSignalStrength; - } - public boolean getMessageWaitingIndicator() { return (getVoiceMessageCount() > 0); @@ -851,7 +848,7 @@ public class CDMAPhone extends PhoneBase { //Send an Intent Intent intent = new Intent(TelephonyIntents.ACTION_EMERGENCY_CALLBACK_MODE_CHANGED); intent.putExtra(PhoneConstants.PHONE_IN_ECM_STATE, mIsPhoneInEcmState); - ActivityManagerNative.broadcastStickyIntent(intent,null); + ActivityManagerNative.broadcastStickyIntent(intent,null,UserHandle.USER_ALL); if (DBG) Log.d(LOG_TAG, "sendEmergencyCallbackModeChange"); } diff --git a/src/java/com/android/internal/telephony/cdma/CdmaLteServiceStateTracker.java b/src/java/com/android/internal/telephony/cdma/CdmaLteServiceStateTracker.java index c19cc5e..e82f07d 100755..100644 --- a/src/java/com/android/internal/telephony/cdma/CdmaLteServiceStateTracker.java +++ b/src/java/com/android/internal/telephony/cdma/CdmaLteServiceStateTracker.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2008 The Android Open Source Project + * Copyright (C) 2012 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,12 +23,17 @@ import com.android.internal.telephony.EventLogTags; import com.android.internal.telephony.RILConstants; import com.android.internal.telephony.IccCard; -import android.content.Intent; +import android.telephony.CellInfo; +import android.telephony.CellInfoLte; +import android.telephony.CellSignalStrengthLte; +import android.telephony.CellIdentityLte; import android.telephony.SignalStrength; import android.telephony.ServiceState; import android.telephony.cdma.CdmaCellLocation; +import android.text.TextUtils; import android.os.AsyncResult; import android.os.Message; +import android.os.SystemClock; import android.os.SystemProperties; import android.text.TextUtils; @@ -40,17 +45,27 @@ import com.android.internal.telephony.IccCardConstants; import java.io.FileDescriptor; import java.io.PrintWriter; +import java.util.ArrayList; +import java.util.List; public class CdmaLteServiceStateTracker extends CdmaServiceStateTracker { - CDMALTEPhone mCdmaLtePhone; + private CDMALTEPhone mCdmaLtePhone; + private final CellInfoLte mCellInfoLte; private ServiceState mLteSS; // The last LTE state from Voice Registration + private CellIdentityLte mNewCellIdentityLte = new CellIdentityLte(); + private CellIdentityLte mLasteCellIdentityLte = new CellIdentityLte(); + public CdmaLteServiceStateTracker(CDMALTEPhone phone) { - super(phone); + super(phone, new CellInfoLte()); mCdmaLtePhone = phone; + mCellInfoLte = (CellInfoLte) mCellInfo; mLteSS = new ServiceState(); + ((CellInfoLte)mCellInfo).setCellSignalStrength(new CellSignalStrengthLte()); + ((CellInfoLte)mCellInfo).setCellIdentity(new CellIdentityLte()); + if (DBG) log("CdmaLteServiceStateTracker Constructors"); } @@ -101,8 +116,11 @@ public class CdmaLteServiceStateTracker extends CdmaServiceStateTracker { @Override protected void handlePollStateResultMessage(int what, AsyncResult ar) { if (what == EVENT_POLL_STATE_GPRS) { - if (DBG) log("handlePollStateResultMessage: EVENT_POLL_STATE_GPRS"); String states[] = (String[])ar.result; + if (DBG) { + log("handlePollStateResultMessage: EVENT_POLL_STATE_GPRS states.length=" + + states.length + " states=" + states); + } int type = 0; int regState = -1; @@ -118,6 +136,71 @@ public class CdmaLteServiceStateTracker extends CdmaServiceStateTracker { loge("handlePollStateResultMessage: error parsing GprsRegistrationState: " + ex); } + if (states.length >= 10) { + int mcc; + int mnc; + int tac; + int pci; + int eci; + int csgid; + String operatorNumeric = null; + + try { + operatorNumeric = mLteSS.getOperatorNumeric(); + mcc = Integer.parseInt(operatorNumeric.substring(0,3)); + } catch (Exception e) { + try { + operatorNumeric = ss.getOperatorNumeric(); + mcc = Integer.parseInt(operatorNumeric.substring(0,3)); + } catch (Exception ex) { + loge("handlePollStateResultMessage: bad mcc operatorNumeric=" + + operatorNumeric + " ex=" + ex); + operatorNumeric = ""; + mcc = Integer.MAX_VALUE; + } + } + try { + mnc = Integer.parseInt(operatorNumeric.substring(3)); + } catch (Exception e) { + loge("handlePollStateResultMessage: bad mnc operatorNumeric=" + + operatorNumeric + " e=" + e); + mnc = Integer.MAX_VALUE; + } + try { + tac = Integer.parseInt(states[6], 16); + } catch (Exception e) { + loge("handlePollStateResultMessage: bad tac states[6]=" + + states[6] + " e=" + e); + tac = Integer.MAX_VALUE; + } + try { + pci = Integer.parseInt(states[7], 16); + } catch (Exception e) { + loge("handlePollStateResultMessage: bad pci states[7]=" + + states[7] + " e=" + e); + pci = Integer.MAX_VALUE; + } + try { + eci = Integer.parseInt(states[8], 16); + } catch (Exception e) { + loge("handlePollStateResultMessage: bad eci states[8]=" + + states[8] + " e=" + e); + eci = Integer.MAX_VALUE; + } + try { + csgid = Integer.parseInt(states[9], 16); + } catch (Exception e) { + // FIX: Always bad so don't pollute the logs + // loge("handlePollStateResultMessage: bad csgid states[9]=" + + // states[9] + " e=" + e); + csgid = Integer.MAX_VALUE; + } + mNewCellIdentityLte = new CellIdentityLte(mcc, mnc, eci, pci, tac); + if (DBG) { + log("handlePollStateResultMessage: mNewLteCellIdentity=" + + mNewCellIdentityLte); + } + } } mLteSS.setRadioTechnology(type); @@ -165,18 +248,10 @@ public class CdmaLteServiceStateTracker extends CdmaServiceStateTracker { cm.getVoiceRegistrationState(obtainMessage(EVENT_POLL_STATE_REGISTRATION_CDMA, pollingContext)); - int networkMode = android.provider.Settings.Secure.getInt(phone.getContext() - .getContentResolver(), - android.provider.Settings.Secure.PREFERRED_NETWORK_MODE, - RILConstants.PREFERRED_NETWORK_MODE); - if (DBG) log("pollState: network mode here is = " + networkMode); - if ((networkMode == RILConstants.NETWORK_MODE_GLOBAL) - || (networkMode == RILConstants.NETWORK_MODE_LTE_ONLY)) { - pollingContext[0]++; - // RIL_REQUEST_DATA_REGISTRATION_STATE - cm.getDataRegistrationState(obtainMessage(EVENT_POLL_STATE_GPRS, - pollingContext)); - } + pollingContext[0]++; + // RIL_REQUEST_DATA_REGISTRATION_STATE + cm.getDataRegistrationState(obtainMessage(EVENT_POLL_STATE_GPRS, + pollingContext)); break; } } @@ -434,14 +509,53 @@ public class CdmaLteServiceStateTracker extends CdmaServiceStateTracker { if (hasLocationChanged) { phone.notifyLocationChanged(); } + + ArrayList<CellInfo> arrayCi = new ArrayList<CellInfo>(); + synchronized(mCellInfo) { + CellInfoLte cil = (CellInfoLte)mCellInfo; + + boolean cidChanged = ! mNewCellIdentityLte.equals(mLasteCellIdentityLte); + if (hasRegistered || hasDeregistered || cidChanged) { + // TODO: Handle the absence of LteCellIdentity + long timeStamp = SystemClock.elapsedRealtime() * 1000; + boolean registered = ss.getState() == ServiceState.STATE_IN_SERVICE; + mLasteCellIdentityLte = mNewCellIdentityLte; + + cil.setRegisterd(registered); + cil.setCellIdentity(mLasteCellIdentityLte); + if (DBG) { + log("pollStateDone: hasRegistered=" + hasRegistered + + " hasDeregistered=" + hasDeregistered + + " cidChanged=" + cidChanged + + " mCellInfo=" + mCellInfo); + } + arrayCi.add(mCellInfo); + } + mPhoneBase.notifyCellInfo(arrayCi); + } } @Override - protected void onSignalStrengthResult(AsyncResult ar, PhoneBase phone, boolean isGsm) { + protected boolean onSignalStrengthResult(AsyncResult ar, boolean isGsm) { if (mRilRadioTechnology == ServiceState.RIL_RADIO_TECHNOLOGY_LTE) { isGsm = true; } - super.onSignalStrengthResult(ar, phone, isGsm); + boolean ssChanged = super.onSignalStrengthResult(ar, isGsm); + + synchronized (mCellInfo) { + if (mRilRadioTechnology == ServiceState.RIL_RADIO_TECHNOLOGY_LTE) { + mCellInfoLte.setTimeStamp(SystemClock.elapsedRealtime() * 1000); + mCellInfoLte.setTimeStampType(CellInfo.TIMESTAMP_TYPE_JAVA_RIL); + mCellInfoLte.getCellSignalStrength() + .initialize(mSignalStrength,SignalStrength.INVALID); + } + if (mCellInfoLte.getCellIdentity() != null) { + ArrayList<CellInfo> arrayCi = new ArrayList<CellInfo>(); + arrayCi.add(mCellInfoLte); + mPhoneBase.notifyCellInfo(arrayCi); + } + } + return ssChanged; } @Override @@ -480,6 +594,20 @@ public class CdmaLteServiceStateTracker extends CdmaServiceStateTracker { return false; } + /** + * @return all available cell information, the returned List maybe empty but never null. + */ + @Override + public List<CellInfo> getAllCellInfo() { + ArrayList<CellInfo> arrayList = new ArrayList<CellInfo>(); + CellInfo ci; + synchronized(mCellInfo) { + arrayList.add(mCellInfoLte); + } + if (DBG) log ("getAllCellInfo: arrayList=" + arrayList); + return arrayList; + } + @Override protected void log(String s) { Log.d(LOG_TAG, "[CdmaLteSST] " + s); diff --git a/src/java/com/android/internal/telephony/cdma/CdmaServiceStateTracker.java b/src/java/com/android/internal/telephony/cdma/CdmaServiceStateTracker.java index 697ad73..5c91983 100755 --- a/src/java/com/android/internal/telephony/cdma/CdmaServiceStateTracker.java +++ b/src/java/com/android/internal/telephony/cdma/CdmaServiceStateTracker.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2008 The Android Open Source Project + * Copyright (C) 2012 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -47,6 +47,8 @@ import android.os.SystemProperties; import android.provider.Settings; import android.provider.Settings.Secure; import android.provider.Settings.SettingNotFoundException; +import android.telephony.CellInfo; +import android.telephony.CellInfoCdma; import android.telephony.ServiceState; import android.telephony.SignalStrength; import android.telephony.cdma.CdmaCellLocation; @@ -60,6 +62,7 @@ import java.io.PrintWriter; import java.util.Arrays; import java.util.Calendar; import java.util.Date; +import java.util.List; import java.util.TimeZone; /** @@ -157,15 +160,16 @@ public class CdmaServiceStateTracker extends ServiceStateTracker { }; public CdmaServiceStateTracker(CDMAPhone phone) { - super(phone, phone.mCM); + this(phone, new CellInfoCdma()); + } + + protected CdmaServiceStateTracker(CDMAPhone phone, CellInfo cellInfo) { + super(phone, phone.mCM, cellInfo); this.phone = phone; cr = phone.getContext().getContentResolver(); - ss = new ServiceState(); - newSS = new ServiceState(); cellLoc = new CdmaCellLocation(); newCellLoc = new CdmaCellLocation(); - mSignalStrength = new SignalStrength(); mCdmaSSM = CdmaSubscriptionSourceManager.getInstance(phone.getContext(), cm, this, EVENT_CDMA_SUBSCRIPTION_SOURCE_CHANGED, null); @@ -180,7 +184,6 @@ public class CdmaServiceStateTracker extends ServiceStateTracker { cm.registerForVoiceNetworkStateChanged(this, EVENT_NETWORK_STATE_CHANGED_CDMA, null); cm.setOnNITZTime(this, EVENT_NITZ_TIME, null); - cm.setOnSignalStrengthUpdate(this, EVENT_SIGNAL_STRENGTH_UPDATE, null); cm.registerForCdmaPrlChanged(this, EVENT_CDMA_PRL_VERSION_CHANGED, null); phone.registerForEriFileLoaded(this, EVENT_ERI_FILE_LOADED, null); @@ -199,6 +202,7 @@ public class CdmaServiceStateTracker extends ServiceStateTracker { setSignalStrengthDefaultValues(); } + @Override public void dispose() { checkCorrectThread(); // Unregister for all events. @@ -208,12 +212,12 @@ public class CdmaServiceStateTracker extends ServiceStateTracker { phone.unregisterForEriFileLoaded(this); if (mIccCard != null) {mIccCard.unregisterForReady(this);} if (mIccRecords != null) {mIccRecords.unregisterForRecordsLoaded(this);} - cm.unSetOnSignalStrengthUpdate(this); cm.unSetOnNITZTime(this); cr.unregisterContentObserver(mAutoTimeObserver); cr.unregisterContentObserver(mAutoTimeZoneObserver); mCdmaSSM.dispose(this); cm.unregisterForCdmaPrlChanged(this); + super.dispose(); } @Override @@ -322,7 +326,7 @@ public class CdmaServiceStateTracker extends ServiceStateTracker { return; } ar = (AsyncResult) msg.obj; - onSignalStrengthResult(ar, phone, false); + onSignalStrengthResult(ar, false); queueNextSignalStrengthPoll(); break; @@ -443,7 +447,7 @@ public class CdmaServiceStateTracker extends ServiceStateTracker { // so we don't have to ask it. dontPollSignalStrength = true; - onSignalStrengthResult(ar, phone, false); + onSignalStrengthResult(ar, false); break; case EVENT_RUIM_RECORDS_LOADED: @@ -1070,6 +1074,7 @@ public class CdmaServiceStateTracker extends ServiceStateTracker { if (hasLocationChanged) { phone.notifyLocationChanged(); } + // TODO: Add CdmaCellIdenity updating, see CdmaLteServiceStateTracker. } /** @@ -1337,7 +1342,8 @@ public class CdmaServiceStateTracker extends ServiceStateTracker { mZoneTime = c.getTimeInMillis(); } if (DBG) { - log("NITZ: tzOffset=" + tzOffset + " dst=" + dst + " zone=" + zone.getID() + + log("NITZ: tzOffset=" + tzOffset + " dst=" + dst + " zone=" + + (zone!=null ? zone.getID() : "NULL") + " iso=" + iso + " mGotCountryCode=" + mGotCountryCode + " mNeedFixZone=" + mNeedFixZone); } @@ -1691,6 +1697,14 @@ public class CdmaServiceStateTracker extends ServiceStateTracker { } } + /** + * @return all available cell information or null if none. + */ + @Override + public List<CellInfo> getAllCellInfo() { + return null; + } + @Override protected void log(String s) { Log.d(LOG_TAG, "[CdmaSST] " + s); diff --git a/src/java/com/android/internal/telephony/gsm/GSMPhone.java b/src/java/com/android/internal/telephony/gsm/GSMPhone.java index b429cd2..06ae841 100644 --- a/src/java/com/android/internal/telephony/gsm/GSMPhone.java +++ b/src/java/com/android/internal/telephony/gsm/GSMPhone.java @@ -262,18 +262,14 @@ public class GSMPhone extends PhoneBase { return PhoneConstants.PHONE_TYPE_GSM; } - public SignalStrength getSignalStrength() { - return mSST.mSignalStrength; + public ServiceStateTracker getServiceStateTracker() { + return mSST; } public CallTracker getCallTracker() { return mCT; } - public ServiceStateTracker getServiceStateTracker() { - return mSST; - } - public List<? extends MmiCode> getPendingMmiCodes() { return mPendingMMIs; diff --git a/src/java/com/android/internal/telephony/gsm/GsmServiceStateTracker.java b/src/java/com/android/internal/telephony/gsm/GsmServiceStateTracker.java index 42443fe..bf37a62 100755..100644 --- a/src/java/com/android/internal/telephony/gsm/GsmServiceStateTracker.java +++ b/src/java/com/android/internal/telephony/gsm/GsmServiceStateTracker.java @@ -52,6 +52,8 @@ import android.os.SystemClock; import android.os.SystemProperties; import android.provider.Settings; import android.provider.Settings.SettingNotFoundException; +import android.telephony.CellInfo; +import android.telephony.CellInfoGsm; import android.telephony.ServiceState; import android.telephony.SignalStrength; import android.telephony.gsm.GsmCellLocation; @@ -187,14 +189,11 @@ final class GsmServiceStateTracker extends ServiceStateTracker { }; public GsmServiceStateTracker(GSMPhone phone) { - super(phone, phone.mCM); + super(phone, phone.mCM, new CellInfoGsm()); this.phone = phone; - ss = new ServiceState(); - newSS = new ServiceState(); cellLoc = new GsmCellLocation(); newCellLoc = new GsmCellLocation(); - mSignalStrength = new SignalStrength(); PowerManager powerManager = (PowerManager)phone.getContext().getSystemService(Context.POWER_SERVICE); @@ -205,7 +204,6 @@ final class GsmServiceStateTracker extends ServiceStateTracker { cm.registerForVoiceNetworkStateChanged(this, EVENT_NETWORK_STATE_CHANGED, null); cm.setOnNITZTime(this, EVENT_NITZ_TIME, null); - cm.setOnSignalStrengthUpdate(this, EVENT_SIGNAL_STRENGTH_UPDATE, null); cm.setOnRestrictedStateChanged(this, EVENT_RESTRICTED_STATE_CHANGED, null); // system setting property AIRPLANE_MODE_ON is set in Settings. @@ -233,6 +231,7 @@ final class GsmServiceStateTracker extends ServiceStateTracker { phone.notifyOtaspChanged(OTASP_NOT_NEEDED); } + @Override public void dispose() { checkCorrectThread(); // Unregister for all events. @@ -241,12 +240,12 @@ final class GsmServiceStateTracker extends ServiceStateTracker { cm.unregisterForVoiceNetworkStateChanged(this); if (mIccCard != null) {mIccCard.unregisterForReady(this);} if (mIccRecords != null) {mIccRecords.unregisterForRecordsLoaded(this);} - cm.unSetOnSignalStrengthUpdate(this); cm.unSetOnRestrictedStateChanged(this); cm.unSetOnNITZTime(this); cr.unregisterContentObserver(this.mAutoTimeObserver); cr.unregisterContentObserver(this.mAutoTimeZoneObserver); phone.getContext().unregisterReceiver(mIntentReceiver); + super.dispose(); } protected void finalize() { @@ -311,7 +310,7 @@ final class GsmServiceStateTracker extends ServiceStateTracker { return; } ar = (AsyncResult) msg.obj; - onSignalStrengthResult(ar, phone, true); + onSignalStrengthResult(ar, true); queueNextSignalStrengthPoll(); break; @@ -378,7 +377,7 @@ final class GsmServiceStateTracker extends ServiceStateTracker { // we don't have to ask it dontPollSignalStrength = true; - onSignalStrengthResult(ar, phone, true); + onSignalStrengthResult(ar, true); break; case EVENT_SIM_RECORDS_LOADED: @@ -1002,6 +1001,7 @@ final class GsmServiceStateTracker extends ServiceStateTracker { } else { mReportedGprsNoReg = false; } + // TODO: Add GsmCellIdenity updating, see CdmaLteServiceStateTracker. } /** diff --git a/src/java/com/android/internal/telephony/sip/SipPhoneBase.java b/src/java/com/android/internal/telephony/sip/SipPhoneBase.java index b0a6080..43b0de3 100755 --- a/src/java/com/android/internal/telephony/sip/SipPhoneBase.java +++ b/src/java/com/android/internal/telephony/sip/SipPhoneBase.java @@ -24,6 +24,7 @@ import android.os.Message; import android.os.Registrant; import android.os.RegistrantList; import android.os.SystemProperties; +import android.telephony.CellInfo; import android.telephony.CellLocation; import android.telephony.ServiceState; import android.telephony.SignalStrength; @@ -120,6 +121,14 @@ abstract class SipPhoneBase extends PhoneBase { return s; } + /** + * @return all available cell information or null if none. + */ + @Override + public List<CellInfo> getAllCellInfo() { + return getServiceStateTracker().getAllCellInfo(); + } + public CellLocation getCellLocation() { return null; } |