1. 程式人生 > >youtobe導致功耗變大的解決方法

youtobe導致功耗變大的解決方法

在測試功耗的時候,發現youtobe應用會導致功耗變大,下面介紹下解決方法:

1:首先可以調整最大背光亮度,將最大值從255調整為245.經過驗證分析這種變動使用者無法察覺,但是將會降低功耗。

 private static final void initCodecList() {         synchronized (sInitLock) {             if (sRegularCodecInfos == null) {                 int count = native_getCodecCount();                 ArrayList<MediaCodecInfo> regulars = new ArrayList<MediaCodecInfo>();                 ArrayList<MediaCodecInfo> all = new ArrayList<MediaCodecInfo>();                 for (int index = 0; index < count; index++) {                     try {                         MediaCodecInfo info = getNewCodecInfoAt(index);

                        //#ifdef 1                         //modify 2018-01-30,disable vp9 codec for youtube                         if (isWritelist() && "OMX.MTK.VIDEO.DECODER.VP9".equals(info.getName())) {                               Log.e(TAG, "Skip " + info.getName() + " Codec");                              continue;                         }

                        // endif  

 //#ifdef 1     //modify 2018-01-30,disable vp9 codec for youtube

    public static boolean isWritelist() {         boolean ret = false;         String callingAPP = "";         FileInputStream fis = null;         try {             fis = new FileInputStream("/proc/" + android.os.Process.myPid() + "/cmdline");             byte[] buffer = new byte[100];             int count = fis.read(buffer);             if (count > 0) {                 callingAPP = new String(buffer, 0, count);                 Log.d("mtk debug", "callingAPP is " + callingAPP);             }         } catch (Exception e) {             e.printStackTrace();         } finally {             if (fis != null) {                 try {                     fis.close();                 } catch (Exception exp) {                 }             }         }

        if (callingAPP.startsWith("com.google.android.youtube")                 || true)             ret = true;         return ret;

    }     // endif

3:device/mediatek/mt6761 / media_codecs_mediatek_video.xml

<MediaCodec name="OMX.MTK.VIDEO.DECODER.VP9" type="video/x-vnd.on2.vp9" >改為:

 <MediaCodec name="OMX.MTK.VIDEO.DECODER.SW.VP9" type="video/x-vnd.on2.vp9" >

第三條僅僅作為參考,建議不要修改。