Commit b500c2e0 authored by Kuo Jen Wei's avatar Kuo Jen Wei Committed by Commit Bot

CCA: Check external monitor with screen backlight off

Add check of no external monitor plugged in with screen backlight forced
off event to judge whether to suspend camera stream.

Bug: 1114967
Test: Pluggin both external camera and external monitor, check CCA's
preview is still on after closing lid of device.

Change-Id: Ia07e1efe9d21814521a62a4ad1c63324221b991d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2351579Reviewed-by: default avatarShik Chen <shik@chromium.org>
Commit-Queue: Kuo Jen Wei <inker@chromium.org>
Auto-Submit: Kuo Jen Wei <inker@chromium.org>
Cr-Commit-Position: refs/heads/master@{#797514}
parent b0835455
...@@ -24,6 +24,7 @@ export const State = { ...@@ -24,6 +24,7 @@ export const State = {
GRID_GOLDEN: 'golden', GRID_GOLDEN: 'golden',
GRID: 'grid', GRID: 'grid',
HAS_BACK_CAMERA: 'has-back-camera', HAS_BACK_CAMERA: 'has-back-camera',
HAS_EXTERNAL_SCREEN: 'has-external-screen',
HAS_FRONT_CAMERA: 'has-front-camera', HAS_FRONT_CAMERA: 'has-front-camera',
MAX_WND: 'max-wnd', MAX_WND: 'max-wnd',
MIC: 'mic', MIC: 'mic',
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
// found in the LICENSE file. // found in the LICENSE file.
import {browserProxy} from '../browser_proxy/browser_proxy.js'; import {browserProxy} from '../browser_proxy/browser_proxy.js';
import {assert, assertInstanceof} from '../chrome_util.js'; import {assert, assertInstanceof, promisify} from '../chrome_util.js';
import { import {
PhotoConstraintsPreferrer, // eslint-disable-line no-unused-vars PhotoConstraintsPreferrer, // eslint-disable-line no-unused-vars
VideoConstraintsPreferrer, // eslint-disable-line no-unused-vars VideoConstraintsPreferrer, // eslint-disable-line no-unused-vars
...@@ -257,10 +257,6 @@ export class Camera extends View { ...@@ -257,10 +257,6 @@ export class Camera extends View {
this.start(); this.start();
} }
}); });
state.addObserver(state.State.SCREEN_OFF_AUTO, () => this.start());
this.configuring_ = null;
} }
/** /**
...@@ -280,6 +276,34 @@ export class Camera extends View { ...@@ -280,6 +276,34 @@ export class Camera extends View {
}; };
const screenState = await helper.initScreenStateMonitor(setScreenOffAuto); const screenState = await helper.initScreenStateMonitor(setScreenOffAuto);
setScreenOffAuto(screenState); setScreenOffAuto(screenState);
const updateExternalScreen = async () => {
const allInfo = await promisify(chrome.system.display.getInfo)(
{singleUnified: false});
const hasExternalScreen = allInfo.some(({isInternal}) => !isInternal);
state.set(state.State.HAS_EXTERNAL_SCREEN, hasExternalScreen);
};
await updateExternalScreen();
chrome.system.display.onDisplayChanged.addListener(updateExternalScreen);
const checkScreenOff = () => {
if (this.screenOff_) {
this.start();
}
};
state.addObserver(state.State.SCREEN_OFF_AUTO, checkScreenOff);
state.addObserver(state.State.HAS_EXTERNAL_SCREEN, checkScreenOff);
}
/**
* @return {boolean} If the App window is invisible to user with respect to
* screen off state.
* @private
*/
get screenOff_() {
return state.get(state.State.SCREEN_OFF_AUTO) &&
!state.get(state.State.HAS_EXTERNAL_SCREEN);
} }
/** /**
...@@ -305,8 +329,8 @@ export class Camera extends View { ...@@ -305,8 +329,8 @@ export class Camera extends View {
*/ */
isSuspended() { isSuspended() {
return this.locked_ || browserProxy.isMinimized() || return this.locked_ || browserProxy.isMinimized() ||
state.get(state.State.SUSPEND) || state.get(state.State.SUSPEND) || this.screenOff_ ||
state.get(state.State.SCREEN_OFF_AUTO) || this.isTabletBackground_(); this.isTabletBackground_();
} }
/** /**
......
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
"videoCapture", "videoCapture",
"audioCapture", "audioCapture",
"storage", "storage",
"system.display",
"unlimitedStorage", "unlimitedStorage",
"chromeosInfoPrivate", "chromeosInfoPrivate",
"metricsPrivate", "metricsPrivate",
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment