Черный экран на устройствах oppo только при использовании flutter_pdfview с FLAG_SECURE, чтобы предотвратить создание снимков экрана

Привет, я использую FLAG_SECURE, чтобы избежать снимков экрана с пакетом flutter_pdfview , пакет хорошо работает с FLAG_SECURE на всех устройствах, ожидаемых на противоположных устройствах, он отображает черный экран, я использую собственный код в Android, чтобы установить FLAG_SECURE, я пытался использовать пакет flutter_windowmanager , но у меня есть такая же проблема с черным экраном только на устройствах oppo

Это мой собственный код в MainActivity.kt

      package com.online.education.mostafa.elsheikh
import android.os.Bundle
import android.util.Log
import android.view.SurfaceView
import android.view.View
import android.view.ViewGroup
import android.view.WindowManager
import androidx.annotation.NonNull
import io.flutter.embedding.android.FlutterActivity
import io.flutter.embedding.engine.FlutterEngine
import io.flutter.plugins.GeneratedPluginRegistrant

class MainActivity: FlutterActivity() {

override fun configureFlutterEngine(@nonnull flutterEngine: FlutterEngine) {
GeneratedPluginRegistrant.registerWith(flutterEngine);
}

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
if (!setSecureSurfaceView()) {
Log.e("MainActivity", "Could not secure the MainActivity!")
// React as appropriate.
}
}

private fun setSecureSurfaceView(): Boolean {
val content = findViewById(android.R.id.content)
if (!isNonEmptyContainer(content)) {
return false
}
val splashView = content.getChildAt(0)
if (!isNonEmptyContainer(splashView)) {
return false
}
val flutterView = (splashView as ViewGroup).getChildAt(0)
if (!isNonEmptyContainer(flutterView)) {
return false
}
val surfaceView = (flutterView as ViewGroup).getChildAt(0)
if (surfaceView !is SurfaceView) {
return false
}
surfaceView.setSecure(true)
this.window.setFlags(WindowManager.LayoutParams.FLAG_SECURE, WindowManager.LayoutParams.FLAG_SECURE)
return true
}

private fun isNonEmptyContainer(view: View): Boolean {
if (view !is ViewGroup) {
return false
}
if (view.childCount < 1) {
return false
}
return true
}
}

Любая помощь, пожалуйста ??

0 ответов

Другие вопросы по тегам