Program: 197338
Project: 197338
Buggy source:
final void updateOomAdjLocked(){
  final ActivityRecord TOP_ACT=resumedAppLocked();
  final ProcessRecord TOP_APP=TOP_ACT != null ? TOP_ACT.app : null;
  final long now=SystemClock.uptimeMillis();
  final long oldTime=now - ProcessList.MAX_EMPTY_TIME;
  final int N=mLruProcesses.size();
  if (false) {
    RuntimeException e=new RuntimeException();
    e.fillInStackTrace();
    Slog.i(TAG,"String_Node_Str" + TOP_ACT,e);
  }
  mAdjSeq++;
  mNewNumServiceProcs=0;
  mNewNumAServiceProcs=0;
  final int emptyProcessLimit;
  final int cachedProcessLimit;
  if (mProcessLimit <= 0) {
    emptyProcessLimit=cachedProcessLimit=0;
  }
 else   if (mProcessLimit == 1) {
    emptyProcessLimit=1;
    cachedProcessLimit=0;
  }
 else {
    emptyProcessLimit=ProcessList.computeEmptyProcessLimit(mProcessLimit);
    cachedProcessLimit=mProcessLimit - emptyProcessLimit;
  }
  int numSlots=(ProcessList.CACHED_APP_MAX_ADJ - ProcessList.CACHED_APP_MIN_ADJ + 1) / 2;
  int numEmptyProcs=N - mNumNonCachedProcs - mNumCachedHiddenProcs;
  if (numEmptyProcs > cachedProcessLimit) {
    numEmptyProcs=cachedProcessLimit;
  }
  int emptyFactor=numEmptyProcs / numSlots;
  if (emptyFactor < 1)   emptyFactor=1;
  int cachedFactor=(mNumCachedHiddenProcs > 0 ? mNumCachedHiddenProcs : 1) / numSlots;
  if (cachedFactor < 1)   cachedFactor=1;
  int stepCached=0;
  int stepEmpty=0;
  int numCached=0;
  int numEmpty=0;
  int numTrimming=0;
  mNumNonCachedProcs=0;
  mNumCachedHiddenProcs=0;
  int curCachedAdj=ProcessList.CACHED_APP_MIN_ADJ;
  int nextCachedAdj=curCachedAdj + 1;
  int curEmptyAdj=ProcessList.CACHED_APP_MIN_ADJ;
  int nextEmptyAdj=curEmptyAdj + 2;
  for (int i=N - 1; i >= 0; i--) {
    ProcessRecord app=mLruProcesses.get(i);
    if (!app.killedByAm && app.thread != null) {
      app.procStateChanged=false;
      computeOomAdjLocked(app,ProcessList.UNKNOWN_ADJ,TOP_APP,true,now);
      if (app.curAdj >= ProcessList.UNKNOWN_ADJ) {
switch (app.curProcState) {
case ActivityManager.PROCESS_STATE_CACHED_ACTIVITY:
case ActivityManager.PROCESS_STATE_CACHED_ACTIVITY_CLIENT:
          app.curRawAdj=curCachedAdj;
        app.curAdj=app.modifyRawOomAdj(curCachedAdj);
      if (DEBUG_LRU && false)       Slog.d(TAG,"String_Node_Str" + i + "String_Node_Str"+ app.curAdj+ "String_Node_Str"+ curCachedAdj+ "String_Node_Str");
    if (curCachedAdj != nextCachedAdj) {
      stepCached++;
      if (stepCached >= cachedFactor) {
        stepCached=0;
        curCachedAdj=nextCachedAdj;
        nextCachedAdj+=2;
        if (nextCachedAdj > ProcessList.CACHED_APP_MAX_ADJ) {
          nextCachedAdj=ProcessList.CACHED_APP_MAX_ADJ;
        }
      }
    }
  break;
default :
app.curRawAdj=curEmptyAdj;
app.curAdj=app.modifyRawOomAdj(curEmptyAdj);
if (DEBUG_LRU && false) Slog.d(TAG,"String_Node_Str" + i + "String_Node_Str"+ app.curAdj+ "String_Node_Str"+ curEmptyAdj+ "String_Node_Str");
if (curEmptyAdj != nextEmptyAdj) {
stepEmpty++;
if (stepEmpty >= emptyFactor) {
stepEmpty=0;
curEmptyAdj=nextEmptyAdj;
nextEmptyAdj+=2;
if (nextEmptyAdj > ProcessList.CACHED_APP_MAX_ADJ) {
nextEmptyAdj=ProcessList.CACHED_APP_MAX_ADJ;
}
}
}
break;
}
}
applyOomAdjLocked(app,TOP_APP,true,now);
switch (app.curProcState) {
case ActivityManager.PROCESS_STATE_CACHED_ACTIVITY:
case ActivityManager.PROCESS_STATE_CACHED_ACTIVITY_CLIENT:
mNumCachedHiddenProcs++;
numCached++;
if (numCached > cachedProcessLimit) {
app.kill("String_Node_Str" + numCached,true);
}
break;
case ActivityManager.PROCESS_STATE_CACHED_EMPTY:
if (numEmpty > ProcessList.TRIM_EMPTY_APPS && app.lastActivityTime < oldTime) {
app.kill("String_Node_Str" + ((oldTime + ProcessList.MAX_EMPTY_TIME - app.lastActivityTime) / 1000) + "String_Node_Str",true);
}
 else {
numEmpty++;
if (numEmpty > emptyProcessLimit) {
app.kill("String_Node_Str" + numEmpty,true);
}
}
break;
default :
mNumNonCachedProcs++;
break;
}
if (app.isolated && app.services.size() <= 0) {
app.kill("String_Node_Str",true);
}
if (app.curProcState >= ActivityManager.PROCESS_STATE_HOME && !app.killedByAm) {
numTrimming++;
}
}
}
mNumServiceProcs=mNewNumServiceProcs;
final int numCachedAndEmpty=numCached + numEmpty;
int memFactor;
if (numCached <= ProcessList.TRIM_CACHED_APPS && numEmpty <= ProcessList.TRIM_EMPTY_APPS) {
if (numCachedAndEmpty <= ProcessList.TRIM_CRITICAL_THRESHOLD) {
memFactor=ProcessStats.ADJ_MEM_FACTOR_CRITICAL;
}
 else if (numCachedAndEmpty <= ProcessList.TRIM_LOW_THRESHOLD) {
memFactor=ProcessStats.ADJ_MEM_FACTOR_LOW;
}
 else {
memFactor=ProcessStats.ADJ_MEM_FACTOR_MODERATE;
}
}
 else {
memFactor=ProcessStats.ADJ_MEM_FACTOR_NORMAL;
}
if (DEBUG_OOM_ADJ) Slog.d(TAG,"String_Node_Str" + memFactor + "String_Node_Str"+ mLastMemoryLevel+ "String_Node_Str"+ mAllowLowerMemLevel+ "String_Node_Str"+ mLruProcesses.size()+ "String_Node_Str"+ mLastNumProcesses);
if (memFactor > mLastMemoryLevel) {
if (!mAllowLowerMemLevel || mLruProcesses.size() >= mLastNumProcesses) {
memFactor=mLastMemoryLevel;
if (DEBUG_OOM_ADJ) Slog.d(TAG,"String_Node_Str");
}
}
mLastMemoryLevel=memFactor;
mLastNumProcesses=mLruProcesses.size();
boolean allChanged=mProcessStats.setMemFactorLocked(memFactor,!isSleeping(),now);
final int trackerMemFactor=mProcessStats.getMemFactorLocked();
if (memFactor != ProcessStats.ADJ_MEM_FACTOR_NORMAL) {
if (mLowRamStartTime == 0) {
mLowRamStartTime=now;
}
int step=0;
int fgTrimLevel;
switch (memFactor) {
case ProcessStats.ADJ_MEM_FACTOR_CRITICAL:
fgTrimLevel=ComponentCallbacks2.TRIM_MEMORY_RUNNING_CRITICAL;
break;
case ProcessStats.ADJ_MEM_FACTOR_LOW:
fgTrimLevel=ComponentCallbacks2.TRIM_MEMORY_RUNNING_LOW;
break;
default :
fgTrimLevel=ComponentCallbacks2.TRIM_MEMORY_RUNNING_MODERATE;
break;
}
int factor=numTrimming / 3;
int minFactor=2;
if (mHomeProcess != null) minFactor++;
if (mPreviousProcess != null) minFactor++;
if (factor < minFactor) factor=minFactor;
int curLevel=ComponentCallbacks2.TRIM_MEMORY_COMPLETE;
for (int i=N - 1; i >= 0; i--) {
ProcessRecord app=mLruProcesses.get(i);
if (allChanged || app.procStateChanged) {
setProcessTrackerStateLocked(app,trackerMemFactor,now);
app.procStateChanged=false;
}
if (app.curProcState >= ActivityManager.PROCESS_STATE_HOME && !app.killedByAm) {
if (app.trimMemoryLevel < curLevel && app.thread != null) {
try {
if (DEBUG_SWITCH || DEBUG_OOM_ADJ) Slog.v(TAG,"String_Node_Str" + app.processName + "String_Node_Str"+ curLevel);
app.thread.scheduleTrimMemory(curLevel);
}
 catch (RemoteException e) {
}
if (false) {
if (curLevel >= ComponentCallbacks2.TRIM_MEMORY_COMPLETE && app != mHomeProcess && app != mPreviousProcess) {
mStackSupervisor.scheduleDestroyAllActivities(app,"String_Node_Str");
}
}
}
app.trimMemoryLevel=curLevel;
step++;
if (step >= factor) {
step=0;
switch (curLevel) {
case ComponentCallbacks2.TRIM_MEMORY_COMPLETE:
curLevel=ComponentCallbacks2.TRIM_MEMORY_MODERATE;
break;
case ComponentCallbacks2.TRIM_MEMORY_MODERATE:
curLevel=ComponentCallbacks2.TRIM_MEMORY_BACKGROUND;
break;
}
}
}
 else if (app.curProcState == ActivityManager.PROCESS_STATE_HEAVY_WEIGHT) {
if (app.trimMemoryLevel < ComponentCallbacks2.TRIM_MEMORY_BACKGROUND && app.thread != null) {
try {
if (DEBUG_SWITCH || DEBUG_OOM_ADJ) Slog.v(TAG,"String_Node_Str" + app.processName + "String_Node_Str"+ ComponentCallbacks2.TRIM_MEMORY_BACKGROUND);
app.thread.scheduleTrimMemory(ComponentCallbacks2.TRIM_MEMORY_BACKGROUND);
}
 catch (RemoteException e) {
}
}
app.trimMemoryLevel=ComponentCallbacks2.TRIM_MEMORY_BACKGROUND;
}
 else {
if ((app.curProcState >= ActivityManager.PROCESS_STATE_IMPORTANT_BACKGROUND || app.systemNoUi) && app.pendingUiClean) {
final int level=ComponentCallbacks2.TRIM_MEMORY_UI_HIDDEN;
if (app.trimMemoryLevel < level && app.thread != null) {
try {
if (DEBUG_SWITCH || DEBUG_OOM_ADJ) Slog.v(TAG,"String_Node_Str" + app.processName + "String_Node_Str"+ level);
app.thread.scheduleTrimMemory(level);
}
 catch (RemoteException e) {
}
}
app.pendingUiClean=false;
}
if (app.trimMemoryLevel < fgTrimLevel && app.thread != null) {
try {
if (DEBUG_SWITCH || DEBUG_OOM_ADJ) Slog.v(TAG,"String_Node_Str" + app.processName + "String_Node_Str"+ fgTrimLevel);
app.thread.scheduleTrimMemory(fgTrimLevel);
}
 catch (RemoteException e) {
}
}
app.trimMemoryLevel=fgTrimLevel;
}
}
}
 else {
if (mLowRamStartTime != 0) {
mLowRamTimeSinceLastIdle+=now - mLowRamStartTime;
mLowRamStartTime=0;
}
for (int i=N - 1; i >= 0; i--) {
ProcessRecord app=mLruProcesses.get(i);
if (allChanged || app.procStateChanged) {
setProcessTrackerStateLocked(app,trackerMemFactor,now);
app.procStateChanged=false;
}
if ((app.curProcState >= ActivityManager.PROCESS_STATE_IMPORTANT_BACKGROUND || app.systemNoUi) && app.pendingUiClean) {
if (app.trimMemoryLevel < ComponentCallbacks2.TRIM_MEMORY_UI_HIDDEN && app.thread != null) {
try {
if (DEBUG_SWITCH || DEBUG_OOM_ADJ) Slog.v(TAG,"String_Node_Str" + app.processName + "String_Node_Str"+ ComponentCallbacks2.TRIM_MEMORY_UI_HIDDEN);
app.thread.scheduleTrimMemory(ComponentCallbacks2.TRIM_MEMORY_UI_HIDDEN);
}
 catch (RemoteException e) {
}
}
app.pendingUiClean=false;
}
app.trimMemoryLevel=0;
}
}
if (mAlwaysFinishActivities) {
mStackSupervisor.scheduleDestroyAllActivities(null,"String_Node_Str");
}
if (allChanged) {
requestPssAllProcsLocked(now,false,mProcessStats.isMemFactorLowered());
}
if (mProcessStats.shouldWriteNowLocked(now)) {
mHandler.post(new Runnable(){
@Override public void run(){
synchronized (ActivityManagerService.this) {
mProcessStats.writeStateAsyncLocked();
}
}
}
);
}
if (DEBUG_OOM_ADJ) {
Slog.d(TAG,"String_Node_Str" + (SystemClock.uptimeMillis() - now) + "String_Node_Str");
}
}

