From bab3a59f08cb7e635719308673f22aa7a770ca6b Mon Sep 17 00:00:00 2001 From: Jorge Silva Date: Tue, 10 Apr 2012 14:12:42 -0400 Subject: [PATCH] Reverting changes to wake lock routines The changes were causing some issues with wake lock management that cannot be solved quickly --- source/src/ca/idi/tekla/TeclaApp.java | 8 ++------ source/src/ca/idi/tekla/TeclaPrefs.java | 12 ++++-------- 2 files changed, 6 insertions(+), 14 deletions(-) diff --git a/source/src/ca/idi/tekla/TeclaApp.java b/source/src/ca/idi/tekla/TeclaApp.java index 09de3cf..ac6a756 100644 --- a/source/src/ca/idi/tekla/TeclaApp.java +++ b/source/src/ca/idi/tekla/TeclaApp.java @@ -366,12 +366,8 @@ public void holdWakeLock(long length) { } public void releaseWakeLock () { - if (mWakeLock.isHeld()) { - if (DEBUG) Log.d(TeclaApp.TAG, "Releasing wake lock..."); - mWakeLock.release(); - } else { - if (DEBUG) Log.d(TeclaApp.TAG, "Wake lock not held, so not releasing"); - } + if (DEBUG) Log.d(TeclaApp.TAG, "Releasing wake lock..."); + mWakeLock.release(); } /** diff --git a/source/src/ca/idi/tekla/TeclaPrefs.java b/source/src/ca/idi/tekla/TeclaPrefs.java index 02466c9..8b33901 100644 --- a/source/src/ca/idi/tekla/TeclaPrefs.java +++ b/source/src/ca/idi/tekla/TeclaPrefs.java @@ -181,8 +181,7 @@ protected void onDestroy() { private void discoverShield() { mShieldFound = false; - if (mBluetoothAdapter.isDiscovering()) - mBluetoothAdapter.cancelDiscovery(); + if (mBluetoothAdapter.isDiscovering()) mBluetoothAdapter.cancelDiscovery(); mBluetoothAdapter.startDiscovery(); showDiscoveryDialog(); } @@ -201,8 +200,8 @@ public void onReceive(Context context, Intent intent) { mShieldFound = true; mShieldAddress = dev.getAddress(); mShieldName = dev.getName(); - if (mBluetoothAdapter.isDiscovering()) mBluetoothAdapter.cancelDiscovery(); if (TeclaApp.DEBUG) Log.d(TeclaApp.TAG, CLASS_TAG + "Found a Tecla Access Shield candidate"); + if (mBluetoothAdapter.isDiscovering()) mBluetoothAdapter.cancelDiscovery(); } } @@ -368,27 +367,24 @@ public void onCancel(DialogInterface arg0) { if (TeclaApp.DEBUG) Log.d(TeclaApp.TAG, CLASS_TAG + "Tecla Shield discovery cancelled"); if (mBluetoothAdapter != null && mBluetoothAdapter.isDiscovering()) { mBluetoothAdapter.cancelDiscovery(); - //since we have cancelled the discovery the check state needs to be reset - mPrefConnectToShield.setChecked(false); } + //since we have cancelled the discovery the check state needs to be reset + mPrefConnectToShield.setChecked(false); } }); mProgressDialog.show(); - TeclaApp.getInstance().holdWakeLock(); } private void cancelDialog() { if (mProgressDialog != null && mProgressDialog.isShowing()) { mProgressDialog.cancel(); } - TeclaApp.getInstance().releaseWakeLock(); } private void dismissDialog() { if (mProgressDialog != null && mProgressDialog.isShowing()) { mProgressDialog.dismiss(); } - TeclaApp.getInstance().releaseWakeLock(); } }