summaryrefslogtreecommitdiffstats
path: root/telephony
diff options
context:
space:
mode:
authorDan Egnor <egnor@google.com>2010-04-08 14:45:07 -0700
committerAndroid (Google) Code Review <android-gerrit@google.com>2010-04-08 14:45:07 -0700
commit5945579e4ed8fbe6dae6adaa4c222b321c2ec80b (patch)
tree729744da98ba88ccd14ba8de8a6fa546c9764104 /telephony
parent2124808060a1eb5ea396238b7b99d2ed266b0b53 (diff)
parent2b4abcd0c7c4361af8ab6d5d7b073fb75ac6d219 (diff)
downloadframeworks_base-5945579e4ed8fbe6dae6adaa4c222b321c2ec80b.zip
frameworks_base-5945579e4ed8fbe6dae6adaa4c222b321c2ec80b.tar.gz
frameworks_base-5945579e4ed8fbe6dae6adaa4c222b321c2ec80b.tar.bz2
Merge "Change TrafficStats to a new JNI implementation." into froyo
Diffstat (limited to 'telephony')
-rw-r--r--telephony/java/com/android/internal/telephony/DataConnectionTracker.java2
-rw-r--r--telephony/java/com/android/internal/telephony/cdma/CdmaDataConnectionTracker.java112
-rw-r--r--telephony/java/com/android/internal/telephony/gsm/GsmDataConnectionTracker.java14
3 files changed, 54 insertions, 74 deletions
diff --git a/telephony/java/com/android/internal/telephony/DataConnectionTracker.java b/telephony/java/com/android/internal/telephony/DataConnectionTracker.java
index e8e18a1..3b9e6cc 100644
--- a/telephony/java/com/android/internal/telephony/DataConnectionTracker.java
+++ b/telephony/java/com/android/internal/telephony/DataConnectionTracker.java
@@ -19,7 +19,6 @@ package com.android.internal.telephony;
import android.app.PendingIntent;
import android.os.AsyncResult;
import android.os.Handler;
-import android.os.INetStatService;
import android.os.Message;
import android.os.RemoteException;
import android.provider.Settings;
@@ -172,7 +171,6 @@ public abstract class DataConnectionTracker extends Handler {
protected Handler mDataConnectionTracker = null;
- protected INetStatService netstat;
protected long txPkts, rxPkts, sentSinceLastRecv;
protected int netStatPollPeriod;
protected int mNoRecvPollCount = 0;
diff --git a/telephony/java/com/android/internal/telephony/cdma/CdmaDataConnectionTracker.java b/telephony/java/com/android/internal/telephony/cdma/CdmaDataConnectionTracker.java
index 2f801cc..217e1e8 100644
--- a/telephony/java/com/android/internal/telephony/cdma/CdmaDataConnectionTracker.java
+++ b/telephony/java/com/android/internal/telephony/cdma/CdmaDataConnectionTracker.java
@@ -26,9 +26,9 @@ import android.content.SharedPreferences;
import android.net.ConnectivityManager;
import android.net.IConnectivityManager;
import android.net.NetworkInfo;
+import android.net.TrafficStats;
import android.net.wifi.WifiManager;
import android.os.AsyncResult;
-import android.os.INetStatService;
import android.os.Message;
import android.os.RemoteException;
import android.os.ServiceManager;
@@ -176,8 +176,6 @@ public final class CdmaDataConnectionTracker extends DataConnectionTracker {
p.mSST.registerForRoamingOff(this, EVENT_ROAMING_OFF, null);
p.mCM.registerForCdmaOtaProvision(this, EVENT_CDMA_OTA_PROVISION, null);
- this.netstat = INetStatService.Stub.asInterface(ServiceManager.getService("netstat"));
-
IntentFilter filter = new IntentFilter();
filter.addAction(INTENT_RECONNECT_ALARM);
filter.addAction(Intent.ACTION_SCREEN_ON);
@@ -495,78 +493,70 @@ public final class CdmaDataConnectionTracker extends DataConnectionTracker {
preTxPkts = txPkts;
preRxPkts = rxPkts;
- // check if netstat is still valid to avoid NullPointerException after NTC
- if (netstat != null) {
- try {
- txPkts = netstat.getMobileTxPackets();
- rxPkts = netstat.getMobileRxPackets();
- } catch (RemoteException e) {
- txPkts = 0;
- rxPkts = 0;
- }
+ txPkts = TrafficStats.getMobileTxPackets();
+ rxPkts = TrafficStats.getMobileRxPackets();
- //Log.d(LOG_TAG, "rx " + String.valueOf(rxPkts) + " tx " + String.valueOf(txPkts));
+ //Log.d(LOG_TAG, "rx " + String.valueOf(rxPkts) + " tx " + String.valueOf(txPkts));
- if (netStatPollEnabled && (preTxPkts > 0 || preRxPkts > 0)) {
- sent = txPkts - preTxPkts;
- received = rxPkts - preRxPkts;
+ if (netStatPollEnabled && (preTxPkts > 0 || preRxPkts > 0)) {
+ sent = txPkts - preTxPkts;
+ received = rxPkts - preRxPkts;
- if ( sent > 0 && received > 0 ) {
- sentSinceLastRecv = 0;
- newActivity = Activity.DATAINANDOUT;
- } else if (sent > 0 && received == 0) {
- if (phone.getState() == Phone.State.IDLE) {
- sentSinceLastRecv += sent;
- } else {
- sentSinceLastRecv = 0;
- }
- newActivity = Activity.DATAOUT;
- } else if (sent == 0 && received > 0) {
- sentSinceLastRecv = 0;
- newActivity = Activity.DATAIN;
- } else if (sent == 0 && received == 0) {
- newActivity = (activity == Activity.DORMANT) ? activity : Activity.NONE;
+ if ( sent > 0 && received > 0 ) {
+ sentSinceLastRecv = 0;
+ newActivity = Activity.DATAINANDOUT;
+ } else if (sent > 0 && received == 0) {
+ if (phone.getState() == Phone.State.IDLE) {
+ sentSinceLastRecv += sent;
} else {
sentSinceLastRecv = 0;
- newActivity = (activity == Activity.DORMANT) ? activity : Activity.NONE;
}
+ newActivity = Activity.DATAOUT;
+ } else if (sent == 0 && received > 0) {
+ sentSinceLastRecv = 0;
+ newActivity = Activity.DATAIN;
+ } else if (sent == 0 && received == 0) {
+ newActivity = (activity == Activity.DORMANT) ? activity : Activity.NONE;
+ } else {
+ sentSinceLastRecv = 0;
+ newActivity = (activity == Activity.DORMANT) ? activity : Activity.NONE;
+ }
- if (activity != newActivity) {
- activity = newActivity;
- phone.notifyDataActivity();
- }
+ if (activity != newActivity) {
+ activity = newActivity;
+ phone.notifyDataActivity();
}
+ }
- if (sentSinceLastRecv >= NUMBER_SENT_PACKETS_OF_HANG) {
- // Packets sent without ack exceeded threshold.
+ if (sentSinceLastRecv >= NUMBER_SENT_PACKETS_OF_HANG) {
+ // Packets sent without ack exceeded threshold.
- if (mNoRecvPollCount == 0) {
- EventLog.writeEvent(
- EventLogTags.PDP_RADIO_RESET_COUNTDOWN_TRIGGERED,
- sentSinceLastRecv);
- }
+ if (mNoRecvPollCount == 0) {
+ EventLog.writeEvent(
+ EventLogTags.PDP_RADIO_RESET_COUNTDOWN_TRIGGERED,
+ sentSinceLastRecv);
+ }
- if (mNoRecvPollCount < NO_RECV_POLL_LIMIT) {
- mNoRecvPollCount++;
- // Slow down the poll interval to let things happen
- netStatPollPeriod = POLL_NETSTAT_SLOW_MILLIS;
- } else {
- if (DBG) log("Sent " + String.valueOf(sentSinceLastRecv) +
- " pkts since last received");
- // We've exceeded the threshold. Restart the radio.
- netStatPollEnabled = false;
- stopNetStatPoll();
- restartRadio();
- EventLog.writeEvent(EventLogTags.PDP_RADIO_RESET, NO_RECV_POLL_LIMIT);
- }
+ if (mNoRecvPollCount < NO_RECV_POLL_LIMIT) {
+ mNoRecvPollCount++;
+ // Slow down the poll interval to let things happen
+ netStatPollPeriod = POLL_NETSTAT_SLOW_MILLIS;
} else {
- mNoRecvPollCount = 0;
- netStatPollPeriod = POLL_NETSTAT_MILLIS;
+ if (DBG) log("Sent " + String.valueOf(sentSinceLastRecv) +
+ " pkts since last received");
+ // We've exceeded the threshold. Restart the radio.
+ netStatPollEnabled = false;
+ stopNetStatPoll();
+ restartRadio();
+ EventLog.writeEvent(EventLogTags.PDP_RADIO_RESET, NO_RECV_POLL_LIMIT);
}
+ } else {
+ mNoRecvPollCount = 0;
+ netStatPollPeriod = POLL_NETSTAT_MILLIS;
+ }
- if (netStatPollEnabled) {
- mDataConnectionTracker.postDelayed(this, netStatPollPeriod);
- }
+ if (netStatPollEnabled) {
+ mDataConnectionTracker.postDelayed(this, netStatPollPeriod);
}
}
};
diff --git a/telephony/java/com/android/internal/telephony/gsm/GsmDataConnectionTracker.java b/telephony/java/com/android/internal/telephony/gsm/GsmDataConnectionTracker.java
index f968652..cbfb550 100644
--- a/telephony/java/com/android/internal/telephony/gsm/GsmDataConnectionTracker.java
+++ b/telephony/java/com/android/internal/telephony/gsm/GsmDataConnectionTracker.java
@@ -30,10 +30,10 @@ import android.database.Cursor;
import android.net.ConnectivityManager;
import android.net.IConnectivityManager;
import android.net.NetworkInfo;
+import android.net.TrafficStats;
import android.net.Uri;
import android.net.wifi.WifiManager;
import android.os.AsyncResult;
-import android.os.INetStatService;
import android.os.Message;
import android.os.RemoteException;
import android.os.ServiceManager;
@@ -83,7 +83,6 @@ public final class GsmDataConnectionTracker extends DataConnectionTracker {
//***** Instance Variables
- INetStatService netstat;
// Indicates baseband will not auto-attach
private boolean noAutoAttach = false;
@@ -219,8 +218,6 @@ public final class GsmDataConnectionTracker extends DataConnectionTracker {
p.mSST.registerForPsRestrictedEnabled(this, EVENT_PS_RESTRICT_ENABLED, null);
p.mSST.registerForPsRestrictedDisabled(this, EVENT_PS_RESTRICT_DISABLED, null);
- this.netstat = INetStatService.Stub.asInterface(ServiceManager.getService("netstat"));
-
IntentFilter filter = new IntentFilter();
filter.addAction(INTENT_RECONNECT_ALARM);
filter.addAction(Intent.ACTION_SCREEN_ON);
@@ -841,13 +838,8 @@ public final class GsmDataConnectionTracker extends DataConnectionTracker {
preTxPkts = txPkts;
preRxPkts = rxPkts;
- try {
- txPkts = netstat.getMobileTxPackets();
- rxPkts = netstat.getMobileRxPackets();
- } catch (RemoteException e) {
- txPkts = 0;
- rxPkts = 0;
- }
+ txPkts = TrafficStats.getMobileTxPackets();
+ rxPkts = TrafficStats.getMobileRxPackets();
//Log.d(LOG_TAG, "rx " + String.valueOf(rxPkts) + " tx " + String.valueOf(txPkts));