mirror of
https://github.com/moparisthebest/k-9
synced 2024-11-27 11:42:16 -05:00
Removed useless try block
This commit is contained in:
parent
2d1f9f9c84
commit
f345c33728
@ -86,91 +86,88 @@ public class MailService extends CoreService {
|
|||||||
@Override
|
@Override
|
||||||
public void startService(Intent intent, int startId) {
|
public void startService(Intent intent, int startId) {
|
||||||
long startTime = System.currentTimeMillis();
|
long startTime = System.currentTimeMillis();
|
||||||
try {
|
boolean oldIsSyncDisabled = isSyncDisabled();
|
||||||
boolean oldIsSyncDisabled = isSyncDisabled();
|
ConnectivityManager connectivityManager = (ConnectivityManager)getApplication().getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||||
ConnectivityManager connectivityManager = (ConnectivityManager)getApplication().getSystemService(Context.CONNECTIVITY_SERVICE);
|
boolean doBackground = true;
|
||||||
boolean doBackground = true;
|
boolean hasConnectivity = false;
|
||||||
boolean hasConnectivity = false;
|
|
||||||
|
|
||||||
if (connectivityManager != null) {
|
if (connectivityManager != null) {
|
||||||
NetworkInfo netInfo = connectivityManager.getActiveNetworkInfo();
|
NetworkInfo netInfo = connectivityManager.getActiveNetworkInfo();
|
||||||
if (netInfo != null) {
|
if (netInfo != null) {
|
||||||
State state = netInfo.getState();
|
State state = netInfo.getState();
|
||||||
hasConnectivity = state == State.CONNECTED;
|
hasConnectivity = state == State.CONNECTED;
|
||||||
}
|
}
|
||||||
boolean backgroundData = connectivityManager.getBackgroundDataSetting();
|
boolean backgroundData = connectivityManager.getBackgroundDataSetting();
|
||||||
boolean autoSync = true;
|
boolean autoSync = true;
|
||||||
if (AutoSyncHelper.isAvailable()) {
|
if (AutoSyncHelper.isAvailable()) {
|
||||||
autoSync = AutoSyncHelper.getMasterSyncAutomatically();
|
autoSync = AutoSyncHelper.getMasterSyncAutomatically();
|
||||||
|
|
||||||
Log.i(K9.LOG_TAG, "AutoSync help is available, autoSync = " + autoSync);
|
|
||||||
}
|
|
||||||
|
|
||||||
K9.BACKGROUND_OPS bOps = K9.getBackgroundOps();
|
|
||||||
|
|
||||||
switch (bOps) {
|
|
||||||
case NEVER:
|
|
||||||
doBackground = false;
|
|
||||||
break;
|
|
||||||
case ALWAYS:
|
|
||||||
doBackground = true;
|
|
||||||
break;
|
|
||||||
case WHEN_CHECKED:
|
|
||||||
doBackground = backgroundData;
|
|
||||||
break;
|
|
||||||
case WHEN_CHECKED_AUTO_SYNC:
|
|
||||||
doBackground = backgroundData & autoSync;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
Log.i(K9.LOG_TAG, "AutoSync help is available, autoSync = " + autoSync);
|
||||||
}
|
}
|
||||||
|
|
||||||
syncBlocked = !(doBackground && hasConnectivity);
|
K9.BACKGROUND_OPS bOps = K9.getBackgroundOps();
|
||||||
|
|
||||||
if (K9.DEBUG)
|
switch (bOps) {
|
||||||
Log.i(K9.LOG_TAG, "MailService.onStart(" + intent + ", " + startId
|
case NEVER:
|
||||||
+ "), hasConnectivity = " + hasConnectivity + ", doBackground = " + doBackground);
|
doBackground = false;
|
||||||
|
break;
|
||||||
// MessagingController.getInstance(getApplication()).addListener(mListener);
|
case ALWAYS:
|
||||||
if (ACTION_CHECK_MAIL.equals(intent.getAction())) {
|
doBackground = true;
|
||||||
if (K9.DEBUG)
|
break;
|
||||||
Log.i(K9.LOG_TAG, "***** MailService *****: checking mail");
|
case WHEN_CHECKED:
|
||||||
if (hasConnectivity && doBackground) {
|
doBackground = backgroundData;
|
||||||
PollService.startService(this);
|
break;
|
||||||
}
|
case WHEN_CHECKED_AUTO_SYNC:
|
||||||
reschedulePollInBackground(hasConnectivity, doBackground, startId, false);
|
doBackground = backgroundData & autoSync;
|
||||||
} else if (ACTION_CANCEL.equals(intent.getAction())) {
|
break;
|
||||||
if (K9.DEBUG)
|
|
||||||
Log.v(K9.LOG_TAG, "***** MailService *****: cancel");
|
|
||||||
cancel();
|
|
||||||
} else if (ACTION_RESET.equals(intent.getAction())) {
|
|
||||||
if (K9.DEBUG)
|
|
||||||
Log.v(K9.LOG_TAG, "***** MailService *****: reschedule");
|
|
||||||
rescheduleAllInBackground(hasConnectivity, doBackground, startId);
|
|
||||||
} else if (ACTION_RESTART_PUSHERS.equals(intent.getAction())) {
|
|
||||||
if (K9.DEBUG)
|
|
||||||
Log.v(K9.LOG_TAG, "***** MailService *****: restarting pushers");
|
|
||||||
reschedulePushersInBackground(hasConnectivity, doBackground, startId);
|
|
||||||
} else if (ACTION_RESCHEDULE_POLL.equals(intent.getAction())) {
|
|
||||||
if (K9.DEBUG)
|
|
||||||
Log.v(K9.LOG_TAG, "***** MailService *****: rescheduling poll");
|
|
||||||
reschedulePollInBackground(hasConnectivity, doBackground, startId, true);
|
|
||||||
} else if (ACTION_REFRESH_PUSHERS.equals(intent.getAction())) {
|
|
||||||
refreshPushersInBackground(hasConnectivity, doBackground, startId);
|
|
||||||
} else if (CONNECTIVITY_CHANGE.equals(intent.getAction())) {
|
|
||||||
rescheduleAllInBackground(hasConnectivity, doBackground, startId);
|
|
||||||
if (K9.DEBUG)
|
|
||||||
Log.i(K9.LOG_TAG, "Got connectivity action with hasConnectivity = " + hasConnectivity + ", doBackground = " + doBackground);
|
|
||||||
} else if (CANCEL_CONNECTIVITY_NOTICE.equals(intent.getAction())) {
|
|
||||||
/* do nothing */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isSyncDisabled() != oldIsSyncDisabled) {
|
|
||||||
MessagingController.getInstance(getApplication()).systemStatusChanged();
|
|
||||||
}
|
|
||||||
} finally {
|
|
||||||
/* nothing to do */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
syncBlocked = !(doBackground && hasConnectivity);
|
||||||
|
|
||||||
|
if (K9.DEBUG)
|
||||||
|
Log.i(K9.LOG_TAG, "MailService.onStart(" + intent + ", " + startId
|
||||||
|
+ "), hasConnectivity = " + hasConnectivity + ", doBackground = " + doBackground);
|
||||||
|
|
||||||
|
// MessagingController.getInstance(getApplication()).addListener(mListener);
|
||||||
|
if (ACTION_CHECK_MAIL.equals(intent.getAction())) {
|
||||||
|
if (K9.DEBUG)
|
||||||
|
Log.i(K9.LOG_TAG, "***** MailService *****: checking mail");
|
||||||
|
if (hasConnectivity && doBackground) {
|
||||||
|
PollService.startService(this);
|
||||||
|
}
|
||||||
|
reschedulePollInBackground(hasConnectivity, doBackground, startId, false);
|
||||||
|
} else if (ACTION_CANCEL.equals(intent.getAction())) {
|
||||||
|
if (K9.DEBUG)
|
||||||
|
Log.v(K9.LOG_TAG, "***** MailService *****: cancel");
|
||||||
|
cancel();
|
||||||
|
} else if (ACTION_RESET.equals(intent.getAction())) {
|
||||||
|
if (K9.DEBUG)
|
||||||
|
Log.v(K9.LOG_TAG, "***** MailService *****: reschedule");
|
||||||
|
rescheduleAllInBackground(hasConnectivity, doBackground, startId);
|
||||||
|
} else if (ACTION_RESTART_PUSHERS.equals(intent.getAction())) {
|
||||||
|
if (K9.DEBUG)
|
||||||
|
Log.v(K9.LOG_TAG, "***** MailService *****: restarting pushers");
|
||||||
|
reschedulePushersInBackground(hasConnectivity, doBackground, startId);
|
||||||
|
} else if (ACTION_RESCHEDULE_POLL.equals(intent.getAction())) {
|
||||||
|
if (K9.DEBUG)
|
||||||
|
Log.v(K9.LOG_TAG, "***** MailService *****: rescheduling poll");
|
||||||
|
reschedulePollInBackground(hasConnectivity, doBackground, startId, true);
|
||||||
|
} else if (ACTION_REFRESH_PUSHERS.equals(intent.getAction())) {
|
||||||
|
refreshPushersInBackground(hasConnectivity, doBackground, startId);
|
||||||
|
} else if (CONNECTIVITY_CHANGE.equals(intent.getAction())) {
|
||||||
|
rescheduleAllInBackground(hasConnectivity, doBackground, startId);
|
||||||
|
if (K9.DEBUG)
|
||||||
|
Log.i(K9.LOG_TAG, "Got connectivity action with hasConnectivity = " + hasConnectivity + ", doBackground = " + doBackground);
|
||||||
|
} else if (CANCEL_CONNECTIVITY_NOTICE.equals(intent.getAction())) {
|
||||||
|
/* do nothing */
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isSyncDisabled() != oldIsSyncDisabled) {
|
||||||
|
MessagingController.getInstance(getApplication()).systemStatusChanged();
|
||||||
|
}
|
||||||
|
|
||||||
if (K9.DEBUG)
|
if (K9.DEBUG)
|
||||||
Log.i(K9.LOG_TAG, "MailService.onStart took " + (System.currentTimeMillis() - startTime) + "ms");
|
Log.i(K9.LOG_TAG, "MailService.onStart took " + (System.currentTimeMillis() - startTime) + "ms");
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user