Chromium Code Reviews| Index: chromecast/browser/android/apk/src/org/chromium/chromecast/shell/CastShellActivity.java |
| diff --git a/chromecast/browser/android/apk/src/org/chromium/chromecast/shell/CastShellActivity.java b/chromecast/browser/android/apk/src/org/chromium/chromecast/shell/CastShellActivity.java |
| index 344d9c1c451a928dac79a926a19c7508bba57fa3..85c91ed2c43f7c87e85a4ada4e5921e08b327cee 100644 |
| --- a/chromecast/browser/android/apk/src/org/chromium/chromecast/shell/CastShellActivity.java |
| +++ b/chromecast/browser/android/apk/src/org/chromium/chromecast/shell/CastShellActivity.java |
| @@ -41,6 +41,7 @@ public class CastShellActivity extends Activity { |
| private CastWindowManager mCastWindowManager; |
| private AudioManager mAudioManager; |
| private BroadcastReceiver mBroadcastReceiver; |
| + private boolean mHadFocusWhenPaused = true; |
| // Native window instance. |
| // TODO(byungchul, gunsch): CastShellActivity, CastWindowAndroid, and native CastWindowAndroid |
| @@ -56,6 +57,16 @@ public class CastShellActivity extends Activity { |
| return true; |
| } |
| + /** |
| + * Intended to be called from "onStop" to determine if this is a "legitimate" stop or not. |
| + * When starting CastShellActivity from the TV in sleep mode, an extra onPause/onStop will be |
| + * fired. |
| + * Details: http://stackoverflow.com/questions/25369909/ |
| + */ |
| + protected boolean isStopping() { |
| + return mHadFocusWhenPaused; |
| + } |
| + |
| @Override |
| protected void onCreate(final Bundle savedInstanceState) { |
| if (DEBUG) Log.d(TAG, "onCreate"); |
| @@ -153,10 +164,14 @@ public class CastShellActivity extends Activity { |
| @Override |
| protected void onStop() { |
| - if (DEBUG) Log.d(TAG, "onStop"); |
| - // As soon as the cast app is no longer in the foreground, we ought to immediately tear |
| - // everything down. |
| - finishGracefully(); |
| + if (DEBUG) Log.d(TAG, "onStop, window focus = " + hasWindowFocus()); |
| + |
| + if (isStopping()) { |
| + // As soon as the cast app is no longer in the foreground, we ought to immediately tear |
| + // everything down. |
| + finishGracefully(); |
| + } |
| + |
| super.onStop(); |
| } |
| @@ -179,7 +194,8 @@ public class CastShellActivity extends Activity { |
| @Override |
| protected void onPause() { |
| - if (DEBUG) Log.d(TAG, "onPause"); |
| + if (DEBUG) Log.d(TAG, "onPause, window focus = " + hasWindowFocus()); |
| + mHadFocusWhenPaused = hasWindowFocus(); |
|
byungchul
2015/01/22 00:48:30
Is it true when screen goes off?
gunsch
2015/01/22 00:52:24
Yes.
01-21 16:50:45.348 I/PowerManagerService( 17
byungchul
2015/01/22 01:15:20
We should check if that is an intended behavior. A
gunsch
2015/01/22 01:26:26
Oh, I think I see what you're asking. When screen
|
| // Release the audio focus. Note that releasing audio focus does not stop audio playback, |
| // it just notifies the framework that this activity has stopped playing audio. |