am 4aa8d943: Merge "Reduce connectivity logging" into ics-factoryrom
* commit '4aa8d943a970008915b703758743b107927d96fa': Reduce connectivity logging
This commit is contained in:
@@ -56,7 +56,7 @@ import java.io.PrintWriter;
|
|||||||
public class MobileDataStateTracker implements NetworkStateTracker {
|
public class MobileDataStateTracker implements NetworkStateTracker {
|
||||||
|
|
||||||
private static final String TAG = "MobileDataStateTracker";
|
private static final String TAG = "MobileDataStateTracker";
|
||||||
private static final boolean DBG = true;
|
private static final boolean DBG = false;
|
||||||
private static final boolean VDBG = false;
|
private static final boolean VDBG = false;
|
||||||
|
|
||||||
private Phone.DataState mMobileDataState;
|
private Phone.DataState mMobileDataState;
|
||||||
|
|||||||
@@ -137,6 +137,8 @@ public class ProxyProperties implements Parcelable {
|
|||||||
if (mExclusionList != null) {
|
if (mExclusionList != null) {
|
||||||
sb.append(" xl=").append(mExclusionList);
|
sb.append(" xl=").append(mExclusionList);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
sb.append("[ProxyProperties.mHost == null]");
|
||||||
}
|
}
|
||||||
return sb.toString();
|
return sb.toString();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -97,7 +97,7 @@ import java.util.List;
|
|||||||
public class ConnectivityService extends IConnectivityManager.Stub {
|
public class ConnectivityService extends IConnectivityManager.Stub {
|
||||||
|
|
||||||
private static final boolean DBG = true;
|
private static final boolean DBG = true;
|
||||||
private static final boolean VDBG = true;
|
private static final boolean VDBG = false;
|
||||||
private static final String TAG = "ConnectivityService";
|
private static final String TAG = "ConnectivityService";
|
||||||
|
|
||||||
private static final boolean LOGD_RULES = false;
|
private static final boolean LOGD_RULES = false;
|
||||||
@@ -867,7 +867,7 @@ public class ConnectivityService extends IConnectivityManager.Stub {
|
|||||||
// javadoc from interface
|
// javadoc from interface
|
||||||
public int startUsingNetworkFeature(int networkType, String feature,
|
public int startUsingNetworkFeature(int networkType, String feature,
|
||||||
IBinder binder) {
|
IBinder binder) {
|
||||||
if (DBG) {
|
if (VDBG) {
|
||||||
log("startUsingNetworkFeature for net " + networkType + ": " + feature);
|
log("startUsingNetworkFeature for net " + networkType + ": " + feature);
|
||||||
}
|
}
|
||||||
enforceChangePermission();
|
enforceChangePermission();
|
||||||
@@ -933,17 +933,19 @@ public class ConnectivityService extends IConnectivityManager.Stub {
|
|||||||
if (ni.isConnected() == true) {
|
if (ni.isConnected() == true) {
|
||||||
// add the pid-specific dns
|
// add the pid-specific dns
|
||||||
handleDnsConfigurationChange(usedNetworkType);
|
handleDnsConfigurationChange(usedNetworkType);
|
||||||
if (DBG) log("special network already active");
|
if (VDBG) log("special network already active");
|
||||||
return Phone.APN_ALREADY_ACTIVE;
|
return Phone.APN_ALREADY_ACTIVE;
|
||||||
}
|
}
|
||||||
if (DBG) log("special network already connecting");
|
if (VDBG) log("special network already connecting");
|
||||||
return Phone.APN_REQUEST_STARTED;
|
return Phone.APN_REQUEST_STARTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
// check if the radio in play can make another contact
|
// check if the radio in play can make another contact
|
||||||
// assume if cannot for now
|
// assume if cannot for now
|
||||||
|
|
||||||
if (DBG) log("reconnecting to special network");
|
if (DBG) {
|
||||||
|
log("startUsingNetworkFeature reconnecting to " + networkType + ": " + feature);
|
||||||
|
}
|
||||||
network.reconnect();
|
network.reconnect();
|
||||||
return Phone.APN_REQUEST_STARTED;
|
return Phone.APN_REQUEST_STARTED;
|
||||||
} else {
|
} else {
|
||||||
@@ -985,7 +987,7 @@ public class ConnectivityService extends IConnectivityManager.Stub {
|
|||||||
return stopUsingNetworkFeature(u, true);
|
return stopUsingNetworkFeature(u, true);
|
||||||
} else {
|
} else {
|
||||||
// none found!
|
// none found!
|
||||||
if (VDBG) log("ignoring stopUsingNetworkFeature - not a live request");
|
if (VDBG) log("stopUsingNetworkFeature - not a live request, ignoring");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -999,12 +1001,15 @@ public class ConnectivityService extends IConnectivityManager.Stub {
|
|||||||
NetworkStateTracker tracker = null;
|
NetworkStateTracker tracker = null;
|
||||||
boolean callTeardown = false; // used to carry our decision outside of sync block
|
boolean callTeardown = false; // used to carry our decision outside of sync block
|
||||||
|
|
||||||
if (DBG) {
|
if (VDBG) {
|
||||||
log("stopUsingNetworkFeature for net " + networkType +
|
log("stopUsingNetworkFeature: net " + networkType + ": " + feature);
|
||||||
": " + feature);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!ConnectivityManager.isNetworkTypeValid(networkType)) {
|
if (!ConnectivityManager.isNetworkTypeValid(networkType)) {
|
||||||
|
if (DBG) {
|
||||||
|
log("stopUsingNetworkFeature: net " + networkType + ": " + feature +
|
||||||
|
", net is invalid");
|
||||||
|
}
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1013,7 +1018,10 @@ public class ConnectivityService extends IConnectivityManager.Stub {
|
|||||||
synchronized(this) {
|
synchronized(this) {
|
||||||
// check if this process still has an outstanding start request
|
// check if this process still has an outstanding start request
|
||||||
if (!mFeatureUsers.contains(u)) {
|
if (!mFeatureUsers.contains(u)) {
|
||||||
if (DBG) log("ignoring - this process has no outstanding requests");
|
if (VDBG) {
|
||||||
|
log("stopUsingNetworkFeature: this process has no outstanding requests" +
|
||||||
|
", ignoring");
|
||||||
|
}
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
u.unlinkDeathRecipient();
|
u.unlinkDeathRecipient();
|
||||||
@@ -1028,7 +1036,7 @@ public class ConnectivityService extends IConnectivityManager.Stub {
|
|||||||
if (ignoreDups == false) {
|
if (ignoreDups == false) {
|
||||||
for (FeatureUser x : mFeatureUsers) {
|
for (FeatureUser x : mFeatureUsers) {
|
||||||
if (x.isSameUser(u)) {
|
if (x.isSameUser(u)) {
|
||||||
if (DBG) log("ignoring stopUsingNetworkFeature as dup is found");
|
if (VDBG) log("stopUsingNetworkFeature: dup is found, ignoring");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1039,7 +1047,10 @@ public class ConnectivityService extends IConnectivityManager.Stub {
|
|||||||
|
|
||||||
tracker = mNetTrackers[usedNetworkType];
|
tracker = mNetTrackers[usedNetworkType];
|
||||||
if (tracker == null) {
|
if (tracker == null) {
|
||||||
if (DBG) log("ignoring - no known tracker for net type " + usedNetworkType);
|
if (DBG) {
|
||||||
|
log("stopUsingNetworkFeature: net " + networkType + ": " + feature +
|
||||||
|
" no known tracker for used net type " + usedNetworkType);
|
||||||
|
}
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (usedNetworkType != networkType) {
|
if (usedNetworkType != networkType) {
|
||||||
@@ -1047,17 +1058,25 @@ public class ConnectivityService extends IConnectivityManager.Stub {
|
|||||||
mNetRequestersPids[usedNetworkType].remove(currentPid);
|
mNetRequestersPids[usedNetworkType].remove(currentPid);
|
||||||
reassessPidDns(pid, true);
|
reassessPidDns(pid, true);
|
||||||
if (mNetRequestersPids[usedNetworkType].size() != 0) {
|
if (mNetRequestersPids[usedNetworkType].size() != 0) {
|
||||||
if (DBG) log("not tearing down special network - " +
|
if (VDBG) {
|
||||||
"others still using it");
|
log("stopUsingNetworkFeature: net " + networkType + ": " + feature +
|
||||||
|
" others still using it");
|
||||||
|
}
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
callTeardown = true;
|
callTeardown = true;
|
||||||
} else {
|
} else {
|
||||||
if (DBG) log("not a known feature - dropping");
|
if (DBG) {
|
||||||
|
log("stopUsingNetworkFeature: net " + networkType + ": " + feature +
|
||||||
|
" not a known feature - dropping");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (DBG) log("Doing network teardown");
|
|
||||||
if (callTeardown) {
|
if (callTeardown) {
|
||||||
|
if (DBG) {
|
||||||
|
log("stopUsingNetworkFeature: teardown net " + networkType + ": " + feature);
|
||||||
|
}
|
||||||
tracker.teardown();
|
tracker.teardown();
|
||||||
return 1;
|
return 1;
|
||||||
} else {
|
} else {
|
||||||
@@ -1592,7 +1611,7 @@ public class ConnectivityService extends IConnectivityManager.Stub {
|
|||||||
mInitialBroadcast = new Intent(intent);
|
mInitialBroadcast = new Intent(intent);
|
||||||
}
|
}
|
||||||
intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT);
|
intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT);
|
||||||
if (DBG) {
|
if (VDBG) {
|
||||||
log("sendStickyBroadcast: action=" + intent.getAction());
|
log("sendStickyBroadcast: action=" + intent.getAction());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1604,7 +1623,7 @@ public class ConnectivityService extends IConnectivityManager.Stub {
|
|||||||
if (delayMs <= 0) {
|
if (delayMs <= 0) {
|
||||||
sendStickyBroadcast(intent);
|
sendStickyBroadcast(intent);
|
||||||
} else {
|
} else {
|
||||||
if (DBG) {
|
if (VDBG) {
|
||||||
log("sendStickyBroadcastDelayed: delayMs=" + delayMs + ", action="
|
log("sendStickyBroadcastDelayed: delayMs=" + delayMs + ", action="
|
||||||
+ intent.getAction());
|
+ intent.getAction());
|
||||||
}
|
}
|
||||||
@@ -1779,12 +1798,12 @@ public class ConnectivityService extends IConnectivityManager.Stub {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (resetDns) {
|
if (resetDns) {
|
||||||
if (DBG) log("resetting DNS cache for " + iface);
|
if (VDBG) log("resetting DNS cache for " + iface);
|
||||||
try {
|
try {
|
||||||
mNetd.flushInterfaceDnsCache(iface);
|
mNetd.flushInterfaceDnsCache(iface);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
// never crash - catch them all
|
// never crash - catch them all
|
||||||
loge("Exception resetting dns cache: " + e);
|
if (DBG) loge("Exception resetting dns cache: " + e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1840,12 +1859,12 @@ public class ConnectivityService extends IConnectivityManager.Stub {
|
|||||||
// remove the default route unless somebody else has asked for it
|
// remove the default route unless somebody else has asked for it
|
||||||
String ifaceName = newLp.getInterfaceName();
|
String ifaceName = newLp.getInterfaceName();
|
||||||
if (TextUtils.isEmpty(ifaceName) == false && mAddedRoutes.contains(r) == false) {
|
if (TextUtils.isEmpty(ifaceName) == false && mAddedRoutes.contains(r) == false) {
|
||||||
if (DBG) log("Removing " + r + " for interface " + ifaceName);
|
if (VDBG) log("Removing " + r + " for interface " + ifaceName);
|
||||||
try {
|
try {
|
||||||
mNetd.removeRoute(ifaceName, r);
|
mNetd.removeRoute(ifaceName, r);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
// never crash - catch them all
|
// never crash - catch them all
|
||||||
loge("Exception trying to remove a route: " + e);
|
if (VDBG) loge("Exception trying to remove a route: " + e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2059,7 +2078,7 @@ public class ConnectivityService extends IConnectivityManager.Stub {
|
|||||||
mNetd.setDnsServersForInterface(iface, NetworkUtils.makeStrings(dnses));
|
mNetd.setDnsServersForInterface(iface, NetworkUtils.makeStrings(dnses));
|
||||||
mNetd.setDefaultInterfaceForDns(iface);
|
mNetd.setDefaultInterfaceForDns(iface);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
loge("exception setting default dns interface: " + e);
|
if (VDBG) loge("exception setting default dns interface: " + e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!domains.equals(SystemProperties.get("net.dns.search"))) {
|
if (!domains.equals(SystemProperties.get("net.dns.search"))) {
|
||||||
@@ -2089,7 +2108,7 @@ public class ConnectivityService extends IConnectivityManager.Stub {
|
|||||||
mNetd.setDnsServersForInterface(p.getInterfaceName(),
|
mNetd.setDnsServersForInterface(p.getInterfaceName(),
|
||||||
NetworkUtils.makeStrings(dnses));
|
NetworkUtils.makeStrings(dnses));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
loge("exception setting dns servers: " + e);
|
if (VDBG) loge("exception setting dns servers: " + e);
|
||||||
}
|
}
|
||||||
// set per-pid dns for attached secondary nets
|
// set per-pid dns for attached secondary nets
|
||||||
List pids = mNetRequestersPids[netType];
|
List pids = mNetRequestersPids[netType];
|
||||||
@@ -2194,9 +2213,12 @@ public class ConnectivityService extends IConnectivityManager.Stub {
|
|||||||
int type = info.getType();
|
int type = info.getType();
|
||||||
NetworkInfo.State state = info.getState();
|
NetworkInfo.State state = info.getState();
|
||||||
|
|
||||||
if (DBG) log("ConnectivityChange for " +
|
if (VDBG || (state == NetworkInfo.State.CONNECTED) ||
|
||||||
|
(state == NetworkInfo.State.DISCONNECTED)) {
|
||||||
|
log("ConnectivityChange for " +
|
||||||
info.getTypeName() + ": " +
|
info.getTypeName() + ": " +
|
||||||
state + "/" + info.getDetailedState());
|
state + "/" + info.getDetailedState());
|
||||||
|
}
|
||||||
|
|
||||||
// Connectivity state changed:
|
// Connectivity state changed:
|
||||||
// [31-13] Reserved for future use
|
// [31-13] Reserved for future use
|
||||||
@@ -2458,23 +2480,24 @@ public class ConnectivityService extends IConnectivityManager.Stub {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void handleInetConditionChange(int netType, int condition) {
|
private void handleInetConditionChange(int netType, int condition) {
|
||||||
if (DBG) {
|
|
||||||
log("Inet connectivity change, net=" +
|
|
||||||
netType + ", condition=" + condition +
|
|
||||||
",mActiveDefaultNetwork=" + mActiveDefaultNetwork);
|
|
||||||
}
|
|
||||||
if (mActiveDefaultNetwork == -1) {
|
if (mActiveDefaultNetwork == -1) {
|
||||||
if (DBG) log("no active default network - aborting");
|
if (DBG) log("handleInetConditionChange: no active default network - ignore");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (mActiveDefaultNetwork != netType) {
|
if (mActiveDefaultNetwork != netType) {
|
||||||
if (DBG) log("given net not default - aborting");
|
if (DBG) log("handleInetConditionChange: net=" + netType +
|
||||||
|
" != default=" + mActiveDefaultNetwork + " - ignore");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (VDBG) {
|
||||||
|
log("handleInetConditionChange: net=" +
|
||||||
|
netType + ", condition=" + condition +
|
||||||
|
",mActiveDefaultNetwork=" + mActiveDefaultNetwork);
|
||||||
|
}
|
||||||
mDefaultInetCondition = condition;
|
mDefaultInetCondition = condition;
|
||||||
int delay;
|
int delay;
|
||||||
if (mInetConditionChangeInFlight == false) {
|
if (mInetConditionChangeInFlight == false) {
|
||||||
if (VDBG) log("starting a change hold");
|
if (VDBG) log("handleInetConditionChange: starting a change hold");
|
||||||
// setup a new hold to debounce this
|
// setup a new hold to debounce this
|
||||||
if (mDefaultInetCondition > 50) {
|
if (mDefaultInetCondition > 50) {
|
||||||
delay = Settings.Secure.getInt(mContext.getContentResolver(),
|
delay = Settings.Secure.getInt(mContext.getContentResolver(),
|
||||||
@@ -2487,26 +2510,25 @@ public class ConnectivityService extends IConnectivityManager.Stub {
|
|||||||
mHandler.sendMessageDelayed(mHandler.obtainMessage(EVENT_INET_CONDITION_HOLD_END,
|
mHandler.sendMessageDelayed(mHandler.obtainMessage(EVENT_INET_CONDITION_HOLD_END,
|
||||||
mActiveDefaultNetwork, mDefaultConnectionSequence), delay);
|
mActiveDefaultNetwork, mDefaultConnectionSequence), delay);
|
||||||
} else {
|
} else {
|
||||||
// we've set the new condition, when this hold ends that will get
|
// we've set the new condition, when this hold ends that will get picked up
|
||||||
// picked up
|
if (VDBG) log("handleInetConditionChange: currently in hold - not setting new end evt");
|
||||||
if (VDBG) log("currently in hold - not setting new end evt");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void handleInetConditionHoldEnd(int netType, int sequence) {
|
private void handleInetConditionHoldEnd(int netType, int sequence) {
|
||||||
if (VDBG) {
|
if (DBG) {
|
||||||
log("Inet hold end, net=" + netType +
|
log("handleInetConditionHoldEnd: net=" + netType +
|
||||||
", condition =" + mDefaultInetCondition +
|
", condition=" + mDefaultInetCondition +
|
||||||
", published condition =" + mDefaultInetConditionPublished);
|
", published condition=" + mDefaultInetConditionPublished);
|
||||||
}
|
}
|
||||||
mInetConditionChangeInFlight = false;
|
mInetConditionChangeInFlight = false;
|
||||||
|
|
||||||
if (mActiveDefaultNetwork == -1) {
|
if (mActiveDefaultNetwork == -1) {
|
||||||
if (DBG) log("no active default network - aborting");
|
if (DBG) log("handleInetConditionHoldEnd: no active default network - ignoring");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (mDefaultConnectionSequence != sequence) {
|
if (mDefaultConnectionSequence != sequence) {
|
||||||
if (DBG) log("event hold for obsolete network - aborting");
|
if (DBG) log("handleInetConditionHoldEnd: event hold for obsolete network - ignoring");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// TODO: Figure out why this optimization sometimes causes a
|
// TODO: Figure out why this optimization sometimes causes a
|
||||||
@@ -2518,7 +2540,7 @@ public class ConnectivityService extends IConnectivityManager.Stub {
|
|||||||
//}
|
//}
|
||||||
NetworkInfo networkInfo = mNetTrackers[mActiveDefaultNetwork].getNetworkInfo();
|
NetworkInfo networkInfo = mNetTrackers[mActiveDefaultNetwork].getNetworkInfo();
|
||||||
if (networkInfo.isConnected() == false) {
|
if (networkInfo.isConnected() == false) {
|
||||||
if (DBG) log("default network not connected - aborting");
|
if (DBG) log("handleInetConditionHoldEnd: default network not connected - ignoring");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
mDefaultInetConditionPublished = mDefaultInetCondition;
|
mDefaultInetConditionPublished = mDefaultInetCondition;
|
||||||
|
|||||||
@@ -560,8 +560,10 @@ public class NetworkManagementService extends INetworkManagementService.Stub
|
|||||||
+ e);
|
+ e);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (String line : rsp) {
|
if (DBG) {
|
||||||
Log.v(TAG, "add route response is " + line);
|
for (String line : rsp) {
|
||||||
|
Log.v(TAG, "add route response is " + line);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -53,6 +53,7 @@ import com.android.server.am.BatteryStatsService;
|
|||||||
*/
|
*/
|
||||||
class TelephonyRegistry extends ITelephonyRegistry.Stub {
|
class TelephonyRegistry extends ITelephonyRegistry.Stub {
|
||||||
private static final String TAG = "TelephonyRegistry";
|
private static final String TAG = "TelephonyRegistry";
|
||||||
|
private static final boolean DBG = false;
|
||||||
|
|
||||||
private static class Record {
|
private static class Record {
|
||||||
String pkgForDebug;
|
String pkgForDebug;
|
||||||
@@ -387,9 +388,11 @@ class TelephonyRegistry extends ITelephonyRegistry.Stub {
|
|||||||
if (!checkNotifyPermission("notifyDataConnection()" )) {
|
if (!checkNotifyPermission("notifyDataConnection()" )) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Slog.i(TAG, "notifyDataConnection: state=" + state + " isDataConnectivityPossible="
|
if (DBG) {
|
||||||
|
Slog.i(TAG, "notifyDataConnection: state=" + state + " isDataConnectivityPossible="
|
||||||
+ isDataConnectivityPossible + " reason='" + reason
|
+ isDataConnectivityPossible + " reason='" + reason
|
||||||
+ "' apn='" + apn + "' apnType=" + apnType + " networkType=" + networkType);
|
+ "' apn='" + apn + "' apnType=" + apnType + " networkType=" + networkType);
|
||||||
|
}
|
||||||
synchronized (mRecords) {
|
synchronized (mRecords) {
|
||||||
boolean modified = false;
|
boolean modified = false;
|
||||||
if (state == TelephonyManager.DATA_CONNECTED) {
|
if (state == TelephonyManager.DATA_CONNECTED) {
|
||||||
@@ -421,8 +424,10 @@ class TelephonyRegistry extends ITelephonyRegistry.Stub {
|
|||||||
modified = true;
|
modified = true;
|
||||||
}
|
}
|
||||||
if (modified) {
|
if (modified) {
|
||||||
Slog.d(TAG, "onDataConnectionStateChanged(" + mDataConnectionState
|
if (DBG) {
|
||||||
|
Slog.d(TAG, "onDataConnectionStateChanged(" + mDataConnectionState
|
||||||
+ ", " + mDataConnectionNetworkType + ")");
|
+ ", " + mDataConnectionNetworkType + ")");
|
||||||
|
}
|
||||||
for (Record r : mRecords) {
|
for (Record r : mRecords) {
|
||||||
if ((r.events & PhoneStateListener.LISTEN_DATA_CONNECTION_STATE) != 0) {
|
if ((r.events & PhoneStateListener.LISTEN_DATA_CONNECTION_STATE) != 0) {
|
||||||
try {
|
try {
|
||||||
@@ -639,7 +644,7 @@ class TelephonyRegistry extends ITelephonyRegistry.Stub {
|
|||||||
}
|
}
|
||||||
String msg = "Modify Phone State Permission Denial: " + method + " from pid="
|
String msg = "Modify Phone State Permission Denial: " + method + " from pid="
|
||||||
+ Binder.getCallingPid() + ", uid=" + Binder.getCallingUid();
|
+ Binder.getCallingPid() + ", uid=" + Binder.getCallingUid();
|
||||||
Slog.w(TAG, msg);
|
if (DBG) Slog.w(TAG, msg);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -71,7 +71,8 @@ public class Tethering extends INetworkManagementEventObserver.Stub {
|
|||||||
|
|
||||||
private Context mContext;
|
private Context mContext;
|
||||||
private final static String TAG = "Tethering";
|
private final static String TAG = "Tethering";
|
||||||
private final static boolean DEBUG = true;
|
private final static boolean DBG = true;
|
||||||
|
private final static boolean VDBG = false;
|
||||||
|
|
||||||
// TODO - remove both of these - should be part of interface inspection/selection stuff
|
// TODO - remove both of these - should be part of interface inspection/selection stuff
|
||||||
private String[] mTetherableUsbRegexs;
|
private String[] mTetherableUsbRegexs;
|
||||||
@@ -178,7 +179,7 @@ public class Tethering extends INetworkManagementEventObserver.Stub {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void interfaceStatusChanged(String iface, boolean up) {
|
public void interfaceStatusChanged(String iface, boolean up) {
|
||||||
if (DEBUG) Log.d(TAG, "interfaceStatusChanged " + iface + ", " + up);
|
if (VDBG) Log.d(TAG, "interfaceStatusChanged " + iface + ", " + up);
|
||||||
boolean found = false;
|
boolean found = false;
|
||||||
boolean usb = false;
|
boolean usb = false;
|
||||||
if (isWifi(iface)) {
|
if (isWifi(iface)) {
|
||||||
@@ -203,7 +204,7 @@ public class Tethering extends INetworkManagementEventObserver.Stub {
|
|||||||
if (isUsb(iface)) {
|
if (isUsb(iface)) {
|
||||||
// ignore usb0 down after enabling RNDIS
|
// ignore usb0 down after enabling RNDIS
|
||||||
// we will handle disconnect in interfaceRemoved instead
|
// we will handle disconnect in interfaceRemoved instead
|
||||||
Log.d(TAG, "ignoring interface down for " + iface);
|
if (VDBG) Log.d(TAG, "ignoring interface down for " + iface);
|
||||||
} else if (sm != null) {
|
} else if (sm != null) {
|
||||||
sm.sendMessage(TetherInterfaceSM.CMD_INTERFACE_DOWN);
|
sm.sendMessage(TetherInterfaceSM.CMD_INTERFACE_DOWN);
|
||||||
mIfaces.remove(iface);
|
mIfaces.remove(iface);
|
||||||
@@ -213,7 +214,7 @@ public class Tethering extends INetworkManagementEventObserver.Stub {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void interfaceLinkStateChanged(String iface, boolean up) {
|
public void interfaceLinkStateChanged(String iface, boolean up) {
|
||||||
if (DEBUG) Log.d(TAG, "interfaceLinkStateChanged " + iface + ", " + up);
|
if (VDBG) Log.d(TAG, "interfaceLinkStateChanged " + iface + ", " + up);
|
||||||
interfaceStatusChanged(iface, up);
|
interfaceStatusChanged(iface, up);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -239,7 +240,7 @@ public class Tethering extends INetworkManagementEventObserver.Stub {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void interfaceAdded(String iface) {
|
public void interfaceAdded(String iface) {
|
||||||
if (DEBUG) Log.d(TAG, "interfaceAdded " + iface);
|
if (VDBG) Log.d(TAG, "interfaceAdded " + iface);
|
||||||
boolean found = false;
|
boolean found = false;
|
||||||
boolean usb = false;
|
boolean usb = false;
|
||||||
if (isWifi(iface)) {
|
if (isWifi(iface)) {
|
||||||
@@ -253,29 +254,29 @@ public class Tethering extends INetworkManagementEventObserver.Stub {
|
|||||||
found = true;
|
found = true;
|
||||||
}
|
}
|
||||||
if (found == false) {
|
if (found == false) {
|
||||||
if (DEBUG) Log.d(TAG, iface + " is not a tetherable iface, ignoring");
|
if (VDBG) Log.d(TAG, iface + " is not a tetherable iface, ignoring");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
synchronized (mIfaces) {
|
synchronized (mIfaces) {
|
||||||
TetherInterfaceSM sm = mIfaces.get(iface);
|
TetherInterfaceSM sm = mIfaces.get(iface);
|
||||||
if (sm != null) {
|
if (sm != null) {
|
||||||
if (DEBUG) Log.d(TAG, "active iface (" + iface + ") reported as added, ignoring");
|
if (VDBG) Log.d(TAG, "active iface (" + iface + ") reported as added, ignoring");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
sm = new TetherInterfaceSM(iface, mLooper, usb);
|
sm = new TetherInterfaceSM(iface, mLooper, usb);
|
||||||
mIfaces.put(iface, sm);
|
mIfaces.put(iface, sm);
|
||||||
sm.start();
|
sm.start();
|
||||||
}
|
}
|
||||||
if (DEBUG) Log.d(TAG, "interfaceAdded :" + iface);
|
if (VDBG) Log.d(TAG, "interfaceAdded :" + iface);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void interfaceRemoved(String iface) {
|
public void interfaceRemoved(String iface) {
|
||||||
if (DEBUG) Log.d(TAG, "interfaceRemoved " + iface);
|
if (VDBG) Log.d(TAG, "interfaceRemoved " + iface);
|
||||||
synchronized (mIfaces) {
|
synchronized (mIfaces) {
|
||||||
TetherInterfaceSM sm = mIfaces.get(iface);
|
TetherInterfaceSM sm = mIfaces.get(iface);
|
||||||
if (sm == null) {
|
if (sm == null) {
|
||||||
if (DEBUG) {
|
if (VDBG) {
|
||||||
Log.e(TAG, "attempting to remove unknown iface (" + iface + "), ignoring");
|
Log.e(TAG, "attempting to remove unknown iface (" + iface + "), ignoring");
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
@@ -288,7 +289,7 @@ public class Tethering extends INetworkManagementEventObserver.Stub {
|
|||||||
public void limitReached(String limitName, String iface) {}
|
public void limitReached(String limitName, String iface) {}
|
||||||
|
|
||||||
public int tether(String iface) {
|
public int tether(String iface) {
|
||||||
Log.d(TAG, "Tethering " + iface);
|
if (DBG) Log.d(TAG, "Tethering " + iface);
|
||||||
TetherInterfaceSM sm = null;
|
TetherInterfaceSM sm = null;
|
||||||
synchronized (mIfaces) {
|
synchronized (mIfaces) {
|
||||||
sm = mIfaces.get(iface);
|
sm = mIfaces.get(iface);
|
||||||
@@ -306,7 +307,7 @@ public class Tethering extends INetworkManagementEventObserver.Stub {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public int untether(String iface) {
|
public int untether(String iface) {
|
||||||
Log.d(TAG, "Untethering " + iface);
|
if (DBG) Log.d(TAG, "Untethering " + iface);
|
||||||
TetherInterfaceSM sm = null;
|
TetherInterfaceSM sm = null;
|
||||||
synchronized (mIfaces) {
|
synchronized (mIfaces) {
|
||||||
sm = mIfaces.get(iface);
|
sm = mIfaces.get(iface);
|
||||||
@@ -383,7 +384,7 @@ public class Tethering extends INetworkManagementEventObserver.Stub {
|
|||||||
broadcast.putStringArrayListExtra(ConnectivityManager.EXTRA_ERRORED_TETHER,
|
broadcast.putStringArrayListExtra(ConnectivityManager.EXTRA_ERRORED_TETHER,
|
||||||
erroredList);
|
erroredList);
|
||||||
mContext.sendStickyBroadcast(broadcast);
|
mContext.sendStickyBroadcast(broadcast);
|
||||||
if (DEBUG) {
|
if (VDBG) {
|
||||||
Log.d(TAG, "sendTetherStateChangedBroadcast " + availableList.size() + ", " +
|
Log.d(TAG, "sendTetherStateChangedBroadcast " + availableList.size() + ", " +
|
||||||
activeList.size() + ", " + erroredList.size());
|
activeList.size() + ", " + erroredList.size());
|
||||||
}
|
}
|
||||||
@@ -468,14 +469,14 @@ public class Tethering extends INetworkManagementEventObserver.Stub {
|
|||||||
mUsbTetherRequested = false;
|
mUsbTetherRequested = false;
|
||||||
}
|
}
|
||||||
} else if (action.equals(ConnectivityManager.CONNECTIVITY_ACTION)) {
|
} else if (action.equals(ConnectivityManager.CONNECTIVITY_ACTION)) {
|
||||||
if (DEBUG) Log.d(TAG, "Tethering got CONNECTIVITY_ACTION");
|
if (VDBG) Log.d(TAG, "Tethering got CONNECTIVITY_ACTION");
|
||||||
mTetherMasterSM.sendMessage(TetherMasterSM.CMD_UPSTREAM_CHANGED);
|
mTetherMasterSM.sendMessage(TetherMasterSM.CMD_UPSTREAM_CHANGED);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void tetherUsb(boolean enable) {
|
private void tetherUsb(boolean enable) {
|
||||||
if (DEBUG) Log.d(TAG, "tetherUsb " + enable);
|
if (VDBG) Log.d(TAG, "tetherUsb " + enable);
|
||||||
|
|
||||||
String[] ifaces = new String[0];
|
String[] ifaces = new String[0];
|
||||||
try {
|
try {
|
||||||
@@ -497,7 +498,7 @@ public class Tethering extends INetworkManagementEventObserver.Stub {
|
|||||||
|
|
||||||
// configured when we start tethering and unconfig'd on error or conclusion
|
// configured when we start tethering and unconfig'd on error or conclusion
|
||||||
private boolean configureUsbIface(boolean enabled) {
|
private boolean configureUsbIface(boolean enabled) {
|
||||||
if (DEBUG) Log.d(TAG, "configureUsbIface(" + enabled + ")");
|
if (VDBG) Log.d(TAG, "configureUsbIface(" + enabled + ")");
|
||||||
|
|
||||||
// toggle the USB interfaces
|
// toggle the USB interfaces
|
||||||
String[] ifaces = new String[0];
|
String[] ifaces = new String[0];
|
||||||
@@ -547,7 +548,7 @@ public class Tethering extends INetworkManagementEventObserver.Stub {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public int setUsbTethering(boolean enable) {
|
public int setUsbTethering(boolean enable) {
|
||||||
if (DEBUG) Log.d(TAG, "setUsbTethering(" + enable + ")");
|
if (VDBG) Log.d(TAG, "setUsbTethering(" + enable + ")");
|
||||||
UsbManager usbManager = (UsbManager)mContext.getSystemService(Context.USB_SERVICE);
|
UsbManager usbManager = (UsbManager)mContext.getSystemService(Context.USB_SERVICE);
|
||||||
|
|
||||||
synchronized (this) {
|
synchronized (this) {
|
||||||
@@ -808,7 +809,7 @@ public class Tethering extends INetworkManagementEventObserver.Stub {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean processMessage(Message message) {
|
public boolean processMessage(Message message) {
|
||||||
if (DEBUG) Log.d(TAG, "InitialState.processMessage what=" + message.what);
|
if (VDBG) Log.d(TAG, "InitialState.processMessage what=" + message.what);
|
||||||
boolean retValue = true;
|
boolean retValue = true;
|
||||||
switch (message.what) {
|
switch (message.what) {
|
||||||
case CMD_TETHER_REQUESTED:
|
case CMD_TETHER_REQUESTED:
|
||||||
@@ -849,7 +850,7 @@ public class Tethering extends INetworkManagementEventObserver.Stub {
|
|||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public boolean processMessage(Message message) {
|
public boolean processMessage(Message message) {
|
||||||
if (DEBUG) Log.d(TAG, "StartingState.processMessage what=" + message.what);
|
if (VDBG) Log.d(TAG, "StartingState.processMessage what=" + message.what);
|
||||||
boolean retValue = true;
|
boolean retValue = true;
|
||||||
switch (message.what) {
|
switch (message.what) {
|
||||||
// maybe a parent class?
|
// maybe a parent class?
|
||||||
@@ -897,14 +898,14 @@ public class Tethering extends INetworkManagementEventObserver.Stub {
|
|||||||
transitionTo(mInitialState);
|
transitionTo(mInitialState);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (DEBUG) Log.d(TAG, "Tethered " + mIfaceName);
|
if (DBG) Log.d(TAG, "Tethered " + mIfaceName);
|
||||||
setAvailable(false);
|
setAvailable(false);
|
||||||
setTethered(true);
|
setTethered(true);
|
||||||
sendTetherStateChangedBroadcast();
|
sendTetherStateChangedBroadcast();
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public boolean processMessage(Message message) {
|
public boolean processMessage(Message message) {
|
||||||
if (DEBUG) Log.d(TAG, "TetheredState.processMessage what=" + message.what);
|
if (VDBG) Log.d(TAG, "TetheredState.processMessage what=" + message.what);
|
||||||
boolean retValue = true;
|
boolean retValue = true;
|
||||||
boolean error = false;
|
boolean error = false;
|
||||||
switch (message.what) {
|
switch (message.what) {
|
||||||
@@ -944,14 +945,14 @@ public class Tethering extends INetworkManagementEventObserver.Stub {
|
|||||||
} else if (message.what == CMD_INTERFACE_DOWN) {
|
} else if (message.what == CMD_INTERFACE_DOWN) {
|
||||||
transitionTo(mUnavailableState);
|
transitionTo(mUnavailableState);
|
||||||
}
|
}
|
||||||
if (DEBUG) Log.d(TAG, "Untethered " + mIfaceName);
|
if (DBG) Log.d(TAG, "Untethered " + mIfaceName);
|
||||||
break;
|
break;
|
||||||
case CMD_TETHER_CONNECTION_CHANGED:
|
case CMD_TETHER_CONNECTION_CHANGED:
|
||||||
String newUpstreamIfaceName = (String)(message.obj);
|
String newUpstreamIfaceName = (String)(message.obj);
|
||||||
if ((mMyUpstreamIfaceName == null && newUpstreamIfaceName == null) ||
|
if ((mMyUpstreamIfaceName == null && newUpstreamIfaceName == null) ||
|
||||||
(mMyUpstreamIfaceName != null &&
|
(mMyUpstreamIfaceName != null &&
|
||||||
mMyUpstreamIfaceName.equals(newUpstreamIfaceName))) {
|
mMyUpstreamIfaceName.equals(newUpstreamIfaceName))) {
|
||||||
if (DEBUG) Log.d(TAG, "Connection changed noop - dropping");
|
if (VDBG) Log.d(TAG, "Connection changed noop - dropping");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (mMyUpstreamIfaceName != null) {
|
if (mMyUpstreamIfaceName != null) {
|
||||||
@@ -1018,7 +1019,7 @@ public class Tethering extends INetworkManagementEventObserver.Stub {
|
|||||||
ConnectivityManager.TETHER_ERROR_MASTER_ERROR);
|
ConnectivityManager.TETHER_ERROR_MASTER_ERROR);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (DEBUG) Log.d(TAG, "Tether lost upstream connection " + mIfaceName);
|
if (VDBG) Log.d(TAG, "Tether lost upstream connection " + mIfaceName);
|
||||||
sendTetherStateChangedBroadcast();
|
sendTetherStateChangedBroadcast();
|
||||||
if (mUsb) {
|
if (mUsb) {
|
||||||
if (!Tethering.this.configureUsbIface(false)) {
|
if (!Tethering.this.configureUsbIface(false)) {
|
||||||
@@ -1248,7 +1249,7 @@ public class Tethering extends INetworkManagementEventObserver.Stub {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (DEBUG) {
|
if (VDBG) {
|
||||||
Log.d(TAG, "chooseUpstreamType(" + tryCell + "), preferredApn ="
|
Log.d(TAG, "chooseUpstreamType(" + tryCell + "), preferredApn ="
|
||||||
+ mPreferredUpstreamMobileApn + ", got type=" + upType);
|
+ mPreferredUpstreamMobileApn + ", got type=" + upType);
|
||||||
}
|
}
|
||||||
@@ -1280,7 +1281,7 @@ public class Tethering extends INetworkManagementEventObserver.Stub {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected void notifyTetheredOfNewUpstreamIface(String ifaceName) {
|
protected void notifyTetheredOfNewUpstreamIface(String ifaceName) {
|
||||||
if (DEBUG) Log.d(TAG, "notifying tethered with iface =" + ifaceName);
|
if (VDBG) Log.d(TAG, "notifying tethered with iface =" + ifaceName);
|
||||||
mUpstreamIfaceName = ifaceName;
|
mUpstreamIfaceName = ifaceName;
|
||||||
for (Object o : mNotifyList) {
|
for (Object o : mNotifyList) {
|
||||||
TetherInterfaceSM sm = (TetherInterfaceSM)o;
|
TetherInterfaceSM sm = (TetherInterfaceSM)o;
|
||||||
@@ -1296,19 +1297,19 @@ public class Tethering extends INetworkManagementEventObserver.Stub {
|
|||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public boolean processMessage(Message message) {
|
public boolean processMessage(Message message) {
|
||||||
if (DEBUG) Log.d(TAG, "MasterInitialState.processMessage what=" + message.what);
|
if (VDBG) Log.d(TAG, "MasterInitialState.processMessage what=" + message.what);
|
||||||
boolean retValue = true;
|
boolean retValue = true;
|
||||||
switch (message.what) {
|
switch (message.what) {
|
||||||
case CMD_TETHER_MODE_REQUESTED:
|
case CMD_TETHER_MODE_REQUESTED:
|
||||||
checkDunRequired();
|
checkDunRequired();
|
||||||
TetherInterfaceSM who = (TetherInterfaceSM)message.obj;
|
TetherInterfaceSM who = (TetherInterfaceSM)message.obj;
|
||||||
if (DEBUG) Log.d(TAG, "Tether Mode requested by " + who.toString());
|
if (VDBG) Log.d(TAG, "Tether Mode requested by " + who.toString());
|
||||||
mNotifyList.add(who);
|
mNotifyList.add(who);
|
||||||
transitionTo(mTetherModeAliveState);
|
transitionTo(mTetherModeAliveState);
|
||||||
break;
|
break;
|
||||||
case CMD_TETHER_MODE_UNREQUESTED:
|
case CMD_TETHER_MODE_UNREQUESTED:
|
||||||
who = (TetherInterfaceSM)message.obj;
|
who = (TetherInterfaceSM)message.obj;
|
||||||
if (DEBUG) Log.d(TAG, "Tether Mode unrequested by " + who.toString());
|
if (VDBG) Log.d(TAG, "Tether Mode unrequested by " + who.toString());
|
||||||
int index = mNotifyList.indexOf(who);
|
int index = mNotifyList.indexOf(who);
|
||||||
if (index != -1) {
|
if (index != -1) {
|
||||||
mNotifyList.remove(who);
|
mNotifyList.remove(who);
|
||||||
@@ -1339,7 +1340,7 @@ public class Tethering extends INetworkManagementEventObserver.Stub {
|
|||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public boolean processMessage(Message message) {
|
public boolean processMessage(Message message) {
|
||||||
if (DEBUG) Log.d(TAG, "TetherModeAliveState.processMessage what=" + message.what);
|
if (VDBG) Log.d(TAG, "TetherModeAliveState.processMessage what=" + message.what);
|
||||||
boolean retValue = true;
|
boolean retValue = true;
|
||||||
switch (message.what) {
|
switch (message.what) {
|
||||||
case CMD_TETHER_MODE_REQUESTED:
|
case CMD_TETHER_MODE_REQUESTED:
|
||||||
@@ -1368,7 +1369,7 @@ public class Tethering extends INetworkManagementEventObserver.Stub {
|
|||||||
// make sure we're still using a requested connection - may have found
|
// make sure we're still using a requested connection - may have found
|
||||||
// wifi or something since then.
|
// wifi or something since then.
|
||||||
if (mCurrentConnectionSequence == message.arg1) {
|
if (mCurrentConnectionSequence == message.arg1) {
|
||||||
if (DEBUG) {
|
if (VDBG) {
|
||||||
Log.d(TAG, "renewing mobile connection - requeuing for another " +
|
Log.d(TAG, "renewing mobile connection - requeuing for another " +
|
||||||
CELL_CONNECTION_RENEW_MS + "ms");
|
CELL_CONNECTION_RENEW_MS + "ms");
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user