diff --git a/app/src/visionglass/java/com/igalia/wolvic/PlatformActivity.java b/app/src/visionglass/java/com/igalia/wolvic/PlatformActivity.java index f2e00259f7b..4c6f7f2ce19 100644 --- a/app/src/visionglass/java/com/igalia/wolvic/PlatformActivity.java +++ b/app/src/visionglass/java/com/igalia/wolvic/PlatformActivity.java @@ -241,7 +241,6 @@ private void onConnectionStateChanged(PhoneUIViewModel.ConnectionState connectio private void initVisionGlassPhoneUI() { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); - getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); setTheme(R.style.FxR_Dark); ContextThemeWrapper themedContext = new ContextThemeWrapper(this, R.style.Theme_WolvicPhone); @@ -249,6 +248,7 @@ private void initVisionGlassPhoneUI() { mBinding = DataBindingUtil.setContentView(this, R.layout.visionglass_layout); mBinding = DataBindingUtil.inflate(themedInflater, R.layout.visionglass_layout, null, false); setContentView(mBinding.getRoot()); + getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); mViewModel = new ViewModelProvider(this).get(PhoneUIViewModel.class); mBinding.setViewModel(mViewModel); @@ -265,8 +265,6 @@ private void initVisionGlassPhoneUI() { Button backButton = findViewById(R.id.back_button); backButton.setOnClickListener(v -> onBackPressed()); - - getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); } private void showAlertDialog(String description) { @@ -404,6 +402,7 @@ public boolean onGenericMotionEvent(MotionEvent aEvent) { protected void onPause() { Log.d(LOGTAG, "PlatformActivity onPause"); super.onPause(); + getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); // This check is needed to prevent a crash when pausing before 3D mode has started. if (mActivePresentation != null) { @@ -425,6 +424,7 @@ protected void onPause() { protected void onResume() { Log.d(LOGTAG, "PlatformActivity onResume"); super.onResume(); + getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); registerPhoneIMUListener();