Search in sources :

Example 11 with SignalStrength

use of android.telephony.SignalStrength in project android_frameworks_base by ParanoidAndroid.

the class TelephonyRegistry method notifySignalStrength.

public void notifySignalStrength(SignalStrength signalStrength) {
    if (!checkNotifyPermission("notifySignalStrength()")) {
        return;
    }
    synchronized (mRecords) {
        mSignalStrength = signalStrength;
        for (Record r : mRecords) {
            if ((r.events & PhoneStateListener.LISTEN_SIGNAL_STRENGTHS) != 0) {
                try {
                    r.callback.onSignalStrengthsChanged(new SignalStrength(signalStrength));
                } catch (RemoteException ex) {
                    mRemoveList.add(r.binder);
                }
            }
            if ((r.events & PhoneStateListener.LISTEN_SIGNAL_STRENGTH) != 0) {
                try {
                    int gsmSignalStrength = signalStrength.getGsmSignalStrength();
                    r.callback.onSignalStrengthChanged((gsmSignalStrength == 99 ? -1 : gsmSignalStrength));
                } catch (RemoteException ex) {
                    mRemoveList.add(r.binder);
                }
            }
        }
        handleRemoveListLocked();
    }
    broadcastSignalStrengthChanged(signalStrength);
}
Also used : RemoteException(android.os.RemoteException) SignalStrength(android.telephony.SignalStrength)

Example 12 with SignalStrength

use of android.telephony.SignalStrength in project android_frameworks_base by DirtyUnicorns.

the class TelephonyRegistry method notifySignalStrengthForPhoneId.

public void notifySignalStrengthForPhoneId(int phoneId, int subId, SignalStrength signalStrength) {
    if (!checkNotifyPermission("notifySignalStrength()")) {
        return;
    }
    if (VDBG) {
        log("notifySignalStrengthForPhoneId: subId=" + subId + " phoneId=" + phoneId + " signalStrength=" + signalStrength);
        toStringLogSSC("notifySignalStrengthForPhoneId");
    }
    synchronized (mRecords) {
        if (validatePhoneId(phoneId)) {
            if (VDBG)
                log("notifySignalStrengthForPhoneId: valid phoneId=" + phoneId);
            mSignalStrength[phoneId] = signalStrength;
            for (Record r : mRecords) {
                if (VDBG) {
                    log("notifySignalStrengthForPhoneId: r=" + r + " subId=" + subId + " phoneId=" + phoneId + " ss=" + signalStrength);
                }
                if (r.matchPhoneStateListenerEvent(PhoneStateListener.LISTEN_SIGNAL_STRENGTHS) && idMatch(r.subId, subId, phoneId)) {
                    try {
                        if (DBG) {
                            log("notifySignalStrengthForPhoneId: callback.onSsS r=" + r + " subId=" + subId + " phoneId=" + phoneId + " ss=" + signalStrength);
                        }
                        r.callback.onSignalStrengthsChanged(new SignalStrength(signalStrength));
                    } catch (RemoteException ex) {
                        mRemoveList.add(r.binder);
                    }
                }
                if (r.matchPhoneStateListenerEvent(PhoneStateListener.LISTEN_SIGNAL_STRENGTH) && idMatch(r.subId, subId, phoneId)) {
                    try {
                        int gsmSignalStrength = signalStrength.getGsmSignalStrength();
                        int ss = (gsmSignalStrength == 99 ? -1 : gsmSignalStrength);
                        if (DBG) {
                            log("notifySignalStrengthForPhoneId: callback.onSS r=" + r + " subId=" + subId + " phoneId=" + phoneId + " gsmSS=" + gsmSignalStrength + " ss=" + ss);
                        }
                        r.callback.onSignalStrengthChanged(ss);
                    } catch (RemoteException ex) {
                        mRemoveList.add(r.binder);
                    }
                }
            }
        } else {
            log("notifySignalStrengthForPhoneId: invalid phoneId=" + phoneId);
        }
        handleRemoveListLocked();
    }
    broadcastSignalStrengthChanged(signalStrength, phoneId, subId);
}
Also used : RemoteException(android.os.RemoteException) SignalStrength(android.telephony.SignalStrength)

Example 13 with SignalStrength

use of android.telephony.SignalStrength in project XobotOS by xamarin.

the class CdmaServiceStateTracker method onSignalStrengthResult.

/**
     *  send signal-strength-changed notification if changed
     *  Called both for solicited and unsolicited signal strength updates
     */
