简体   繁体   English

如何防止我的应用程序内容来自具有“SYSTEM_ALERT_WINDOW”权限的应用程序

[英]How prevent my app content from apps that has “SYSTEM_ALERT_WINDOW” permission

I am implementing a video streaming App and want to secure my content I have used我正在实施视频流应用程序并希望保护我使用过的内容

 getWindow().setFlags(LayoutParams.FLAG_SECURE, LayoutParams.FLAG_SECURE); 

It stopped taking screenshot of app, but if recording app start before my app user can hear content它停止截取应用程序的屏幕截图,但如果在我的应用程序用户可以听到内容之前开始录制应用程序

And some apps able to record video.还有一些应用程序能够录制视频。

I thought to prevent other apps that has ' SYSTEM_ALERT_WINDOW ' permission from capturing my content, so i want to know how to do that?我想阻止其他具有“ SYSTEM_ALERT_WINDOW权限的应用程序捕获我的内容,所以我想知道该怎么做?

Note : MinSdk is 21注意:MinSdk 是 21

Checking if you have the drawOverlays permission is safer using this:使用这个检查你是否有 drawOverlays 权限更安全:

public static boolean canDrawOverlayViews(Context con){
        if(Build.VERSION.SDK_INT< Build.VERSION_CODES.LOLLIPOP){return true;}
        try { 
            return Settings.canDrawOverlays(con); 
        }
        catch(NoSuchMethodError e){ 
            return canDrawOverlaysUsingReflection(con); 
        }
    }
    
    
    public static boolean canDrawOverlaysUsingReflection(Context context) {
    
        try {
    
            AppOpsManager manager = (AppOpsManager) context.getSystemService(Context.APP_OPS_SERVICE);
            Class clazz = AppOpsManager.class;
            Method dispatchMethod = clazz.getMethod("checkOp", new Class[] { int.class, int.class, String.class });
            //AppOpsManager.OP_SYSTEM_ALERT_WINDOW = 24
            int mode = (Integer) dispatchMethod.invoke(manager, new Object[] { 24, Binder.getCallingUid(), context.getApplicationContext().getPackageName() });
    
            return AppOpsManager.MODE_ALLOWED == mode;
    
        } catch (Exception e) {  return false;  }
    
    }

Requesting the permission:请求权限:

public static void requestOverlayDrawPermission(Activity act, int requestCode){
    Intent intent = new Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION, Uri.parse("package:" + act.getPackageName()));
    act.startActivityForResult(intent, requestCode);

}

It is possible if you on android 4.4+, you can specify MediaStore.EXTRA_OUTPUT这是可能的,如果你在 android 4.4+,你可以指定 MediaStore.EXTRA_OUTPUT

Starting in Android 4.4, the owner, group and modes of files on external storage devices are now synthesized based on directory structure.从Android 4.4开始,对外存文件的属主、属组、模式按照目录结构进行合成。 This enables apps to manage their package-specific directories on external storage without requiring they hold the broad WRITE_EXTERNAL_STORAGE permission.这使应用程序能够在外部存储上管理其特定于包的目录,而无需它们拥有广泛的 WRITE_EXTERNAL_STORAGE 权限。 For example, the app with package name com.example.foo can now freely access Android/data/com.example.foo/ on external storage devices with no permissions.例如,package 名称为 com.example.foo 的应用程序现在可以在没有权限的情况下自由访问外部存储设备上的 Android/data/com.example.foo/。 These synthesized permissions are accomplished by wrapping raw storage devices in a FUSE daemon.这些综合权限是通过将原始存储设备包装在 FUSE 守护进程中来实现的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 防止带有 SYSTEM_ALERT_WINDOW 的应用程序遮挡我的应用程序 - Prevent application with SYSTEM_ALERT_WINDOW from obscuring my application 如何在我的 android 应用程序中根据请求自动授予 SYSTEM_ALERT_WINDOW 权限? - How do I grant SYSTEM_ALERT_WINDOW permission automatically on request, in my android App? 如何获取启用了 SYSTEM_ALERT_WINDOW 权限的已安装应用程序? - How to get installed apps which have SYSTEM_ALERT_WINDOW permission enabled? 请求 SYSTEM_ALERT_WINDOW 权限后返回应用程序 - Return to app after requesting SYSTEM_ALERT_WINDOW permission 如何检查权限在Android Lollipop上授予SYSTEM_ALERT_WINDOW? - How to check permission SYSTEM_ALERT_WINDOW is granted on Android Lollipop? 如何在本机反应中删除 SYSTEM_ALERT_WINDOW android 权限 - How remove SYSTEM_ALERT_WINDOW android permission in react native Lux的SYSTEM_ALERT_WINDOW权限使我们的部分应用程序无法运行 - SYSTEM_ALERT_WINDOW permission from Lux renders parts of our app inoperable 如何访问SYSTEM_ALERT_WINDOW权限运行时间? - How to access SYSTEM_ALERT_WINDOW permission run time? SYSTEM_ALERT_WINDOW 的运行时权限 - Runtime permission for SYSTEM_ALERT_WINDOW Android SYSTEM_ALERT_WINDOW权限 - Android SYSTEM_ALERT_WINDOW permission
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM