am 0e3cd546: Merge change 23907 into eclair
Merge commit '0e3cd546001cb82b8d9c8e910cf751d1d2a584df' into eclair-plus-aosp * commit '0e3cd546001cb82b8d9c8e910cf751d1d2a584df': Add sync_details support.
This commit is contained in:
@@ -19,6 +19,8 @@ package android.content;
|
|||||||
import android.accounts.Account;
|
import android.accounts.Account;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Process;
|
import android.os.Process;
|
||||||
|
import android.os.NetStat;
|
||||||
|
import android.util.EventLog;
|
||||||
|
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
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. */
|
/** Kernel event log tag. Also listed in data/etc/event-log-tags. */
|
||||||
public static final int LOG_SYNC_DETAILS = 2743;
|
public static final int LOG_SYNC_DETAILS = 2743;
|
||||||
|
private static final String TAG = "Sync";
|
||||||
private final boolean mAutoInitialize;
|
private final boolean mAutoInitialize;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -127,6 +130,8 @@ public abstract class AbstractThreadedSyncAdapter {
|
|||||||
private final String mAuthority;
|
private final String mAuthority;
|
||||||
private final Account mAccount;
|
private final Account mAccount;
|
||||||
private final Bundle mExtras;
|
private final Bundle mExtras;
|
||||||
|
private long mInitialTxBytes;
|
||||||
|
private long mInitialRxBytes;
|
||||||
|
|
||||||
private SyncThread(String name, SyncContext syncContext, String authority,
|
private SyncThread(String name, SyncContext syncContext, String authority,
|
||||||
Account account, Bundle extras) {
|
Account account, Bundle extras) {
|
||||||
@@ -145,6 +150,9 @@ public abstract class AbstractThreadedSyncAdapter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
SyncResult syncResult = new SyncResult();
|
SyncResult syncResult = new SyncResult();
|
||||||
|
int uid = Process.myUid();
|
||||||
|
mInitialTxBytes = NetStat.getUidTxBytes(uid);
|
||||||
|
mInitialRxBytes = NetStat.getUidRxBytes(uid);
|
||||||
ContentProviderClient provider = null;
|
ContentProviderClient provider = null;
|
||||||
try {
|
try {
|
||||||
provider = mContext.getContentResolver().acquireContentProviderClient(mAuthority);
|
provider = mContext.getContentResolver().acquireContentProviderClient(mAuthority);
|
||||||
@@ -162,6 +170,8 @@ public abstract class AbstractThreadedSyncAdapter {
|
|||||||
if (!isCanceled()) {
|
if (!isCanceled()) {
|
||||||
mSyncContext.onFinished(syncResult);
|
mSyncContext.onFinished(syncResult);
|
||||||
}
|
}
|
||||||
|
logSyncDetails(NetStat.getUidTxBytes(uid) - mInitialTxBytes,
|
||||||
|
NetStat.getUidRxBytes(uid) - mInitialRxBytes, syncResult);
|
||||||
// synchronize so that the assignment will be seen by other threads
|
// synchronize so that the assignment will be seen by other threads
|
||||||
// that also synchronize accesses to mSyncThread
|
// that also synchronize accesses to mSyncThread
|
||||||
synchronized (mSyncThreadLock) {
|
synchronized (mSyncThreadLock) {
|
||||||
@@ -196,4 +206,18 @@ public abstract class AbstractThreadedSyncAdapter {
|
|||||||
*/
|
*/
|
||||||
public abstract void performSync(Account account, Bundle extras,
|
public abstract void performSync(Account account, Bundle extras,
|
||||||
String authority, ContentProviderClient provider, SyncResult syncResult);
|
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