Android 7 添加安装白名单

项目场景:

提示:某些系统只支持已经的apk 安装
例如:项目场景: 车机系统


pm.java代码:

        final File systemDir;final File whiteListFile;final ArrayList<String> whiteListApps = new ArrayList<String>();systemDir = new File("/system/", "etc");whiteListFile = new File(systemDir, "whitelistapps.txt");if (!whiteListFile.exists()) {Log.e(TAG, "isWhiteListApp: whiteListApps.txt file no exists");return false;}try {whiteListApps.clear();BufferedReader br = new BufferedReader(new FileReader(whiteListFile));String line = br.readLine();while (line != null) {Log.d(TAG, "whiteListApps readLine:" + line);whiteListApps.add(line);line = br.readLine();}br.close();} catch (IOException e) {Log.e(TAG, "IO Exception happened while reading whiteListApps");e.printStackTrace();return false;}Iterator<String> it = whiteListApps.iterator();while (it.hasNext()) {String whitelistItem = it.next();if (pkgName.equals(whitelistItem)) {Log.e(TAG, "isWhiteListApp: find matching package name "+pkgName);return true;}}Log.e(TAG, "isWhiteListApp: cann't find matching package name "+pkgName);return false;}

   * Moving the implementation of "pm install" to "cmd package install" changes the executing* context. Instead of being a stand alone process, "cmd package install" runs in the* system_server process. Due to SELinux rules, system_server cannot access many directories;* one of which being the package install staging directory [/data/local/tmp].** The use of "adb install" or "cmd package install" over "pm install" is highly encouraged.*/
private int runInstall() throws RemoteException {final InstallParams params = makeInstallParams();final String inPath = nextArg();String installerPackageName = "";if (mPm == null) {System.err.println(PM_NOT_RUNNING_ERR);return 1;}installerPackageName = mPm.getNameForUid(Binder.getCallingUid());Log.d(TAG, "Binder.getCallingUid() : " + Binder.getCallingUid());Log.d(TAG, "apkFilePath = "+inPath+", installerPackageName = "+installerPackageName);if (SystemProperties.getBoolean("persist.sys.whitelist", true)) {if(!isWhiteListApp(installerPackageName)) {System.err.println("Error: the app is not in app whitelist packageName " + installerPackageName);Log.e(TAG, installerPackageName + " is not in the whitelist.   install(pm way) not allowed");return 1;}}-----省略

Android 7 添加安装白名单相关推荐

  1. Android 10 添加安装白名单和卸载黑名单

    实现思路 1.提供 ContentProvider 保存我需要添加安装白名单和卸载黑名单列表 2.找到安装.卸载应用的系统核心源码, 3.查询ContentProvider 获取安装白名单列表和卸载黑 ...

  2. android 11.0 12.0app应用安装白名单

    1.概述 在11.0 12.0定制化开发中,客户需求要实现应用安装白名单功能,在白名单之中的应用可以安装,其他的app不准安装,实现一个 控制app安装的功能,这需要从app安装流程入手就可以实现功能 ...

  3. android 9.0 app应用安装白名单

    目录 1.概述 2.app应用安装白名单的核心类 3.app应用安装白名单的核心功能分析和实现 1.概述 在9.0的系统产品开发中,在产品开发中,对于控制app的安装需求也是比较常见的,所以在某些产品 ...

  4. NSIS 打包文件添加防火墙白名单

    概述 如果应用程序使用网络,担心被防火墙拦截的话,通常有两种解决方案,第一种是直接关闭电脑防火墙,但是会比较麻烦,每台电脑安装软件后都需要设置防火墙状态, 并且关闭防火墙电脑会不安全:第二种方式就是添 ...

  5. zookeeper添加ip白名单

    1.连接zookeeper 进入zookeeper安装目录 bin目录下 ./zkCli.sh -server 192.168.122.76:2181 (linux环境操作指令)zkCli -serv ...

  6. Centos防火墙添加IP白名单

    Centos iptables防火墙添加IP白名单,指定IP可访问端口 vi /etc/sysconfig/iptables 以下为我虚拟机的防火墙为例(Centos 7) # sample conf ...

  7. 将程序添加防火墙白名单

    将程序添加防火墙白名单 查考文档:https://support.microsoft.com/en-us/kb/947709 add rule: netsh advfirewall firewall ...

  8. Win11怎么添加信任软件?Win11怎么把软件添加进白名单?

    很多朋友都知道Win11系统有一个自带的WindowsDefender杀毒防护功能,不需要下载其他的安全软件,但是大家想知道从网络上下载软件被这个防护功能给自动删除掉怎么办?如何将下载的软件添加到白名 ...

  9. 防火墙添加ip白名单_如何增加网址白名单、IP白名单、策略白名单、协同防御白名单?...

    当使用了知道创宇云安全,在进行网站管理等敏感操作时,如果发现被拦截,且确认操作可信,可以通过添加IP白名单.网址白名单.策略白名单的方式解决,这三种白名单相互独立发挥作用,可按需添加. 知道创宇云安全 ...

最新文章

  1. filebeat配置详解
  2. libtorch 权重封装
  3. 有三AI发布360页11万字深度学习CV算法工程师成长指导手册,可下载收藏打印,未完待续...
  4. SAP 调用smartforms打印如何统计实际打印状态和打印次数
  5. iOS开发 - App程序启动原理
  6. excel导入csv文件_如何将包含以0开头的列的CSV文件导入Excel
  7. php : 常用函数
  8. 专题导读:空天大数据
  9. ffmpeg转换格式
  10. elastic search与mysql的数据同步
  11. 【Git入门之六】远程仓库
  12. 如何使用Aiseesoft Mac FoneTrans传输和管理iOS文件
  13. 小说Symbian的签名
  14. 火车头文章标题伪原创插件(文章双标题插件)
  15. java 发卡器_充值发卡器
  16. 服务器挂微信显示登陆异常怎么办,解决微信提示“该微信账号因登录环境异常,已被限制登录。”的方法...
  17. secureCRT连接阿里云服务器
  18. poj2455 Secret Milking Machine(二分答案+最大流)
  19. 数据类型扩展及面试题讲解
  20. brpc学习笔记(1)

热门文章

  1. 高中生活-第6篇–批评和表扬之间的对决
  2. 微信小程序--证件照换底色项目前端修改+头像框项目前端页面实现修改
  3. mysql 日期类型的取值范围
  4. “贵阳大数据产业上得快、标准高、效果好”
  5. android圆形图标
  6. 代谢环境的大规模重建和系统发育分析(Large-scale reconstruction and phylogenetic analysis of metabolic environments)
  7. 如何提高网络推广员自身的素养?
  8. Kendo UI 框架 HTML5
  9. 下单购买商品启用积分抵扣功能
  10. 东南亚最大综合地产开发商之一SM集团全球第82家购物中心开业