Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit be447d04 authored by Nathan Harold's avatar Nathan Harold Committed by Android (Google) Code Review
Browse files

Merge "Expose PreciseDataConnectionState to Public API"

parents c3078da1 3d245131
Loading
Loading
Loading
Loading
+9 −47
Original line number Diff line number Diff line
@@ -19,8 +19,6 @@ package com.android.internal.telephony;
import android.annotation.NonNull;
import android.compat.annotation.UnsupportedAppUsage;
import android.content.Context;
import android.net.LinkProperties;
import android.net.NetworkCapabilities;
import android.os.Bundle;
import android.os.RemoteException;
import android.os.ServiceManager;
@@ -32,12 +30,11 @@ import android.telephony.CellInfo;
import android.telephony.CellLocation;
import android.telephony.PhoneCapability;
import android.telephony.PreciseCallState;
import android.telephony.PreciseDataConnectionState;
import android.telephony.Rlog;
import android.telephony.ServiceState;
import android.telephony.SubscriptionManager;
import android.telephony.TelephonyManager;
import android.telephony.TelephonyRegistryManager;
import android.telephony.data.ApnSetting;
import android.telephony.emergency.EmergencyNumber;
import android.telephony.ims.ImsReasonInfo;

@@ -84,7 +81,7 @@ public class DefaultPhoneNotifier implements PhoneNotifier {
        int phoneId = sender.getPhoneId();
        int subId = sender.getSubId();

        Rlog.d(LOG_TAG, "nofityServiceState: mRegistry=" + mRegistry + " ss=" + ss
        Rlog.d(LOG_TAG, "notifyServiceState: mRegistry=" + mRegistry + " ss=" + ss
            + " sender=" + sender + " phondId=" + phoneId + " subId=" + subId);
        if (ss == null) {
            ss = new ServiceState();
@@ -134,51 +131,14 @@ public class DefaultPhoneNotifier implements PhoneNotifier {
    }

    @Override
    public void notifyDataConnection(Phone sender, String apnType,
        PhoneConstants.DataState state) {
        doNotifyDataConnection(sender, apnType, state);
    }
    public void notifyDataConnection(
            Phone sender, String apnType, PreciseDataConnectionState preciseState) {

    private void doNotifyDataConnection(Phone sender, String apnType,
        PhoneConstants.DataState state) {
        int subId = sender.getSubId();
        int phoneId = sender.getPhoneId();
        long dds = SubscriptionManager.getDefaultDataSubscriptionId();
        if (DBG) {
            log("subId = " + subId + ", DDS = " + dds);
        }

        // TODO
        // use apnType as the key to which connection we're talking about.
        // pass apnType back up to fetch particular for this one.
        TelephonyManager telephony = TelephonyManager.getDefault();
        LinkProperties linkProperties = null;
        NetworkCapabilities networkCapabilities = null;
        boolean roaming = false;

        if (state == PhoneConstants.DataState.CONNECTED) {
            linkProperties = sender.getLinkProperties(apnType);
            networkCapabilities = sender.getNetworkCapabilities(apnType);
        }
        ServiceState ss = sender.getServiceState();
        if (ss != null) {
            roaming = ss.getDataRoaming();
        }
        mTelephonyRegistryMgr.notifyDataConnectionForSubscriber(phoneId, subId,
            PhoneConstantConversions.convertDataState(state),
            sender.isDataAllowed(ApnSetting.getApnTypesBitmaskFromString(apnType)),
            sender.getActiveApnHost(apnType),
            apnType,
            linkProperties,
            networkCapabilities,
            ((telephony != null) ? telephony.getDataNetworkType(subId) :
                TelephonyManager.NETWORK_TYPE_UNKNOWN), roaming);
    }

    @Override
    public void notifyDataConnectionFailed(Phone sender, String apnType) {
        mTelephonyRegistryMgr.notifyDataConnectionFailed(sender.getSubId(), sender.getPhoneId(),
            apnType);
        mTelephonyRegistryMgr.notifyDataConnectionForSubscriber(
                phoneId, subId, apnType, preciseState);
    }

    @Override
@@ -223,7 +183,9 @@ public class DefaultPhoneNotifier implements PhoneNotifier {
        mTelephonyRegistryMgr.notifyImsDisconnectCause(sender.getSubId(), imsReasonInfo);
    }

    public void notifyPreciseDataConnectionFailed(Phone sender, String apnType,
    @Override
    /** Notify the TelephonyRegistry that a data connection has failed with a specified cause */
    public void notifyDataConnectionFailed(Phone sender, String apnType,
        String apn, @DataFailureCause int failCause) {
        mTelephonyRegistryMgr.notifyPreciseDataConnectionFailed(sender.getSubId(),
            sender.getPhoneId(), apnType, apn, failCause);
+46 −9
Original line number Diff line number Diff line
@@ -62,10 +62,11 @@ import android.telephony.AccessNetworkConstants;
import android.telephony.Annotation.RilRadioTechnology;
import android.telephony.CarrierConfigManager;
import android.telephony.CellLocation;
import android.telephony.DataFailCause;
import android.telephony.ImsiEncryptionInfo;
import android.telephony.NetworkScanRequest;
import android.telephony.PhoneNumberUtils;
import android.telephony.PhysicalChannelConfig;
import android.telephony.PreciseDataConnectionState;
import android.telephony.Rlog;
import android.telephony.ServiceState;
import android.telephony.SignalThresholdInfo;
@@ -503,6 +504,7 @@ public class GsmCdmaPhone extends Phone {

    @UnsupportedAppUsage
    @Override
    @NonNull
    public ServiceState getServiceState() {
        if (mSST == null || mSST.mSS.getState() != ServiceState.STATE_IN_SERVICE) {
            if (mImsPhone != null) {
@@ -594,12 +596,53 @@ public class GsmCdmaPhone extends Phone {
        return mPendingMMIs;
    }

    private @NonNull DcTracker getActiveDcTrackerForApn(@NonNull String apnType) {
        int currentTransport = mTransportManager.getCurrentTransport(
                ApnSetting.getApnTypesBitmaskFromString(apnType));
        return getDcTracker(currentTransport);
    }

    @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);
    }

    boolean isDataSuspended() {
        return mCT.mState != PhoneConstants.State.IDLE && !mSST.isConcurrentVoiceAndDataAllowed();
    }

    @Override
    public PhoneConstants.DataState getDataConnectionState(String apnType) {
        PhoneConstants.DataState ret = PhoneConstants.DataState.DISCONNECTED;

        if (mSST == null) {
            // Radio Technology Change is ongoning, dispose() and removeReferences() have
            // Radio Technology Change is ongoing, dispose() and removeReferences() have
            // already been called

            ret = PhoneConstants.DataState.DISCONNECTED;
@@ -620,8 +663,7 @@ public class GsmCdmaPhone extends Phone {
                switch (getDcTracker(currentTransport).getState(apnType)) {
                    case CONNECTED:
                    case DISCONNECTING:
                        if (mCT.mState != PhoneConstants.State.IDLE
                                && !mSST.isConcurrentVoiceAndDataAllowed()) {
                        if (isDataSuspended()) {
                            ret = PhoneConstants.DataState.SUSPENDED;
                        } else {
                            ret = PhoneConstants.DataState.CONNECTED;
@@ -4079,11 +4121,6 @@ public class GsmCdmaPhone extends Phone {
        updateUiTtyMode(ttyMode);
    }

    @Override
    public List<PhysicalChannelConfig> getPhysicalChannelConfigList() {
        return mSST.getPhysicalChannelConfigList();
    }

    private void reapplyUiccAppsEnablementIfNeeded() {
        UiccSlot slot = mUiccController.getUiccSlotForPhone(mPhoneId);

+29 −26
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package com.android.internal.telephony;

import android.annotation.NonNull;
import android.annotation.Nullable;
import android.app.BroadcastOptions;
import android.compat.annotation.UnsupportedAppUsage;
@@ -50,6 +51,7 @@ import android.telephony.ClientRequestStats;
import android.telephony.ImsiEncryptionInfo;
import android.telephony.PhoneStateListener;
import android.telephony.PhysicalChannelConfig;
import android.telephony.PreciseDataConnectionState;
import android.telephony.RadioAccessFamily;
import android.telephony.Rlog;
import android.telephony.ServiceState;
@@ -2326,17 +2328,16 @@ public abstract class Phone extends Handler implements PhoneInternalInterface {
        mNotifier.notifyMessageWaitingChanged(this);
    }

    /** Send notification with an updated PreciseDataConnectionState to a single data connection */
    public void notifyDataConnection(String apnType) {
        mNotifier.notifyDataConnection(this, apnType, getDataConnectionState(apnType));
        mNotifier.notifyDataConnection(this, apnType, getPreciseDataConnectionState(apnType));
    }

    public void notifyDataConnection() {
    /** Send notification with an updated PreciseDataConnectionState to all data connections */
    public void notifyAllActiveDataConnections() {
        String types[] = getActiveApnTypes();
        if (types != null) {
        for (String apnType : types) {
                mNotifier.notifyDataConnection(this, apnType,
                        getDataConnectionState(apnType));
            }
            mNotifier.notifyDataConnection(this, apnType, getPreciseDataConnectionState(apnType));
        }
    }

@@ -2365,6 +2366,11 @@ public abstract class Phone extends Handler implements PhoneInternalInterface {
        return PhoneConstants.DataState.DISCONNECTED;
    }

    /** Default implementation to get the PreciseDataConnectionState */
    public @Nullable PreciseDataConnectionState getPreciseDataConnectionState(String apnType) {
        return null;
    }

    public void notifyCellInfo(List<CellInfo> cellInfo) {
        AsyncResult ar = new AsyncResult(null, cellInfo, null);
        mCellInfoRegistrants.notifyRegistrants(ar);
@@ -3025,26 +3031,26 @@ public abstract class Phone extends Handler implements PhoneInternalInterface {

    /**
     * Returns an array of string identifiers for the APN types serviced by the
     * currently active.
     * currently active subscription.
     *
     * @return The string array of APN types. Return null if no active APN types.
     */
    @UnsupportedAppUsage
    @Nullable
    @NonNull
    public String[] getActiveApnTypes() {
        if (mTransportManager != null) {
            List<String> typesList = new ArrayList<>();
            for (int transportType : mTransportManager.getAvailableTransports()) {
                if (getDcTracker(transportType) != null) {
                    typesList.addAll(Arrays.asList(
                            getDcTracker(transportType).getActiveApnTypes()));
                }
        if (mTransportManager == null || mDcTrackers == null)  {
            Rlog.e(LOG_TAG, "Invalid state for Transport/DcTrackers");
            return new String[0];
        }

            return typesList.toArray(new String[typesList.size()]);
        Set<String> activeApnTypes = new HashSet<String>();
        for (int transportType : mTransportManager.getAvailableTransports()) {
            DcTracker dct = getDcTracker(transportType);
            if (dct == null) continue; // TODO: should this ever happen?
            activeApnTypes.addAll(Arrays.asList(dct.getActiveApnTypes()));
        }

        return null;
        return activeApnTypes.toArray(new String[activeApnTypes.size()]);
    }

    /**
@@ -3274,13 +3280,10 @@ public abstract class Phone extends Handler implements PhoneInternalInterface {
    public void notifyCallForwardingIndicator() {
    }

    public void notifyDataConnectionFailed(String apnType) {
        mNotifier.notifyDataConnectionFailed(this, apnType);
    }

    public void notifyPreciseDataConnectionFailed(String apnType, String apn,
                                                  @DataFailureCause int failCause) {
        mNotifier.notifyPreciseDataConnectionFailed(this, apnType, apn, failCause);
    /** Send a notification that a particular data connection has failed with specified cause. */
    public void notifyDataConnectionFailed(
            String apnType, String apn, @DataFailureCause int failCause) {
        mNotifier.notifyDataConnectionFailed(this, apnType, apn, failCause);
    }

    /**
+11 −0
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@ import android.os.ResultReceiver;
import android.telecom.VideoProfile;
import android.telephony.ImsiEncryptionInfo;
import android.telephony.NetworkScanRequest;
import android.telephony.PreciseDataConnectionState;
import android.telephony.ServiceState;
import android.telephony.TelephonyManager;

@@ -236,6 +237,16 @@ public interface PhoneInternalInterface {
     */
    DataState getDataConnectionState(String apnType);

    /**
     * Get the current Precise DataState. No change notification exists at this
     * interface -- use
     * {@link android.telephony.PhoneStateListener} instead.
     *
     * @param apnType specify for which apn to get connection state info.
     * @return the PreciseDataConnectionState for the data connection supporting apnType
     */
    PreciseDataConnectionState getPreciseDataConnectionState(String apnType);

    /**
     * Get the current DataActivityState. No change notification exists at this
     * interface -- use
+17 −10
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@ import android.telephony.CallQuality;
import android.telephony.CellInfo;
import android.telephony.CellLocation;
import android.telephony.PhoneCapability;
import android.telephony.PreciseDataConnectionState;
import android.telephony.emergency.EmergencyNumber;
import android.telephony.ims.ImsReasonInfo;

@@ -49,9 +50,9 @@ public interface PhoneNotifier {

    void notifyCallForwardingChanged(Phone sender);

    void notifyDataConnection(Phone sender, String apnType, PhoneConstants.DataState state);

    void notifyDataConnectionFailed(Phone sender, String apnType);
    /** Send a notification that the Data Connection for a particular apnType has changed */
    void notifyDataConnection(
            Phone sender, String apnType, PreciseDataConnectionState preciseState);

    void notifyDataActivity(Phone sender);

@@ -65,21 +66,27 @@ public interface PhoneNotifier {

    void notifyImsDisconnectCause(Phone sender, ImsReasonInfo imsReasonInfo);

    public void notifyPreciseDataConnectionFailed(Phone sender, String apnType, String apn,
    /** Send a notification that a particular data connection has failed with specified cause. */
    void notifyDataConnectionFailed(Phone sender, String apnType, String apn,
                                                  @DataFailureCause int failCause);

    /** send a notification that the SRVCC state has changed.*/
    /** Send a notification that the SRVCC state has changed.*/
    void notifySrvccStateChanged(Phone sender, @SrvccState int state);

    public void notifyVoiceActivationStateChanged(Phone sender, int activationState);
    /** Send a notification that the voice activation state has changed */
    void notifyVoiceActivationStateChanged(Phone sender, int activationState);

    public void notifyDataActivationStateChanged(Phone sender, int activationState);
    /** Send a notification that the data activation state has changed */
    void notifyDataActivationStateChanged(Phone sender, int activationState);

    public void notifyUserMobileDataStateChanged(Phone sender, boolean state);
    /** Send a notification that the users mobile data setting has changed */
    void notifyUserMobileDataStateChanged(Phone sender, boolean state);

    public void notifyOemHookRawEventForSubscriber(Phone sender, byte[] rawData);
    /** Send a notification with an OEM hook payload */
    void notifyOemHookRawEventForSubscriber(Phone sender, byte[] rawData);

    public void notifyPhoneCapabilityChanged(PhoneCapability capability);
    /** Send a notification that the phone capability has changed */
    void notifyPhoneCapabilityChanged(PhoneCapability capability);

    void notifyRadioPowerStateChanged(Phone sender, @RadioPowerState int state);

Loading