android IPTV机顶盒开机时间优化方案

1.Hisi平台

基于HiSTBAndroidV600R001C00SPC060 SDK

  •  去掉uboot打印(0.5s)
--- a/device/hisilicon/bigfish/sdk/source/boot/fastboot/common/console.c
+++ b/device/hisilicon/bigfish/sdk/source/boot/fastboot/common/console.c
@@ -215,7 +215,8 @@ void serial_printf(const char *fmt, ...)
 {
        va_list args;
        char printbuffer[CONFIG_SYS_PBSIZE];
-
+       
+       return 0;
        va_start(args, fmt);
 
        /* For this to work, printbuffer must be larger than

 

  •  关闭内核打印(0.5s)
--- a/device/hisilicon/Hi3798MV100/etc/bootargs_Hi3798MV100_RAM1G_FLASH8G-emmc.txt
+++ b/device/hisilicon/Hi3798MV100/etc/bootargs_Hi3798MV100_RAM1G_FLASH8G-emmc.txt
@@ -10,7 +10,7 @@ use_mdio=0,1
 phy_addr=2,1
 gmac_debug=0
 bootcmd=mmc read 0 0x1FFBFC0 0x60000 0x5000; bootm 0x1FFBFC0
-bootargs=console=ttyAMA0,115200 blkdevparts=mmcblk0:1M(fastboot),1M(bootargs),2M(stbinfo),20M(loader),20M(loaderbak),10M(recovery),2M(deviceinfo),8M(baseparam),8M(pqparam),20M(logo),20M(logobak),40M(fastplay),40M(fastplaybak),40M(kernel),20M(misc),8M(userapi),8M(hibdrv),8M(qbflag),300M(qbdata),800M(system),2560M(userdata),500M(cache),30M(wifi),40M(flashdata),50M(private),-(sdcard) coherent_pool=1M
+bootargs=console=ttyAMA0,115200 blkdevparts=mmcblk0:1M(fastboot),1M(bootargs),2M(stbinfo),20M(loader),20M(loaderbak),10M(recovery),2M(deviceinfo),8M(baseparam),8M(pqparam),20M(logo),20M(logobak),40M(fastplay),40M(fastplaybak),40M(kernel),20M(misc),8M(userapi),8M(hibdrv),8M(qbflag),300M(qbdata),800M(system),2560M(userdata),500M(cache),30M(wifi),40M(flashdata),50M(private),-(sdcard)quiet coherent_pool=1M
 bootargs_512M=mem=512M mmz=ddr,0,0,112M
 bootargs_768M=mem=768M mmz=ddr,0,0,300M
 bootargs_1G=mem=1G mmz=ddr,0,0,300M

 

  • 关闭开机preload功能(1s)
--- a/device/hisilicon/Hi3798MV100/device.mk
+++ b/device/hisilicon/Hi3798MV100/device.mk
@@ -221,7 +221,7 @@ PRODUCT_COPY_FILES += \
     device/hisilicon/bigfish/etc/andsnap:root/sbin/andsnap
 else
 PRODUCT_PROPERTY_OVERRIDES += \
-    ro.laterscan.enable=false
+    ro.laterscan.enable=true
 endif
 
 PRODUCT_PROPERTY_OVERRIDES += \
  •  缩短dhcp重连间隔(2s)
--- a/external/dhcpcd/dhcpcd.c
+++ b/external/dhcpcd/dhcpcd.c
@@ -319,10 +319,11 @@ send_message(struct interface *iface, int type,
                syslog(LOG_DEBUG, "%s: sending %s with xid 0x%x",
                    iface->name, get_dhcp_op(type), state->xid);
        else {
+               
                if (state->interval == 0)
-                       state->interval = 4;
+                       state->interval = 1;
                else {
-                       state->interval *= 2;
+                       state->interval = state->interval*2 + 1;
                        if (state->interval > 64)
                                state->interval = 64;
                }

 

2.Amlogic平台

  • 去掉开机按组合键进recovery功能(约0.5s)

--- a/include/configs/gxl_p211_v1.h
+++ b/include/configs/gxl_p211_v1.h
@@ -323,8 +323,7 @@
             "run init_display;"\
             "run upgrade_check;"\
             "run storeargs;"\
-            "run switch_bootmode;"\
-            "run irremote_update"
+            "run switch_bootmode;"
 #define CONFIG_BOOTCOMMAND "run storeboot"

 

  • 去掉uboot打印(约0.5s)

--- a/common/console.c
+++ b/common/console.c
@@ -486,7 +486,7 @@ int printf(const char *fmt, ...)
        if (!gd->have_console)
                return 0;
 #endif
-
+    return 0;
        va_start(args, fmt);

 

  • 优化开机动画显示速度(约0.5s)

diff --git a/cmds/bootanimation/BootAnimation.cpp b/cmds/bootanimation/BootAnimation.cpp
index 068747e..9514195 100755
--- a/cmds/bootanimation/BootAnimation.cpp
+++ b/cmds/bootanimation/BootAnimation.cpp
@@ -451,11 +451,11 @@ static void handleMovieTimout() {
 static void msleepAndCheckExit(int msec) {
     char value[PROPERTY_VALUE_MAX];
     static bool bfirstpic = true;
-    int lmsec = 3000;
+    int lmsec = 1000;
     if(bfirstpic) {
         bfirstpic = false;
     } else {
-        lmsec = 500;
+        lmsec = 300;
     }
 
     while (lmsec-- > 0) {
@@ -996,9 +996,9 @@ bool BootAnimation::movie()
                         spec.tv_sec  = (now + delay) / 1000000000;
                         spec.tv_nsec = (now + delay) % 1000000000;
                         int err;
-                        do {
-                            err = clock_nanosleep(CLOCK_MONOTONIC, TIMER_ABSTIME, &spec, NULL);
-                        } while (err<0 && errno == EINTR);
+                        //do {
+                            //err = clock_nanosleep(CLOCK_MONOTONIC, TIMER_ABSTIME, &spec, NULL);
+                        //} while (err<0 && errno == EINTR);
                     }
                 } else { // save bootup time!
                     nsecs_t hundredUsDelay = delay/100000;

 

  • 启动硬件加速(约0.3s)

         针对特殊APK启动硬件加速

--- a/core/java/android/view/Window.java
+++ b/core/java/android/view/Window.java
@@ -485,8 +485,7 @@ public abstract class Window {
         //some times,mHardwareAccelerated will cause UI issues
         //mAppName:com.shcmcc.sanping/com.duolebo.shcmcc.activity.HomeActivity 
         if(mAppName != null && (mAppName.contains("com.duolebo.shcmcc.activity.HomeActivity")
-                        || mAppName.contains("net.sunniwell.app.swplayer.photo.PhotoActivity")
-                        || mAppName.contains("net.sunniwell.app.ott.chinamobile.entry.MainApp"))){
+                        || mAppName.contains("net.sunniwell.app.swplayer.photo.PhotoActivity"))){
         mHardwareAccelerated = false;
         android.util.Log.e("Window","remove HardwareAccelerated for "+mAppName);
         }

 

    build文件中的ro.tr069.enable的值true改为false开机时间大幅度缩减,之前一直在29-30S左右,更改后的值在23-24S左右

3.Mstar平台

  • 提前连网时间(2s)
diff --git a/device/mstar/common/libraries/ethernet_deprecated/java/android/net/ethernet/EthernetStateTracker.java b/device/mstar/common/libraries/ethernet_deprecated/java/android/net/ethernet/EthernetStateTracker.java
index e7d8287..310f55a 100755 (executable)
--- a/device/mstar/common/libraries/ethernet_deprecated/java/android/net/ethernet/EthernetStateTracker.java
+++ b/device/mstar/common/libraries/ethernet_deprecated/java/android/net/ethernet/EthernetStateTracker.java
@@ -148,6 +148,7 @@ public class EthernetStateTracker extends Handler implements NetworkStateTracker
         dhcpThread.start();
         mDhcpTarget = new DhcpHandler(dhcpThread.getLooper(), this);
         mMonitor = new EthernetMonitor(this);
+               mMonitor.startMonitoring();
         mDhcpInfo = new DhcpResults();
         setTeardownRequested(false);
     }
diff --git a/frameworks/base/services/java/com/android/server/EthernetService.java b/frameworks/base/services/java/com/android/server/EthernetService.java
index cb53f2e..6c8cc16 100755 (executable)
--- a/frameworks/base/services/java/com/android/server/EthernetService.java
+++ b/frameworks/base/services/java/com/android/server/EthernetService.java
@@ -29,6 +29,7 @@ import android.net.ethernet.IEthernetManager;
 
 import android.provider.Settings;
 import android.util.Slog;
+import android.net.NetworkUtils;
 /*
 import com.mstar.android.ethernet.EthernetDevInfo;
 import com.mstar.android.ethernet.EthernetManager;
@@ -62,8 +63,16 @@ public class EthernetService<syncronized> extends IEthernetManager.Stub {
         mEnabled = getPersistedState();
         if (DEBUG == true) Slog.i(TAG, "Ethernet dev enabled " + mEnabled);
         getDeviceNameList();
-        setState(mEnabled);
-        mTracker.StartPolling();
+           // Mstar Android Patch Begin
+        NetworkUtils.enableInterface("eth0");
+        if (mEnabled == EthernetManager.ETHERNET_STATE_UNKNOWN) {
+            persistEnabled(true);
+           Slog.i(TAG, "Enable ethernet when there isn't config");
+        }
+        // setState(mEnabled);
+        //mTracker.StartPolling();
+        // Mstar Android Patch End
+
     }
 
     /**
diff --git a/frameworks/base/services/java/com/android/server/am/ActivityManagerService.java b/frameworks/base/services/java/com/android/server/am/ActivityManagerService.java
index c5f8996..2b29e38 100755 (executable)
--- a/frameworks/base/services/java/com/android/server/am/ActivityManagerService.java
+++ b/frameworks/base/services/java/com/android/server/am/ActivityManagerService.java
@@ -2873,7 +2873,7 @@ public final class ActivityManagerService extends ActivityManagerNative
 
     boolean startHomeActivityLocked(int userId) {
         // MStar Android Patch Begin
-        if ( "running".equals(SystemProperties.get("init.svc.mi_bootvideo", "stopped"))) {
+    /*    if ( "running".equals(SystemProperties.get("init.svc.mi_bootvideo", "stopped"))) {
                        if (!mDummyActivityRunning) {
                 Intent Dummy = new Intent();
                 Dummy.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
@@ -2882,7 +2882,7 @@ public final class ActivityManagerService extends ActivityManagerNative
                 mDummyActivityRunning = true;
             }
             return false;
-        }
+        } */
         // MStar Android Patch End
 
         if (mHeadless) {

 

4.开机时间分析注意事项

  • 账号问题:非正式账号可能导致时间变长,这种情况建议使用友商的正常账号先验证一下
  • 开机日志分析:

          一般分析四个过程

         (1)硬件启动消耗时间

     上电到开机结束时间减去logcat抓取日志时长

    (2)开机到网络连接上

     搜开机日志dhcpcd ,表示8.469时刻连网成功

    Line 1974: 01-01 00:00:07.655 D/DHCPCD  ( 2072): eth0: sending REQUEST (xid 0xf6212a80), next in 0.69 seconds
    Line 2038: 01-01 00:00:07.795 I/DHCPCD  ( 2072): eth0: acknowledged 192.168.1.25 from 192.168.1.1
    Line 2042: 01-01 00:00:07.804 I/DHCPCD  ( 2072): eth0: leased 192.168.1.25 for 604800 seconds
    Line 2043: 01-01 00:00:07.804 D/DHCPCD  ( 2072): eth0: adding IP address 192.168.1.25/24
    Line 2044: 01-01 00:00:07.804 D/DHCPCD  ( 2072): eth0: writing lease `/data/misc/dhcp/dhcpcd-eth0.lease'
    Line 2044: 01-01 00:00:07.804 D/DHCPCD  ( 2072): eth0: writing lease `/data/misc/dhcp/dhcpcd-eth0.lease'

 

    (3)系统校时

    代表10.916时刻FTP校时成功

01-01 00:00:10.914 D/pcapcmcc3( 1746): g_capture_packets_num = 249, ret = 0
01-01 00:00:10.914 D/pcapcmcc3( 1746): send (0) TCP with http but not finish 
01-01 00:00:10.916 I/System.out( 2425): zzzzz1 null ....onStartCommand()....flags=0,startId=2  Debug
01-01 00:00:10.916 D/AlarmManagerService( 1968): Setting time of day to sec=1540434515
10-25 10:28:35.000 W/AlarmManagerService( 1968): Unable to set rtc to 1540434515: No such device
10-25 10:28:35.003 D/ScanApp ( 2364): [67|Thread-67 ] pkg pkgEnable:0, pkg:com.migusmartlink.ott.tv
10-25 10:28:35.007 D/TTT     ( 2364): [67|Thread-67 ] mPkg:com.migusmartlink.ott.tv,msupkg:com.iflytek.xiri2.hal

 

    (4)launcher启动

            找到对应包名,然后搜start u0

10-25 10:28:35.140 I/ActivityManager( 1968): START u0 {act=cn.cmvideo.action.ITV cmp=tv.icntv.ott/.icntv (has extras)} from pid 2629

 

    (5)launcher启动完成

10-25 10:33:24.417 D/c       ( 2738): _finish() start
10-25 10:33:24.417 D/c       ( 2738): _finish() end
10-25 10:33:24.418 D/c       ( 2738): _done() end

 

posted on 2018-10-24 16:44  world_hello!!!!  阅读(4301)  评论(0编辑  收藏  举报

导航