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

Commit ff4e317d authored by Wink Saville's avatar Wink Saville
Browse files

Move retrying into DC.

This is the first step in refactoring for bug 4772191.

Bug: 4772191
Change-Id: Id54a20ab192783c63939158670faaf531a527640
parent 6ca911a9
Loading
Loading
Loading
Loading

README.txt

0 → 100644
+55 −0
Original line number Diff line number Diff line
This package contains classes used to manage a DataConnection.

A criticial aspect of this class is that most objects in this
package run on the same thread except DataConnectionTracker
This makes processing efficient as it minimizes context
switching and it eliminates issues with multi-threading.

This can be done because all actions are either asynchronous
or are known to be non-blocking and fast. At this time only
DcTesterDeactivateAll takes specific advantage of this
single threading knowledge by using Dcc#mDcListAll so be
very careful when making changes that break this assumption.

A related change was in DataConnectionAc I added code that
checks to see if the caller is on a different thread. If
it is then the AsyncChannel#sendMessageSynchronously is
used. If the caller is on the same thread then a getter
is used. This allows the DCAC to be used from any thread
and was required to fix a bug when Dcc called
PhoneBase#notifyDataConnection which calls DCT#getLinkProperties
and DCT#getLinkCapabilities which call Dcc all on the same
thread. Without this change there was a dead lock when
sendMessageSynchronously blocks.


Testing:

There are three Intents that can be sent for testing pruproses:

The first two cause bringUp and retry requests to fail and the first
causes all DC's to fail the second causes a specific DC to fail:

  adb shell am broadcast -a com.android.internal.telephony.dataconnection.action_fail_bringup --ei counter 2 --ei fail_cause -3
  adb shell am broadcast -a com.android.internal.telephony.dataconnection.DC-1.action_fail_bringup --ei counter 2 --ei fail_cause -3

The other causes all DC's to get torn down, simulating a temporary network outage:

  adb shell am broadcast -a com.android.internal.telephony.dataconnection.action_deactivate_all

To simplify testing we also have detach and attach simulations below where {x} is gsm, cdma or sip

  adb shell am broadcast -a com.android.internal.telephony.{x}.action_detached
  adb shell am broadcast -a com.android.internal.telephony.{x}.action_attached


Additionally, you on DEGUGGABLE builds (userdebug, eng) you can replace the retry configuration
by setting the SystemProperty: test.data_retry_config for instance:

  adb shell setprop test.data_retry_config "5000,5000,5000"

Which changes the retry to 3 retires at 5 second intervals. This can be added to
/data/local.prop, don't forget to "adb shell chmod 0600 /data/local.prop":
  $ cat local.prop.test.data_retry_config
  test.data_retry_config=5000,5000,5000,5000
