So, I looked at the AOSP source code to find out how Unknown Sources validation is performed. This is more complicated than the known source = android.
So, first of all, for the background, the verification and reporting of Unknown sources are generated by INSTALL_NON_MARKET_APP . This flag appears in several places, but PackageInstallerActivity takes the main place. Infact, this is the only place in AOSP where it appears and is used for some effective degree. Let's look at this here:
String callerPackage = getCallingPackage(); if (callerPackage != null && intent.getBooleanExtra( Intent.EXTRA_NOT_UNKNOWN_SOURCE, false)) { try { mSourceInfo = mPm.getApplicationInfo(callerPackage, 0); if (mSourceInfo != null) { if ((mSourceInfo.flags&ApplicationInfo.FLAG_SYSTEM) != 0) {
So PackageInstaller is a package included with AOSP that understands how to handle the ACTION_VIEW intent for APK files. PackageInstaller checks two things before it can install the application.
That application is a system application. If the application is a system application, it doesn’t care, it tells the package manager to install your application. This means that if Samsung places its Samsung store as a system application on Samsung devices, it will automatically become a reliable source. Infact, he will skip step 2 here.
If this system flag is not set. If this flag is not set, and therefore you are not a system application, then you are not a reliable source. At the same time, system applications can also skip the package installer and just go to the call to the hidden installPackage function, which can be found in PackageManagerService . This seems to be what GooglePlayStore does, since when I turn off the installation options in PackageInstallerActivity, I can still just install apks.
So, to summarize: Well-known sources are SYSTEM APPS not only applications downloaded from a Google game. Google play completely bypasses the INSTALL_NON_MARKET_APP flag, since it does not use PackageInstaller. If you are creating an application that is not a system application, the only method for installing the APK is to use PackageInstaller. Since your application is not a system application, it checks if unknown sources are disabled.
Andrew T.
source share