Search in sources :

Example 16 with PreciseDataConnectionState

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

the class TelephonyRegistry method notifyDataConnectionForSubscriber.

public void notifyDataConnectionForSubscriber(int subId, int state, boolean isDataConnectivityPossible, String reason, String apn, String apnType, LinkProperties linkProperties, NetworkCapabilities networkCapabilities, int networkType, boolean roaming) {
    if (!checkNotifyPermission("notifyDataConnection()")) {
        return;
    }
    if (VDBG) {
        log("notifyDataConnectionForSubscriber: subId=" + subId + " state=" + state + " isDataConnectivityPossible=" + isDataConnectivityPossible + " reason='" + reason + "' apn='" + apn + "' apnType=" + apnType + " networkType=" + networkType + " mRecords.size()=" + mRecords.size());
    }
    synchronized (mRecords) {
        int phoneId = SubscriptionManager.getPhoneId(subId);
        if (validatePhoneId(phoneId)) {
            if (VDBG) {
                log(" mConnectedApns[" + phoneId + "]=" + mConnectedApns[phoneId].toString());
            }
            boolean modified = false;
            if (state == TelephonyManager.DATA_CONNECTED) {
                if (!mConnectedApns[phoneId].contains(apnType)) {
                    mConnectedApns[phoneId].add(apnType);
                    if (mDataConnectionState[phoneId] != state) {
                        mDataConnectionState[phoneId] = state;
                        modified = true;
                    }
                }
            } else {
                if (mConnectedApns[phoneId].remove(apnType)) {
                    if (mConnectedApns[phoneId].isEmpty()) {
                        mDataConnectionState[phoneId] = state;
                        modified = true;
                    } else {
                    // leave mDataConnectionState as is and
                    // send out the new status for the APN in question.
                    }
                }
            }
            mDataConnectionPossible[phoneId] = isDataConnectivityPossible;
            mDataConnectionReason[phoneId] = reason;
            mDataConnectionLinkProperties[phoneId] = linkProperties;
            mDataConnectionNetworkCapabilities[phoneId] = networkCapabilities;
            if (mDataConnectionNetworkType[phoneId] != networkType) {
                mDataConnectionNetworkType[phoneId] = networkType;
                // need to tell registered listeners about the new network type
                modified = true;
            }
            if (modified) {
                if (DBG) {
                    log("onDataConnectionStateChanged(" + mDataConnectionState[phoneId] + ", " + mDataConnectionNetworkType[phoneId] + ")");
                }
                for (Record r : mRecords) {
                    if (r.matchPhoneStateListenerEvent(PhoneStateListener.LISTEN_DATA_CONNECTION_STATE) && idMatch(r.subId, subId, phoneId)) {
                        try {
                            log("Notify data connection state changed on sub: " + subId);
                            r.callback.onDataConnectionStateChanged(mDataConnectionState[phoneId], mDataConnectionNetworkType[phoneId]);
                        } catch (RemoteException ex) {
                            mRemoveList.add(r.binder);
                        }
                    }
                }
                handleRemoveListLocked();
            }
            mPreciseDataConnectionState = new PreciseDataConnectionState(state, networkType, apnType, apn, reason, linkProperties, "");
            for (Record r : mRecords) {
                if (r.matchPhoneStateListenerEvent(PhoneStateListener.LISTEN_PRECISE_DATA_CONNECTION_STATE)) {
                    try {
                        r.callback.onPreciseDataConnectionStateChanged(mPreciseDataConnectionState);
                    } catch (RemoteException ex) {
                        mRemoveList.add(r.binder);
                    }
                }
            }
        }
        handleRemoveListLocked();
    }
    broadcastDataConnectionStateChanged(state, isDataConnectivityPossible, reason, apn, apnType, linkProperties, networkCapabilities, roaming, subId);
    broadcastPreciseDataConnectionStateChanged(state, networkType, apnType, apn, reason, linkProperties, "");
}
Also used : RemoteException(android.os.RemoteException) PreciseDataConnectionState(android.telephony.PreciseDataConnectionState)

Example 17 with PreciseDataConnectionState

use of android.telephony.PreciseDataConnectionState in project android_frameworks_base by crdroidandroid.

the class TelephonyRegistry method notifyPreciseDataConnectionFailed.

public void notifyPreciseDataConnectionFailed(String reason, String apnType, String apn, String failCause) {
    if (!checkNotifyPermission("notifyPreciseDataConnectionFailed()")) {
        return;
    }
    synchronized (mRecords) {
        mPreciseDataConnectionState = new PreciseDataConnectionState(TelephonyManager.DATA_UNKNOWN, TelephonyManager.NETWORK_TYPE_UNKNOWN, apnType, apn, reason, null, failCause);
        for (Record r : mRecords) {
            if (r.matchPhoneStateListenerEvent(PhoneStateListener.LISTEN_PRECISE_DATA_CONNECTION_STATE)) {
                try {
                    r.callback.onPreciseDataConnectionStateChanged(mPreciseDataConnectionState);
                } catch (RemoteException ex) {
                    mRemoveList.add(r.binder);
                }
            }
        }
        handleRemoveListLocked();
    }
    broadcastPreciseDataConnectionStateChanged(TelephonyManager.DATA_UNKNOWN, TelephonyManager.NETWORK_TYPE_UNKNOWN, apnType, apn, reason, null, failCause);
}
Also used : RemoteException(android.os.RemoteException) PreciseDataConnectionState(android.telephony.PreciseDataConnectionState)

