Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(95)

Issue 15035013: Keep screen on when there is an active WebRTC session on Android. (Closed)

Created:
7 years, 7 months ago by wjia(left Chromium)
Modified:
7 years, 7 months ago
CC:
chromium-reviews, joi+watch-content_chromium.org, darin-cc_chromium.org, jam, android-webview-reviews_chromium.org, michaelbai
Visibility:
Public.

Description

Keep screen on when there is an active WebRTC session on Android. When WebRTC session has video channel, the screen is kept on. R=bulach@chromium.org, joth@chromium.org, qinmin@chromium.org, sky@chromium.org Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=201424

Patch Set 1 #

Total comments: 2

Patch Set 2 : code review #

Total comments: 2

Patch Set 3 : rebase #

Patch Set 4 : code review: add braces #

Total comments: 2

Patch Set 5 : code review: remove unused |reason_| #

Patch Set 6 : code review: move all calculations on UI thread #

Total comments: 6

Patch Set 7 : code review: nits #

Patch Set 8 : #

Total comments: 4

Patch Set 9 : code review: static member #

Total comments: 7

Patch Set 10 : code review: nits #

Messages

Total messages: 26 (0 generated)
wjia(left Chromium)
7 years, 7 months ago (2013-05-17 02:27:19 UTC) #1
mkosiba (inactive)
https://chromiumcodereview.appspot.com/15035013/diff/1/content/browser/power_save_blocker_android.cc File content/browser/power_save_blocker_android.cc (right): https://chromiumcodereview.appspot.com/15035013/diff/1/content/browser/power_save_blocker_android.cc#newcode59 content/browser/power_save_blocker_android.cc:59: BrowserThread::PostTask( rather than spamming the UI thread maybe make ...
7 years, 7 months ago (2013-05-17 09:34:46 UTC) #2
wjia(left Chromium)
https://chromiumcodereview.appspot.com/15035013/diff/1/content/browser/power_save_blocker_android.cc File content/browser/power_save_blocker_android.cc (right): https://chromiumcodereview.appspot.com/15035013/diff/1/content/browser/power_save_blocker_android.cc#newcode59 content/browser/power_save_blocker_android.cc:59: BrowserThread::PostTask( On 2013/05/17 09:34:47, mkosiba wrote: > rather than ...
7 years, 7 months ago (2013-05-17 18:04:43 UTC) #3
wjia(left Chromium)
ping.
7 years, 7 months ago (2013-05-20 21:00:19 UTC) #4
joth
seems gtm, but +bulach to approve from power usage correctness side. +michaelbai FYI - your ...
7 years, 7 months ago (2013-05-20 22:10:36 UTC) #5
wjia(left Chromium)
braces have been added in patch set 4. https://chromiumcodereview.appspot.com/15035013/diff/10001/content/public/android/java/src/org/chromium/content/browser/ActivityContentVideoViewDelegate.java File content/public/android/java/src/org/chromium/content/browser/ActivityContentVideoViewDelegate.java (right): https://chromiumcodereview.appspot.com/15035013/diff/10001/content/public/android/java/src/org/chromium/content/browser/ActivityContentVideoViewDelegate.java#newcode50 content/public/android/java/src/org/chromium/content/browser/ActivityContentVideoViewDelegate.java:50: mActivity.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); ...
7 years, 7 months ago (2013-05-20 22:18:03 UTC) #6
bulach
lgtm, but qinmin owns the media module. I'm curious how regular videos keep the screen ...
7 years, 7 months ago (2013-05-21 06:58:18 UTC) #7
qinmin
https://chromiumcodereview.appspot.com/15035013/diff/30001/content/browser/power_save_blocker_android.cc File content/browser/power_save_blocker_android.cc (right): https://chromiumcodereview.appspot.com/15035013/diff/30001/content/browser/power_save_blocker_android.cc#newcode56 content/browser/power_save_blocker_android.cc:56: if (count == 1) { hmm...I think you don't ...
7 years, 7 months ago (2013-05-21 14:49:56 UTC) #8
wjia(left Chromium)
On 2013/05/21 14:49:56, qinmin wrote: > https://chromiumcodereview.appspot.com/15035013/diff/30001/content/browser/power_save_blocker_android.cc > File content/browser/power_save_blocker_android.cc (right): > > https://chromiumcodereview.appspot.com/15035013/diff/30001/content/browser/power_save_blocker_android.cc#newcode56 > ...
7 years, 7 months ago (2013-05-21 16:13:51 UTC) #9
qinmin
Then the problem becomes: if thread A calls increment, and see the value is 1, ...
7 years, 7 months ago (2013-05-21 17:12:58 UTC) #10
qinmin
https://chromiumcodereview.appspot.com/15035013/diff/30001/content/browser/power_save_blocker_android.cc File content/browser/power_save_blocker_android.cc (right): https://chromiumcodereview.appspot.com/15035013/diff/30001/content/browser/power_save_blocker_android.cc#newcode34 content/browser/power_save_blocker_android.cc:34: const std::string reason_; nit: you can remove this, not ...
7 years, 7 months ago (2013-05-21 17:18:40 UTC) #11
wjia(left Chromium)
On 2013/05/21 17:12:58, qinmin wrote: > Then the problem becomes: if thread A calls increment, ...
7 years, 7 months ago (2013-05-21 17:48:06 UTC) #12
wjia(left Chromium)
On 2013/05/21 17:18:40, qinmin wrote: > https://chromiumcodereview.appspot.com/15035013/diff/30001/content/browser/power_save_blocker_android.cc > File content/browser/power_save_blocker_android.cc (right): > > https://chromiumcodereview.appspot.com/15035013/diff/30001/content/browser/power_save_blocker_android.cc#newcode34 > ...
7 years, 7 months ago (2013-05-21 17:51:03 UTC) #13
qinmin
what is thread A calls increment, and then it calls decrement, the value becomes 0. ...
7 years, 7 months ago (2013-05-21 17:54:53 UTC) #14
wjia(left Chromium)
On 2013/05/21 17:54:53, qinmin wrote: > what is thread A calls increment, and then it ...
7 years, 7 months ago (2013-05-21 18:16:39 UTC) #15
qinmin
or you can protect the ctor and dtor with a global lock, so that all ...
7 years, 7 months ago (2013-05-21 19:42:15 UTC) #16
wjia(left Chromium)
On 2013/05/21 19:42:15, qinmin wrote: > or you can protect the ctor and dtor with ...
7 years, 7 months ago (2013-05-21 21:15:33 UTC) #17
qinmin
lgtm%nits https://chromiumcodereview.appspot.com/15035013/diff/56001/content/browser/power_save_blocker_android.cc File content/browser/power_save_blocker_android.cc (right): https://chromiumcodereview.appspot.com/15035013/diff/56001/content/browser/power_save_blocker_android.cc#newcode20 content/browser/power_save_blocker_android.cc:20: : type_(type) {} nit: can move to a ...
7 years, 7 months ago (2013-05-21 21:40:24 UTC) #18
wjia(left Chromium)
For owener's stamp: sky@ -> content/browser/ joth@ -> android_webview/ https://chromiumcodereview.appspot.com/15035013/diff/56001/content/browser/power_save_blocker_android.cc File content/browser/power_save_blocker_android.cc (right): https://chromiumcodereview.appspot.com/15035013/diff/56001/content/browser/power_save_blocker_android.cc#newcode20 content/browser/power_save_blocker_android.cc:20: ...
7 years, 7 months ago (2013-05-21 21:50:24 UTC) #19
sky
https://chromiumcodereview.appspot.com/15035013/diff/72001/content/browser/power_save_blocker_android.cc File content/browser/power_save_blocker_android.cc (right): https://chromiumcodereview.appspot.com/15035013/diff/72001/content/browser/power_save_blocker_android.cc#newcode13 content/browser/power_save_blocker_android.cc:13: int blocker_count = 0; Description? Also, since this is ...
7 years, 7 months ago (2013-05-21 21:57:48 UTC) #20
wjia(left Chromium)
PTAL. https://chromiumcodereview.appspot.com/15035013/diff/72001/content/browser/power_save_blocker_android.cc File content/browser/power_save_blocker_android.cc (right): https://chromiumcodereview.appspot.com/15035013/diff/72001/content/browser/power_save_blocker_android.cc#newcode13 content/browser/power_save_blocker_android.cc:13: int blocker_count = 0; On 2013/05/21 21:57:48, sky ...
7 years, 7 months ago (2013-05-21 22:17:03 UTC) #21
sky
LGTM https://chromiumcodereview.appspot.com/15035013/diff/77001/content/browser/power_save_blocker_android.cc File content/browser/power_save_blocker_android.cc (right): https://chromiumcodereview.appspot.com/15035013/diff/77001/content/browser/power_save_blocker_android.cc#newcode16 content/browser/power_save_blocker_android.cc:16: Delegate(PowerSaveBlockerType type) : type_(type) {} nit: explicit
7 years, 7 months ago (2013-05-21 23:54:38 UTC) #22
joth
lgtm % nit https://chromiumcodereview.appspot.com/15035013/diff/77001/content/browser/power_save_blocker_android.cc File content/browser/power_save_blocker_android.cc (right): https://chromiumcodereview.appspot.com/15035013/diff/77001/content/browser/power_save_blocker_android.cc#newcode42 content/browser/power_save_blocker_android.cc:42: ContentVideoView::KeepScreenOn(true); Having PowerSaveBlocker depend on ContentVideoView ...
7 years, 7 months ago (2013-05-21 23:56:07 UTC) #23
wjia(left Chromium)
https://chromiumcodereview.appspot.com/15035013/diff/77001/content/browser/power_save_blocker_android.cc File content/browser/power_save_blocker_android.cc (right): https://chromiumcodereview.appspot.com/15035013/diff/77001/content/browser/power_save_blocker_android.cc#newcode16 content/browser/power_save_blocker_android.cc:16: Delegate(PowerSaveBlockerType type) : type_(type) {} On 2013/05/21 23:54:38, sky ...
7 years, 7 months ago (2013-05-22 02:17:51 UTC) #24
wjia(left Chromium)
Committed patchset #10 manually as r201424 (presubmit successful).
7 years, 7 months ago (2013-05-22 02:21:48 UTC) #25
joth
7 years, 7 months ago (2013-05-24 18:06:59 UTC) #26
Message was sent while issue was closed.
https://chromiumcodereview.appspot.com/15035013/diff/77001/content/browser/po...
File content/browser/power_save_blocker_android.cc (right):

