Android: how to set the app to be disabled by system k

Source: Internet
Author: User

There is one way to set the app to never be killed, AndroidManifest. add: android: persistent = "true" to the xml file. After the app is set in/system/app, the app is upgraded to the system core level without being killed, the stop operation is also blocked in settings-> applications. Proc #19: adj = svc/B 4067b028 255: com. xxx. xxx/10001 (started-services) # cat/proc/255/oom_adj4 after setting PERS #19: adj = core/F 406291f0 155: com. xxx. xxx/10001 (fixed) # cat/proc/155/oom_adj-12 lowmemorykiller operation rules such as write/sys/module/lowmemorykiller/parameters/adj, 2, 4, write/sys/module/lowmemorykiller/parameters/minfree 2048,3072, 4096, 6144, 7168, 8192 can be seen. After persistent is set, oom_adj =-12, there is no chance to be processed by lowmemorykiller: persistent Whether or not the application shocould remain running at all times-"true" if it shocould, and "false" if not. the default value is "false ". applications shocould not normally set this flag; persistence mode is intended only for certain system applications code

ActivityManagerService.java      final ProcessRecord addAppLocked(ApplicationInfo info) {          ProcessRecord app = getProcessRecordLocked(info.processName, info.uid);              if (app == null) {              app = newProcessRecordLocked(null, info, null);              mProcessNames.put(info.processName, info.uid, app);              updateLruProcessLocked(app, true, true);          }              if ((info.flags&(ApplicationInfo.FLAG_SYSTEM|ApplicationInfo.FLAG_PERSISTENT))                  == (ApplicationInfo.FLAG_SYSTEM|ApplicationInfo.FLAG_PERSISTENT)) {              app.persistent = true;              app.maxAdj = CORE_SERVER_ADJ;          }          if (app.thread == null && mPersistentStartingProcesses.indexOf(app) < 0) {              mPersistentStartingProcesses.add(app);              startProcessLocked(app, "added application", app.processName);          }              return app;      }  

 

You can see the app that meets both the FLAG_SYSTEM (/system/app directory) and FLAG_PERSISTENT (android: persistent = "true"), and set the app. maxAdj = CORE_SERVER_ADJ (-12), whereas adj =-12 won't be processed by lowmemorykiller

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.