use of android.telephony.PhysicalChannelConfig in project android_frameworks_opt_telephony by LineageOS.
the class PhysicalChannelConfigTest method testBuilder.
@Test
public void testBuilder() {
PhysicalChannelConfig config = new Builder().setRat(RAT).setCellConnectionStatus(CONNECTION_STATUS).setCellBandwidthDownlinkKhz(CELL_BANDWIDTH).setFrequencyRange(FREQUENCY_RANGE).setChannelNumber(CHANNEL_NUMBER).setContextIds(CONTEXT_IDS).setPhysicalCellId(PHYSICAL_CELL_ID).build();
assertThat(config.getRat()).isEqualTo(RAT);
assertThat(config.getConnectionStatus()).isEqualTo(CONNECTION_STATUS);
assertThat(config.getCellBandwidthDownlink()).isEqualTo(CELL_BANDWIDTH);
assertThat(config.getFrequencyRange()).isEqualTo(FREQUENCY_RANGE);
assertThat(config.getChannelNumber()).isEqualTo(CHANNEL_NUMBER);
assertThat(config.getContextIds()).isEqualTo(CONTEXT_IDS);
assertThat(config.getPhysicalCellId()).isEqualTo(PHYSICAL_CELL_ID);
}
use of android.telephony.PhysicalChannelConfig in project android_frameworks_opt_telephony by LineageOS.
the class Phone method registerForPhysicalChannelConfig.
/**
* Registration point for PhysicalChannelConfig change.
* @param h handler to notify
* @param what what code of message when delivered
* @param obj placed in Message.obj.userObj
*/
public void registerForPhysicalChannelConfig(Handler h, int what, Object obj) {
checkCorrectThread(h);
Registrant registrant = new Registrant(h, what, obj);
mPhysicalChannelConfigRegistrants.add(registrant);
// notify first
List<PhysicalChannelConfig> physicalChannelConfigs = getPhysicalChannelConfigList();
if (physicalChannelConfigs != null) {
registrant.notifyRegistrant(new AsyncResult(null, physicalChannelConfigs, null));
}
}
use of android.telephony.PhysicalChannelConfig in project android_frameworks_opt_telephony by LineageOS.
the class ServiceStateTracker method handleMessage.
@Override
public void handleMessage(Message msg) {
AsyncResult ar;
int[] ints;
Message message;
if (VDBG)
log("received event " + msg.what);
switch(msg.what) {
case EVENT_SET_RADIO_POWER_OFF:
synchronized (this) {
if (mPendingRadioPowerOffAfterDataOff && (msg.arg1 == mPendingRadioPowerOffAfterDataOffTag)) {
if (DBG)
log("EVENT_SET_RADIO_OFF, turn radio off now.");
hangupAndPowerOff();
mPendingRadioPowerOffAfterDataOffTag += 1;
mPendingRadioPowerOffAfterDataOff = false;
} else {
log("EVENT_SET_RADIO_OFF is stale arg1=" + msg.arg1 + "!= tag=" + mPendingRadioPowerOffAfterDataOffTag);
}
}
break;
case EVENT_ICC_CHANGED:
if (isSimAbsent()) {
if (DBG)
log("EVENT_ICC_CHANGED: SIM absent");
// cancel notifications if SIM is removed/absent
cancelAllNotifications();
// clear cached values on SIM removal
mMdn = null;
mMin = null;
mIsMinInfoReady = false;
// Remove the EF records that come from UICC.
mCdnr.updateEfFromRuim(null);
mCdnr.updateEfFromUsim(null);
}
onUpdateIccAvailability();
if (mUiccApplcation == null || mUiccApplcation.getState() != AppState.APPSTATE_READY) {
mIsSimReady = false;
updateSpnDisplay();
}
break;
// fallthrough
case EVENT_GET_CELL_INFO_LIST:
case EVENT_UNSOL_CELL_INFO_LIST:
{
List<CellInfo> cellInfo = null;
Throwable ex = null;
if (msg.obj != null) {
ar = (AsyncResult) msg.obj;
if (ar.exception != null) {
log("EVENT_GET_CELL_INFO_LIST: error ret null, e=" + ar.exception);
ex = ar.exception;
} else if (ar.result == null) {
loge("Invalid CellInfo result");
} else {
cellInfo = (List<CellInfo>) ar.result;
updateOperatorNameForCellInfo(cellInfo);
mLastCellInfoList = cellInfo;
mPhone.notifyCellInfo(cellInfo);
if (VDBG) {
log("CELL_INFO_LIST: size=" + cellInfo.size() + " list=" + cellInfo);
}
}
} else {
synchronized (mPendingCellInfoRequests) {
// pending request, drop it.
if (!mIsPendingCellInfoRequest)
break;
// If there is a request pending, we still need to check whether it's a
// timeout for the current request of whether it's leftover from a
// previous request.
final long curTime = SystemClock.elapsedRealtime();
if ((curTime - mLastCellInfoReqTime) < CELL_INFO_LIST_QUERY_TIMEOUT) {
break;
}
// We've received a legitimate timeout, so something has gone terribly
// wrong.
loge("Timeout waiting for CellInfo; (everybody panic)!");
mLastCellInfoList = null;
// Since the timeout is applicable, fall through and update all synchronous
// callers with the failure.
}
}
synchronized (mPendingCellInfoRequests) {
// timeout, we send null responses back to the callers.
if (mIsPendingCellInfoRequest) {
// regardless of timeout or valid response, when something arrives,
mIsPendingCellInfoRequest = false;
for (Message m : mPendingCellInfoRequests) {
AsyncResult.forMessage(m, cellInfo, ex);
m.sendToTarget();
}
mPendingCellInfoRequests.clear();
}
}
break;
}
case // received unsol
EVENT_IMS_STATE_CHANGED:
mCi.getImsRegistrationState(this.obtainMessage(EVENT_IMS_STATE_DONE));
break;
case EVENT_IMS_STATE_DONE:
ar = (AsyncResult) msg.obj;
if (ar.exception == null) {
int[] responseArray = (int[]) ar.result;
mImsRegistered = (responseArray[0] == 1) ? true : false;
}
break;
case EVENT_RADIO_POWER_OFF_DONE:
if (DBG)
log("EVENT_RADIO_POWER_OFF_DONE");
if (mDeviceShuttingDown && mCi.getRadioState() != TelephonyManager.RADIO_POWER_UNAVAILABLE) {
// during shutdown the modem may not send radio state changed event
// as a result of radio power request
// Hence, issuing shut down regardless of radio power response
mCi.requestShutdown(null);
}
break;
// GSM
case EVENT_SIM_READY:
// Reset the mPreviousSubId so we treat a SIM power bounce
// as a first boot. See b/19194287
mOnSubscriptionsChangedListener.mPreviousSubId.set(SubscriptionManager.INVALID_SUBSCRIPTION_ID);
mPrevSubId = SubscriptionManager.INVALID_SUBSCRIPTION_ID;
mIsSimReady = true;
pollStateInternal(false);
// Signal strength polling stops when radio is off
queueNextSignalStrengthPoll();
break;
case EVENT_RADIO_STATE_CHANGED:
case EVENT_PHONE_TYPE_SWITCHED:
if (!mPhone.isPhoneTypeGsm() && mCi.getRadioState() == TelephonyManager.RADIO_POWER_ON) {
handleCdmaSubscriptionSource(mCdmaSSM.getCdmaSubscriptionSource());
// Signal strength polling stops when radio is off.
queueNextSignalStrengthPoll();
}
// This will do nothing in the 'radio not available' case
setPowerStateToDesired();
if (needsLegacyPollState()) {
// Some older radio blobs need this to put device
// properly into airplane mode.
pollState();
} else {
// These events are modem triggered, so pollState() needs to be forced
pollStateInternal(true);
}
break;
case EVENT_NETWORK_STATE_CHANGED:
pollStateInternal(true);
break;
case EVENT_GET_SIGNAL_STRENGTH:
if (!(mCi.getRadioState() == TelephonyManager.RADIO_POWER_ON)) {
// Polling will continue when radio turns back on
return;
}
ar = (AsyncResult) msg.obj;
onSignalStrengthResult(ar);
queueNextSignalStrengthPoll();
break;
case EVENT_GET_LOC_DONE:
ar = (AsyncResult) msg.obj;
if (ar.exception == null) {
CellIdentity cellIdentity = ((NetworkRegistrationInfo) ar.result).getCellIdentity();
updateOperatorNameForCellIdentity(cellIdentity);
mCellIdentity = cellIdentity;
mPhone.notifyLocationChanged(getCellIdentity());
}
// Release any temporary cell lock, which could have been
// acquired to allow a single-shot location update.
disableSingleLocationUpdate();
break;
case EVENT_POLL_STATE_CS_CELLULAR_REGISTRATION:
case EVENT_POLL_STATE_PS_CELLULAR_REGISTRATION:
case EVENT_POLL_STATE_PS_IWLAN_REGISTRATION:
case EVENT_POLL_STATE_OPERATOR:
ar = (AsyncResult) msg.obj;
handlePollStateResult(msg.what, ar);
break;
case EVENT_POLL_STATE_NETWORK_SELECTION_MODE:
if (DBG)
log("EVENT_POLL_STATE_NETWORK_SELECTION_MODE");
ar = (AsyncResult) msg.obj;
if (mPhone.isPhoneTypeGsm()) {
handlePollStateResult(msg.what, ar);
} else {
if (ar.exception == null && ar.result != null) {
ints = (int[]) ar.result;
if (ints[0] == 1) {
// Manual selection.
mPhone.setNetworkSelectionModeAutomatic(null);
}
} else {
log("Unable to getNetworkSelectionMode");
}
}
break;
case EVENT_POLL_SIGNAL_STRENGTH:
// Just poll signal strength...not part of pollState()
mCi.getSignalStrength(obtainMessage(EVENT_GET_SIGNAL_STRENGTH));
break;
case EVENT_NITZ_TIME:
ar = (AsyncResult) msg.obj;
String nitzString = (String) ((Object[]) ar.result)[0];
long nitzReceiveTime = ((Long) ((Object[]) ar.result)[1]).longValue();
setTimeFromNITZString(nitzString, nitzReceiveTime);
break;
case EVENT_SIGNAL_STRENGTH_UPDATE:
// This is a notification from CommandsInterface.setOnSignalStrengthUpdate
ar = (AsyncResult) msg.obj;
// The radio is telling us about signal strength changes
// we don't have to ask it
mDontPollSignalStrength = true;
onSignalStrengthResult(ar);
break;
case EVENT_SIM_RECORDS_LOADED:
log("EVENT_SIM_RECORDS_LOADED: what=" + msg.what);
updatePhoneObject();
updateOtaspState();
if (mPhone.isPhoneTypeGsm()) {
mCdnr.updateEfFromUsim((SIMRecords) mIccRecords);
updateSpnDisplay();
}
break;
case EVENT_LOCATION_UPDATES_ENABLED:
ar = (AsyncResult) msg.obj;
if (ar.exception == null) {
mRegStateManagers.get(AccessNetworkConstants.TRANSPORT_TYPE_WWAN).requestNetworkRegistrationInfo(NetworkRegistrationInfo.DOMAIN_CS, obtainMessage(EVENT_GET_LOC_DONE, null));
}
break;
case EVENT_SET_PREFERRED_NETWORK_TYPE:
ar = (AsyncResult) msg.obj;
// Don't care the result, only use for dereg network (COPS=2)
message = obtainMessage(EVENT_RESET_PREFERRED_NETWORK_TYPE, ar.userObj);
mCi.setPreferredNetworkType(mPreferredNetworkType, message);
break;
case EVENT_RESET_PREFERRED_NETWORK_TYPE:
ar = (AsyncResult) msg.obj;
if (ar.userObj != null) {
AsyncResult.forMessage(((Message) ar.userObj)).exception = ar.exception;
((Message) ar.userObj).sendToTarget();
}
break;
case EVENT_GET_PREFERRED_NETWORK_TYPE:
ar = (AsyncResult) msg.obj;
if (ar.exception == null) {
mPreferredNetworkType = ((int[]) ar.result)[0];
} else {
mPreferredNetworkType = RILConstants.NETWORK_MODE_GLOBAL;
}
message = obtainMessage(EVENT_SET_PREFERRED_NETWORK_TYPE, ar.userObj);
int toggledNetworkType = RILConstants.NETWORK_MODE_GLOBAL;
mCi.setPreferredNetworkType(toggledNetworkType, message);
break;
case EVENT_CHECK_REPORT_GPRS:
if (mPhone.isPhoneTypeGsm() && mSS != null && !isGprsConsistent(mSS.getDataRegistrationState(), mSS.getState())) {
// Can't register data service while voice service is ok
// i.e. CREG is ok while CGREG is not
// possible a network or baseband side error
EventLog.writeEvent(EventLogTags.DATA_NETWORK_REGISTRATION_FAIL, mSS.getOperatorNumeric(), getCidFromCellIdentity(mCellIdentity));
mReportedGprsNoReg = true;
}
mStartedGprsRegCheck = false;
break;
case EVENT_RESTRICTED_STATE_CHANGED:
if (mPhone.isPhoneTypeGsm()) {
if (DBG)
log("EVENT_RESTRICTED_STATE_CHANGED");
ar = (AsyncResult) msg.obj;
onRestrictedStateChanged(ar);
}
break;
case EVENT_ALL_DATA_DISCONNECTED:
int dds = SubscriptionManager.getDefaultDataSubscriptionId();
ProxyController.getInstance().unregisterForAllDataDisconnected(dds, this);
synchronized (this) {
if (mPendingRadioPowerOffAfterDataOff) {
if (DBG)
log("EVENT_ALL_DATA_DISCONNECTED, turn radio off now.");
hangupAndPowerOff();
mPendingRadioPowerOffAfterDataOff = false;
} else {
log("EVENT_ALL_DATA_DISCONNECTED is stale");
}
}
break;
case EVENT_CHANGE_IMS_STATE:
if (DBG)
log("EVENT_CHANGE_IMS_STATE:");
setPowerStateToDesired();
break;
case EVENT_IMS_CAPABILITY_CHANGED:
if (DBG)
log("EVENT_IMS_CAPABILITY_CHANGED");
updateSpnDisplay();
mImsCapabilityChangedRegistrants.notifyRegistrants();
break;
case EVENT_IMS_SERVICE_STATE_CHANGED:
if (DBG)
log("EVENT_IMS_SERVICE_STATE_CHANGED");
// GsmCdma phone is not STATE_IN_SERVICE.
if (mSS.getState() != ServiceState.STATE_IN_SERVICE) {
mPhone.notifyServiceStateChanged(mPhone.getServiceState());
}
break;
// CDMA
case EVENT_CDMA_SUBSCRIPTION_SOURCE_CHANGED:
handleCdmaSubscriptionSource(mCdmaSSM.getCdmaSubscriptionSource());
break;
case EVENT_RUIM_READY:
if (mPhone.getLteOnCdmaMode() == PhoneConstants.LTE_ON_CDMA_TRUE) {
// Subscription will be read from SIM I/O
if (DBG)
log("Receive EVENT_RUIM_READY");
pollStateInternal(false);
} else {
if (DBG)
log("Receive EVENT_RUIM_READY and Send Request getCDMASubscription.");
getSubscriptionInfoAndStartPollingThreads();
}
// Only support automatic selection mode in CDMA.
mCi.getNetworkSelectionMode(obtainMessage(EVENT_POLL_STATE_NETWORK_SELECTION_MODE));
break;
case EVENT_NV_READY:
updatePhoneObject();
// Only support automatic selection mode in CDMA.
mCi.getNetworkSelectionMode(obtainMessage(EVENT_POLL_STATE_NETWORK_SELECTION_MODE));
// For Non-RUIM phones, the subscription information is stored in
// Non Volatile. Here when Non-Volatile is ready, we can poll the CDMA
// subscription info.
getSubscriptionInfoAndStartPollingThreads();
break;
case // Handle RIL_CDMA_SUBSCRIPTION
EVENT_POLL_STATE_CDMA_SUBSCRIPTION:
if (!mPhone.isPhoneTypeGsm()) {
ar = (AsyncResult) msg.obj;
if (ar.exception == null) {
String[] cdmaSubscription = (String[]) ar.result;
if (cdmaSubscription != null && cdmaSubscription.length >= 5) {
mMdn = cdmaSubscription[0];
parseSidNid(cdmaSubscription[1], cdmaSubscription[2]);
mMin = cdmaSubscription[3];
mPrlVersion = cdmaSubscription[4];
if (DBG)
log("GET_CDMA_SUBSCRIPTION: MDN=" + mMdn);
mIsMinInfoReady = true;
updateOtaspState();
// Notify apps subscription info is ready
notifyCdmaSubscriptionInfoReady();
if (!mIsSubscriptionFromRuim && mIccRecords != null) {
if (DBG) {
log("GET_CDMA_SUBSCRIPTION set imsi in mIccRecords");
}
mIccRecords.setImsi(getImsi());
} else {
if (DBG) {
log("GET_CDMA_SUBSCRIPTION either mIccRecords is null or NV " + "type device - not setting Imsi in mIccRecords");
}
}
} else {
if (DBG) {
log("GET_CDMA_SUBSCRIPTION: error parsing cdmaSubscription " + "params num=" + cdmaSubscription.length);
}
}
}
}
break;
case EVENT_RUIM_RECORDS_LOADED:
if (!mPhone.isPhoneTypeGsm()) {
log("EVENT_RUIM_RECORDS_LOADED: what=" + msg.what);
mCdnr.updateEfFromRuim((RuimRecords) mIccRecords);
updatePhoneObject();
if (mPhone.isPhoneTypeCdma()) {
updateSpnDisplay();
} else {
RuimRecords ruim = (RuimRecords) mIccRecords;
if (ruim != null) {
// Do not wait for RUIM to be provisioned before using mdn. Line1Number
// can be queried before that and mdn may still be available.
// Also note that any special casing is not done in getMdnNumber() as it
// may be called on another thread, so simply doing a read operation
// there.
mMdn = ruim.getMdn();
if (ruim.isProvisioned()) {
mMin = ruim.getMin();
parseSidNid(ruim.getSid(), ruim.getNid());
mPrlVersion = ruim.getPrlVersion();
mIsMinInfoReady = true;
}
updateOtaspState();
// Notify apps subscription info is ready
notifyCdmaSubscriptionInfoReady();
}
// SID/NID/PRL is loaded. Poll service state
// again to update to the roaming state with
// the latest variables.
pollStateInternal(false);
}
}
break;
case EVENT_OTA_PROVISION_STATUS_CHANGE:
ar = (AsyncResult) msg.obj;
if (ar.exception == null) {
ints = (int[]) ar.result;
int otaStatus = ints[0];
if (otaStatus == Phone.CDMA_OTA_PROVISION_STATUS_COMMITTED || otaStatus == Phone.CDMA_OTA_PROVISION_STATUS_OTAPA_STOPPED) {
if (DBG)
log("EVENT_OTA_PROVISION_STATUS_CHANGE: Complete, Reload MDN");
mCi.getCDMASubscription(obtainMessage(EVENT_POLL_STATE_CDMA_SUBSCRIPTION));
}
}
break;
case EVENT_CDMA_PRL_VERSION_CHANGED:
ar = (AsyncResult) msg.obj;
if (ar.exception == null) {
ints = (int[]) ar.result;
mPrlVersion = Integer.toString(ints[0]);
}
break;
case EVENT_RADIO_POWER_FROM_CARRIER:
ar = (AsyncResult) msg.obj;
if (ar.exception == null) {
boolean enable = (boolean) ar.result;
if (DBG)
log("EVENT_RADIO_POWER_FROM_CARRIER: " + enable);
setRadioPowerFromCarrier(enable);
}
break;
case EVENT_PHYSICAL_CHANNEL_CONFIG:
ar = (AsyncResult) msg.obj;
if (ar.exception == null) {
List<PhysicalChannelConfig> list = (List<PhysicalChannelConfig>) ar.result;
if (VDBG) {
log("EVENT_PHYSICAL_CHANNEL_CONFIG: size=" + list.size() + " list=" + list);
}
mPhone.notifyPhysicalChannelConfiguration(list);
mLastPhysicalChannelConfigList = list;
boolean hasChanged = false;
if (updateNrStateFromPhysicalChannelConfigs(list, mSS)) {
mNrStateChangedRegistrants.notifyRegistrants();
hasChanged = true;
}
if (updateNrFrequencyRangeFromPhysicalChannelConfigs(list, mSS)) {
mNrFrequencyChangedRegistrants.notifyRegistrants();
hasChanged = true;
}
hasChanged |= RatRatcheter.updateBandwidths(getBandwidthsFromConfigs(list), mSS);
// Notify NR frequency, NR connection status or bandwidths changed.
if (hasChanged) {
mPhone.notifyServiceStateChanged(mSS);
TelephonyMetrics.getInstance().writeServiceStateChanged(mPhone.getPhoneId(), mSS);
mPhone.getVoiceCallSessionStats().onServiceStateChanged(mSS);
}
}
break;
case EVENT_CELL_LOCATION_RESPONSE:
ar = (AsyncResult) msg.obj;
if (ar == null) {
loge("Invalid null response to getCellIdentity!");
break;
}
// This response means that the correct CellInfo is already cached; thus we
// can rely on the last cell info to already contain any cell info that is
// available, which means that we can return the result of the existing
// getCellIdentity() function without any additional processing here.
Message rspRspMsg = (Message) ar.userObj;
AsyncResult.forMessage(rspRspMsg, getCellIdentity(), ar.exception);
rspRspMsg.sendToTarget();
break;
case EVENT_CARRIER_CONFIG_CHANGED:
onCarrierConfigChanged();
break;
case EVENT_POLL_STATE_REQUEST:
pollStateInternal(false);
break;
default:
log("Unhandled message with number: " + msg.what);
break;
}
}
Aggregations