android11源码中如何提⾼应⽤oom_adj级别,保活应⽤动态调整某个应⽤的进程级别,防⽌系统因低内存被kill,可配合读取⽩名单列表(列表中是应⽤包名列表)使⽤,这⾥只是介绍思路。
1.到⽂件frameworks/base/services/core/java/com/android/server/am/OomAdjuster.java
//引⽤此包android11适配机型
import com.android.server.am.ProcessList;
2.到⽅法private final boolean applyOomAdjLocked(ProcessRecord app, boolean doingAll, long now,long nowElapsed) boolean success = true;
if (CurRawAdj() != app.setRawAdj) {
app.setRawAdj = CurRawAdj();
}
int changes = 0;
//step1.这⾥是读取⾃定义的⽩名单列表
String[] OomAdjusterArray();
// don't compact during bootup
if (mCachedAppOptimizer.useCompaction() && mService.mBooted) {
// Cached and prev/home compaction
if (app.curAdj != app.setAdj) {
// Perform a minor compaction when a perceptible app becomes the prev/home
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论