am cecccecc: Merge changes Ib1274847,I2eb2a1bf into klp-dev
* commit 'ceccceccffbd2668b98e21487f2323f80d2c7b98': Fix SDK build. Request all tethering interfaces, fix corruption.
This commit is contained in:
@@ -93,12 +93,6 @@ interface IConnectivityManager
|
||||
|
||||
String[] getTetheredIfaces();
|
||||
|
||||
/**
|
||||
* Return list of interface pairs that are actively tethered. Even indexes are
|
||||
* remote interface, and odd indexes are corresponding local interfaces.
|
||||
*/
|
||||
String[] getTetheredIfacePairs();
|
||||
|
||||
String[] getTetheringErroredIfaces();
|
||||
|
||||
String[] getTetherableUsbRegexs();
|
||||
|
||||
@@ -260,11 +260,9 @@ interface INetworkManagementService
|
||||
NetworkStats getNetworkStatsUidDetail(int uid);
|
||||
|
||||
/**
|
||||
* Return summary of network statistics for the requested pairs of
|
||||
* tethering interfaces. Even indexes are remote interface, and odd
|
||||
* indexes are corresponding local interfaces.
|
||||
* Return summary of network statistics all tethering interfaces.
|
||||
*/
|
||||
NetworkStats getNetworkStatsTethering(in String[] ifacePairs);
|
||||
NetworkStats getNetworkStatsTethering();
|
||||
|
||||
/**
|
||||
* Set quota for an interface.
|
||||
|
||||
@@ -40,12 +40,4 @@
|
||||
android:listSelector="@android:color/transparent"
|
||||
android:visibility="gone" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/more"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="bottom"
|
||||
android:text="@string/more"
|
||||
android:visibility="gone" />
|
||||
|
||||
</FrameLayout>
|
||||
|
||||
@@ -58,8 +58,8 @@ import android.net.INetworkPolicyManager;
|
||||
import android.net.INetworkStatsService;
|
||||
import android.net.LinkAddress;
|
||||
import android.net.LinkProperties;
|
||||
import android.net.LinkQualityInfo;
|
||||
import android.net.LinkProperties.CompareResult;
|
||||
import android.net.LinkQualityInfo;
|
||||
import android.net.MobileDataStateTracker;
|
||||
import android.net.NetworkConfig;
|
||||
import android.net.NetworkInfo;
|
||||
@@ -89,7 +89,6 @@ import android.os.ParcelFileDescriptor;
|
||||
import android.os.PowerManager;
|
||||
import android.os.Process;
|
||||
import android.os.RemoteException;
|
||||
import android.os.ResultReceiver;
|
||||
import android.os.ServiceManager;
|
||||
import android.os.SystemClock;
|
||||
import android.os.SystemProperties;
|
||||
@@ -114,7 +113,6 @@ import com.android.internal.telephony.Phone;
|
||||
import com.android.internal.telephony.PhoneConstants;
|
||||
import com.android.internal.util.IndentingPrintWriter;
|
||||
import com.android.internal.util.XmlUtils;
|
||||
import com.android.net.IProxyService;
|
||||
import com.android.server.am.BatteryStatsService;
|
||||
import com.android.server.connectivity.DataConnectionStats;
|
||||
import com.android.server.connectivity.Nat464Xlat;
|
||||
@@ -3209,12 +3207,6 @@ public class ConnectivityService extends IConnectivityManager.Stub {
|
||||
return mTethering.getTetheredIfaces();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getTetheredIfacePairs() {
|
||||
enforceTetherAccessPermission();
|
||||
return mTethering.getTetheredIfacePairs();
|
||||
}
|
||||
|
||||
public String[] getTetheringErroredIfaces() {
|
||||
enforceTetherAccessPermission();
|
||||
return mTethering.getErroredIfaces();
|
||||
|
||||
@@ -24,15 +24,15 @@ import static android.net.NetworkStats.TAG_NONE;
|
||||
import static android.net.NetworkStats.UID_ALL;
|
||||
import static android.net.TrafficStats.UID_TETHERING;
|
||||
import static com.android.server.NetworkManagementService.NetdResponseCode.ClatdStatusResult;
|
||||
import static com.android.server.NetworkManagementService.NetdResponseCode.GetMarkResult;
|
||||
import static com.android.server.NetworkManagementService.NetdResponseCode.InterfaceGetCfgResult;
|
||||
import static com.android.server.NetworkManagementService.NetdResponseCode.InterfaceListResult;
|
||||
import static com.android.server.NetworkManagementService.NetdResponseCode.IpFwdStatusResult;
|
||||
import static com.android.server.NetworkManagementService.NetdResponseCode.TetherDnsFwdTgtListResult;
|
||||
import static com.android.server.NetworkManagementService.NetdResponseCode.TetherInterfaceListResult;
|
||||
import static com.android.server.NetworkManagementService.NetdResponseCode.TetherStatusResult;
|
||||
import static com.android.server.NetworkManagementService.NetdResponseCode.TetheringStatsResult;
|
||||
import static com.android.server.NetworkManagementService.NetdResponseCode.TetheringStatsListResult;
|
||||
import static com.android.server.NetworkManagementService.NetdResponseCode.TtyListResult;
|
||||
import static com.android.server.NetworkManagementService.NetdResponseCode.GetMarkResult;
|
||||
import static com.android.server.NetworkManagementSocketTagger.PROP_QTAGUID_ENABLED;
|
||||
|
||||
import android.content.Context;
|
||||
@@ -118,6 +118,7 @@ public class NetworkManagementService extends INetworkManagementService.Stub
|
||||
public static final int TetherInterfaceListResult = 111;
|
||||
public static final int TetherDnsFwdTgtListResult = 112;
|
||||
public static final int TtyListResult = 113;
|
||||
public static final int TetheringStatsListResult = 114;
|
||||
|
||||
public static final int TetherStatusResult = 210;
|
||||
public static final int IpFwdStatusResult = 211;
|
||||
@@ -523,7 +524,8 @@ public class NetworkManagementService extends INetworkManagementService.Stub
|
||||
throw new IllegalStateException(msg);
|
||||
}
|
||||
|
||||
int flags, scope;
|
||||
int flags;
|
||||
int scope;
|
||||
try {
|
||||
flags = Integer.parseInt(cooked[5]);
|
||||
scope = Integer.parseInt(cooked[6]);
|
||||
@@ -1373,55 +1375,42 @@ public class NetworkManagementService extends INetworkManagementService.Stub
|
||||
}
|
||||
|
||||
@Override
|
||||
public NetworkStats getNetworkStatsTethering(String[] ifacePairs) {
|
||||
public NetworkStats getNetworkStatsTethering() {
|
||||
mContext.enforceCallingOrSelfPermission(CONNECTIVITY_INTERNAL, TAG);
|
||||
|
||||
if (ifacePairs.length % 2 != 0) {
|
||||
throw new IllegalArgumentException(
|
||||
"unexpected ifacePairs; length=" + ifacePairs.length);
|
||||
}
|
||||
|
||||
final NetworkStats stats = new NetworkStats(SystemClock.elapsedRealtime(), 1);
|
||||
for (int i = 0; i < ifacePairs.length; i += 2) {
|
||||
final String ifaceIn = ifacePairs[i];
|
||||
final String ifaceOut = ifacePairs[i + 1];
|
||||
if (ifaceIn != null && ifaceOut != null) {
|
||||
stats.combineValues(getNetworkStatsTethering(ifaceIn, ifaceOut));
|
||||
}
|
||||
}
|
||||
return stats;
|
||||
}
|
||||
|
||||
private NetworkStats.Entry getNetworkStatsTethering(String ifaceIn, String ifaceOut) {
|
||||
final NativeDaemonEvent event;
|
||||
try {
|
||||
event = mConnector.execute("bandwidth", "gettetherstats", ifaceIn, ifaceOut);
|
||||
final NativeDaemonEvent[] events = mConnector.executeForList(
|
||||
"bandwidth", "gettetherstats");
|
||||
for (NativeDaemonEvent event : events) {
|
||||
if (event.getCode() != TetheringStatsListResult) continue;
|
||||
|
||||
// 114 ifaceIn ifaceOut rx_bytes rx_packets tx_bytes tx_packets
|
||||
final StringTokenizer tok = new StringTokenizer(event.getMessage());
|
||||
try {
|
||||
final String ifaceIn = tok.nextToken();
|
||||
final String ifaceOut = tok.nextToken();
|
||||
|
||||
final NetworkStats.Entry entry = new NetworkStats.Entry();
|
||||
entry.iface = ifaceOut;
|
||||
entry.uid = UID_TETHERING;
|
||||
entry.set = SET_DEFAULT;
|
||||
entry.tag = TAG_NONE;
|
||||
entry.rxBytes = Long.parseLong(tok.nextToken());
|
||||
entry.rxPackets = Long.parseLong(tok.nextToken());
|
||||
entry.txBytes = Long.parseLong(tok.nextToken());
|
||||
entry.txPackets = Long.parseLong(tok.nextToken());
|
||||
stats.combineValues(entry);
|
||||
} catch (NoSuchElementException e) {
|
||||
throw new IllegalStateException("problem parsing tethering stats: " + event);
|
||||
} catch (NumberFormatException e) {
|
||||
throw new IllegalStateException("problem parsing tethering stats: " + event);
|
||||
}
|
||||
}
|
||||
} catch (NativeDaemonConnectorException e) {
|
||||
throw e.rethrowAsParcelableException();
|
||||
}
|
||||
|
||||
event.checkCode(TetheringStatsResult);
|
||||
|
||||
// 221 ifaceIn ifaceOut rx_bytes rx_packets tx_bytes tx_packets
|
||||
final StringTokenizer tok = new StringTokenizer(event.getMessage());
|
||||
tok.nextToken();
|
||||
tok.nextToken();
|
||||
|
||||
try {
|
||||
final NetworkStats.Entry entry = new NetworkStats.Entry();
|
||||
entry.iface = ifaceIn;
|
||||
entry.uid = UID_TETHERING;
|
||||
entry.set = SET_DEFAULT;
|
||||
entry.tag = TAG_NONE;
|
||||
entry.rxBytes = Long.parseLong(tok.nextToken());
|
||||
entry.rxPackets = Long.parseLong(tok.nextToken());
|
||||
entry.txBytes = Long.parseLong(tok.nextToken());
|
||||
entry.txPackets = Long.parseLong(tok.nextToken());
|
||||
return entry;
|
||||
} catch (NumberFormatException e) {
|
||||
throw new IllegalStateException(
|
||||
"problem parsing tethering stats for " + ifaceIn + " " + ifaceOut + ": " + e);
|
||||
}
|
||||
return stats;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -688,19 +688,6 @@ public class Tethering extends INetworkManagementEventObserver.Stub {
|
||||
return retVal;
|
||||
}
|
||||
|
||||
public String[] getTetheredIfacePairs() {
|
||||
final ArrayList<String> list = Lists.newArrayList();
|
||||
synchronized (mPublicSync) {
|
||||
for (TetherInterfaceSM sm : mIfaces.values()) {
|
||||
if (sm.isTethered()) {
|
||||
list.add(sm.mMyUpstreamIfaceName);
|
||||
list.add(sm.mIfaceName);
|
||||
}
|
||||
}
|
||||
}
|
||||
return list.toArray(new String[list.size()]);
|
||||
}
|
||||
|
||||
public String[] getTetherableIfaces() {
|
||||
ArrayList<String> list = new ArrayList<String>();
|
||||
synchronized (mPublicSync) {
|
||||
|
||||
@@ -135,6 +135,9 @@ public class NetworkStatsRecorder {
|
||||
} catch (IOException e) {
|
||||
Log.wtf(TAG, "problem completely reading network stats", e);
|
||||
recoverFromWtf();
|
||||
} catch (OutOfMemoryError e) {
|
||||
Log.wtf(TAG, "problem completely reading network stats", e);
|
||||
recoverFromWtf();
|
||||
}
|
||||
}
|
||||
return complete;
|
||||
@@ -226,6 +229,9 @@ public class NetworkStatsRecorder {
|
||||
} catch (IOException e) {
|
||||
Log.wtf(TAG, "problem persisting pending stats", e);
|
||||
recoverFromWtf();
|
||||
} catch (OutOfMemoryError e) {
|
||||
Log.wtf(TAG, "problem persisting pending stats", e);
|
||||
recoverFromWtf();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -241,6 +247,9 @@ public class NetworkStatsRecorder {
|
||||
} catch (IOException e) {
|
||||
Log.wtf(TAG, "problem removing UIDs " + Arrays.toString(uids), e);
|
||||
recoverFromWtf();
|
||||
} catch (OutOfMemoryError e) {
|
||||
Log.wtf(TAG, "problem removing UIDs " + Arrays.toString(uids), e);
|
||||
recoverFromWtf();
|
||||
}
|
||||
|
||||
// Remove any pending stats
|
||||
|
||||
@@ -412,6 +412,8 @@ public class NetworkStatsService extends INetworkStatsService.Stub {
|
||||
}
|
||||
} catch (IOException e) {
|
||||
Log.wtf(TAG, "problem during legacy upgrade", e);
|
||||
} catch (OutOfMemoryError e) {
|
||||
Log.wtf(TAG, "problem during legacy upgrade", e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1186,8 +1188,7 @@ public class NetworkStatsService extends INetworkStatsService.Stub {
|
||||
*/
|
||||
private NetworkStats getNetworkStatsTethering() throws RemoteException {
|
||||
try {
|
||||
final String[] tetheredIfacePairs = mConnManager.getTetheredIfacePairs();
|
||||
return mNetworkManager.getNetworkStatsTethering(tetheredIfacePairs);
|
||||
return mNetworkManager.getNetworkStatsTethering();
|
||||
} catch (IllegalStateException e) {
|
||||
Log.wtf(TAG, "problem reading network stats", e);
|
||||
return new NetworkStats(0L, 10);
|
||||
|
||||
@@ -40,7 +40,6 @@ import static android.text.format.DateUtils.MINUTE_IN_MILLIS;
|
||||
import static android.text.format.DateUtils.WEEK_IN_MILLIS;
|
||||
import static com.android.server.net.NetworkStatsService.ACTION_NETWORK_STATS_POLL;
|
||||
import static org.easymock.EasyMock.anyLong;
|
||||
import static org.easymock.EasyMock.aryEq;
|
||||
import static org.easymock.EasyMock.capture;
|
||||
import static org.easymock.EasyMock.createMock;
|
||||
import static org.easymock.EasyMock.eq;
|
||||
@@ -74,13 +73,13 @@ import com.android.server.net.NetworkStatsService;
|
||||
import com.android.server.net.NetworkStatsService.NetworkStatsSettings;
|
||||
import com.android.server.net.NetworkStatsService.NetworkStatsSettings.Config;
|
||||
|
||||
import libcore.io.IoUtils;
|
||||
|
||||
import org.easymock.Capture;
|
||||
import org.easymock.EasyMock;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import libcore.io.IoUtils;
|
||||
|
||||
/**
|
||||
* Tests for {@link NetworkStatsService}.
|
||||
*/
|
||||
@@ -919,8 +918,7 @@ public class NetworkStatsServiceTest extends AndroidTestCase {
|
||||
expect(mNetManager.getNetworkStatsUidDetail(eq(UID_ALL))).andReturn(detail).atLeastOnce();
|
||||
|
||||
// also include tethering details, since they are folded into UID
|
||||
expect(mConnManager.getTetheredIfacePairs()).andReturn(tetherIfacePairs).atLeastOnce();
|
||||
expect(mNetManager.getNetworkStatsTethering(aryEq(tetherIfacePairs)))
|
||||
expect(mNetManager.getNetworkStatsTethering())
|
||||
.andReturn(tetherStats).atLeastOnce();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user