动态调整某个应用的进程级别,防止系统因低内存被 kill,可配合读取白名单
列表(列表中是应用包名列表)使用,这里只是介绍思路。
1.找到文件
frameworks/base/services/core/java/com/android/server/am/OomAdjuster.
java
//引用此包
import com.android.server.am.ProcessList;
2.找到方法 private final boolean applyOomAdjLocked(ProcessRecord app,
boolean doingAll, long now,long nowElapsed)
boolean success = true;
if (app.getCurRawAdj() != app.setRawAdj) {
app.setRawAdj = app.getCurRawAdj();
}
int changes = 0;
//step1.这里是读取自定义的白名单列表
String[] pkgArray=mService.getOomAdjusterArray();
// 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
评论10
最新资源