PackageManagerService.java

InstallParams
handleStartCopy 下把ret 直接改成
int ret =PackageManager.XXXXX ;//非PackageManager.INSTALL_SUCCEEDED; 

如果需要其他需求也可以在这里修改

如:

1. 判断apk名字来判断是否安装

2.判断apk签名来决定是否安装

ps:apk安装错误码

安装APK的错误码,定义在android源码中的这个文件中:
frameworks\base\core\java\android\content\pm\PackageManager.java

/**
* if the package is already installed.
* 程序已经存在
*/
public static final int INSTALL_FAILED_ALREADY_EXISTS = -1;

/**
* if the package archive file is invalid.
* 无效的APK
*/
public static final int INSTALL_FAILED_INVALID_APK = -2;

/**
* if the URI passed in is invalid.
* 无效的链接
*/
public static final int INSTALL_FAILED_INVALID_URI = -3;

/**
* if the package manager service found that the device
*   didn't have enough storage space to install the app.
* 没有足够的存储空间
*/
public static final int INSTALL_FAILED_INSUFFICIENT_STORAGE = -4;

/**
* if a package is already installed with the same name.
* 已存在同名程序
*/
public static final int INSTALL_FAILED_DUPLICATE_PACKAGE = -5;

/**
* if the requested shared user does not exist.
* 共享用户不存在
*/
public static final int INSTALL_FAILED_NO_SHARED_USER = -6;

/**
* if a previously installed package of the same name has a different signature
*   than the new package (and the old package's data was not removed).
* 更新不兼容
*/
public static final int INSTALL_FAILED_UPDATE_INCOMPATIBLE = -7;

/**
* if the new package is requested a shared user which is already installed
*   on the device and does not have matching signature.
* 共享用户不兼容
*/
public static final int INSTALL_FAILED_SHARED_USER_INCOMPATIBLE = -8;

/**
* if the new package uses a shared library that is not available.
* 共享库已丢失
*/
public static final int INSTALL_FAILED_MISSING_SHARED_LIBRARY = -9;

/**
* if the new package uses a shared library that is not available.
* 替换时无法删除
*/
public static final int INSTALL_FAILED_REPLACE_COULDNT_DELETE = -10;

/**
* if the new package failed while optimizing and validating its dex files,
*   either because there was not enough storage or the validation failed.
* 空间不足或验证失败
*/
public static final int INSTALL_FAILED_DEXOPT = -11;

/**
* if the new package failed because the current SDK version is older than
* that required by the package.
* 系统版本过旧
*/
public static final int INSTALL_FAILED_OLDER_SDK = -12;

/**
* if the new package failed because it contains a content provider with the
*   same authority as a provider already installed in the system.
* 存在同名的内容提供者
*/
public static final int INSTALL_FAILED_CONFLICTING_PROVIDER = -13;

/**
* if the new package failed because the current SDK version is newer than
*   that required by the package.
* 系统版本过新
*/
public static final int INSTALL_FAILED_NEWER_SDK = -14;

/**
* if the new package failed because it has specified that it is a test-only
*   package and the caller has not supplied the {@link #INSTALL_ALLOW_TEST}
*   flag.
* 调用者不被允许测试的测试程序
*/
public static final int INSTALL_FAILED_TEST_ONLY = -15;

/**
* if the package being installed contains native code, but none that is
*   compatible with the the device's CPU_ABI.
* 包含的本机代码不兼容CPU_ABI
*/
public static final int INSTALL_FAILED_CPU_ABI_INCOMPATIBLE = -16;

/**
* if the new package uses a feature that is not available.
* 使用了一个无效的特性
*/
public static final int INSTALL_FAILED_MISSING_FEATURE = -17;

// ------ Errors related to sdcard
/**
* if a secure container mount point couldn't be accessed on external media.
* SD卡访问失败
*/
public static final int INSTALL_FAILED_CONTAINER_ERROR = -18;

/**
* if the new package couldn't be installed in the specified install location.
* 无效的安装路径
*/
public static final int INSTALL_FAILED_INVALID_INSTALL_LOCATION = -19;

