Sensor

本文详细介绍了安卓系统中Sensor输入子系统的工作原理,包括如何采用Linux输入框架、Evdev进行交互,系统开机启动过程,特别是SystemServer启动及SensorService的初始化。SensorService在新的线程中读取HAL层数据,APP客户端通过SensorManager获取和使用Sensor数据。文章还列举了不同类型的安卓传感器及其用途。
摘要由CSDN通过智能技术生成
Sensor输入子系统

采用了通用的Linux输入框架,它通过/sys/class/input节点和用户空间进行交互。

Evdev提供了一种访问/dev/input/eventX输入设备事件的通用方法。

系统开机启动

init 是 zygote的父进程, 而system_server和其他所有的com.xxx结尾的应用程序都是从zygote fork 而来

#init.rc
service zygote /system/bin/app_process -Xzygote /system/bin --zygote --start-system-server
SystemServer 启动

系统启动时SystemServer main() 调用android_server_systemserver_nativeInit()

   public static void main(String[] args) {

        /*
         * In case the runtime switched since last boot (such as when
         * the old runtime was removed in an OTA), set the system
         * property so that it is in sync. We can't do this in
         * libnativehelper's JniInvocation::Init code where we already
         * had to fallback to a different runtime because it is
         * running as root and we need to be the system user to set
         * the property. http://b/11463182
         */
        SystemProperties.set("persist.sys.dalvik.vm.lib",
                             VMRuntime.getRuntime().vmLibrary());

        if (System.currentTimeMillis() < EARLIEST_SUPPORTED_TIME) {
            // If a device's clock is before 1970 (before 0), a lot of
            // APIs crash dealing with negative numbers, notably
            // java.io.File#setLastModified, so instead we fake it and
            // hope that time from cell towers or NTP fixes it
            // shortly.
            Slog.w(TAG, "System clock is before 1970; setting to 1970.");
            SystemClock.setCurrentTimeMillis(EARLIEST_SUPPORTED_TIME);
        }

        if (SamplingProfilerIntegration.isEnabled()) {
            SamplingProfilerIntegration.start();
            timer = new Timer();
            timer.schedule(new TimerTask() {
                @Override
                public 
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值