Android 11.0 system framework disables screenshot and screen recording functions

1 Introduction

In the product development of 11.0, for some product development needs, in some educational products, the system screenshot and screen recording functions are required to be removed, so as to prevent users from taking screenshots and recording to protect the resources of an app, so it is necessary
to There are restrictions in the system that do not allow screenshots and recordings.

2. The system framework disables the core class of screen capture and screen recording functions

    frameworks\native\services\surfaceflinger\Layer.cpp
    frameworks\base\core\java\android\app\ActivityThread.java

3. Analysis and implementation of core functions of system framework that disables screen capture and screen recording functions

ActivityThread is a very important component. It functions like the soul of Android applications. It handles most of the work in applications and activities, such as creating new application instances, loading and managing classes, and creating new activities.
ActivityThread is the main thread (UI thread) of Android applications. Speaking of ActivityThread, we have to mention the creation and startup process of Activity and ActivityManagerService.

 In the system, you can disable the screen recording and screen capture functions in the app. You can also disable the screen capture and screen recording functions in the system source code. First, let’s take a look at how to disable the screen capture and screen recording functions in the app. Disable it in the app. The relevant source code for screen recording and screenshot functions is as follows:

            @Override
            protected void onCreate(Bundle savedInstanceState) {
         
                getWindow().addFlags(WindowManager.LayoutParams.FLAG_SECURE);
         
                super.onCreate(savedInstanceS

Guess you like

Origin blog.csdn.net/baidu_41666295/article/details/132951872