Chinaunix首页 | 论坛 | 博客
  • 博客访问: 397396
  • 博文数量: 78
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 940
  • 用 户 组: 普通用户
  • 注册时间: 2013-08-25 09:39
文章分类

全部博文(78)

文章存档

2016年(7)

2015年(1)

2014年(35)

2013年(35)

我的朋友

分类: Android平台

2013-12-09 19:54:21

adbd源码位于system/core/adb/目录下,可执行文件位于/sbin/adbd

1init.rc文件代码片段

# adbd on at boot in emulator

on property:ro.kernel.qemu=1

start adbd

//定义了一个触发器,只要persist.service.adb.enable值被置为1,就会启动/sbin/adbd

on property:persist.service.adb.enable=1    

start adbd

on property:persist.service.adb.enable=0

    stop adbd

2build/ core/main.mk代码片段

else # !user_variant

  # Turn on checkjni for non-user builds.

  ADDITIONAL_BUILD_PROPERTIES += ro.kernel.android.checkjni=1

  # Set device insecure for non-user builds.

  ADDITIONAL_DEFAULT_PROPERTIES += ro.secure=0

  # Allow mock locations by default for non user builds

  ADDITIONAL_DEFAULT_PROPERTIES += ro.allow.mock.location=1

endif # !user_variant

 

ifeq (true,$(strip $(enable_target_debugging)))

  # Target is more debuggable and adbd is on by default

  ADDITIONAL_DEFAULT_PROPERTIES += ro.debuggable=1 persist.service.adb.enable=1

  # Include the debugging/testing OTA keys in this build.

  INCLUDE_TEST_OTA_KEYS := true

else # !enable_target_debugging

  # Target is less debuggable and adbd is off by default

  ADDITIONAL_DEFAULT_PROPERTIES += ro.debuggable=0 persist.service.adb.enable=0

endif # !enable_target_debugging

通过判断当前的编译模式来对属性赋予不同的值,然后把属性存储在ADDITIONAL_DEFAULT_PROPERTIES变量中,这个变量在后面是要写到根目录下的/default.prop中去,在系统启动时被属**加载的。

user模式的话,编译系统会把ro.secure置为1,把persist.service.adb.enable置为0。也就是说,用user模式编译出来的系统运行在安全模式下,adbd默认关闭。即使通过设置属性的方式打开,adbd进程的用户也是shell,不具有root权限。这样,普通用户或者开发者拿到一个机器后,通过PC运行adb shell时,是以shell用户登录机器的。把ro.secure置为0,再重新编译,只要设置属性persist.service.adb.enable的值为1adbd进程就会以root用户的身份启动。

阅读(16233) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~