zoukankan      html  css  js  c++  java
  • Amlogic优化开机时间--提前网络连接

    --- a/main.cpp
    +++ b/main.cpp
    @@ -35,6 +35,10 @@
     #include "DnsProxyListener.h"
     #include "MDnsSdListener.h"
     #include "UidMarkMap.h"
    +extern "C" {
    +int ifc_enable(const char *ifname);
    +int ifc_disable(const char *ifname);
    +}
     
     static void coldboot(const char *path);
     static void sigchld_handler(int sig);
    @@ -51,7 +55,8 @@ int main() {
     
     //    signal(SIGCHLD, sigchld_handler);
         blockSigpipe();
    -
    +    //enable eth early
    +    ifc_enable("eth0");
         if (!(nm = NetlinkManager::Instance())) {
             ALOGE("Unable to create NetlinkManager");
             exit(1);
    --
    
    
    --- a/services/java/com/android/server/EthernetService.java
    +++ b/services/java/com/android/server/EthernetService.java
    @@ -93,6 +93,8 @@ public class EthernetService<syncronized> extends IEthernetManager.Stub{
         public EthernetService(Context context, EthernetStateTracker Tracker){
             mTracker = Tracker;
             mContext = context;
    +        
    +        initEth();
     
             mWakeLock = ((PowerManager)mContext.getSystemService(Context.POWER_SERVICE)).newWakeLock(
                     PowerManager.PARTIAL_WAKE_LOCK, TAG);
    @@ -113,9 +115,18 @@ public class EthernetService<syncronized> extends IEthernetManager.Stub{
             Slog.v(TAG, "Trigger the ethernet monitor");
             mTracker.StartPolling();
             mDelayedHandler = new Handler();  
    +
    +        checkIfNeddStart();
             parserConf(createAuthFileName());
         }
    - 
    +    
    +    private void initEth() {
    +       int state = getPersistedState();
    +       if (state == 1) {
    +           NetworkUtils.disableInterface("eth0");
    +       }
    +    }
    +    
         public void checkIfNeddStart(){
             isEthEnabled = getPersistedState();
             Slog.v(TAG,"Ethernet dev enabled " + isEthEnabled );
    
    
    --- a/services/java/com/android/server/am/ActivityManagerService.java
    +++ b/services/java/com/android/server/am/ActivityManagerService.java
    @@ -9908,30 +9907,67 @@ public final class ActivityManagerService extends ActivityManagerNative
             synchronized (this) {
                 readGrantedUriPermissionsLocked();
             }
    -
             if (goingCallback != null) goingCallback.run();
             
             synchronized (this) {
    -            if (mFactoryTest != SystemServer.FACTORY_TEST_LOW_LEVEL) {
    -                try {
    -                    List apps = AppGlobals.getPackageManager().
    -                        getPersistentApplications(STOCK_PM_FLAGS);
    -                    if (apps != null) {
    -                        int N = apps.size();
    -                        int i;
    -                        for (i=0; i<N; i++) {
    -                            ApplicationInfo info
    -                                = (ApplicationInfo)apps.get(i);
    -                            if (info != null &&
    -                                    !info.packageName.equals("android")) {
    -                                addAppLocked(info, false);
    +            Thread thrd = new Thread( new Runnable() {
    +                public void run() {
    +                    if ("mobile".equals(SystemProperties.get("sys.proj.type", null))) {
    +                    // first add bestv and washu apk for improved starup time.
    +                        try {
    +                            ApplicationInfo launch = mSelf.mContext.getPackageManager().getApplicationInfo(
    +                                "com.bestv.ott.baseservices", PackageManager.GET_UNINSTALLED_PACKAGES);
    +                            if(launch != null) {
    +                                 //Slog.d(TAG,"add bestv apk to applock");
    +                                 synchronized(ActivityManagerService.this) {
    +                                     addAppLocked(launch, false);
    +                                 }
                                 }
    +                        } catch (NameNotFoundException e) {
    +                            //Slog.w(TAG,"get bestv apk error");
    +                        }
    +
    +                        //add washu apk 
    +                        try {
    +                            ApplicationInfo launch = mSelf.mContext.getPackageManager().getApplicationInfo(
    +                                "net.sunniwell.app.ott.chinamobile", PackageManager.GET_UNINSTALLED_PACKAGES);
    +                            if(launch != null) {
    +                                //Slog.d(TAG,"add washu apk to applock");
    +                                synchronized(ActivityManagerService.this){
    +                                    addAppLocked(launch, false);
    +                                }
    +                            }
    +                        } catch (NameNotFoundException e) {
    +                        //Slog.w(TAG,"get washu apk error");
    +                        }
    +                    }
    +
    +                    if (mFactoryTest != SystemServer.FACTORY_TEST_LOW_LEVEL) {
    +                        try {
    +                            List apps = AppGlobals.getPackageManager().
    +                                getPersistentApplications(STOCK_PM_FLAGS);
    +                            if (apps != null) {
    +                                int N = apps.size();
    +                                int i;
    +                                for (i=0; i<N; i++) {
    +                                    ApplicationInfo info
    +                                        = (ApplicationInfo)apps.get(i);
    +                                    //Slog.d(TAG,"N="+N+",packageName="+info.packageName);
    +                                    if (info != null &&
    +                                        !info.packageName.equals("android")) {
    +                                        synchronized(ActivityManagerService.this){
    +                                            addAppLocked(info, false);
    +                                        }
    +                                    }
    +                                }
    +                            }
    +                        } catch (RemoteException ex) {
    +                            // pm is in same process, this will never happen.
                             }
                         }
    -                } catch (RemoteException ex) {
    -                    // pm is in same process, this will never happen.
                     }
    -            }
    +            });
    +            thrd.start();
     
                 // Start up initial activity.
                 mBooting = true;
  • 相关阅读:
    vue.js click点击事件获取当前元素对象及获取自定义属性
    在C#的MVC中 Vue的基本用法实例
    使用Dictionary做特殊的json字符串时(可以随意起key的名称)怎么将json字符串反序列化为json匿名对象?及匿名对象的使用方法
    C#生成城市按照一定格式且按字母顺序的方法
    sid-msg.map文件概述
    Linux中 /boot 目录介绍 【转载】
    suricata 命令行解释【转】
    Ubuntu下查看软件版本及安装位置【转】
    linux top命令查看内存及多核CPU的使用讲述【转】
    linux下如何查看多核负载情况【转】
  • 原文地址:https://www.cnblogs.com/leishuanger/p/9844474.html
Copyright © 2011-2022 走看看