20171010聯通流量懸浮球導致的瀏覽器功耗偏大
功耗現象
留意下流量球
分析
現象:聯通流量懸浮球會在某些網頁才會出現。
對比發現:
1.不帶聯通流量懸浮球的介面CPU開核數1核,且電量540mA
2.帶聯通流量懸浮球的介面CPU開核數3核,且電量993mA
即遮蔽聯通流量懸浮球來解決流量網頁功耗大現象
優化前後測試電流資料如下
功耗原因
聯通卡在原生瀏覽器中會出現流量球,並不斷重新整理流量資料,導致CPU被強制佔用到3核最高頻率執行,導致電流過大,一下會手機就嚴重發燙,且快速掉電。
具體日誌如下:
Line 7: 01-10 20:16:26.391 3936 4171 D suhuazhi: shouldInterceptRequest url:
Line 9: 01-10 20:16:26.392 3936 3936 D suhuazhi: Tab onLoadResource url:http://120.80.57.123/www/default/base.js?v2.1
Line 24: 01-10 20:16:29.220 3936 4171 D suhuazhi: shouldInterceptRequest url:http://120.80.57.123/get?time=1484050589213&tlbsip=http://120.80.57.123/&website=video.m.baidu.com&charset=utf-8
Line 24: 01-10 20:16:29.220 3936 4171 D suhuazhi: shouldInterceptRequest url:http://120.80.57.123/get?time=1484050589213&tlbsip=http://120.80.57.123/&website=video.m.baidu.com&charset=utf-8
Line 25: 01-10 20:16:29.221 3936 3936 D suhuazhi: Tab onLoadResource url:http://120.80.57.123/get?time=1484050589213&tlbsip=http://120.80.57.123/&website=video.m.baidu.com&charset=utf-8
Line 25: 01-10 20:16:29.221 3936 3936 D suhuazhi: Tab onLoadResource url:http://120.80.57.123/get?time=1484050589213&tlbsip=http://120.80.57.123/&website=video.m.baidu.com&charset=utf-8
Line 26: 01-10 20:16:29.383 3936 4171 D suhuazhi: shouldInterceptRequest url:http://120.80.57.123/html/www/resources/templates/default/fullscreenbar/components.css?v=1482463411443
Line 27: 01-10 20:16:29.418 3936 4171 D suhuazhi: shouldInterceptRequest url:http://120.80.57.123/html/www/resources/templates/common/libs/framework.js?v=V500R005C60
……………..
解決方案
瀏覽器過濾掉聯通懸浮球的uri及其執行指令碼
http://120.80.57.123/www/default/base.js?v2.1
package com.android.browser.homepages;
public class HomeProvider extends ContentProvider {
public static WebResourceResponse shouldInterceptRequest(Context context,
String url) {
//Log.e(TAG, "shouldInterceptRequest: url=" + url);
try {
//#ifdef LAVA_EDIT
//suhuazhi.2017-01-11,remove unicom float ball
if (url.startsWith("http://120.80.57.123/www/default")) {
Uri uri = Uri.parse("content://com.android.browser.home/");
InputStream ins = context.getContentResolver().openInputStream(uri);
return new WebResourceResponse("text/html", "utf-8", ins);
}
// #endif
程式碼進一步優化
//#ifdef LAVA_EDIT
//suhuazhi.2017-01-11,remove unicom float ball
if (url.startsWith("http://120.80.57.123/www/default")) {
return new WebResourceResponse("text/html", "utf-8", null);
}
// #endif
測試現象如下:body不執行,懸浮球消失,功耗恢復正常
body不執行
懸浮球消失
結語
以前的功耗分析筆記,以後慢慢往CSDN搬,作為給自己的筆記參考,方便檢視,也督促自己每天學習,人容易生鏽。