+4 −4
Original line number Diff line number Diff line
@@ -705,7 +705,7 @@ public interface CommandsInterface {
     *  retMsg.obj = AsyncResult ar
     *  ar.exception carries exception on failure
     *  ar.userObject contains the orignal value of result.obj
     *  ar.result contains a List of DataCallState
     *  ar.result contains a List of DataCallResponse
     *  @deprecated Do not use.
     */
    @Deprecated
@@ -716,7 +716,7 @@ public interface CommandsInterface {
     *  retMsg.obj = AsyncResult ar
     *  ar.exception carries exception on failure
     *  ar.userObject contains the orignal value of result.obj
     *  ar.result contains a List of DataCallState
     *  ar.result contains a List of DataCallResponse
     */
    void getDataCallList(Message result);

@@ -1471,8 +1471,8 @@ public interface CommandsInterface {

    /**
     * Setup a packet data connection On successful completion, the result
     * message will return a {@link DataCallState} object containing the connection
     * information.
     * message will return a {@link com.android.internal.telephony.dataconnection.DataCallResponse}
     * object containing the connection information.
     *
     * @param radioTechnology
     *            indicates whether to setup connection on radio technology CDMA
+2 −0
Original line number Diff line number Diff line
@@ -101,6 +101,8 @@ public interface Phone {
    static final String REASON_NW_TYPE_CHANGED = "nwTypeChanged";
    static final String REASON_DATA_DEPENDENCY_MET = "dependencyMet";
    static final String REASON_DATA_DEPENDENCY_UNMET = "dependencyUnmet";
    static final String REASON_LOST_DATA_CONNECTION = "lostDataConnection";
    static final String REASON_CONNECTED = "connected";

    // Used for band mode selection methods
    static final int BM_UNSPECIFIED = 0; // selected by baseband automatically
+49 −8
Original line number Diff line number Diff line
@@ -65,6 +65,8 @@ import java.util.concurrent.atomic.AtomicReference;

public abstract class PhoneBase extends Handler implements Phone {
    private static final String LOG_TAG = "PhoneBase";
    protected static final boolean DEBUGGABLE = SystemProperties.getInt("ro.debuggable", 0) == 1;

    // Key used to read and write the saved network selection numeric value
    public static final String NETWORK_SELECTION_KEY = "network_selection_key";
    // Key used to read and write the saved network selection operator name
@@ -136,11 +138,42 @@ public abstract class PhoneBase extends Handler implements Phone {
            new AtomicReference<UiccCardApplication>();
    public SMSDispatcher mSMS;

    private TelephonyTester mTelephonyTester;
    private final String mName;
    private final String mActionDetached;
    private final String mActionAttached;

    @Override
    public String getPhoneName() {
        return mName;
    }

    /**
     * Return the ActionDetached string. When this action is received by components
     * they are to simulate detaching from the network.
     *
     * @return com.android.internal.telephony.{mName}.action_detached
     *          {mName} is GSM, CDMA ...
     */
    public String getActionDetached() {
        return mActionDetached;
    }

    /**
     * Return the ActionAttached string. When this action is received by components
     * they are to simulate attaching to the network.
     *
     * @return com.android.internal.telephony.{mName}.action_detached
     *          {mName} is GSM, CDMA ...
     */
    public String getActionAttached() {
        return mActionAttached;
    }

    /**
     * Set a system property, unless we're in unit test mode
     */
    public void
    setSystemProperty(String property, String value) {
    public void setSystemProperty(String property, String value) {
        if(getUnitTestMode()) {
            return;
        }
@@ -198,8 +231,8 @@ public abstract class PhoneBase extends Handler implements Phone {
     * unless unit testing.
     * @param ci the CommandsInterface
     */
    protected PhoneBase(PhoneNotifier notifier, Context context, CommandsInterface ci) {
        this(notifier, context, ci, false);
    protected PhoneBase(String name, PhoneNotifier notifier, Context context, CommandsInterface ci) {
        this(name, notifier, context, ci, false);
    }

    /**
@@ -212,12 +245,19 @@ public abstract class PhoneBase extends Handler implements Phone {
     * @param unitTestMode when true, prevents notifications
     * of state change events
     */
    protected PhoneBase(PhoneNotifier notifier, Context context, CommandsInterface ci,
    protected PhoneBase(String name, PhoneNotifier notifier, Context context, CommandsInterface ci,
            boolean unitTestMode) {
        mName = name;
        mNotifier = notifier;
        mContext = context;
        mLooper = Looper.myLooper();
        mCi = ci;
        mActionDetached = this.getClass().getPackage().getName() + ".action_detached";
        mActionAttached = this.getClass().getPackage().getName() + ".action_attached";

        if (DEBUGGABLE) {
            mTelephonyTester = new TelephonyTester(this);
        }

        setPropertiesByCarrier();

@@ -272,6 +312,10 @@ public abstract class PhoneBase extends Handler implements Phone {
            mSmsStorageMonitor.dispose();
            mSmsUsageMonitor.dispose();
            mUiccController.unregisterForIccChanged(this);

            if (mTelephonyTester != null) {
                mTelephonyTester.dispose();
            }
        }
    }

@@ -919,9 +963,6 @@ public abstract class PhoneBase extends Handler implements Phone {
        return false;
    }

    @Override
    public abstract String getPhoneName();

    @Override
    public abstract int getPhoneType();

+12 −11
Original line number Diff line number Diff line
@@ -59,7 +59,8 @@ import com.android.internal.telephony.uicc.IccUtils;
import com.android.internal.telephony.cdma.CdmaCallWaitingNotification;
import com.android.internal.telephony.cdma.CdmaInformationRecords;
import com.android.internal.telephony.cdma.CdmaSmsBroadcastConfigInfo;
import com.android.internal.telephony.dataconnection.DataConnectionBase;
import com.android.internal.telephony.dataconnection.DcFailCause;
import com.android.internal.telephony.dataconnection.DataCallResponse;

import java.io.ByteArrayInputStream;
import java.io.DataInputStream;
@@ -3230,8 +3231,8 @@ public final class RIL extends BaseCommands implements CommandsInterface {
        return response;
    }

    private DataCallState getDataCallState(Parcel p, int version) {
        DataCallState dataCall = new DataCallState();
    private DataCallResponse getDataCallResponse(Parcel p, int version) {
        DataCallResponse dataCall = new DataCallResponse();

        dataCall.version = version;
        if (version < 5) {
@@ -3249,9 +3250,9 @@ public final class RIL extends BaseCommands implements CommandsInterface {
            dataCall.active = p.readInt();
            dataCall.type = p.readString();
            dataCall.ifname = p.readString();
            if ((dataCall.status == DataConnectionBase.FailCause.NONE.getErrorCode()) &&
            if ((dataCall.status == DcFailCause.NONE.getErrorCode()) &&
                    TextUtils.isEmpty(dataCall.ifname)) {
              throw new RuntimeException("getDataCallState, no ifname");
              throw new RuntimeException("getDataCallResponse, no ifname");
            }
            String addresses = p.readString();
            if (!TextUtils.isEmpty(addresses)) {
@@ -3271,15 +3272,15 @@ public final class RIL extends BaseCommands implements CommandsInterface {

    private Object
    responseDataCallList(Parcel p) {
        ArrayList<DataCallState> response;
        ArrayList<DataCallResponse> response;

        int ver = p.readInt();
        int num = p.readInt();
        riljLog("responseDataCallList ver=" + ver + " num=" + num);

        response = new ArrayList<DataCallState>(num);
        response = new ArrayList<DataCallResponse>(num);
        for (int i = 0; i < num; i++) {
            response.add(getDataCallState(p, ver));
            response.add(getDataCallResponse(p, ver));
        }

        return response;
@@ -3291,10 +3292,10 @@ public final class RIL extends BaseCommands implements CommandsInterface {
        int num = p.readInt();
        if (RILJ_LOGV) riljLog("responseSetupDataCall ver=" + ver + " num=" + num);

        DataCallState dataCall;
        DataCallResponse dataCall;

        if (ver < 5) {
            dataCall = new DataCallState();
            dataCall = new DataCallResponse();
            dataCall.version = ver;
            dataCall.cid = Integer.parseInt(p.readString());
            dataCall.ifname = p.readString();
@@ -3326,7 +3327,7 @@ public final class RIL extends BaseCommands implements CommandsInterface {
                        "RIL_REQUEST_SETUP_DATA_CALL response expecting 1 RIL_Data_Call_response_v5"
                        + " got " + num);
            }
            dataCall = getDataCallState(p, ver);
            dataCall = getDataCallResponse(p, ver);
        }

        return dataCall;
Loading