Fix leaked intent receiver by using onStartCommand in SyncManager
Change-Id: I914c597aede6904a11a5d3119b3f7097e65b2fba
This commit is contained in:
parent
2bab07c71e
commit
e13ff84df7
@ -671,7 +671,7 @@ public class SyncManager extends Service implements Runnable {
|
|||||||
if (INSTANCE != null) {
|
if (INSTANCE != null) {
|
||||||
Log.d(TAG, "onCreate called on running SyncManager");
|
Log.d(TAG, "onCreate called on running SyncManager");
|
||||||
} else {
|
} else {
|
||||||
Log.d(TAG, "!!! EAS SyncManager started");
|
Log.d(TAG, "!!! EAS SyncManager, onCreate");
|
||||||
INSTANCE = this;
|
INSTANCE = this;
|
||||||
try {
|
try {
|
||||||
sDeviceId = getDeviceId();
|
sDeviceId = getDeviceId();
|
||||||
@ -687,12 +687,34 @@ public class SyncManager extends Service implements Runnable {
|
|||||||
mMessageObserver = new MessageObserver(mHandler);
|
mMessageObserver = new MessageObserver(mHandler);
|
||||||
mSyncStatusObserver = new EasSyncStatusObserver();
|
mSyncStatusObserver = new EasSyncStatusObserver();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int onStartCommand(Intent intent, int flags, int startId) {
|
||||||
|
Log.d(TAG, "!!! EAS SyncManager, onStartCommand");
|
||||||
maybeStartSyncManagerThread();
|
maybeStartSyncManagerThread();
|
||||||
if (sServiceThread == null) {
|
if (sServiceThread == null) {
|
||||||
Log.d(TAG, "!!! EAS SyncManager stopping self");
|
Log.d(TAG, "!!! EAS SyncManager, stopping self");
|
||||||
stopSelf();
|
stopSelf();
|
||||||
}
|
}
|
||||||
|
return Service.START_REDELIVER_INTENT;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDestroy() {
|
||||||
|
Log.d(TAG, "!!! EAS SyncManager, onDestroy");
|
||||||
|
}
|
||||||
|
|
||||||
|
void maybeStartSyncManagerThread() {
|
||||||
|
// Start our thread...
|
||||||
|
// See if there are any EAS accounts; otherwise, just go away
|
||||||
|
if (EmailContent.count(this, HostAuth.CONTENT_URI, WHERE_PROTOCOL_EAS, null) > 0) {
|
||||||
|
if (sServiceThread == null || !sServiceThread.isAlive()) {
|
||||||
|
log(sServiceThread == null ? "Starting thread..." : "Restarting thread...");
|
||||||
|
sServiceThread = new Thread(this, "SyncManager");
|
||||||
|
sServiceThread.start();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static public ConnPerRoute sConnPerRoute = new ConnPerRoute() {
|
static public ConnPerRoute sConnPerRoute = new ConnPerRoute() {
|
||||||
@ -741,23 +763,6 @@ public class SyncManager extends Service implements Runnable {
|
|||||||
return sClientConnectionManager;
|
return sClientConnectionManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onDestroy() {
|
|
||||||
log("!!! EAS SyncManager destroyed");
|
|
||||||
}
|
|
||||||
|
|
||||||
void maybeStartSyncManagerThread() {
|
|
||||||
// Start our thread...
|
|
||||||
// See if there are any EAS accounts; otherwise, just go away
|
|
||||||
if (EmailContent.count(this, HostAuth.CONTENT_URI, WHERE_PROTOCOL_EAS, null) > 0) {
|
|
||||||
if (sServiceThread == null || !sServiceThread.isAlive()) {
|
|
||||||
log(sServiceThread == null ? "Starting thread..." : "Restarting thread...");
|
|
||||||
sServiceThread = new Thread(this, "SyncManager");
|
|
||||||
sServiceThread.start();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static public void reloadFolderList(Context context, long accountId, boolean force) {
|
static public void reloadFolderList(Context context, long accountId, boolean force) {
|
||||||
if (INSTANCE == null) return;
|
if (INSTANCE == null) return;
|
||||||
Cursor c = context.getContentResolver().query(Mailbox.CONTENT_URI,
|
Cursor c = context.getContentResolver().query(Mailbox.CONTENT_URI,
|
||||||
|
Loading…
Reference in New Issue
Block a user