diff options
author | Brint E. Kriebel <bekit@cyngn.com> | 2014-06-30 19:36:28 -0700 |
---|---|---|
committer | Brint E. Kriebel <bekit@cyngn.com> | 2014-06-30 19:36:28 -0700 |
commit | 1bebd9e564634c7c7feaf9bcbcb1297cfc02f8b6 (patch) | |
tree | 0ff15251db7e77ec08fd889479f32137e0fafb53 /src/com/android/bluetooth/pbap/BluetoothPbapService.java | |
parent | 4f63bf9904f4babfd928250adc6646c6669bf484 (diff) | |
parent | d4ab3f4d65d816e6185f946b3b29e977262220d3 (diff) | |
download | android_packages_apps_Bluetooth-cm-11.0-XNPH33R-bacon-3628510d76.tar.gz android_packages_apps_Bluetooth-cm-11.0-XNPH33R-bacon-3628510d76.tar.bz2 android_packages_apps_Bluetooth-cm-11.0-XNPH33R-bacon-3628510d76.zip |
Merge branch 'cm-11.0' into stable/cm-11.0cm-11.0-XNPH33R-bacon-3628510d76cm-11.0-XNPH30O-bacon-4f280f505a
Diffstat (limited to 'src/com/android/bluetooth/pbap/BluetoothPbapService.java')
-rw-r--r-- | src/com/android/bluetooth/pbap/BluetoothPbapService.java | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/src/com/android/bluetooth/pbap/BluetoothPbapService.java b/src/com/android/bluetooth/pbap/BluetoothPbapService.java index d73781480..fd53ceb1b 100644 --- a/src/com/android/bluetooth/pbap/BluetoothPbapService.java +++ b/src/com/android/bluetooth/pbap/BluetoothPbapService.java @@ -49,6 +49,7 @@ import android.bluetooth.BluetoothUuid; import android.content.Context; import android.content.Intent; import android.os.Handler; +import android.os.PowerManager; import android.os.IBinder; import android.os.Message; import android.os.RemoteException; @@ -162,6 +163,8 @@ public class BluetoothPbapService extends Service { private static String sRemoteDeviceName = null; + private PowerManager.WakeLock mFullWakeLock = null; + private boolean mHasStarted = false; private volatile boolean mInterrupted; @@ -559,6 +562,7 @@ public class BluetoothPbapService extends Service { sRemoteDeviceName = getString(R.string.defaultname); } + acquirePbapWakeLock(); Intent intent = new Intent(BluetoothDevice.ACTION_CONNECTION_ACCESS_REQUEST); intent.setClassName(ACCESS_AUTHORITY_PACKAGE, ACCESS_AUTHORITY_CLASS); @@ -579,6 +583,8 @@ public class BluetoothPbapService extends Service { // phonebook access, while UI still there waiting for user to confirm mSessionStatusHandler.sendMessageDelayed(mSessionStatusHandler .obtainMessage(USER_TIMEOUT), USER_CONFIRM_TIMEOUT_VALUE); + + releasePbapWakeLock(); stopped = true; // job done ,close this thread; } catch (IOException ex) { stopped=true; @@ -721,6 +727,32 @@ public class BluetoothPbapService extends Service { return sRemoteDeviceName; } + private void acquirePbapWakeLock() { + if (mFullWakeLock == null) { + PowerManager pm = (PowerManager) this.getSystemService(Context.POWER_SERVICE); + mFullWakeLock = pm.newWakeLock(PowerManager.FULL_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP + | PowerManager.ON_AFTER_RELEASE, "StartingObexPbapTransaction"); + mFullWakeLock.setReferenceCounted(false); + + mFullWakeLock.acquire(); + if (VERBOSE) Log.v(TAG, "Pbap: mFullWakeLock acquired"); + } else { + Log.e(TAG, "Pbap:mFullWakeLock already acquired"); + } + } + + private void releasePbapWakeLock() { + if (mFullWakeLock != null) { + if (mFullWakeLock.isHeld()) { + mFullWakeLock.release(); + if (VERBOSE) Log.v(TAG, "Pbap: mFullWakeLock released"); + } else { + if (VERBOSE) Log.v(TAG, "Pbap: mFullWakeLock already released"); + } + mFullWakeLock = null; + } + } + /** * Handlers for incoming service calls */ |