Skip to content

Commit

Permalink
Reverting changes to wake lock routines
Browse files Browse the repository at this point in the history
The changes were causing some issues with wake lock management that cannot be solved quickly
  • Loading branch information
Jorge Silva committed Apr 10, 2012
1 parent 26a20f4 commit bab3a59
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 14 deletions.
8 changes: 2 additions & 6 deletions source/src/ca/idi/tekla/TeclaApp.java
Expand Up @@ -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();
}

/**
Expand Down
12 changes: 4 additions & 8 deletions source/src/ca/idi/tekla/TeclaPrefs.java
Expand Up @@ -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();
}
Expand All @@ -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();
}
}

Expand Down Expand Up @@ -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();
}

}

0 comments on commit bab3a59

Please sign in to comment.