[英]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
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; }
}
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);
}
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.