安卓已知来源[英] Android Known Sources

本文是小编为大家收集整理的关于安卓已知来源的处理/解决方法,可以参考本文帮助大家快速定位并解决问题,中文翻译不准确的可切换到English标签页查看源文。

问题描述

当您从未知来源安装APK文件时,Android将抱怨并验证要安装该APK文件.必须签到此文件到已知源的列表.

我有兴趣知道已知来源列表位于Android AOSP上.

编辑: 如果我的问题令人困惑,我深表歉意,但允许我澄清.当您从USB或电子邮件安装APK时,Android将提示您在未知的源中提示您安装应用程序.此时,您可以拒绝或接受该事实并继续前进.为了确定应用程序是否从未知的源安装,我假设是有一个已知的AOP中包含的已知源列表.我可能是错误的,因为一个评论指出它只是从Google Play商店安装的所有应用程序.

我想看看这个检查完成的地方.如果没有列表,则在AOSP中的哪个检查,或者如果有列表,则在哪里是已知来源的列表.

推荐答案

所以我现在看了通过AOSP源代码来了解如何完成该未知源检查.它比已知的来源更复杂= Android播放.

所以首先是背景,由 install_non_market_app生成该未知源检查和消息.这个国旗在很少的地方出现,但主席地在 packageinstalleractivity . INFACT,这是AOP中唯一的位置,它曾经是一些有效程度.让我们看看这里:

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) {
                    // System apps don't need to be approved.
                    initiateInstall();
                    return;
                }
            }
        } catch (NameNotFoundException e) {
        }
    }
    if (!isInstallingUnknownAppsAllowed()) {
         //ask user to enable setting first
         showDialogInner(DLG_UNKNOWN_APPS);
         return;
     }
    initiateInstall();

所以packageInstaller是一个包,包括AOSP,了解如何处理APK文件的Action_View意图. PackageInstaller在允许安装应用程序之前检查两件事.

  1. 该应用程序是一个系统应用程序.如果一个应用程序是一个系统应用程序,它不关心,它告诉包管理器安装您的应用程序.这意味着如果三星将他们的三星市场存储作为Samsung设备上的系统应用程序,那么它是自动可信的源. INFACT,它将在此跳过步骤2.

  2. 如果未设置该系统标志.如果该标志未设置,因此您不是系统应用程序,因此您不是可信源.据说,系统应用程序也可以跳过包安装程序,只需直接调用隐藏的函数installpackage,它可以在 packagemanagerservice .这似乎是GooglePlayStore所做的那样,就像我禁用PackageInstallActivity上的安装功能时,我仍然可以安装APKS.

总结:已知的来源是系统应用程序,而不仅仅是从Google Play下载的应用程序. Google播放完全避免install_non_market_app标志,因为它不使用packageInstaller.如果您创建一个不是系统应用程序的应用程序,则唯一用于安装APK的方法是使用ProdantInstaller.由于您的应用不是系统应用程序,它将检查是否已禁用未知源.

其他推荐答案

作为评论已经建议,"源"表示"原点"(如应用程序包存储器),不是"源代码".这与AOSP完全无关.

通常,这意味着"从Google Play下载的应用程序"(和以前的Android市场).

我说"通常是",因为你可以想象地在自定义叉子中定义另一个源 - 但是

本文地址:https://www.itbaoku.cn/post/1937925.html

问题描述

When you install an apk file that is from an unknown source, Android will complain and verify that you want to install that apk file. This file must be checked to a list of known sources.

I am interested to know where that list of known sources is located on Android AOSP.

Edit: I apologize if my question is confusing but allow me to clarify. When you install an APK from usb or email Android will prompt you saying you are installing an app from an unknown source. At this point you can either deny or accept that fact and move on. In order to determine if an app is being installed from an unknown source, I am assuming that there is a list of known sources that is included with AOSP. I may be wrong, as one comment has pointed out that it's just all apps that are not installed from the google play store.

I would like to see where this check is done. Where in AOSP is this check made if there is no list, or where is this list of known sources if there is a list.

推荐答案

So I have looked through the AOSP Source code now to see how that Unknown Sources check is done. It is more complicated than known source = android play.

So first of all for background, that Unknown Sources check and message are generated by INSTALL_NON_MARKET_APP. This flag comes up in few places, but the main place is in PackageInstallerActivity. Infact, this is the only place in AOSP where it comes up and is used to some effective degree. Let's look at that 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) {
                    // System apps don't need to be approved.
                    initiateInstall();
                    return;
                }
            }
        } catch (NameNotFoundException e) {
        }
    }
    if (!isInstallingUnknownAppsAllowed()) {
         //ask user to enable setting first
         showDialogInner(DLG_UNKNOWN_APPS);
         return;
     }
    initiateInstall();

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 allows an app to be installed.

  1. That the app is a system app. If an app is a system app, it doesn't care, it tells the package manager to install your app. This means that if Samsung puts their Samsung market store as a system app on Samsung devices, then it is automatically a trusted source. Infact, it will skip step 2 here.

  2. If that system flag is not set. If that flag is not set, and thus you are not a system app, then therefore you are not a trusted source. That being said, System apps can also skip the package installer and just go straight to calling the hidden function installPackage which can be found in PackageManagerService. This seems to be what the GooglePlayStore does, as when I disable the installation capabilities on PackageInstallerActivity I can still install apks just fine.

So to sum up: Known sources are SYSTEM APPS not just applications downloaded from google play. Google play completely circumvents the INSTALL_NON_MARKET_APP flag because it does not use the PackageInstaller. If you create an app that is not a system app, your only method for installing APKs is to use the PackageInstaller. Since your app is not a system app it will check to see if unknown sources is disabled.

其他推荐答案

As the comments have already suggested, the word "sources" means "place of origin" (as in, application package repositories), not "source code". This is completely unrelated to the AOSP.

Usually, that means "applications downloaded from Google Play" (and the previous Android Market).

I say "usually", because you could conceivably define another source in a custom fork - haven't encountered this personally 'though (don't know how that meshes with Samsung's app store).