tryping to resolve the wake lock bug

This commit is contained in:
Daniel Gultsch 2014-04-03 10:41:21 +02:00
parent 2b8dfc2bab
commit 01925fb2cc
3 changed files with 9 additions and 9 deletions

View file

@ -361,6 +361,7 @@ public class XmppConnectionService extends Service {
private Intent pingIntent; private Intent pingIntent;
private PendingIntent pendingPingIntent = null; private PendingIntent pendingPingIntent = null;
private WakeLock wakeLock; private WakeLock wakeLock;
private PowerManager pm;
public PgpEngine getPgpEngine() { public PgpEngine getPgpEngine() {
if (pgpServiceConnection.isBound()) { if (pgpServiceConnection.isBound()) {
@ -528,9 +529,9 @@ public class XmppConnectionService extends Service {
getApplicationContext(), "org.sufficientlysecure.keychain"); getApplicationContext(), "org.sufficientlysecure.keychain");
this.pgpServiceConnection.bindToService(); this.pgpServiceConnection.bindToService();
PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE); this.pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
this.wakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, this.wakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK,
"XmppConnection"); "XmppConnectionService");
} }
@Override @Override
@ -587,7 +588,7 @@ public class XmppConnectionService extends Service {
SharedPreferences sharedPref = PreferenceManager SharedPreferences sharedPref = PreferenceManager
.getDefaultSharedPreferences(getApplicationContext()); .getDefaultSharedPreferences(getApplicationContext());
account.setResource(sharedPref.getString("resource", "mobile").toLowerCase(Locale.getDefault())); account.setResource(sharedPref.getString("resource", "mobile").toLowerCase(Locale.getDefault()));
XmppConnection connection = new XmppConnection(account, this.wakeLock); XmppConnection connection = new XmppConnection(account, this.pm);
connection.setOnMessagePacketReceivedListener(this.messageListener); connection.setOnMessagePacketReceivedListener(this.messageListener);
connection.setOnStatusChangedListener(this.statusListener); connection.setOnStatusChangedListener(this.statusListener);
connection.setOnPresencePacketReceivedListener(this.presenceListener); connection.setOnPresencePacketReceivedListener(this.presenceListener);

View file

@ -128,9 +128,9 @@ public class DNSHelper {
} catch (SocketTimeoutException e) { } catch (SocketTimeoutException e) {
Log.d("xmppService", "timeout during dns"); Log.d("xmppService", "timeout during dns");
namePort.putString("error", "timeout"); namePort.putString("error", "timeout");
} catch (IOException e) { } catch (Exception e) {
Log.d("xmppService","io exception during dns"); Log.d("xmppService","unhandled exception in sub project");
namePort.putString("error", "timeout"); namePort.putString("error", "unhandled");
} }
return namePort; return namePort;
} }

View file

@ -94,10 +94,9 @@ public class XmppConnection implements Runnable {
private OnTLSExceptionReceived tlsListener = null; private OnTLSExceptionReceived tlsListener = null;
private OnBindListener bindListener = null; private OnBindListener bindListener = null;
public XmppConnection(Account account, WakeLock wakeLock) { public XmppConnection(Account account, PowerManager pm) {
this.account = account; this.account = account;
this.wakeLock = wakeLock; this.wakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK,account.getJid());
tagReader = new XmlReader(wakeLock);
tagWriter = new TagWriter(); tagWriter = new TagWriter();
} }