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

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

Remove pingtest in GsmDataConnectionTracker.

The pingtest have been disabled since petit-four and ping's use is
being deprecated. Removing the ping test code, if needed use
InetAddress.isReachable instead.

bug: 1824738
Change-Id: I42b3de85b67b82dc6389e7a2234afa7b1d687209
parent f5c4111f
Loading
Loading
Loading
Loading
+0 −14
Original line number Diff line number Diff line
@@ -3317,20 +3317,6 @@ public final class Settings {
        public static final String PDP_WATCHDOG_MAX_PDP_RESET_FAIL_COUNT =
                "pdp_watchdog_max_pdp_reset_fail_count";

        /**
         * Address to ping as a last sanity check before attempting any recovery.
         * Unset or set to "0.0.0.0" to skip this check.
         * @hide
         */
        public static final String PDP_WATCHDOG_PING_ADDRESS = "pdp_watchdog_ping_address";

        /**
         * The "-w deadline" parameter for the ping, ie, the max time in
         * seconds to spend pinging.
         * @hide
         */
        public static final String PDP_WATCHDOG_PING_DEADLINE = "pdp_watchdog_ping_deadline";

        /**
         * The interval in milliseconds at which to check gprs registration
         * after the first registration mismatch of gprs and voice service,
+0 −2
Original line number Diff line number Diff line
@@ -149,8 +149,6 @@ public abstract class DataConnectionTracker extends Handler {

    /** Slow poll when attempting connection recovery. */
    protected static final int POLL_NETSTAT_SLOW_MILLIS = 5000;
    /** Default ping deadline, in seconds. */
    protected static final int DEFAULT_PING_DEADLINE = 5;
    /** Default max failure count before attempting to network re-registration. */
    protected static final int DEFAULT_MAX_PDP_RESET_FAIL = 3;

+3 −46
Original line number Diff line number Diff line
@@ -81,7 +81,6 @@ public final class GsmDataConnectionTracker extends DataConnectionTracker {
    private boolean mReregisterOnReconnectFailure = false;
    private ContentResolver mResolver;

    private boolean mPingTestActive = false;
    // Count of PDP reset attempts; reset when we see incoming,
    // call reRegisterNetwork, or pingTest succeeds.
    private int mPdpResetCount = 0;
@@ -654,7 +653,7 @@ public final class GsmDataConnectionTracker extends DataConnectionTracker {

    @Override
    protected void startNetStatPoll() {
        if (mState == State.CONNECTED && mPingTestActive == false && mNetStatPollEnabled == false) {
        if (mState == State.CONNECTED && mNetStatPollEnabled == false) {
            log("[DataConnection] Start poll NetStat");
            resetPollStats();
            mNetStatPollEnabled = true;
@@ -763,18 +762,9 @@ public final class GsmDataConnectionTracker extends DataConnectionTracker {
                            POLL_NETSTAT_SLOW_MILLIS);
                } else {
                    if (DBG) log("Sent " + String.valueOf(mSentSinceLastRecv) +
                                        " pkts since last received");
                    // We've exceeded the threshold.  Run ping test as a final check;
                    // it will proceed with recovery if ping fails.
                                        " pkts since last received start recovery process");
                    stopNetStatPoll();
                    Thread pingTest = new Thread() {
                        @Override
                        public void run() {
                            runPingTest();
                        }
                    };
                    mPingTestActive = true;
                    pingTest.start();
                    sendMessage(obtainMessage(EVENT_START_RECOVERY));
                }
            } else {
                mNoRecvPollCount = 0;
@@ -794,37 +784,6 @@ public final class GsmDataConnectionTracker extends DataConnectionTracker {
        }
    };

    private void runPingTest () {
        int status = -1;
        try {
            String address = Settings.Secure.getString(mResolver,
                    Settings.Secure.PDP_WATCHDOG_PING_ADDRESS);
            int deadline = Settings.Secure.getInt(mResolver,
                        Settings.Secure.PDP_WATCHDOG_PING_DEADLINE, DEFAULT_PING_DEADLINE);
            if (DBG) log("pinging " + address + " for " + deadline + "s");
            if (address != null && !NULL_IP.equals(address)) {
                Process p = Runtime.getRuntime()
                                .exec("ping -c 1 -i 1 -w "+ deadline + " " + address);
                status = p.waitFor();
            }
        } catch (IOException e) {
            loge("ping failed: IOException");
        } catch (Exception e) {
            loge("exception trying to ping");
        }

        if (status == 0) {
            // ping succeeded.  False alarm.  Reset netStatPoll.
            // ("-1" for this event indicates a false alarm)
            EventLog.writeEvent(EventLogTags.PDP_RADIO_RESET, -1);
            mPdpResetCount = 0;
            sendMessage(obtainMessage(EVENT_START_NETSTAT_POLL));
        } else {
            // ping failed.  Proceed with recovery.
            sendMessage(obtainMessage(EVENT_START_RECOVERY));
        }
    }

    /**
     * Returns true if the last fail cause is something that
     * seems like it deserves an error notification.
@@ -1399,12 +1358,10 @@ public final class GsmDataConnectionTracker extends DataConnectionTracker {
                break;

            case EVENT_START_NETSTAT_POLL:
                mPingTestActive = false;
                startNetStatPoll();
                break;

            case EVENT_START_RECOVERY:
                mPingTestActive = false;
                doRecovery();
                break;