/**
* if the new package couldn't be installed in the specified install
*   location because the media is not available.
* SD卡不可用
*/
public static final int INSTALL_FAILED_MEDIA_UNAVAILABLE = -20;

/**
* if the new package couldn't be installed because the verification timed out.
* 验证超时
*/
public static final int INSTALL_FAILED_VERIFICATION_TIMEOUT = -21;

/**
* if the new package couldn't be installed because the verification did not succeed.
* 验证失败
*/
public static final int INSTALL_FAILED_VERIFICATION_FAILURE = -22;

/**
* if the package changed from what the calling program expected.
* 预期的应用被改变
*/
public static final int INSTALL_FAILED_PACKAGE_CHANGED = -23;

/**
* if the parser was given a path that is not a file, or does not end
*   with the expected '.apk' extension.
* 解析失败,不是APK
*/
public static final int INSTALL_PARSE_FAILED_NOT_APK = -100;

/**
* if the parser was unable to retrieve the AndroidManifest.xml file.
* 解析失败,无法提取Manifest
*/
public static final int INSTALL_PARSE_FAILED_BAD_MANIFEST = -101;

/**
* if the parser encountered an unexpected exception.
* 解析失败,无法预期的异常
*/
public static final int INSTALL_PARSE_FAILED_UNEXPECTED_EXCEPTION = -102;

/**
* if the parser did not find any certificates in the .apk.
* 解析失败,找不到证书
*/
public static final int INSTALL_PARSE_FAILED_NO_CERTIFICATES = -103;

/**
* if the parser found inconsistent certificates on the files in the .apk.
* 解析失败,证书不一致
*/
public static final int INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES = -104;

/**
* if the parser encountered a CertificateEncodingException in one of the
*   files in the .apk.
* 解析失败,证书编码异常
*/
public static final int INSTALL_PARSE_FAILED_CERTIFICATE_ENCODING = -105;

/**
* if the parser encountered a bad or missing package name in the manifest.
* 解析失败,manifest中的包名错误或丢失
*/
public static final int INSTALL_PARSE_FAILED_BAD_PACKAGE_NAME = -106;

/**
* if the parser encountered a bad shared user id name in the manifest.
* 解析失败,manifest中的共享用户错误
*/
public static final int INSTALL_PARSE_FAILED_BAD_SHARED_USER_ID = -107;

/**
* if the parser encountered some structural problem in the manifest.
* 解析失败,manifest中出现结构性错误
*/
public static final int INSTALL_PARSE_FAILED_MANIFEST_MALFORMED = -108;

/**
* if the parser did not find any actionable tags (instrumentation or application)
*   in the manifest.
* 解析失败,manifest中没有actionable tags
*/
public static final int INSTALL_PARSE_FAILED_MANIFEST_EMPTY = -109;

/**
* if the system failed to install the package because of system issues.
* 系统问题导致安装失败
*/
public static final int INSTALL_FAILED_INTERNAL_ERROR = -110;

