Merge change 23907 into eclair
* changes: Add sync_details support.
This commit is contained in:
@@ -19,6 +19,8 @@ package android.content;
|
||||
import android.accounts.Account;
|
||||
import android.os.Bundle;
|
||||
import android.os.Process;
|
||||
import android.os.NetStat;
|
||||
import android.util.EventLog;
|
||||
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
@@ -45,6 +47,7 @@ public abstract class AbstractThreadedSyncAdapter {
|
||||
|
||||
/** Kernel event log tag. Also listed in data/etc/event-log-tags. */
|
||||
public static final int LOG_SYNC_DETAILS = 2743;
|
||||
private static final String TAG = "Sync";
|
||||
private final boolean mAutoInitialize;
|
||||
|
||||
/**
|
||||
@@ -127,6 +130,8 @@ public abstract class AbstractThreadedSyncAdapter {
|
||||
private final String mAuthority;
|
||||
private final Account mAccount;
|
||||
private final Bundle mExtras;
|
||||
private long mInitialTxBytes;
|
||||
private long mInitialRxBytes;
|
||||
|
||||
private SyncThread(String name, SyncContext syncContext, String authority,
|
||||
Account account, Bundle extras) {
|
||||
@@ -145,6 +150,9 @@ public abstract class AbstractThreadedSyncAdapter {
|
||||
}
|
||||
|
||||
SyncResult syncResult = new SyncResult();
|
||||
int uid = Process.myUid();
|
||||
mInitialTxBytes = NetStat.getUidTxBytes(uid);
|
||||
mInitialRxBytes = NetStat.getUidRxBytes(uid);
|
||||
ContentProviderClient provider = null;
|
||||
try {
|
||||
provider = mContext.getContentResolver().acquireContentProviderClient(mAuthority);
|
||||
@@ -162,6 +170,8 @@ public abstract class AbstractThreadedSyncAdapter {
|
||||
if (!isCanceled()) {
|
||||
mSyncContext.onFinished(syncResult);
|
||||
}
|
||||
logSyncDetails(NetStat.getUidTxBytes(uid) - mInitialTxBytes,
|
||||
NetStat.getUidRxBytes(uid) - mInitialRxBytes, syncResult);
|
||||
// synchronize so that the assignment will be seen by other threads
|
||||
// that also synchronize accesses to mSyncThread
|
||||
synchronized (mSyncThreadLock) {
|
||||
@@ -196,4 +206,18 @@ public abstract class AbstractThreadedSyncAdapter {
|
||||
*/
|
||||
public abstract void performSync(Account account, Bundle extras,
|
||||
String authority, ContentProviderClient provider, SyncResult syncResult);
|
||||
|
||||
/**
|
||||
* Logs details on the sync.
|
||||
* Normally this will be overridden by a subclass that will provide
|
||||
* provider-specific details.
|
||||
*
|
||||
* @param bytesSent number of bytes the sync sent over the network
|
||||
* @param bytesReceived number of bytes the sync received over the network
|
||||
* @param result The SyncResult object holding info on the sync
|
||||
*/
|
||||
protected void logSyncDetails(long bytesSent, long bytesReceived, SyncResult result) {
|
||||
EventLog.writeEvent(SyncAdapter.LOG_SYNC_DETAILS, TAG, bytesSent, bytesReceived, "");
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user