https://chromiumcodereview.appspot.com/15035013/diff/77001/content/browser/po...
content/browser/power_save_blocker_android.cc:42:
ContentVideoView::KeepScreenOn(true);
On 2013/05/22 02:17:51, wjia wrote:
> On 2013/05/21 23:56:08, joth wrote:
> > Having PowerSaveBlocker depend on ContentVideoView seems a  random
dependency.
> > And as this is static, it relies on the (possibly null?) static instance
> inside
> > ContentVideoView to get to the activity to find the window is awkward; it
> would
> > be better if PowerSaveBlocker instances could be associated with a specific
> > android view, and then you would  add/remove View.KEEP_SCREEN_ON flag to
that
> > view only.
> > That's a pretty major change to PowerSaveBlocker though I imagine, and I
can't
> > think of anything less brittle to suggest.
> 
> Yeah, we could iterate later.

I realized part of the answer - the screen_on state should be handled via
ViewAndroid and/or WindowAndroid. In terms of correctness, perhaps the nicest
thing would be every time a ApplyBlock() call is made we create a small View
instance with the KEEP_SCREEN_ON flag and attach to the window, and
RemoveBlock() releases that View. This way it plays nicely with any other usage
of the flags that an application may have (i.e. we don't want to remove the flag
from the window if the application is also keeping it on for another reason we
don't know about)

The only remaining question then is from here (effectively, from the
PowerSaveBlocker c'tor) how do we find the appropriate WindowAndroid to attach
to? I think that implies a cross platform change to always pass the window (or
view) into said c'tor.

Powered by Google App Engine
This is Rietveld 408576698