Android 7.1 prohibits third-party sharing of non source APK split screen method

Two methods

The first method is to decompile apk directly and get Android manifest XML file; The second way is to go to the framework layer. There is a file dedicated to parsing apk data, where changes are made.

1. apk decompilation method

This method focuses on the reverse compilation of apk. I spent most of my time looking up tutorials online. Although I wasted a lot of time, I learned it in the end.
There are many decompilation methods in CSDN, which are described in detail, but we only need to compile androidmanifest XML is OK. There is no need to compile the java source code.
Compile androidmanifest Add a line of code directly after XML, which can be done in androidmanifest In the XML file, find the application node or activity node and add the following:

android:resizeableActivity="false"

After adding, you can prohibit split screen, which is also the most commonly used and easiest method. But for some apks that can be decompiled, it's better not to change other people's official software, such as QQ and wechat. Because I don't know whether this behavior is illegal or not, and I heard that the previous use of third-party QQ and wechat should be sealed. So don't change it easily. This method is only applicable to those irrelevant apks. Don't touch some commercial apks to avoid any trouble.

2,PackageParser.java

Location: there is a packageparser in frameworks\base\core\java\android\content\pm Java class file.

In the first method, you must wonder why it's in Android manifest After adding a line of code to XML, you can prohibit the application from dividing the screen. I thought so at first. Later, I read a lot of blog tutorials and spent a week!!! Finally tracked this file!!!
(these are just my guesses) this file is specially used to parse the files of the installation package, including androidmanifest The line by line code in XML is parsed. Sure enough, looking down the code, a key position is found!
be careful:

final boolean resizeableSetExplicitly

                = sa.hasValue(R.styleable.AndroidManifestActivity_resizeableActivity);            
                 //Trace to Android in Android manifest: resizeableactivity = "true" or "false"
   
        final boolean resizeable = sa.getBoolean(
    
                R.styleable.AndroidManifestActivity_resizeableActivity, appDefault);
     
        if (resizeable) {
            if (sa.getBoolean(R.styleable.AndroidManifestActivity_supportsPictureInPicture,
                    false)) {
                a.info.resizeMode = RESIZE_MODE_RESIZEABLE_AND_PIPABLE;
            } else {
                a.info.resizeMode = RESIZE_MODE_RESIZEABLE;
            }
        } else if (owner.applicationInfo.targetSdkVersion >= Build.VERSION_CODES.N
                || resizeableSetExplicitly) {
            a.info.resizeMode = RESIZE_MODE_UNRESIZEABLE;
        } else if (!a.info.isFixedOrientation() && (a.info.flags & FLAG_IMMERSIVE) == 0) {
            a.info.resizeMode = RESIZE_MODE_FORCE_RESIZEABLE;

See the first line of code above and compare the first method. Do you think everything is figured out!!! Yes, it is in this position that the Android manifest is parsed The attribute Android: resizableactivity = "true" or "false" set in XML!!!
After parsing to true, a series of operations will be carried out, that is, what is in the if statement. Due to the time relationship, the general meaning is to judge whether he supports the picture in picture mode after it is true. In short, it supports split screen when parsing to true (I guess)
After analyzing the third-party apk, we can add a judgment:
if resolved package name = = name of the third party apk package whose screen splitting is prohibited
{
final boolean resizeableSetExplicitly = false; // Directly make this parameter equal to false, violence!!!
} else {
··· ···
}
That's OK. I'm afraid I'm not complete enough. I'll post the code to you:

if(owner.packageName == "Package names that prohibit third-party screen splitting"){         //ldq
			final boolean resizeableSetExplicitly = false; 
				Log.e( "LDQ ", "owner.packageName :" + owner.packageName );       //The log here can be deleted
		}else{			         
			final boolean resizeableSetExplicitly
                = sa.hasValue(R.styleable.AndroidManifestActivity_resizeableActivity);             //Trace to Android in Android manifest: resizeableactivity = "true" or "false"
        final boolean resizeable = sa.getBoolean(
                R.styleable.AndroidManifestActivity_resizeableActivity, appDefault);

        if (resizeable) {
            if (sa.getBoolean(R.styleable.AndroidManifestActivity_supportsPictureInPicture,
                    false)) {
                a.info.resizeMode = RESIZE_MODE_RESIZEABLE_AND_PIPABLE;
            } else {
                a.info.resizeMode = RESIZE_MODE_RESIZEABLE;
            }
        } else if (owner.applicationInfo.targetSdkVersion >= Build.VERSION_CODES.N
                || resizeableSetExplicitly) {
            a.info.resizeMode = RESIZE_MODE_UNRESIZEABLE;
        } else if (!a.info.isFixedOrientation() && (a.info.flags & FLAG_IMMERSIVE) == 0) {
            a.info.resizeMode = RESIZE_MODE_FORCE_RESIZEABLE;
        } }                       // by ldq

For the third-party apk package name acquisition is more simple, there are a lot of online methods!!!

summary

Because a third-party source free apk changed according to the work needs does not support split screen, but there is no way for the third-party source free apk to prohibit split screen on the Internet, so I have explored and pondered for a week, invented this method and selflessly dedicated to you! If you have any questions, you can leave a message below. If you are eager to know one-on-one, you can follow my wechat official account (hahaha, a bit like advertising):

Tags: Android xml

Posted by kamasheto on Sun, 22 May 2022 10:02:46 +0300