安卓禁止用户安装程序相关推荐

  1. 如何禁止用户安装盗版?

    你身边有哪些软件是盗版的呢?最常用的盗版软件Office居多,然后就是大部分公司都会在昂贵的设计软件相关工具中使用盗版:有的企业为了不担法律风险以及高额的罚款,会不允许员工使用盗版软件:并且有的盗版软 ...

  2. MTK android 安卓禁止apk安装

    安卓禁止apk安装 安卓禁止单个apk安装 frameworks\base\services\core\java\com\android\server\pm\PackageManagerService ...

  3. Visual studio Code User Installer(用户安装程序)和System Installer(系统安装程式)的区别

    user版会安装在当前计算机帐户目录,这意味着如果使用另一个帐号登陆计算机将无法使用别人安装的vscode. 而system版本可以安装在非用户目录,例如C盘根目录,任何帐户都可以使用.这个是主要的区 ...

  4. win10计算机策略禁止用户安装,win10系统使用组策略禁止用户安装软件的操作方法...

    很多小伙伴都遇到过对win10系统使用组策略禁止用户安装软件进行设置的困惑吧,一些朋友看过网上对win10系统使用组策略禁止用户安装软件设置的零散处理方法,并没有完完全全明白win10系统使用组策略禁 ...

  5. 通过组策略禁止用户安装任何软件

    开始-运行-GPEDIT.msc-用户配置-WINDOW组件-终端服务-WINDOWS INSTALL 有四个选项,可以根据需要选择其中的若干项,如果权限足够的话,可以选择: 第一项"永远以 ...

  6. win10计算机上的策略禁止用户安装,Win10装软件提示“系统管理员设置了系统策略禁止进行此安装”怎么办?...

    最近一位用户在Win10系统下安装软件时,系统出现提示"系统管理员设置了系统策略,禁止进行此安装",这该怎么办呢?既然系统管理员禁止了程序安装,那么我们只要开启相应的安装权限就可以 ...

  7. 计算机上策略禁止用户安装,教您系统管理员设置了系统策略禁止进行此安装怎么解决...

    用户常常会根据自己的需要在电脑系统中安装一些自己所需要的软件,有用户在安装软件的时候被禁止了,提示"系统管理员设置了系统策略,禁止进行此安装",这样的好处是可以防止他人恶意安装软件 ...

  8. win10域用户安装程序时总是弹出用户账户控制

    ①先用管理员更改UAC控制,改为从不提醒 ②在域控上解锁域用户,重启用户电脑 ③在本地账户以管理员登录,打开控制面板→更改账户类型→添加→把需要更改设置的账户添加上去→授予管理员权限→下一步→完成

  9. XP系统如何禁止别人在电脑上安装程序

    自已的电脑,如果自已不在电脑旁时,家人或朋友就会玩我的电脑,而且还会在电脑上安装很多软件,每次都得花很多时间去清理垃圾软件,拒绝他们动我的电脑,又觉得不太好意思,要怎样既能够让他们玩,而且又不能让他们 ...

最新文章

  1. linux中cc和S的区别,为什么在linux命令(iostat)中每秒读取(r/s)一直为零?
  2. 51nod 修改数组
  3. linux ping策略打开_linux ping策略打开_如何在Linux服务器禁止和开启ping包 互联网技术圈 互联网技术圈......
  4. 大型网站系统架构实践(五)深入探讨web应用高可用方案
  5. IDA Pro逆向实战之Crackme(简单篇)
  6. ssh linux 配置文件详解,Linux ssh服务常用配置的详细描述及建议配置
  7. java nextlong_Java Random nextLong()方法与示例
  8. python run之后出现>>> runfile(‘F:xxx.py‘, wdir=‘F:xxx‘) 快速干掉它的办法
  9. 工业大数据分析综述:模型与算法
  10. Kaggle | 用 YoloV5 将物体检测的性能翻倍的心路历程
  11. Intel® Nehalem/Westmere架构/微架构/流水线 (2) - 流水线概述
  12. android adb 模拟来电,在Android模拟器中模拟GPS、打电话、发短信……
  13. 计算机网络知识如何建立数据库,如何将本机的SQL Server数据库上传到网站的数据服务器?...
  14. redis的set类型
  15. 安卓手机端口号怎么查看_安卓手机来电闪光灯怎么设置
  16. Maven Oracle JDBC
  17. Part I 1.介绍Lustre文件系统
  18. 解决OpenCV编译时./bin: error while loading shared libraries: libopencv_highgui.so.3.2: cannot open的问题
  19. CakePHP查询数据
  20. 069 模块基础总结

热门文章

  1. 2023最新SSM计算机毕业设计选题大全(附源码+LW)之java手游账号交易系统u2741
  2. python根据出生日期计算年龄的源码
  3. 骨传导蓝牙耳机哪款好、好用的骨传导耳机推荐
  4. AtCoder Beginner Contest 217
  5. 在滴滴云 DC2 云服务器上搭建 MongoDB 实战
  6. 华为OD机试题 - 找出重复代码(JavaScript)| 包含代码编写思路
  7. MAC、IP、ARP协议
  8. windows上配置本地深度学习工作站
  9. JavaScript零基础入门 13:DOM规范中的MutationObserver接口
  10. 实训(学生管理系统)