diff options
author | John Spurlock <jspurlock@google.com> | 2012-12-04 13:45:10 -0800 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2012-12-04 13:45:50 -0800 |
commit | 33669f35e4b63bec10bb7202b94340ebd41fbb10 (patch) | |
tree | 061c2dc18ee46d64199d0897697f055588c58fab /services | |
parent | 80a90efcbf32b30b886380c67585ddfb41c35437 (diff) | |
parent | 006f567c214d67752cc7c2b6446c328744f40af7 (diff) | |
download | frameworks_base-33669f35e4b63bec10bb7202b94340ebd41fbb10.zip frameworks_base-33669f35e4b63bec10bb7202b94340ebd41fbb10.tar.gz frameworks_base-33669f35e4b63bec10bb7202b94340ebd41fbb10.tar.bz2 |
Merge "Kill dreams that do not create a timely service connection." into jb-mr1.1-dev
Diffstat (limited to 'services')
-rw-r--r-- | services/java/com/android/server/dreams/DreamController.java | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/services/java/com/android/server/dreams/DreamController.java b/services/java/com/android/server/dreams/DreamController.java index 1ab6a77..45ae2c5 100644 --- a/services/java/com/android/server/dreams/DreamController.java +++ b/services/java/com/android/server/dreams/DreamController.java @@ -44,6 +44,9 @@ import java.util.NoSuchElementException; final class DreamController { private static final String TAG = "DreamController"; + // How long we wait for a newly bound dream to create the service connection + private static final int DREAM_CONNECTION_TIMEOUT = 5 * 1000; + private final Context mContext; private final Handler mHandler; private final Listener mListener; @@ -58,6 +61,16 @@ final class DreamController { private DreamRecord mCurrentDream; + private final Runnable mStopUnconnectedDreamRunnable = new Runnable() { + @Override + public void run() { + if (mCurrentDream != null && mCurrentDream.mBound && !mCurrentDream.mConnected) { + Slog.w(TAG, "Bound dream did not connect in the time allotted"); + stopDream(); + } + } + }; + public DreamController(Context context, Handler handler, Listener listener) { mContext = context; mHandler = handler; @@ -116,6 +129,7 @@ final class DreamController { } mCurrentDream.mBound = true; + mHandler.postDelayed(mStopUnconnectedDreamRunnable, DREAM_CONNECTION_TIMEOUT); } public void stopDream() { @@ -128,6 +142,8 @@ final class DreamController { Slog.i(TAG, "Stopping dream: name=" + oldDream.mName + ", isTest=" + oldDream.mIsTest + ", userId=" + oldDream.mUserId); + mHandler.removeCallbacks(mStopUnconnectedDreamRunnable); + if (oldDream.mSentStartBroadcast) { mContext.sendBroadcastAsUser(mDreamingStoppedIntent, UserHandle.ALL); } @@ -200,6 +216,7 @@ final class DreamController { public final int mUserId; public boolean mBound; + public boolean mConnected; public IDreamService mService; public boolean mSentStartBroadcast; @@ -231,6 +248,7 @@ final class DreamController { mHandler.post(new Runnable() { @Override public void run() { + mConnected = true; if (mCurrentDream == DreamRecord.this && mService == null) { attach(IDreamService.Stub.asInterface(service)); } |