Skip to content

Commit 85e486d

Browse files
committed
encapp: keep screen on an unlocked if possible
If screen is locked camera may fail. Signed-off-by: Johan Blome <johan@gunhildcarling.net>
1 parent 8e3c6c0 commit 85e486d

1 file changed

Lines changed: 10 additions & 5 deletions

File tree

app/src/main/java/com/facebook/encapp/MainActivity.java

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -146,8 +146,13 @@ private String getCurrentAppVersion() {
146146
protected void onCreate(Bundle savedInstanceState) {
147147
super.onCreate(savedInstanceState);
148148

149-
getWindow().addFlags(android.view.WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
150-
Log.d(TAG, "Screen will stay on during encoding to prevent system freezing");
149+
// Keep screen on, unlocked, and turn it on if off - required for camera access
150+
getWindow().addFlags(
151+
android.view.WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON |
152+
android.view.WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON |
153+
android.view.WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED |
154+
android.view.WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD);
155+
Log.d(TAG, "Screen will stay on and unlocked during encoding for camera access");
151156

152157
mVsyncHandler = new VsyncHandler();
153158
mVsyncHandler.start();
@@ -173,12 +178,12 @@ protected void onCreate(Bundle savedInstanceState) {
173178
// need to check permission strategy
174179
getTestSettings();
175180
CliSettings.setWorkDir(this, mExtraData);
176-
181+
177182
// Check if performance tracing is enabled
178183
if (mExtraData != null && mExtraData.containsKey(CliSettings.ENABLE_TRACING)) {
179184
CliSettings.setEnableTracing(mExtraData.getBoolean(CliSettings.ENABLE_TRACING, false));
180185
}
181-
186+
182187
boolean useNewMethod = true;
183188
if (mExtraData != null && mExtraData.size() > 0) {
184189
useNewMethod = !mExtraData.getBoolean(CliSettings.OLD_AUTH_METHOD, false);
@@ -795,7 +800,7 @@ private Thread PerformTest(Test test) {
795800
Log.d(TAG, "0. Custom encoder");
796801
coder = new CustomEncoder(test, this.getFilesDir().getPath());
797802
} else if (test.getConfigure().getCodec().startsWith("lcevc")) {
798-
803+
799804
Log.d(TAG, "1. LCEVC encoder");
800805
coder = LcevcFactory.createEncoderOrNull(test);
801806
if (coder == null) {

0 commit comments

Comments
 (0)