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

Commit 696c04fa authored by Jack Yu's avatar Jack Yu
Browse files

Refactored precise data connection state

Instead of triggering the data connection state changed
event from outside, now the event is triggering from
DataConnection. Whenever detecting data connection
state changes, the event will be triggered. This significantly
reduced the unnecessary redundant events sent to telephony registry,
even though it has a duplicate detection mechanism.

This are also two behavioral changes.

1. Previously if a data connection supports multiple APN types,
there will be multiple data connection state changed event for
each APN type. Now there is only one. The listener should use
PreciseDataConnectionState.getApnSetting().getApnTypeBitmask()
to check which APN types this data connection supports.

2. If setup data call fails before a data connection instance
can be created, there won't be any event with fail cause.

Fix: 161572838
Test: FrameworksTelephonyTests and manual
Merged-In: Idf61f7c66b8291446315ab54a18b54080a9107c0
Change-Id: Idf61f7c66b8291446315ab54a18b54080a9107c0
(cherry picked from commit 68ad414f)
parent 503f1869
Loading
Loading
Loading
Loading
+3 −20
Original line number Diff line number Diff line
@@ -18,7 +18,6 @@ package com.android.internal.telephony;

import android.annotation.NonNull;
import android.content.Context;
import android.telephony.Annotation.DataFailureCause;
import android.telephony.Annotation.RadioPowerState;
import android.telephony.Annotation.SrvccState;
import android.telephony.BarringInfo;
@@ -32,7 +31,6 @@ import android.telephony.ServiceState;
import android.telephony.TelephonyDisplayInfo;
import android.telephony.TelephonyManager;
import android.telephony.TelephonyRegistryManager;
import android.telephony.data.ApnSetting;
import android.telephony.emergency.EmergencyNumber;
import android.telephony.ims.ImsReasonInfo;

@@ -124,15 +122,9 @@ public class DefaultPhoneNotifier implements PhoneNotifier {
    }

    @Override
    public void notifyDataConnection(
            Phone sender, String apnType, PreciseDataConnectionState preciseState) {

        int subId = sender.getSubId();
        int phoneId = sender.getPhoneId();
        int apnTypeBitmask = ApnSetting.getApnTypesBitmaskFromString(apnType);

        mTelephonyRegistryMgr.notifyDataConnectionForSubscriber(
                phoneId, subId, apnTypeBitmask, preciseState);
    public void notifyDataConnection(Phone sender, PreciseDataConnectionState preciseState) {
        mTelephonyRegistryMgr.notifyDataConnectionForSubscriber(sender.getPhoneId(),
                sender.getSubId(), preciseState);
    }

    @Override
@@ -169,15 +161,6 @@ public class DefaultPhoneNotifier implements PhoneNotifier {
        mTelephonyRegistryMgr.notifyImsDisconnectCause(sender.getSubId(), imsReasonInfo);
    }

    @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(),
                ApnSetting.getApnTypesBitmaskFromString(apnType), apn, failCause);
    }

    @Override
    public void notifySrvccStateChanged(Phone sender, @SrvccState int state) {
        mTelephonyRegistryMgr.notifySrvccStateChanged(sender.getSubId(), state);
+1 −36
Original line number Diff line number Diff line
@@ -68,7 +68,6 @@ import android.telephony.CellIdentity;
import android.telephony.ImsiEncryptionInfo;
import android.telephony.NetworkScanRequest;
import android.telephony.PhoneNumberUtils;
import android.telephony.PreciseDataConnectionState;
import android.telephony.ServiceState;
import android.telephony.ServiceState.RilRadioTechnology;
import android.telephony.SignalThresholdInfo;
@@ -629,41 +628,7 @@ public class GsmCdmaPhone extends Phone {
    }

    @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.Builder()
                    .setTransportType(mTransportManager.getCurrentTransport(
                            ApnSetting.getApnTypesBitmaskFromString(apnType)))
                    .setState(TelephonyManager.DATA_DISCONNECTED)
                    .setApnSetting(new ApnSetting.Builder()
                            .setApnTypeBitmask(ApnSetting.getApnTypesBitmaskFromString(apnType))
                            .build())
                    .build();
        }

        // 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() {
    public boolean isDataSuspended() {
        return mCT.mState != PhoneConstants.State.IDLE && !mSST.isConcurrentVoiceAndDataAllowed();
    }

+9 −24
Original line number Diff line number Diff line
@@ -41,7 +41,6 @@ import android.sysprop.TelephonyProperties;
import android.telecom.VideoProfile;
import android.telephony.AccessNetworkConstants;
import android.telephony.Annotation.ApnType;
import android.telephony.Annotation.DataFailureCause;
import android.telephony.CarrierConfigManager;
import android.telephony.CarrierRestrictionRules;
import android.telephony.CellIdentity;
@@ -2540,23 +2539,8 @@ public abstract class Phone extends Handler implements PhoneInternalInterface {
    }

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

    /** Send notification with an updated PreciseDataConnectionState to all data connections */
    public void notifyAllActiveDataConnections() {
        if (mTransportManager != null) {
            for (int transportType : mTransportManager.getAvailableTransports()) {
                DcTracker dct = getDcTracker(transportType);
                if (dct != null) {
                    for (String apnType : dct.getConnectedApnTypes()) {
                        mNotifier.notifyDataConnection(
                                this, apnType, getPreciseDataConnectionState(apnType));
                    }
                }
            }
        }
    public void notifyDataConnection(PreciseDataConnectionState state) {
        mNotifier.notifyDataConnection(this, state);
    }

    @UnsupportedAppUsage
@@ -2908,6 +2892,13 @@ public abstract class Phone extends Handler implements PhoneInternalInterface {
        return null;
    }

    /**
     * @return {@code true} if data is suspended.
     */
    public boolean isDataSuspended() {
        return false;
    }

    /**
     * send burst DTMF tone, it can send the string as single character or multiple character
     * ignore if there is no active call or not valid digits string.
@@ -3570,12 +3561,6 @@ public abstract class Phone extends Handler implements PhoneInternalInterface {
    public void notifyCallForwardingIndicator() {
    }

    /** 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);
    }

    /**
     * Sets the SIM voice message waiting indicator records.
     * @param line GSM Subscriber Profile Number, one-based. Only '1' is supported
+1 −7
Original line number Diff line number Diff line
@@ -18,7 +18,6 @@ package com.android.internal.telephony;

import android.annotation.NonNull;
import android.compat.annotation.UnsupportedAppUsage;
import android.telephony.Annotation.DataFailureCause;
import android.telephony.Annotation.RadioPowerState;
import android.telephony.Annotation.SrvccState;
import android.telephony.BarringInfo;
@@ -58,8 +57,7 @@ public interface PhoneNotifier {
    void notifyCallForwardingChanged(Phone sender);

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

    void notifyDataActivity(Phone sender);

@@ -71,10 +69,6 @@ public interface PhoneNotifier {

    void notifyImsDisconnectCause(Phone sender, ImsReasonInfo imsReasonInfo);

    /** 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.*/
    void notifySrvccStateChanged(Phone sender, @SrvccState int state);

+0 −5
Original line number Diff line number Diff line
@@ -3410,10 +3410,6 @@ public class ServiceStateTracker extends Handler {
                }
            }

            if (hasCssIndicatorChanged) {
                mPhone.notifyAllActiveDataConnections();
            }

            mReasonDataDenied = mNewReasonDataDenied;
            mMaxDataCalls = mNewMaxDataCalls;
            mRejectCode = mNewRejectCode;
@@ -3563,7 +3559,6 @@ public class ServiceStateTracker extends Handler {
                    || hasDataTransportPreferenceChanged) {
                setDataNetworkTypeForPhone(mSS.getRilDataRadioTechnology());
                notifyDataRegStateRilRadioTechnologyChanged(transport);
                mPhone.notifyAllActiveDataConnections();
            }

            if (hasDataAttached.get(transport)) {
Loading