CameraServiceProxy启动-Android12

Posted xhBruce

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了CameraServiceProxy启动-Android12相关的知识,希望对你有一定的参考价值。

CameraServiceProxy启动-android12

android12-release
CameraService启动-Android12
CameraProvider进程-Android12


1. 在SystemServer的startOtherServices中启动

  • mSystemServiceManager.startService(CameraServiceProxy.class)先调用CameraServiceProxy构造方法constructor.newInstance(mContext),在调用CameraServiceProxy的service.onStart()方法
  • class CameraServiceProxy extends SystemService

frameworks/base/services/java/com/android/server/SystemServer.java

private void startOtherServices(@NonNull TimingsTraceAndSlog t) 
    t.traceBegin("startOtherServices");
    // ... ...
    boolean disableCameraService = SystemProperties.getBoolean("config.disable_cameraservice",
            false);
	// ... ...
        if (!disableCameraService) 
            t.traceBegin("StartCameraServiceProxy");
            mSystemServiceManager.startService(CameraServiceProxy.class);
            t.traceEnd();
        
	// ... ...

2. CameraServiceProxy初始化并调用onStart()

  • publishBinderService(CAMERA_SERVICE_PROXY_BINDER_NAME, mCameraServiceProxy)添加服务到Binder IPC(Binder系列3-framework层)
  • publishLocalService(CameraServiceProxy.class, this)添加到LocalServices
public void onStart() 
    mUserManager = UserManager.get(mContext);
    if (mUserManager == null) 
        // Should never see this unless someone messes up the SystemServer service boot order.
        throw new IllegalStateException("UserManagerService must start before" +
                " CameraServiceProxy!");
    

    IntentFilter filter = new IntentFilter();
    filter.addAction(Intent.ACTION_USER_ADDED);
    filter.addAction(Intent.ACTION_USER_REMOVED);
    filter.addAction(Intent.ACTION_USER_INFO_CHANGED);
    filter.addAction(Intent.ACTION_MANAGED_PROFILE_ADDED);
    filter.addAction(Intent.ACTION_MANAGED_PROFILE_REMOVED);
    mContext.registerReceiver(mIntentReceiver, filter);

    publishBinderService(CAMERA_SERVICE_PROXY_BINDER_NAME, mCameraServiceProxy);
    publishLocalService(CameraServiceProxy.class, this);

3. 连接CameraService进程

CameraServiceProxy.java中getCameraServiceRawLocked()通过Binder IPC获取


4. 简要时序图

以上是关于CameraServiceProxy启动-Android12的主要内容,如果未能解决你的问题,请参考以下文章

PowerManagerService启动-Android12

PowerManagerService启动-Android12

ANDR-PERF tryGetService 失败; SELinux

Android - 启动时启动服务

IVIVehicleService启动

IVIVehicleService启动