9797public class ConnectivityService extends IConnectivityManager .Stub {
9898
9999 private static final boolean DBG = true ;
100- private static final boolean VDBG = true ;
100+ private static final boolean VDBG = false ;
101101 private static final String TAG = "ConnectivityService" ;
102102
103103 private static final boolean LOGD_RULES = false ;
@@ -867,7 +867,7 @@ public String toString() {
867867 // javadoc from interface
868868 public int startUsingNetworkFeature (int networkType , String feature ,
869869 IBinder binder ) {
870- if (DBG ) {
870+ if (VDBG ) {
871871 log ("startUsingNetworkFeature for net " + networkType + ": " + feature );
872872 }
873873 enforceChangePermission ();
@@ -933,17 +933,19 @@ public int startUsingNetworkFeature(int networkType, String feature,
933933 if (ni .isConnected () == true ) {
934934 // add the pid-specific dns
935935 handleDnsConfigurationChange (usedNetworkType );
936- if (DBG ) log ("special network already active" );
936+ if (VDBG ) log ("special network already active" );
937937 return Phone .APN_ALREADY_ACTIVE ;
938938 }
939- if (DBG ) log ("special network already connecting" );
939+ if (VDBG ) log ("special network already connecting" );
940940 return Phone .APN_REQUEST_STARTED ;
941941 }
942942
943943 // check if the radio in play can make another contact
944944 // assume if cannot for now
945945
946- if (DBG ) log ("reconnecting to special network" );
946+ if (DBG ) {
947+ log ("startUsingNetworkFeature reconnecting to " + networkType + ": " + feature );
948+ }
947949 network .reconnect ();
948950 return Phone .APN_REQUEST_STARTED ;
949951 } else {
@@ -985,7 +987,7 @@ public int stopUsingNetworkFeature(int networkType, String feature) {
985987 return stopUsingNetworkFeature (u , true );
986988 } else {
987989 // none found!
988- if (VDBG ) log ("ignoring stopUsingNetworkFeature - not a live request" );
990+ if (VDBG ) log ("stopUsingNetworkFeature - not a live request, ignoring " );
989991 return 1 ;
990992 }
991993 }
@@ -999,12 +1001,15 @@ private int stopUsingNetworkFeature(FeatureUser u, boolean ignoreDups) {
9991001 NetworkStateTracker tracker = null ;
10001002 boolean callTeardown = false ; // used to carry our decision outside of sync block
10011003
1002- if (DBG ) {
1003- log ("stopUsingNetworkFeature for net " + networkType +
1004- ": " + feature );
1004+ if (VDBG ) {
1005+ log ("stopUsingNetworkFeature: net " + networkType + ": " + feature );
10051006 }
10061007
10071008 if (!ConnectivityManager .isNetworkTypeValid (networkType )) {
1009+ if (DBG ) {
1010+ log ("stopUsingNetworkFeature: net " + networkType + ": " + feature +
1011+ ", net is invalid" );
1012+ }
10081013 return -1 ;
10091014 }
10101015
@@ -1013,7 +1018,10 @@ private int stopUsingNetworkFeature(FeatureUser u, boolean ignoreDups) {
10131018 synchronized (this ) {
10141019 // check if this process still has an outstanding start request
10151020 if (!mFeatureUsers .contains (u )) {
1016- if (DBG ) log ("ignoring - this process has no outstanding requests" );
1021+ if (VDBG ) {
1022+ log ("stopUsingNetworkFeature: this process has no outstanding requests" +
1023+ ", ignoring" );
1024+ }
10171025 return 1 ;
10181026 }
10191027 u .unlinkDeathRecipient ();
@@ -1028,7 +1036,7 @@ private int stopUsingNetworkFeature(FeatureUser u, boolean ignoreDups) {
10281036 if (ignoreDups == false ) {
10291037 for (FeatureUser x : mFeatureUsers ) {
10301038 if (x .isSameUser (u )) {
1031- if (DBG ) log ("ignoring stopUsingNetworkFeature as dup is found" );
1039+ if (VDBG ) log ("stopUsingNetworkFeature: dup is found, ignoring " );
10321040 return 1 ;
10331041 }
10341042 }
@@ -1039,25 +1047,36 @@ private int stopUsingNetworkFeature(FeatureUser u, boolean ignoreDups) {
10391047
10401048 tracker = mNetTrackers [usedNetworkType ];
10411049 if (tracker == null ) {
1042- if (DBG ) log ("ignoring - no known tracker for net type " + usedNetworkType );
1050+ if (DBG ) {
1051+ log ("stopUsingNetworkFeature: net " + networkType + ": " + feature +
1052+ " no known tracker for used net type " + usedNetworkType );
1053+ }
10431054 return -1 ;
10441055 }
10451056 if (usedNetworkType != networkType ) {
10461057 Integer currentPid = new Integer (pid );
10471058 mNetRequestersPids [usedNetworkType ].remove (currentPid );
10481059 reassessPidDns (pid , true );
10491060 if (mNetRequestersPids [usedNetworkType ].size () != 0 ) {
1050- if (DBG ) log ("not tearing down special network - " +
1051- "others still using it" );
1061+ if (VDBG ) {
1062+ log ("stopUsingNetworkFeature: net " + networkType + ": " + feature +
1063+ " others still using it" );
1064+ }
10521065 return 1 ;
10531066 }
10541067 callTeardown = true ;
10551068 } else {
1056- if (DBG ) log ("not a known feature - dropping" );
1069+ if (DBG ) {
1070+ log ("stopUsingNetworkFeature: net " + networkType + ": " + feature +
1071+ " not a known feature - dropping" );
1072+ }
10571073 }
10581074 }
1059- if ( DBG ) log ( "Doing network teardown" );
1075+
10601076 if (callTeardown ) {
1077+ if (DBG ) {
1078+ log ("stopUsingNetworkFeature: teardown net " + networkType + ": " + feature );
1079+ }
10611080 tracker .teardown ();
10621081 return 1 ;
10631082 } else {
@@ -1592,7 +1611,7 @@ private void sendStickyBroadcast(Intent intent) {
15921611 mInitialBroadcast = new Intent (intent );
15931612 }
15941613 intent .addFlags (Intent .FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT );
1595- if (DBG ) {
1614+ if (VDBG ) {
15961615 log ("sendStickyBroadcast: action=" + intent .getAction ());
15971616 }
15981617
@@ -1604,7 +1623,7 @@ private void sendStickyBroadcastDelayed(Intent intent, int delayMs) {
16041623 if (delayMs <= 0 ) {
16051624 sendStickyBroadcast (intent );
16061625 } else {
1607- if (DBG ) {
1626+ if (VDBG ) {
16081627 log ("sendStickyBroadcastDelayed: delayMs=" + delayMs + ", action="
16091628 + intent .getAction ());
16101629 }
@@ -1779,12 +1798,12 @@ private void handleConnectivityChange(int netType, boolean doReset) {
17791798 }
17801799 }
17811800 if (resetDns ) {
1782- if (DBG ) log ("resetting DNS cache for " + iface );
1801+ if (VDBG ) log ("resetting DNS cache for " + iface );
17831802 try {
17841803 mNetd .flushInterfaceDnsCache (iface );
17851804 } catch (Exception e ) {
17861805 // never crash - catch them all
1787- loge ("Exception resetting dns cache: " + e );
1806+ if ( DBG ) loge ("Exception resetting dns cache: " + e );
17881807 }
17891808 }
17901809 }
@@ -1840,12 +1859,12 @@ private boolean updateRoutes(LinkProperties newLp, LinkProperties curLp,
18401859 // remove the default route unless somebody else has asked for it
18411860 String ifaceName = newLp .getInterfaceName ();
18421861 if (TextUtils .isEmpty (ifaceName ) == false && mAddedRoutes .contains (r ) == false ) {
1843- if (DBG ) log ("Removing " + r + " for interface " + ifaceName );
1862+ if (VDBG ) log ("Removing " + r + " for interface " + ifaceName );
18441863 try {
18451864 mNetd .removeRoute (ifaceName , r );
18461865 } catch (Exception e ) {
18471866 // never crash - catch them all
1848- loge ("Exception trying to remove a route: " + e );
1867+ if ( VDBG ) loge ("Exception trying to remove a route: " + e );
18491868 }
18501869 }
18511870 }
@@ -2059,7 +2078,7 @@ private boolean updateDns(String network, String iface,
20592078 mNetd .setDnsServersForInterface (iface , NetworkUtils .makeStrings (dnses ));
20602079 mNetd .setDefaultInterfaceForDns (iface );
20612080 } catch (Exception e ) {
2062- loge ("exception setting default dns interface: " + e );
2081+ if ( VDBG ) loge ("exception setting default dns interface: " + e );
20632082 }
20642083 }
20652084 if (!domains .equals (SystemProperties .get ("net.dns.search" ))) {
@@ -2089,7 +2108,7 @@ private void handleDnsConfigurationChange(int netType) {
20892108 mNetd .setDnsServersForInterface (p .getInterfaceName (),
20902109 NetworkUtils .makeStrings (dnses ));
20912110 } catch (Exception e ) {
2092- loge ("exception setting dns servers: " + e );
2111+ if ( VDBG ) loge ("exception setting dns servers: " + e );
20932112 }
20942113 // set per-pid dns for attached secondary nets
20952114 List pids = mNetRequestersPids [netType ];
@@ -2194,9 +2213,12 @@ public void handleMessage(Message msg) {
21942213 int type = info .getType ();
21952214 NetworkInfo .State state = info .getState ();
21962215
2197- if (DBG ) log ("ConnectivityChange for " +
2216+ if (VDBG || (state == NetworkInfo .State .CONNECTED ) ||
2217+ (state == NetworkInfo .State .DISCONNECTED )) {
2218+ log ("ConnectivityChange for " +
21982219 info .getTypeName () + ": " +
21992220 state + "/" + info .getDetailedState ());
2221+ }
22002222
22012223 // Connectivity state changed:
22022224 // [31-13] Reserved for future use
@@ -2458,23 +2480,24 @@ public void reportInetCondition(int networkType, int percentage) {
24582480 }
24592481
24602482 private void handleInetConditionChange (int netType , int condition ) {
2461- if (DBG ) {
2462- log ("Inet connectivity change, net=" +
2463- netType + ", condition=" + condition +
2464- ",mActiveDefaultNetwork=" + mActiveDefaultNetwork );
2465- }
24662483 if (mActiveDefaultNetwork == -1 ) {
2467- if (DBG ) log ("no active default network - aborting " );
2484+ if (DBG ) log ("handleInetConditionChange: no active default network - ignore " );
24682485 return ;
24692486 }
24702487 if (mActiveDefaultNetwork != netType ) {
2471- if (DBG ) log ("given net not default - aborting" );
2488+ if (DBG ) log ("handleInetConditionChange: net=" + netType +
2489+ " != default=" + mActiveDefaultNetwork + " - ignore" );
24722490 return ;
24732491 }
2492+ if (VDBG ) {
2493+ log ("handleInetConditionChange: net=" +
2494+ netType + ", condition=" + condition +
2495+ ",mActiveDefaultNetwork=" + mActiveDefaultNetwork );
2496+ }
24742497 mDefaultInetCondition = condition ;
24752498 int delay ;
24762499 if (mInetConditionChangeInFlight == false ) {
2477- if (VDBG ) log ("starting a change hold" );
2500+ if (VDBG ) log ("handleInetConditionChange: starting a change hold" );
24782501 // setup a new hold to debounce this
24792502 if (mDefaultInetCondition > 50 ) {
24802503 delay = Settings .Secure .getInt (mContext .getContentResolver (),
@@ -2487,26 +2510,25 @@ private void handleInetConditionChange(int netType, int condition) {
24872510 mHandler .sendMessageDelayed (mHandler .obtainMessage (EVENT_INET_CONDITION_HOLD_END ,
24882511 mActiveDefaultNetwork , mDefaultConnectionSequence ), delay );
24892512 } else {
2490- // we've set the new condition, when this hold ends that will get
2491- // picked up
2492- if (VDBG ) log ("currently in hold - not setting new end evt" );
2513+ // we've set the new condition, when this hold ends that will get picked up
2514+ if (VDBG ) log ("handleInetConditionChange: currently in hold - not setting new end evt" );
24932515 }
24942516 }
24952517
24962518 private void handleInetConditionHoldEnd (int netType , int sequence ) {
2497- if (VDBG ) {
2498- log ("Inet hold end, net=" + netType +
2499- ", condition =" + mDefaultInetCondition +
2500- ", published condition =" + mDefaultInetConditionPublished );
2519+ if (DBG ) {
2520+ log ("handleInetConditionHoldEnd: net=" + netType +
2521+ ", condition=" + mDefaultInetCondition +
2522+ ", published condition=" + mDefaultInetConditionPublished );
25012523 }
25022524 mInetConditionChangeInFlight = false ;
25032525
25042526 if (mActiveDefaultNetwork == -1 ) {
2505- if (DBG ) log ("no active default network - aborting " );
2527+ if (DBG ) log ("handleInetConditionHoldEnd: no active default network - ignoring " );
25062528 return ;
25072529 }
25082530 if (mDefaultConnectionSequence != sequence ) {
2509- if (DBG ) log ("event hold for obsolete network - aborting " );
2531+ if (DBG ) log ("handleInetConditionHoldEnd: event hold for obsolete network - ignoring " );
25102532 return ;
25112533 }
25122534 // TODO: Figure out why this optimization sometimes causes a
@@ -2518,7 +2540,7 @@ private void handleInetConditionHoldEnd(int netType, int sequence) {
25182540 //}
25192541 NetworkInfo networkInfo = mNetTrackers [mActiveDefaultNetwork ].getNetworkInfo ();
25202542 if (networkInfo .isConnected () == false ) {
2521- if (DBG ) log ("default network not connected - aborting " );
2543+ if (DBG ) log ("handleInetConditionHoldEnd: default network not connected - ignoring " );
25222544 return ;
25232545 }
25242546 mDefaultInetConditionPublished = mDefaultInetCondition ;
0 commit comments