Fixed version (ground truth):
final void updateOomAdjLocked(){
  final ActivityRecord TOP_ACT=resumedAppLocked();
  final ProcessRecord TOP_APP=TOP_ACT != null ? TOP_ACT.app : null;
  final long now=SystemClock.uptimeMillis();
  final long oldTime=now - ProcessList.MAX_EMPTY_TIME;
  final int N=mLruProcesses.size();
  if (false) {
    RuntimeException e=new RuntimeException();
    e.fillInStackTrace();
    Slog.i(TAG,"String_Node_Str" + TOP_ACT,e);
  }
  mAdjSeq++;
  mNewNumServiceProcs=0;
  mNewNumAServiceProcs=0;
  final int emptyProcessLimit;
  final int cachedProcessLimit;
  if (mProcessLimit <= 0) {
    emptyProcessLimit=cachedProcessLimit=0;
  }
 else   if (mProcessLimit == 1) {
    emptyProcessLimit=1;
    cachedProcessLimit=0;
  }
 else {
    emptyProcessLimit=ProcessList.computeEmptyProcessLimit(mProcessLimit);
    cachedProcessLimit=mProcessLimit - emptyProcessLimit;
  }
  int numSlots=(ProcessList.CACHED_APP_MAX_ADJ - ProcessList.CACHED_APP_MIN_ADJ + 1) / 2;
  int numEmptyProcs=N - mNumNonCachedProcs - mNumCachedHiddenProcs;
  if (numEmptyProcs > cachedProcessLimit) {
    numEmptyProcs=cachedProcessLimit;
  }
  int emptyFactor=numEmptyProcs / numSlots;
  if (emptyFactor < 1)   emptyFactor=1;
  int cachedFactor=(mNumCachedHiddenProcs > 0 ? mNumCachedHiddenProcs : 1) / numSlots;
  if (cachedFactor < 1)   cachedFactor=1;
  int stepCached=0;
  int stepEmpty=0;
  int numCached=0;
  int numEmpty=0;
  int numTrimming=0;
  mNumNonCachedProcs=0;
  mNumCachedHiddenProcs=0;
  int curCachedAdj=ProcessList.CACHED_APP_MIN_ADJ;
  int nextCachedAdj=curCachedAdj + 1;
  int curEmptyAdj=ProcessList.CACHED_APP_MIN_ADJ;
  int nextEmptyAdj=curEmptyAdj + 2;
  for (int i=N - 1; i >= 0; i--) {
    ProcessRecord app=mLruProcesses.get(i);
    if (!app.killedByAm && app.thread != null) {
      app.procStateChanged=false;
      computeOomAdjLocked(app,ProcessList.UNKNOWN_ADJ,TOP_APP,true,now);
      if (app.curAdj >= ProcessList.UNKNOWN_ADJ) {
switch (app.curProcState) {
case ActivityManager.PROCESS_STATE_CACHED_ACTIVITY:
case ActivityManager.PROCESS_STATE_CACHED_ACTIVITY_CLIENT:
          app.curRawAdj=curCachedAdj;
        app.curAdj=app.modifyRawOomAdj(curCachedAdj);
      if (DEBUG_LRU && false)       Slog.d(TAG,"String_Node_Str" + i + "String_Node_Str"+ app.curAdj+ "String_Node_Str"+ curCachedAdj+ "String_Node_Str");
    if (curCachedAdj != nextCachedAdj) {
      stepCached++;
      if (stepCached >= cachedFactor) {
        stepCached=0;
        curCachedAdj=nextCachedAdj;
        nextCachedAdj+=2;
        if (nextCachedAdj > ProcessList.CACHED_APP_MAX_ADJ) {
          nextCachedAdj=ProcessList.CACHED_APP_MAX_ADJ;
        }
      }
    }
  break;
default :
app.curRawAdj=curEmptyAdj;
app.curAdj=app.modifyRawOomAdj(curEmptyAdj);
if (DEBUG_LRU && false) Slog.d(TAG,"String_Node_Str" + i + "String_Node_Str"+ app.curAdj+ "String_Node_Str"+ curEmptyAdj+ "String_Node_Str");
if (curEmptyAdj != nextEmptyAdj) {
stepEmpty++;
if (stepEmpty >= emptyFactor) {
stepEmpty=0;
curEmptyAdj=nextEmptyAdj;
nextEmptyAdj+=2;
if (nextEmptyAdj > ProcessList.CACHED_APP_MAX_ADJ) {
nextEmptyAdj=ProcessList.CACHED_APP_MAX_ADJ;
}
}
}
break;
}
}
applyOomAdjLocked(app,TOP_APP,true,now);
switch (app.curProcState) {
case ActivityManager.PROCESS_STATE_CACHED_ACTIVITY:
case ActivityManager.PROCESS_STATE_CACHED_ACTIVITY_CLIENT:
mNumCachedHiddenProcs++;
numCached++;
if (numCached > cachedProcessLimit) {
app.kill("String_Node_Str" + numCached,true);
}
break;
case ActivityManager.PROCESS_STATE_CACHED_EMPTY:
if (numEmpty > ProcessList.TRIM_EMPTY_APPS && app.lastActivityTime < oldTime) {
app.kill("String_Node_Str" + ((oldTime + ProcessList.MAX_EMPTY_TIME - app.lastActivityTime) / 1000) + "String_Node_Str",true);
}
 else {
numEmpty++;
if (numEmpty > emptyProcessLimit) {
app.kill("String_Node_Str" + numEmpty,true);
}
}
break;
default :
mNumNonCachedProcs++;
break;
}
if (app.isolated && app.services.size() <= 0) {
app.kill("String_Node_Str",true);
}
if (app.curProcState >= ActivityManager.PROCESS_STATE_HOME && !app.killedByAm) {
numTrimming++;
}
}
}
mNumServiceProcs=mNewNumServiceProcs;
final int numCachedAndEmpty=numCached + numEmpty;
int memFactor;
if (numCached <= ProcessList.TRIM_CACHED_APPS && numEmpty <= ProcessList.TRIM_EMPTY_APPS) {
if (numCachedAndEmpty <= ProcessList.TRIM_CRITICAL_THRESHOLD) {
memFactor=ProcessStats.ADJ_MEM_FACTOR_CRITICAL;
}
 else if (numCachedAndEmpty <= ProcessList.TRIM_LOW_THRESHOLD) {
memFactor=ProcessStats.ADJ_MEM_FACTOR_LOW;
}
 else {
memFactor=ProcessStats.ADJ_MEM_FACTOR_MODERATE;
}
}
 else {
memFactor=ProcessStats.ADJ_MEM_FACTOR_NORMAL;
}
if (DEBUG_OOM_ADJ) Slog.d(TAG,"String_Node_Str" + memFactor + "String_Node_Str"+ mLastMemoryLevel+ "String_Node_Str"+ mAllowLowerMemLevel+ "String_Node_Str"+ mLruProcesses.size()+ "String_Node_Str"+ mLastNumProcesses);
if (memFactor > mLastMemoryLevel) {
if (!mAllowLowerMemLevel || mLruProcesses.size() >= mLastNumProcesses) {
memFactor=mLastMemoryLevel;
if (DEBUG_OOM_ADJ) Slog.d(TAG,"String_Node_Str");
}
}
mLastMemoryLevel=memFactor;
mLastNumProcesses=mLruProcesses.size();
boolean allChanged=mProcessStats.setMemFactorLocked(memFactor,!isSleeping(),now);
final int trackerMemFactor=mProcessStats.getMemFactorLocked();
if (memFactor != ProcessStats.ADJ_MEM_FACTOR_NORMAL) {
if (mLowRamStartTime == 0) {
mLowRamStartTime=now;
}
int step=0;
int fgTrimLevel;
switch (memFactor) {
case ProcessStats.ADJ_MEM_FACTOR_CRITICAL:
fgTrimLevel=ComponentCallbacks2.TRIM_MEMORY_RUNNING_CRITICAL;
break;
case ProcessStats.ADJ_MEM_FACTOR_LOW:
fgTrimLevel=ComponentCallbacks2.TRIM_MEMORY_RUNNING_LOW;
break;
default :
fgTrimLevel=ComponentCallbacks2.TRIM_MEMORY_RUNNING_MODERATE;
break;
}
int factor=numTrimming / 3;
int minFactor=2;
if (mHomeProcess != null) minFactor++;
if (mPreviousProcess != null) minFactor++;
if (factor < minFactor) factor=minFactor;
int curLevel=ComponentCallbacks2.TRIM_MEMORY_COMPLETE;
for (int i=N - 1; i >= 0; i--) {
ProcessRecord app=mLruProcesses.get(i);
if (allChanged || app.procStateChanged) {
setProcessTrackerStateLocked(app,trackerMemFactor,now);
app.procStateChanged=false;
}
if (app.curProcState >= ActivityManager.PROCESS_STATE_HOME && !app.killedByAm) {
if (app.trimMemoryLevel < curLevel && app.thread != null) {
try {
if (DEBUG_SWITCH || DEBUG_OOM_ADJ) Slog.v(TAG,"String_Node_Str" + app.processName + "String_Node_Str"+ curLevel);
app.thread.scheduleTrimMemory(curLevel);
}
 catch (RemoteException e) {
}
if (false) {
if (curLevel >= ComponentCallbacks2.TRIM_MEMORY_COMPLETE && app != mHomeProcess && app != mPreviousProcess) {
mStackSupervisor.scheduleDestroyAllActivities(app,"String_Node_Str");
}
}
}
app.trimMemoryLevel=curLevel;
step++;
if (step >= factor) {
step=0;
switch (curLevel) {
case ComponentCallbacks2.TRIM_MEMORY_COMPLETE:
curLevel=ComponentCallbacks2.TRIM_MEMORY_MODERATE;
break;
case ComponentCallbacks2.TRIM_MEMORY_MODERATE:
curLevel=ComponentCallbacks2.TRIM_MEMORY_BACKGROUND;
break;
}
}
}
 else if (app.curProcState == ActivityManager.PROCESS_STATE_HEAVY_WEIGHT) {
if (app.trimMemoryLevel < ComponentCallbacks2.TRIM_MEMORY_BACKGROUND && app.thread != null) {
try {
if (DEBUG_SWITCH || DEBUG_OOM_ADJ) Slog.v(TAG,"String_Node_Str" + app.processName + "String_Node_Str"+ ComponentCallbacks2.TRIM_MEMORY_BACKGROUND);
app.thread.scheduleTrimMemory(ComponentCallbacks2.TRIM_MEMORY_BACKGROUND);
}
 catch (RemoteException e) {
}
}
app.trimMemoryLevel=ComponentCallbacks2.TRIM_MEMORY_BACKGROUND;
}
 else {
if ((app.curProcState >= ActivityManager.PROCESS_STATE_IMPORTANT_BACKGROUND || app.systemNoUi) && app.pendingUiClean) {
final int level=ComponentCallbacks2.TRIM_MEMORY_UI_HIDDEN;
if (app.trimMemoryLevel < level && app.thread != null) {
try {
if (DEBUG_SWITCH || DEBUG_OOM_ADJ) Slog.v(TAG,"String_Node_Str" + app.processName + "String_Node_Str"+ level);
app.thread.scheduleTrimMemory(level);
}
 catch (RemoteException e) {
}
}
app.pendingUiClean=false;
}
if (app.trimMemoryLevel < fgTrimLevel && app.thread != null) {
try {
if (DEBUG_SWITCH || DEBUG_OOM_ADJ) Slog.v(TAG,"String_Node_Str" + app.processName + "String_Node_Str"+ fgTrimLevel);
app.thread.scheduleTrimMemory(fgTrimLevel);
}
 catch (RemoteException e) {
}
}
app.trimMemoryLevel=fgTrimLevel;
}
}
}
 else {
if (mLowRamStartTime != 0) {
mLowRamTimeSinceLastIdle+=now - mLowRamStartTime;
mLowRamStartTime=0;
}
for (int i=N - 1; i >= 0; i--) {
ProcessRecord app=mLruProcesses.get(i);
if (allChanged || app.procStateChanged) {
setProcessTrackerStateLocked(app,trackerMemFactor,now);
app.procStateChanged=false;
}
if ((app.curProcState >= ActivityManager.PROCESS_STATE_IMPORTANT_BACKGROUND || app.systemNoUi) && app.pendingUiClean) {
if (app.trimMemoryLevel < ComponentCallbacks2.TRIM_MEMORY_UI_HIDDEN && app.thread != null) {
try {
if (DEBUG_SWITCH || DEBUG_OOM_ADJ) Slog.v(TAG,"String_Node_Str" + app.processName + "String_Node_Str"+ ComponentCallbacks2.TRIM_MEMORY_UI_HIDDEN);
app.thread.scheduleTrimMemory(ComponentCallbacks2.TRIM_MEMORY_UI_HIDDEN);
}
 catch (RemoteException e) {
}
}
app.pendingUiClean=false;
}
app.trimMemoryLevel=0;
}
}
if (mAlwaysFinishActivities) {
mStackSupervisor.scheduleDestroyAllActivities(null,"String_Node_Str");
}
if (allChanged) {
requestPssAllProcsLocked(now,false,mProcessStats.isMemFactorLowered());
}
if (mProcessStats.shouldWriteNowLocked(now)) {
mHandler.post(new Runnable(){
@Override public void run(){
synchronized (ActivityManagerService.this) {
mProcessStats.writeStateAsyncLocked();
}
}
}
);
}
if (DEBUG_OOM_ADJ) {
if (false) {
RuntimeException here=new RuntimeException("String_Node_Str");
here.fillInStackTrace();
Slog.d(TAG,"String_Node_Str" + (SystemClock.uptimeMillis() - now) + "String_Node_Str",here);
}
 else {
Slog.d(TAG,"String_Node_Str" + (SystemClock.uptimeMillis() - now) + "String_Node_Str");
}
}
}