protected void onSignalStrengthResult(AsyncResult ar) {
    SignalStrength oldSignalStrength = mSignalStrength;
    if (ar.exception != null) {
        // Most likely radio is resetting/disconnected change to default values.
        setSignalStrengthDefaultValues();
    } else {
        int[] ints = (int[]) ar.result;
        int offset = 2;
        int cdmaDbm = (ints[offset] > 0) ? -ints[offset] : -120;
        int cdmaEcio = (ints[offset + 1] > 0) ? -ints[offset + 1] : -160;
        int evdoRssi = (ints[offset + 2] > 0) ? -ints[offset + 2] : -120;
        int evdoEcio = (ints[offset + 3] > 0) ? -ints[offset + 3] : -1;
        int evdoSnr = ((ints[offset + 4] > 0) && (ints[offset + 4] <= 8)) ? ints[offset + 4] : -1;
        //log(String.format("onSignalStrengthResult cdmaDbm=%d cdmaEcio=%d evdoRssi=%d evdoEcio=%d evdoSnr=%d",
        //        cdmaDbm, cdmaEcio, evdoRssi, evdoEcio, evdoSnr));
        mSignalStrength = new SignalStrength(99, -1, cdmaDbm, cdmaEcio, evdoRssi, evdoEcio, evdoSnr, false);
    }
    try {
        phone.notifySignalStrength();
    } catch (NullPointerException ex) {
        loge("onSignalStrengthResult() Phone already destroyed: " + ex + "SignalStrength not notified");
    }
}
Also used : SignalStrength(android.telephony.SignalStrength)

Example 14 with SignalStrength

use of android.telephony.SignalStrength in project XobotOS by xamarin.

the class CdmaLteServiceStateTracker method onSignalStrengthResult.

@Override
protected void onSignalStrengthResult(AsyncResult ar) {
    SignalStrength oldSignalStrength = mSignalStrength;
    if (ar.exception != null) {
        // Most likely radio is resetting/disconnected change to default
        // values.
        setSignalStrengthDefaultValues();
    } else {
        int[] ints = (int[]) ar.result;
        int lteCqi = 99, lteRsrp = -1;
        int lteRssi = 99;
        int offset = 2;
        int cdmaDbm = (ints[offset] > 0) ? -ints[offset] : -120;
        int cdmaEcio = (ints[offset + 1] > 0) ? -ints[offset + 1] : -160;
        int evdoRssi = (ints[offset + 2] > 0) ? -ints[offset + 2] : -120;
        int evdoEcio = (ints[offset + 3] > 0) ? -ints[offset + 3] : -1;
        int evdoSnr = ((ints[offset + 4] > 0) && (ints[offset + 4] <= 8)) ? ints[offset + 4] : -1;
        if (networkType == ServiceState.RADIO_TECHNOLOGY_LTE) {
            lteRssi = (ints[offset + 5] >= 0) ? ints[offset + 5] : 99;
            lteRsrp = (ints[offset + 6] < 0) ? ints[offset + 6] : -1;
            lteCqi = (ints[offset + 7] >= 0) ? ints[offset + 7] : 99;
        }
        if (networkType != ServiceState.RADIO_TECHNOLOGY_LTE) {
            mSignalStrength = new SignalStrength(99, -1, cdmaDbm, cdmaEcio, evdoRssi, evdoEcio, evdoSnr, false);
        } else {
            mSignalStrength = new SignalStrength(99, -1, cdmaDbm, cdmaEcio, evdoRssi, evdoEcio, evdoSnr, lteRssi, lteRsrp, -1, -1, lteCqi, true);
        }
    }
    try {
        phone.notifySignalStrength();
    } catch (NullPointerException ex) {
        loge("onSignalStrengthResult() Phone already destroyed: " + ex + "SignalStrength not notified");
    }
}
Also used : SignalStrength(android.telephony.SignalStrength)

Example 15 with SignalStrength

use of android.telephony.SignalStrength in project android_frameworks_base by ResurrectionRemix.

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)

Aggregations

SignalStrength (android.telephony.SignalStrength)15 RemoteException (android.os.RemoteException)11 ServiceState (android.telephony.ServiceState)6 Bundle (android.os.Bundle)5 VoLteServiceState (android.telephony.VoLteServiceState)5 PhoneStateListener (android.telephony.PhoneStateListener)1 Phone (com.android.internal.telephony.Phone)1