Android开发

android P 提高进程优先级

本文主要是介绍android P 提高进程优先级,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

说明

camera录像过程中发现,退出预览界面帧率只有16帧,达不到正常的25帧。进入预览界面帧率达到25帧,发现引用必须是前台进程才能使camera的帧率达到25帧,需要提高进程优先级。

方法

在ActivityManagerService中修改进程优先级,主要是在computeOomAdjLocked方法中添加

diff --git a/frameworks/base/services/core/java/com/android/server/am/ActivityManagerService.java b/frameworks/base/services/core/java/com/android/server/am/ActivityManagerService.java
index ead4c01..67d2796 100755
--- a/frameworks/base/services/core/java/com/android/server/am/ActivityManagerService.java
+++ b/frameworks/base/services/core/java/com/android/server/am/ActivityManagerService.java
@@ -23314,7 +23314,10 @@ public class ActivityManagerService extends IActivityManager.Stub

         int prevAppAdj = app.curAdj;
         int prevProcState = app.curProcState;
-
+        if((app.processName.equals("video.evs.camera"))
+            || (app.processName.equals("video.evs.camera:renderservice"))) {
+               app.maxAdj = ProcessList.FOREGROUND_APP_ADJ;
+       }
         if (app.maxAdj <= ProcessList.FOREGROUND_APP_ADJ) {
             // The max adjustment doesn't allow this app to be anything
             // below foreground, so it is not worth doing work for it.

这篇关于android P 提高进程优先级的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!