Search in sources :

Example 1 with SignalStrength

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

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 2 with SignalStrength

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

the class SimStatus method updatePhoneInfos.

private void updatePhoneInfos() {
    if (mSir != null) {
        // TODO: http://b/23763013
        final Phone phone = PhoneFactory.getPhone(SubscriptionManager.getPhoneId(mSir.getSubscriptionId()));
        if (UserManager.get(getContext()).isAdminUser() && SubscriptionManager.isValidSubscriptionId(mSir.getSubscriptionId())) {
            if (phone == null) {
                Log.e(TAG, "Unable to locate a phone object for the given Subscription ID.");
                return;
            }
            mPhone = phone;
            //avoid left at TelephonyManager Memory leak before create a new PhoneStateLister
            if (mPhoneStateListener != null && mTelephonyManager != null) {
                mTelephonyManager.listen(mPhoneStateListener, PhoneStateListener.LISTEN_NONE);
            }
            mPhoneStateListener = new PhoneStateListener(mSir.getSubscriptionId()) {

                @Override
                public void onDataConnectionStateChanged(int state) {
                    updateDataState();
                    updateNetworkType();
                }

                @Override
                public void onSignalStrengthsChanged(SignalStrength signalStrength) {
                    updateSignalStrength(signalStrength);
                }

                @Override
                public void onServiceStateChanged(ServiceState serviceState) {
                    updateServiceState(serviceState);
                }
            };
        }
    }
}
Also used : ServiceState(android.telephony.ServiceState) Phone(com.android.internal.telephony.Phone) PhoneStateListener(android.telephony.PhoneStateListener) SignalStrength(android.telephony.SignalStrength)

Example 3 with SignalStrength

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

the class GsmServiceStateTracker method onSignalStrengthResult.

/**
     *  Send signal-strength-changed notification if changed.
     *  Called both for solicited and unsolicited signal strength updates.
     */
private void onSignalStrengthResult(AsyncResult ar) {
    SignalStrength oldSignalStrength = mSignalStrength;
    int rssi = 99;
    int lteSignalStrength = -1;
    int lteRsrp = -1;
    int lteRsrq = -1;
    int lteRssnr = -1;
    int lteCqi = -1;
    if (ar.exception != null) {
        // -1 = unknown
        // most likely radio is resetting/disconnected
        setSignalStrengthDefaultValues();
    } else {
        int[] ints = (int[]) ar.result;
        // bug 658816 seems to be a case where the result is 0-length
        if (ints.length != 0) {
            rssi = ints[0];
            lteSignalStrength = ints[7];
            lteRsrp = ints[8];
            lteRsrq = ints[9];
            lteRssnr = ints[10];
            lteCqi = ints[11];
        } else {
            loge("Bogus signal strength response");
            rssi = 99;
        }
    }
    mSignalStrength = new SignalStrength(rssi, -1, -1, -1, -1, -1, -1, lteSignalStrength, lteRsrp, lteRsrq, lteRssnr, lteCqi, true);
    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");
        }
    }
}
Also used : SignalStrength(android.telephony.SignalStrength)

Example 4 with SignalStrength

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

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 5 with SignalStrength

use of android.telephony.SignalStrength in project platform_frameworks_base by android.

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)35 ServiceState (android.telephony.ServiceState)13 RemoteException (android.os.RemoteException)11 PhoneStateListener (android.telephony.PhoneStateListener)9 Phone (com.android.internal.telephony.Phone)7 Bundle (android.os.Bundle)5 VoLteServiceState (android.telephony.VoLteServiceState)5 TelephonyManager (android.telephony.TelephonyManager)3 Test (org.junit.Test)3 SuppressLint (android.annotation.SuppressLint)2 CellSignalStrength (android.telephony.CellSignalStrength)2 Method (java.lang.reflect.Method)2 Config (org.robolectric.annotation.Config)2 AsyncResult (android.os.AsyncResult)1 ServiceStateTable.getContentValuesForServiceState (android.provider.Telephony.ServiceStateTable.getContentValuesForServiceState)1 FlakyTest (android.support.test.filters.FlakyTest)1 SubscriptionInfo (android.telephony.SubscriptionInfo)1 CdmaCellLocation (android.telephony.cdma.CdmaCellLocation)1 GsmCellLocation (android.telephony.gsm.GsmCellLocation)1 MediumTest (android.test.suitebuilder.annotation.MediumTest)1