if (z_max < task->z)
z_max = task->z;
- if (task->oom_score_lru == OOMADJ_APP_IN_FOREGROUND_APP_LIST)
+ if (task->oom_score_lru == OOMADJ_APP_IN_FOREGROUND_APP_LIST) {
+ if (task->is_focused)
+ return -EINVAL;
+
foreground_app_count++;
+ }
z_candidates[task->z] = task;
}
- foreground_app_index = candidates->len - foreground_app_count;
- if (foreground_app_index < 0)
+ focused_app_index = candidates->len - 1;
+ if (focused_app_index < 0)
return -EINVAL;
- focused_app_index = foreground_app_index - 1;
- if (focused_app_index < 0)
+ foreground_app_index = focused_app_index - foreground_app_count;
+ if (foreground_app_index < 0)
return -EINVAL;
z_index = 0;
* Reorder foreground app candidates according to policy.
*
* 1. Basically, sorting candidates from high value of z to low one.
- * 2. If window information's is_focus is equal to 1,
- * put it before foreground app list.
- * 3. If task_info's oom_score_lru is OOMADJ_APP_IN_FOREGROUND_APP_LIST,
- * put it to end of candidates.
+ * 2. If task_info's oom_score_lru is OOMADJ_APP_IN_FOREGROUND_APP_LIST,
+ * put it before focused app.
+ * 3. If window information's is_focus is equal to 1,
+ * put it to the end of candidates list.
* 4. App memory size is out of interest
*
* candidates will be sorted like below:
*
- * |(high z) --> (low z)|(is_focused = 1)|(OOMADJ_APP_IN_FOREGROUND_APP_LIST)|
+ * |(high z) --> (low z)|(OOMADJ_APP_IN_FOREGROUND_APP_LIST)|(is_focused == 1)|
*/
if (z_task->oom_score_lru == OOMADJ_APP_IN_FOREGROUND_APP_LIST) {
task_ptr = &g_array_index(candidates,