• Android init.rc


      丙记零号田  http://www.ccbu.cc/index.php/framework/51.html 

    一.init.rc脚本包括了文件系统初始化、装载的许多过程。init.rc的工作主要是:
    1)设置一些环境变量
    2)创建system、sdcard、data、cache等目录
    3)把一些文件系统mount到一些目录去,如,mount tmpfs tmpfs /sqlite_stmt_journals
    4)设置一些文件的用户群组、权限
    5)设置一些线程参数
    6)设置TCP缓存大小
    init脚本的关键字(如mkdir,chmod,service等等)可以参考init进程的system/core/init/keyword.h文件

    修改init.rc文件内容的唯一方式是修改Android的ROM中的内核镜像(boot.img) 

    二.init.rc包括四种类型的语句:

    动作 Action
    命令 Command
    服务 Service
    选项 Option

    2.1. 动作 Action
    on <trigger> ##触发条件
    <command1> ##执行命令
    <command2> ##可以同时执行多个命令
    <command3>

    sys.boot_completed  开机完成
    #当属性sys.boot_completed被设置为1时执行
    # cpu min freq must change to 126M when boot completed
    on property:sys.boot_completed=1
        write /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq 0
        setprop persist.sys.first_booting false
        start up_eth0
    	
    # for Internet adb
    on property:netadb.status=true
        setprop service.adb.tcp.port 5555
        restart adbd
    
    # for Internet adb
    on property:netadb.status=false
        setprop service.adb.tcp.port 0
        restart adbd
        
    on property:net.control=true
        start network_control
    
    on property:net.control=false
        stop network_control
    
    on property:persist.adb_connect.status=true
    		write /sys/bus/platform/drivers/usb20_otg/force_usb_mode 2 
    		
    on property:persist.adb_connect.status=false
    		write /sys/bus/platform/drivers/usb20_otg/force_usb_mode 1	
    

    2.2. 命令 Command  

    setprop <name> <value> 设置系统属性<name>为<value>
    start <service> 启动一个服务(如果服务尚未启动)
    stop  <service>  停止服务(如果正在运行)
    wait  <path> [ <timeout> ] poll特定的<path>,出现后返回,或timeout到达。如果timeout没有指定,默认为5秒
    write <path> <string>      打开一个位于<path>的文件,写入(不是追加)字符串<string>
    

    2.3. 服务 Service

    service <name> <pathname> [ <argument> ]*
         <option>
         <option>
         ...
    	 
    <name> ——表示service 的名字
    <pathname> ——表示service所在路径,此处的service是可执行文件,所以一定有存储路径
    <argument> ——启动service所带的参数 
    <option> ——对此service的约束选项
    

    2.4. 选项 Option  

    Option用来定义Service的行为,决定了Service将在何时启动,如何运行等。常用的Option有包括以下一些。	
    class <name> 为一service指定一个类名,所有有相同类名的service可以一同启动或停止。如果没有用class选项指定类名,该service属于"default"。
    disabled 这种类型的服务不会自动启动。它必须明确的使用名字启动
    oneshot  退出不重启服务(名副其实,一次性)
    

    for example……

    service  network_control /system/bin/network_control.sh
        class main
        disabled
        oneshot    
    
    service lcdparamservice /system/bin/lcdparamservice 
       class main
    

       

      

      

  • 相关阅读:
    Docker运行python容器
    SharePoint Online 创建门户网站系列之定制栏目
    SharePoint Online 创建门户网站系列之创建栏目
    SharePoint Online 创建门户网站系列之图片滚动
    SharePoint Online 创建门户网站系列之导航
    SharePoint Online 创建门户网站系列之首页布局
    SharePoint Online 创建门户网站系列之母版页
    SharePoint Online 创建门户网站系列之准备篇
    SharePoint 2013 数据库中手动更新用户信息
    SharePoint 2013 新建项目字段自动加载上次保存值
  • 原文地址:https://www.cnblogs.com/crushgirl/p/14189758.html
Copyright © 2020-2023  润新知