use of android.telephony.ServiceState in project Android-IMSI-Catcher-Detector by CellularPrivacy.
the class CellTracker method startTrackingFemto.
//=================================================================================================
// TODO: Consider REMOVAL! See issues: #6, #457, #489
// TODO: Summary: We can detect femtocells by other means, using network data that we already have!
// The below code section was copied and modified with permission from
// Femtocatcher at: https://github.com/iSECPartners/femtocatcher
//
// Copyright (C) 2013 iSEC Partners
//=================================================================================================
/**
* Start FemtoCell detection tracking (For CDMA Devices ONLY!)
*/
public void startTrackingFemto() {
/* Check if it is a CDMA phone */
if (device.getPhoneId() != TelephonyManager.PHONE_TYPE_CDMA) {
Helpers.msgShort(context, context.getString(R.string.femtocell_only_on_cdma_devices));
return;
}
trackingFemtocell = true;
mPhoneStateListener = new PhoneStateListener() {
public void onServiceStateChanged(ServiceState s) {
log.debug(context.getString(R.string.service_state_changed));
getServiceStateInfo(s);
}
};
tm.listen(mPhoneStateListener, PhoneStateListener.LISTEN_CELL_LOCATION);
tm.listen(mPhoneStateListener, PhoneStateListener.LISTEN_SERVICE_STATE);
setNotification();
}
use of android.telephony.ServiceState in project android_frameworks_base by crdroidandroid.
the class NetworkControllerSignalTest method testEmergencyOnlyNoSubscriptions.
public void testEmergencyOnlyNoSubscriptions() {
setupDefaultSignal();
setSubscriptions();
mNetworkController.mLastServiceState = new ServiceState();
mNetworkController.mLastServiceState.setEmergencyOnly(true);
mNetworkController.recalculateEmergency();
verifyEmergencyOnly(true);
}
use of android.telephony.ServiceState in project android_frameworks_base by crdroidandroid.
the class TelephonyRegistry method notifyServiceStateForPhoneId.
public void notifyServiceStateForPhoneId(int phoneId, int subId, ServiceState state) {
if (!checkNotifyPermission("notifyServiceState()")) {
return;
}
synchronized (mRecords) {
if (VDBG) {
log("notifyServiceStateForSubscriber: subId=" + subId + " phoneId=" + phoneId + " state=" + state);
}
if (validatePhoneId(phoneId)) {
mServiceState[phoneId] = state;
logServiceStateChanged("notifyServiceStateForSubscriber", subId, phoneId, state);
if (VDBG)
toStringLogSSC("notifyServiceStateForSubscriber");
for (Record r : mRecords) {
if (VDBG) {
log("notifyServiceStateForSubscriber: r=" + r + " subId=" + subId + " phoneId=" + phoneId + " state=" + state);
}
if (r.matchPhoneStateListenerEvent(PhoneStateListener.LISTEN_SERVICE_STATE) && idMatch(r.subId, subId, phoneId)) {
try {
if (DBG) {
log("notifyServiceStateForSubscriber: callback.onSSC r=" + r + " subId=" + subId + " phoneId=" + phoneId + " state=" + state);
}
r.callback.onServiceStateChanged(new ServiceState(state));
} catch (RemoteException ex) {
mRemoveList.add(r.binder);
}
}
}
} else {
log("notifyServiceStateForSubscriber: INVALID phoneId=" + phoneId);
}
handleRemoveListLocked();
}
broadcastServiceStateChanged(state, phoneId, subId);
}
use of android.telephony.ServiceState in project android_frameworks_base by crdroidandroid.
the class TelephonyRegistry method checkPossibleMissNotify.
private void checkPossibleMissNotify(Record r, int phoneId) {
int events = r.events;
if ((events & PhoneStateListener.LISTEN_SERVICE_STATE) != 0) {
try {
if (VDBG)
log("checkPossibleMissNotify: onServiceStateChanged state=" + mServiceState[phoneId]);
r.callback.onServiceStateChanged(new ServiceState(mServiceState[phoneId]));
} catch (RemoteException ex) {
mRemoveList.add(r.binder);
}
}
if ((events & PhoneStateListener.LISTEN_SIGNAL_STRENGTHS) != 0) {
try {
SignalStrength signalStrength = mSignalStrength[phoneId];
if (DBG) {
log("checkPossibleMissNotify: onSignalStrengthsChanged SS=" + signalStrength);
}
r.callback.onSignalStrengthsChanged(new SignalStrength(signalStrength));
} catch (RemoteException ex) {
mRemoveList.add(r.binder);
}
}
if ((events & PhoneStateListener.LISTEN_SIGNAL_STRENGTH) != 0) {
try {
int gsmSignalStrength = mSignalStrength[phoneId].getGsmSignalStrength();
if (DBG) {
log("checkPossibleMissNotify: onSignalStrengthChanged SS=" + gsmSignalStrength);
}
r.callback.onSignalStrengthChanged((gsmSignalStrength == 99 ? -1 : gsmSignalStrength));
} catch (RemoteException ex) {
mRemoveList.add(r.binder);
}
}
if (validateEventsAndUserLocked(r, PhoneStateListener.LISTEN_CELL_INFO)) {
try {
if (DBG_LOC) {
log("checkPossibleMissNotify: onCellInfoChanged[" + phoneId + "] = " + mCellInfo.get(phoneId));
}
r.callback.onCellInfoChanged(mCellInfo.get(phoneId));
} catch (RemoteException ex) {
mRemoveList.add(r.binder);
}
}
if ((events & PhoneStateListener.LISTEN_MESSAGE_WAITING_INDICATOR) != 0) {
try {
if (VDBG) {
log("checkPossibleMissNotify: onMessageWaitingIndicatorChanged phoneId=" + phoneId + " mwi=" + mMessageWaiting[phoneId]);
}
r.callback.onMessageWaitingIndicatorChanged(mMessageWaiting[phoneId]);
} catch (RemoteException ex) {
mRemoveList.add(r.binder);
}
}
if ((events & PhoneStateListener.LISTEN_CALL_FORWARDING_INDICATOR) != 0) {
try {
if (VDBG) {
log("checkPossibleMissNotify: onCallForwardingIndicatorChanged phoneId=" + phoneId + " cfi=" + mCallForwarding[phoneId]);
}
r.callback.onCallForwardingIndicatorChanged(mCallForwarding[phoneId]);
} catch (RemoteException ex) {
mRemoveList.add(r.binder);
}
}
if (validateEventsAndUserLocked(r, PhoneStateListener.LISTEN_CELL_LOCATION)) {
try {
if (DBG_LOC)
log("checkPossibleMissNotify: onCellLocationChanged mCellLocation = " + mCellLocation[phoneId]);
r.callback.onCellLocationChanged(new Bundle(mCellLocation[phoneId]));
} catch (RemoteException ex) {
mRemoveList.add(r.binder);
}
}
if ((events & PhoneStateListener.LISTEN_DATA_CONNECTION_STATE) != 0) {
try {
if (DBG) {
log("checkPossibleMissNotify: onDataConnectionStateChanged(mDataConnectionState" + "=" + mDataConnectionState[phoneId] + ", mDataConnectionNetworkType=" + mDataConnectionNetworkType[phoneId] + ")");
}
r.callback.onDataConnectionStateChanged(mDataConnectionState[phoneId], mDataConnectionNetworkType[phoneId]);
} catch (RemoteException ex) {
mRemoveList.add(r.binder);
}
}
}
use of android.telephony.ServiceState in project android_frameworks_base by crdroidandroid.
the class ComprehensiveCountryDetector method addPhoneStateListener.
protected synchronized void addPhoneStateListener() {
if (mPhoneStateListener == null) {
mPhoneStateListener = new PhoneStateListener() {
@Override
public void onServiceStateChanged(ServiceState serviceState) {
mCountServiceStateChanges++;
mTotalCountServiceStateChanges++;
if (!isNetworkCountryCodeAvailable()) {
return;
}
if (DEBUG)
Slog.d(TAG, "onServiceStateChanged: " + serviceState.getState());
detectCountry(true, true);
}
};
mTelephonyManager.listen(mPhoneStateListener, PhoneStateListener.LISTEN_SERVICE_STATE);
}
}
Aggregations