Android: app不被系统kill掉
2023-09-14 09:09:54 时间
有一种方法可以设置app永远不会被kill,AndroidManifest.xml 中添加:
android:persistent="true"
适用于放在/system/app下的app
设置后app提升为系统核心级别,任何情况下不会被kill掉, settings->applications里面也会屏蔽掉stop操作,
设置前 Proc #19: adj=svc /B 4067b028 255:com.xxx.xxx/10001 (started-services)
# cat /proc/255/oom_adj
4
设置后 PERS #19: adj=core /F 406291f0 155:com.xxx.xxx/10001 (fixed)
# cat /proc/155/oom_adj
-12
lowmemorykiller的操作规则比如为
write /sys/module/lowmemorykiller/parameters/adj 0,1,2,4,7,15
write /sys/module/lowmemorykiller/parameters/minfree 2048,3072,4096,6144,7168,8192
可以看到,设置persistent后, oom_adj=-12,永远没有机会被lowmemorykiller处理
Android:persistent
Whether or not the application should remain running at all times — "true" if it should, and "false" if not. The default value is "false". Applications should not normally set this flag; persistence mode is intended only for certain system applications
代码
可以看到同时符合FLAG_SYSTEM(/system/app目录)及FLAG_PERSISTENT(android:persistent="true")
的app,设置app.maxAdj = CORE_SERVER_ADJ(-12),而adj=-12不会被lowmemorykiller处理
相关文章
- Android数据库加密
- android系统开机画面_Android开机画面
- 代码加密 android,Android 开发怎样做代码加密或混淆「建议收藏」
- android启动一个app的命令
- mac 电脑android环境变量设置,mac上Android环境变量配置[通俗易懂]
- Android进程与线程
- android系统中toast是什么_Android个人资料简单布局
- android activitymanager 系统api_Android view
- Android | Handler.runWithScissors 解析
- 解决第三方邮箱APP登陆QQ、163邮箱无法验证账户名或密码的问题(IOS、MacOS、Windows、Android)
- app自动化测试(Android)--App 控件定位
- java基于springboot外卖系统在线订餐系统app源码厨艺论坛APP
- Android studio更新后出现警告:Warning:The `android.dexOptions.incremental` property is deprecated and it has
- 2018最新苹果APP上架App Store流程(超详细)
- 一步步了解iOS APP上架流程,让你的APP顺利进入App Store的大门
- 【错误记录】Android Studio 创建 Flutter 应用被卡住 ( 更新 Flutter 插件 | 命令行创建 | 断网 )
- 【Android 热修复】热修复原理 ( 合并两个 Element[] dexElements | 自定义 Application 加载 Dex 设置 | 源码资源 )
- 【Android 逆向】Android 系统文件分析 ( /system/ 系统命令和系统应用数据目录 | /system/app/ 系统应用目录 | sys Linux 系统内核文件目录 )
- 【Android 逆向】Android 权限 ( Android 逆向中使用的 android.permission 权限 | Android 系统中的 Linux 用户权限 )
- 【错误记录】Android Studio 编译时 lint 检查报错 ( WARNING: DSL element ‘android.dataBinding.enabled‘ is obsolet )
- Android开发中遇到的问题(五)——Eclipse导入Android项目出现”Invalid project description overlaps the location of another project”错误的解决办法详解手机开发
- Android TextView中文字通过SpannableString来设置超链接、颜色、字体等属性详解手机开发
- Android ormLite复杂条件查询详解手机开发
- android-async-http框架源码分析详解手机开发
- Android系统与Linux之间的联系(android和linux)
- Linux下的打造智能App之旅(linux系统app)
- Canonical宣布Ubuntu Touch与Android双启动开发者预览版
- 使用Android实现连接MySQL数据库:实现快速数据交互与管理(android连接mysql数据库)
- 基于MSSQL的手机APP编程实践(mssql编程app)
- App中数据库优势之MySQL(app数据库mysql)
- 数据库利用App制作读取MySQL数据库的简单方法(app制作读取mysql)
- App企业使用MySQL实现信息管理梦想(app企业用mysql)
- android计时器,时间计算器的实现方法
- Android笔记之:App应用之启动界面SplashActivity的使用
- android使用webwiew载入页面使用示例(HybridApp开发)
- 探讨Android的屏幕滚动操作不如iPhone流畅顺滑的原因