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

Commit 17db4067 authored by Wink Saville's avatar Wink Saville Committed by Android (Google) Code Review
Browse files

Merge "Cleanup logging."

parents 6a956659 ed9c02b5
Loading
Loading
Loading
Loading
+42 −31
Original line number Original line Diff line number Diff line
@@ -32,7 +32,7 @@ import android.net.NetworkInfo.DetailedState;
import android.net.NetworkInfo;
import android.net.NetworkInfo;
import android.net.LinkProperties;
import android.net.LinkProperties;
import android.telephony.TelephonyManager;
import android.telephony.TelephonyManager;
import android.util.Log;
import android.util.Slog;
import android.text.TextUtils;
import android.text.TextUtils;


/**
/**
@@ -162,10 +162,11 @@ public class MobileDataStateTracker implements NetworkStateTracker {
            if (intent.getAction().equals(TelephonyIntents.
            if (intent.getAction().equals(TelephonyIntents.
                    ACTION_ANY_DATA_CONNECTION_STATE_CHANGED)) {
                    ACTION_ANY_DATA_CONNECTION_STATE_CHANGED)) {
                String apnType = intent.getStringExtra(Phone.DATA_APN_TYPE_KEY);
                String apnType = intent.getStringExtra(Phone.DATA_APN_TYPE_KEY);
                if (VDBG) Log.d(TAG,
                if (VDBG) {
                        String.format("Broadcast received: ACTION_ANY_DATA_CONNECTION_STATE_CHANGED"
                    log(String.format("Broadcast received: ACTION_ANY_DATA_CONNECTION_STATE_CHANGED"
                                            + "mApnType=%s %s received apnType=%s",
                        + "mApnType=%s %s received apnType=%s", mApnType,
                        mApnType, TextUtils.equals(apnType, mApnType) ? "==" : "!=", apnType));
                        TextUtils.equals(apnType, mApnType) ? "==" : "!=", apnType));
                }
                if (!TextUtils.equals(apnType, mApnType)) {
                if (!TextUtils.equals(apnType, mApnType)) {
                    return;
                    return;
                }
                }
@@ -177,10 +178,10 @@ public class MobileDataStateTracker implements NetworkStateTracker {
                mNetworkInfo.setIsAvailable(!intent.getBooleanExtra(Phone.NETWORK_UNAVAILABLE_KEY,
                mNetworkInfo.setIsAvailable(!intent.getBooleanExtra(Phone.NETWORK_UNAVAILABLE_KEY,
                        false));
                        false));


                if (DBG) Log.d(TAG, mApnType + " Received state=" + state + ", old=" +
                if (DBG) {
                        mMobileDataState + ", reason=" +
                    log(mApnType + " Received state=" + state + ", old=" + mMobileDataState +
                        (reason == null ? "(unspecified)" : reason));
                        ", reason=" + (reason == null ? "(unspecified)" : reason));

                }
                if (mMobileDataState != state) {
                if (mMobileDataState != state) {
                    mMobileDataState = state;
                    mMobileDataState = state;
                    switch (state) {
                    switch (state) {
@@ -211,8 +212,7 @@ public class MobileDataStateTracker implements NetworkStateTracker {
                                    }
                                    }
                                } catch (RemoteException e) {
                                } catch (RemoteException e) {
                                    // just go ahead with the reset
                                    // just go ahead with the reset
                                    Log.e(TAG, "Exception trying to contact ConnService: "
                                    loge("Exception trying to contact ConnService: " + e);
                                            + e);
                                }
                                }
                            }
                            }
                            if (doReset && mLinkProperties != null) {
                            if (doReset && mLinkProperties != null) {
@@ -223,7 +223,7 @@ public class MobileDataStateTracker implements NetworkStateTracker {
                            // can't do this here - ConnectivityService needs it to clear stuff
                            // can't do this here - ConnectivityService needs it to clear stuff
                            // it's ok though - just leave it to be refreshed next time
                            // it's ok though - just leave it to be refreshed next time
                            // we connect.
                            // we connect.
                            //if (DBG) Log.d(TAG, "clearing mInterfaceName for "+ mApnType +
                            //if (DBG) log("clearing mInterfaceName for "+ mApnType +
                            //        " as it DISCONNECTED");
                            //        " as it DISCONNECTED");
                            //mInterfaceName = null;
                            //mInterfaceName = null;
                            //mDefaultGatewayAddr = 0;
                            //mDefaultGatewayAddr = 0;
@@ -238,13 +238,13 @@ public class MobileDataStateTracker implements NetworkStateTracker {
                            mLinkProperties = intent.getParcelableExtra(
                            mLinkProperties = intent.getParcelableExtra(
                                    Phone.DATA_LINK_PROPERTIES_KEY);
                                    Phone.DATA_LINK_PROPERTIES_KEY);
                            if (mLinkProperties == null) {
                            if (mLinkProperties == null) {
                                Log.d(TAG, "CONNECTED event did not supply link properties.");
                                log("CONNECTED event did not supply link properties.");
                                mLinkProperties = new LinkProperties();
                                mLinkProperties = new LinkProperties();
                            }
                            }
                            mLinkCapabilities = intent.getParcelableExtra(
                            mLinkCapabilities = intent.getParcelableExtra(
                                    Phone.DATA_LINK_CAPABILITIES_KEY);
                                    Phone.DATA_LINK_CAPABILITIES_KEY);
                            if (mLinkCapabilities == null) {
                            if (mLinkCapabilities == null) {
                                Log.d(TAG, "CONNECTED event did not supply link capabilities.");
                                log("CONNECTED event did not supply link capabilities.");
                                mLinkCapabilities = new LinkCapabilities();
                                mLinkCapabilities = new LinkCapabilities();
                            }
                            }
                            setDetailedState(DetailedState.CONNECTED, reason, apnName);
                            setDetailedState(DetailedState.CONNECTED, reason, apnName);
@@ -255,17 +255,22 @@ public class MobileDataStateTracker implements NetworkStateTracker {
                    equals(TelephonyIntents.ACTION_DATA_CONNECTION_FAILED)) {
                    equals(TelephonyIntents.ACTION_DATA_CONNECTION_FAILED)) {
                String apnType = intent.getStringExtra(Phone.DATA_APN_TYPE_KEY);
                String apnType = intent.getStringExtra(Phone.DATA_APN_TYPE_KEY);
                if (!TextUtils.equals(apnType, mApnType)) {
                if (!TextUtils.equals(apnType, mApnType)) {
                    if (DBG) Log.d(TAG, String.format("Broadcast received: ACTION_ANY_DATA_CONNECTION_FAILED ignore, mApnType=%s != received apnType=%s",
                    if (DBG) {
                            mApnType, apnType));
                        log(String.format(
                                "Broadcast received: ACTION_ANY_DATA_CONNECTION_FAILED ignore, " +
                                "mApnType=%s != received apnType=%s", mApnType, apnType));
                    }
                    return;
                    return;
                }
                }
                String reason = intent.getStringExtra(Phone.FAILURE_REASON_KEY);
                String reason = intent.getStringExtra(Phone.FAILURE_REASON_KEY);
                String apnName = intent.getStringExtra(Phone.DATA_APN_KEY);
                String apnName = intent.getStringExtra(Phone.DATA_APN_KEY);
                if (DBG) Log.d(TAG, mApnType + "Received " + intent.getAction() +
                if (DBG) {
                    log(mApnType + "Received " + intent.getAction() +
                                " broadcast" + reason == null ? "" : "(" + reason + ")");
                                " broadcast" + reason == null ? "" : "(" + reason + ")");
                }
                setDetailedState(DetailedState.FAILED, reason, apnName);
                setDetailedState(DetailedState.FAILED, reason, apnName);
            } else {
            } else {
                if (DBG) Log.d(TAG, "Broadcast received: ignore " + intent.getAction());
                if (DBG) log("Broadcast received: ignore " + intent.getAction());
            }
            }
        }
        }
    }
    }
@@ -335,7 +340,7 @@ public class MobileDataStateTracker implements NetworkStateTracker {
            networkTypeStr = "ehrpd";
            networkTypeStr = "ehrpd";
            break;
            break;
        default:
        default:
            Log.e(TAG, "unknown network type: " + tm.getNetworkType());
            loge("unknown network type: " + tm.getNetworkType());
        }
        }
        return "net.tcp.buffersize." + networkTypeStr;
        return "net.tcp.buffersize." + networkTypeStr;
    }
    }
@@ -359,8 +364,9 @@ public class MobileDataStateTracker implements NetworkStateTracker {
     * if one was supplied. May be {@code null}.
     * if one was supplied. May be {@code null}.
     * @param extraInfo optional {@code String} providing extra information about the state change
     * @param extraInfo optional {@code String} providing extra information about the state change
     */
     */
    private void setDetailedState(NetworkInfo.DetailedState state, String reason, String extraInfo) {
    private void setDetailedState(NetworkInfo.DetailedState state, String reason,
        if (DBG) Log.d(TAG, "setDetailed state, old ="
            String extraInfo) {
        if (DBG) log("setDetailed state, old ="
                + mNetworkInfo.getDetailedState() + " and new state=" + state);
                + mNetworkInfo.getDetailedState() + " and new state=" + state);
        if (state != mNetworkInfo.getDetailedState()) {
        if (state != mNetworkInfo.getDetailedState()) {
            boolean wasConnecting = (mNetworkInfo.getState() == NetworkInfo.State.CONNECTING);
            boolean wasConnecting = (mNetworkInfo.getState() == NetworkInfo.State.CONNECTING);
@@ -407,7 +413,7 @@ public class MobileDataStateTracker implements NetworkStateTracker {
            case Phone.APN_TYPE_NOT_AVAILABLE:
            case Phone.APN_TYPE_NOT_AVAILABLE:
                break;
                break;
            default:
            default:
                Log.e(TAG, "Error in reconnect - unexpected response.");
                loge("Error in reconnect - unexpected response.");
                break;
                break;
        }
        }
        return retValue;
        return retValue;
@@ -426,8 +432,7 @@ public class MobileDataStateTracker implements NetworkStateTracker {
         */
         */
        for (int retry = 0; retry < 2; retry++) {
        for (int retry = 0; retry < 2; retry++) {
            if (mPhoneService == null) {
            if (mPhoneService == null) {
                Log.w(TAG,
                log("Ignoring mobile radio request because could not acquire PhoneService");
                    "Ignoring mobile radio request because could not acquire PhoneService");
                break;
                break;
            }
            }


@@ -438,7 +443,7 @@ public class MobileDataStateTracker implements NetworkStateTracker {
            }
            }
        }
        }


        Log.w(TAG, "Could not set radio power to " + (turnOn ? "on" : "off"));
        log("Could not set radio power to " + (turnOn ? "on" : "off"));
        return false;
        return false;
    }
    }


@@ -506,8 +511,7 @@ public class MobileDataStateTracker implements NetworkStateTracker {
         */
         */
        for (int retry = 0; retry < 2; retry++) {
        for (int retry = 0; retry < 2; retry++) {
            if (mPhoneService == null) {
            if (mPhoneService == null) {
                Log.w(TAG,
                log("Ignoring feature request because could not acquire PhoneService");
                    "Ignoring feature request because could not acquire PhoneService");
                break;
                break;
            }
            }


@@ -522,8 +526,7 @@ public class MobileDataStateTracker implements NetworkStateTracker {
            }
            }
        }
        }


        Log.w(TAG, "Could not " + (enable ? "enable" : "disable")
        log("Could not " + (enable ? "enable" : "disable") + " APN type \"" + apnType + "\"");
                + " APN type \"" + apnType + "\"");
        return Phone.APN_REQUEST_FAILED;
        return Phone.APN_REQUEST_FAILED;
    }
    }


@@ -540,7 +543,7 @@ public class MobileDataStateTracker implements NetworkStateTracker {
            case ConnectivityManager.TYPE_MOBILE_HIPRI:
            case ConnectivityManager.TYPE_MOBILE_HIPRI:
                return Phone.APN_TYPE_HIPRI;
                return Phone.APN_TYPE_HIPRI;
            default:
            default:
                Log.e(TAG, "Error mapping networkType " + netType + " to apnType.");
                loge("Error mapping networkType " + netType + " to apnType.");
                return null;
                return null;
        }
        }
    }
    }
@@ -558,4 +561,12 @@ public class MobileDataStateTracker implements NetworkStateTracker {
    public LinkCapabilities getLinkCapabilities() {
    public LinkCapabilities getLinkCapabilities() {
        return new LinkCapabilities(mLinkCapabilities);
        return new LinkCapabilities(mLinkCapabilities);
    }
    }

    static private void log(String s) {
        Slog.d(TAG, s);
    }

    static private void loge(String s) {
        Slog.e(TAG, s);
    }
}
}
+88 −82

File changed.

Preview size limit exceeded, changes collapsed.