Loading services/java/com/android/server/am/ActivityManagerService.java +36 −0 Original line number Diff line number Diff line Loading @@ -343,6 +343,16 @@ public final class ActivityManagerService extends ActivityManagerNative // devices. private boolean mShowDialogs = true; // Penalise Large applications going to background only for Low-RAM devices private boolean mPenaliseLargeApps = ActivityManager.isLowRamDeviceStatic(); // ADJ to be set for new background app (if found to be large) private int mPenalisedAdj = SystemProperties.getInt("ro.am.penalise_large_apps.adj", ProcessList.CACHED_APP_MAX_ADJ); // Threshold Pss to be compared against new background app's Pss private long mPenalisedThreshold; /** * Description of a request to start a new activity, which has been held * due to app switches being disabled. Loading Loading @@ -1991,6 +2001,15 @@ public final class ActivityManagerService extends ActivityManagerNative mHeadless = "1".equals(SystemProperties.get("ro.config.headless", "0")); if (mPenaliseLargeApps == true) { long cachedAppMaxMemLevel = mProcessList.getMemLevel(ProcessList.CACHED_APP_MAX_ADJ)/1024; mPenalisedThreshold = SystemProperties.getLong( "ro.am.penalise_large_apps.pss", cachedAppMaxMemLevel); Slog.i(TAG,"Large apps penalisation enabled. Threshold Pss = " + mPenalisedThreshold + ", ADJ = " + mPenalisedAdj); } // User 0 is the first and only user that runs at boot. mStartedUsers.put(0, new UserStartedState(new UserHandle(0), true)); mUserLru.add(Integer.valueOf(0)); Loading Loading @@ -15327,6 +15346,23 @@ public final class ActivityManagerService extends ActivityManagerNative app.setRawAdj = app.curRawAdj; } if ( (mPenaliseLargeApps == true) && ((app.curAdj == ProcessList.PREVIOUS_APP_ADJ) || ((app.curAdj >= ProcessList.CACHED_APP_MIN_ADJ) && (app.curAdj < ProcessList.CACHED_APP_MAX_ADJ))) ) { // Validate the PSS to be compared against for penalisation if (app.lastCachedPss == 0) { app.lastCachedPss = Debug.getPss(app.pid, null); } if (app.lastCachedPss > mPenalisedThreshold) { if (DEBUG_SWITCH || DEBUG_OOM_ADJ) Slog.i( TAG,"New BG app : " + app.processName + " is heavy! (pss = " + app.lastCachedPss + " kB). Forcing to ADJ " + mPenalisedAdj); app.curAdj = mPenalisedAdj; } } if (app.curAdj != app.setAdj) { if (Process.setOomAdj(app.pid, app.curAdj)) { if (DEBUG_SWITCH || DEBUG_OOM_ADJ) Slog.v( Loading
services/java/com/android/server/am/ActivityManagerService.java +36 −0 Original line number Diff line number Diff line Loading @@ -343,6 +343,16 @@ public final class ActivityManagerService extends ActivityManagerNative // devices. private boolean mShowDialogs = true; // Penalise Large applications going to background only for Low-RAM devices private boolean mPenaliseLargeApps = ActivityManager.isLowRamDeviceStatic(); // ADJ to be set for new background app (if found to be large) private int mPenalisedAdj = SystemProperties.getInt("ro.am.penalise_large_apps.adj", ProcessList.CACHED_APP_MAX_ADJ); // Threshold Pss to be compared against new background app's Pss private long mPenalisedThreshold; /** * Description of a request to start a new activity, which has been held * due to app switches being disabled. Loading Loading @@ -1991,6 +2001,15 @@ public final class ActivityManagerService extends ActivityManagerNative mHeadless = "1".equals(SystemProperties.get("ro.config.headless", "0")); if (mPenaliseLargeApps == true) { long cachedAppMaxMemLevel = mProcessList.getMemLevel(ProcessList.CACHED_APP_MAX_ADJ)/1024; mPenalisedThreshold = SystemProperties.getLong( "ro.am.penalise_large_apps.pss", cachedAppMaxMemLevel); Slog.i(TAG,"Large apps penalisation enabled. Threshold Pss = " + mPenalisedThreshold + ", ADJ = " + mPenalisedAdj); } // User 0 is the first and only user that runs at boot. mStartedUsers.put(0, new UserStartedState(new UserHandle(0), true)); mUserLru.add(Integer.valueOf(0)); Loading Loading @@ -15327,6 +15346,23 @@ public final class ActivityManagerService extends ActivityManagerNative app.setRawAdj = app.curRawAdj; } if ( (mPenaliseLargeApps == true) && ((app.curAdj == ProcessList.PREVIOUS_APP_ADJ) || ((app.curAdj >= ProcessList.CACHED_APP_MIN_ADJ) && (app.curAdj < ProcessList.CACHED_APP_MAX_ADJ))) ) { // Validate the PSS to be compared against for penalisation if (app.lastCachedPss == 0) { app.lastCachedPss = Debug.getPss(app.pid, null); } if (app.lastCachedPss > mPenalisedThreshold) { if (DEBUG_SWITCH || DEBUG_OOM_ADJ) Slog.i( TAG,"New BG app : " + app.processName + " is heavy! (pss = " + app.lastCachedPss + " kB). Forcing to ADJ " + mPenalisedAdj); app.curAdj = mPenalisedAdj; } } if (app.curAdj != app.setAdj) { if (Process.setOomAdj(app.pid, app.curAdj)) { if (DEBUG_SWITCH || DEBUG_OOM_ADJ) Slog.v(