Example 18 with PreciseDataConnectionState

use of android.telephony.PreciseDataConnectionState in project robolectric by robolectric.

the class PreciseDataConnectionStateBuilderTest method build_preciseDataConnectionState.

@Test
public void build_preciseDataConnectionState() {
    ApnSetting apnSetting = new ApnSetting.Builder().setApnName("apnName").build();
    PreciseDataConnectionState state = PreciseDataConnectionStateBuilder.newBuilder().setDataState(TelephonyManager.DATA_DISCONNECTED).setNetworkType(TelephonyManager.NETWORK_TYPE_LTE).setApnSetting(apnSetting).setDataFailCause(DataFailCause.IMEI_NOT_ACCEPTED).build();
    assertThat(state).isNotNull();
    assertThat(state.getState()).isEqualTo(TelephonyManager.DATA_DISCONNECTED);
    assertThat(state.getNetworkType()).isEqualTo(TelephonyManager.NETWORK_TYPE_LTE);
    assertThat(state.getLastCauseCode()).isEqualTo(DataFailCause.IMEI_NOT_ACCEPTED);
    assertThat(state.getApnSetting()).isEqualTo(apnSetting);
}
Also used : ApnSetting(android.telephony.data.ApnSetting) PreciseDataConnectionState(android.telephony.PreciseDataConnectionState) Test(org.junit.Test)

Example 19 with PreciseDataConnectionState

use of android.telephony.PreciseDataConnectionState in project android_frameworks_opt_telephony by LineageOS.

the class DcTracker method getPreciseDataConnectionState.

/**
 * Return the Precise Data Connection State information
 */
@NonNull
public PreciseDataConnectionState getPreciseDataConnectionState(String apnType, boolean isSuspended, int networkType) {
    int telState = convertDctStateToTelephonyDataState(getState(apnType));
    // voice call state and device + rat capability
    if ((telState == TelephonyManager.DATA_CONNECTED || telState == TelephonyManager.DATA_DISCONNECTING) && isSuspended) {
        telState = TelephonyManager.DATA_SUSPENDED;
    }
    ApnSetting apnSetting = getActiveApnSetting(apnType);
    int apnTypesBitmask = ApnSetting.getApnTypesBitmaskFromString(apnType);
    // TODO: should the data fail cause be populated?
    return new PreciseDataConnectionState(telState, networkType, apnTypesBitmask, apnType, getLinkProperties(apnType), DataFailCause.NONE, apnSetting);
}
Also used : ApnSetting(android.telephony.data.ApnSetting) PreciseDataConnectionState(android.telephony.PreciseDataConnectionState) NonNull(android.annotation.NonNull)

Example 20 with PreciseDataConnectionState

use of android.telephony.PreciseDataConnectionState in project android_frameworks_opt_telephony by LineageOS.

the class GsmCdmaPhone method getPreciseDataConnectionState.

@Override
public PreciseDataConnectionState getPreciseDataConnectionState(String apnType) {
    // If we are OOS, then all data connections are null.
    // FIXME: we need to figure out how to report the EIMS PDN connectivity here, which
    // should imply emergency attach - today emergency attach is unknown at the AP,
    // so, we take a guess.
    boolean isEmergencyData = isPhoneTypeGsm() && apnType.equals(PhoneConstants.APN_TYPE_EMERGENCY);
    if (mSST == null || ((mSST.getCurrentDataConnectionState() != ServiceState.STATE_IN_SERVICE) && !isEmergencyData)) {
        return new PreciseDataConnectionState(TelephonyManager.DATA_DISCONNECTED, TelephonyManager.NETWORK_TYPE_UNKNOWN, ApnSetting.getApnTypesBitmaskFromString(apnType), apnType, null, DataFailCause.NONE, null);
    }
    // must never be null
    final DcTracker dctForApn = getActiveDcTrackerForApn(apnType);
    int networkType = TelephonyManager.NETWORK_TYPE_UNKNOWN;
    // Always non-null
    ServiceState ss = getServiceState();
    if (ss != null) {
        networkType = ss.getDataNetworkType();
    }
    return dctForApn.getPreciseDataConnectionState(apnType, isDataSuspended(), networkType);
}
Also used : DcTracker(com.android.internal.telephony.dataconnection.DcTracker) ServiceState(android.telephony.ServiceState) PreciseDataConnectionState(android.telephony.PreciseDataConnectionState)

Aggregations

PreciseDataConnectionState (android.telephony.PreciseDataConnectionState)20 RemoteException (android.os.RemoteException)15 Test (org.junit.Test)3 ApnSetting (android.telephony.data.ApnSetting)2 NonNull (android.annotation.NonNull)1 LinkProperties (android.net.LinkProperties)1 ServiceState (android.telephony.ServiceState)1 SmallTest (android.test.suitebuilder.annotation.SmallTest)1 DcTracker (com.android.internal.telephony.dataconnection.DcTracker)1