diff options
author | Jorim Jaggi <jjaggi@google.com> | 2015-08-17 20:17:30 -0700 |
---|---|---|
committer | Jorim Jaggi <jjaggi@google.com> | 2015-08-19 00:01:45 +0000 |
commit | f610bd78b2cf574faa197ed9f21128ac7795a407 (patch) | |
tree | dd292ca717e95b6afee95a8158ce69195cc26d5a | |
parent | 0b8045425ff58f992046ff2be35bc91001dabf7b (diff) | |
download | frameworks_base-f610bd78b2cf574faa197ed9f21128ac7795a407.zip frameworks_base-f610bd78b2cf574faa197ed9f21128ac7795a407.tar.gz frameworks_base-f610bd78b2cf574faa197ed9f21128ac7795a407.tar.bz2 |
Fix race conditions for camera prewarm service
When the unbind request came in before the service was actually
bound, we dropped the unbind request because mPrewarmBound was still
false. Fix that by tracking whether a bind is pending and if a unbind
event comes in during that time, set another flag to unbind it
directly again when the service is actually bound. In addition, don't
allow binding again if any of the previous events are still pending.
Bug: 23143748
Change-Id: I2b8ace86e35479a9848668a3462a2ce687835413
-rw-r--r-- | packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBottomAreaView.java | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBottomAreaView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBottomAreaView.java index 42a2f90..9af8ab7 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBottomAreaView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBottomAreaView.java @@ -115,12 +115,10 @@ public class KeyguardBottomAreaView extends FrameLayout implements View.OnClickL @Override public void onServiceConnected(ComponentName name, IBinder service) { mPrewarmMessenger = new Messenger(service); - mPrewarmBound = true; } @Override public void onServiceDisconnected(ComponentName name) { - mPrewarmBound = false; mPrewarmMessenger = null; } }; @@ -386,8 +384,10 @@ public class KeyguardBottomAreaView extends FrameLayout implements View.OnClickL serviceIntent.setClassName(targetInfo.packageName, clazz); serviceIntent.setAction(CameraPrewarmService.ACTION_PREWARM); try { - getContext().bindServiceAsUser(serviceIntent, mPrewarmConnection, - Context.BIND_AUTO_CREATE, new UserHandle(UserHandle.USER_CURRENT)); + if (getContext().bindServiceAsUser(serviceIntent, mPrewarmConnection, + Context.BIND_AUTO_CREATE, new UserHandle(UserHandle.USER_CURRENT))) { + mPrewarmBound = true; + } } catch (SecurityException e) { Log.w(TAG, "Unable to bind to prewarm service package=" + targetInfo.packageName + " class=" + clazz, e); @@ -398,7 +398,7 @@ public class KeyguardBottomAreaView extends FrameLayout implements View.OnClickL public void unbindCameraPrewarmService(boolean launched) { if (mPrewarmBound) { - if (launched) { + if (mPrewarmMessenger != null && launched) { try { mPrewarmMessenger.send(Message.obtain(null /* handler */, CameraPrewarmService.MSG_CAMERA_FIRED)); |