Search in sources :

Example 26 with ServiceState

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();
}
Also used : ServiceState(android.telephony.ServiceState) PhoneStateListener(android.telephony.PhoneStateListener)

Example 27 with ServiceState

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);
}
Also used : ServiceState(android.telephony.ServiceState)

Example 28 with ServiceState

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);
}
Also used : VoLteServiceState(android.telephony.VoLteServiceState) ServiceState(android.telephony.ServiceState) RemoteException(android.os.RemoteException)

Example 29 with ServiceState

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);
        }
    }
}
Also used : VoLteServiceState(android.telephony.VoLteServiceState) ServiceState(android.telephony.ServiceState) Bundle(android.os.Bundle) RemoteException(android.os.RemoteException) SignalStrength(android.telephony.SignalStrength)

Example 30 with ServiceState

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);
    }
}
Also used : ServiceState(android.telephony.ServiceState) PhoneStateListener(android.telephony.PhoneStateListener)

Aggregations

ServiceState (android.telephony.ServiceState)55 RemoteException (android.os.RemoteException)19 VoLteServiceState (android.telephony.VoLteServiceState)15 Bundle (android.os.Bundle)11 PhoneStateListener (android.telephony.PhoneStateListener)10 SubscriptionInfo (android.telephony.SubscriptionInfo)7 IBinder (android.os.IBinder)6 SignalStrength (android.telephony.SignalStrength)6 Intent (android.content.Intent)5 IntentFilter (android.content.IntentFilter)5 State (com.android.internal.telephony.IccCardConstants.State)5 TelephonyManager (android.telephony.TelephonyManager)3 Paint (android.graphics.Paint)2 Fingerprint (android.hardware.fingerprint.Fingerprint)2 CdmaCellLocation (android.telephony.cdma.CdmaCellLocation)2 BitSet (java.util.BitSet)2 LinkCapabilities (android.net.LinkCapabilities)1 LinkProperties (android.net.LinkProperties)1 GsmCellLocation (android.telephony.gsm.GsmCellLocation)1 Phone (com.android.internal.telephony.Phone)1