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

Commit 876763e9 authored by Wink Saville's avatar Wink Saville
Browse files

Make EnableFailFastRefCounter a singleton.

Since there is only one DCT the mEnableFailFastRefCounter can be a
static/singleton and thus properly refcount the
CMD_SET_ENABLE_FAIL_FAST_MOBILE_DATA. There is still one problem
and that is if the PhoneApp crashes the singleton will be reinstantiated
and we'll have the same problem, but the frequency of this is small.
Also, the consequence of this is the DCT will be behaving "normally"
in that it will be attempting to do data-stall recovery although we
might like it not to it is the "normal" behavior.

Bug: 10304904
Change-Id: I4197c4236a402aa247f775e480e747620fd189bd
parent a76fa595
Loading
Loading
Loading
Loading
+9 −9
Original line number Diff line number Diff line
@@ -206,7 +206,7 @@ public abstract class DcTrackerBase extends Handler {
    // Controls when a simple recovery attempt it to be tried
    protected int mNoRecvPollCount = 0;
    // Refrence counter for enabling fail fast
    protected int mEnableFailFastRefCounter = 0;
    protected static int sEnableFailFastRefCounter = 0;
    // True if data stall detection is enabled
    protected volatile boolean mDataStallDetectionEnabled = true;

@@ -757,24 +757,24 @@ public abstract class DcTrackerBase extends Handler {
                break;
            }
            case DctConstants.CMD_SET_ENABLE_FAIL_FAST_MOBILE_DATA: {
                mEnableFailFastRefCounter += (msg.arg1 == DctConstants.ENABLED) ? 1 : -1;
                sEnableFailFastRefCounter += (msg.arg1 == DctConstants.ENABLED) ? 1 : -1;
                if (DBG) {
                    log("CMD_SET_ENABLE_FAIL_FAST_MOBILE_DATA: "
                            + " mEnableFailFastRefCounter=" + mEnableFailFastRefCounter);
                            + " sEnableFailFastRefCounter=" + sEnableFailFastRefCounter);
                }
                if (mEnableFailFastRefCounter < 0) {
                if (sEnableFailFastRefCounter < 0) {
                    final String s = "CMD_SET_ENABLE_FAIL_FAST_MOBILE_DATA: "
                            + "mEnableFailFastRefCounter < 0";
                            + "sEnableFailFastRefCounter:" + sEnableFailFastRefCounter + " < 0";
                    loge(s);
                    sEnableFailFastRefCounter = 0;
                    if (Build.IS_DEBUGGABLE) {
                        throw new RuntimeException(s);
                    }
                    loge(s);
                    mEnableFailFastRefCounter = 0;
                }
                final boolean enabled = mEnableFailFastRefCounter > 0;
                final boolean enabled = sEnableFailFastRefCounter > 0;
                if (DBG) {
                    log("CMD_SET_ENABLE_FAIL_FAST_MOBILE_DATA: enabled=" + enabled
                            + " mEnableFailFastRefCounter=" + mEnableFailFastRefCounter);
                            + " sEnableFailFastRefCounter=" + sEnableFailFastRefCounter);
                }
                if (mFailFast != enabled) {
                    mFailFast = enabled;