Search code examples
javaandroidandroid-source

Where is AOSP surfaceflinger initiated?


SurfaceFlinger is essential in Android graphics rendering. I ve researched and found some code about surfaceflinger. This is its main: https://android.googlesource.com/platform/frameworks/native/+/refs/tags/android-11.0.0_r28/services/surfaceflinger/main_surfaceflinger.cpp

I couldnt find anything related to starting surfaceflinger on init.rc: https://android.googlesource.com/platform/system/core/+/refs/tags/android-11.0.0_r28/rootdir/init.rc

I ve found here: https://proandroiddev.com/how-android-boot-up-9864376d911c that surfaceflinger is started by SystemServer. So I found SystemServer source code here: https://android.googlesource.com/platform/frameworks/base/+/refs/tags/android-11.0.0_r28/services/java/com/android/server/SystemServer.java but I saw no mention of SurfaceFlinger/surfaceflinger or Surface Flinger

There is a surfaceflinger.rc file in the Surface Flinger directory but I couldn t find any file that includes it: https://android.googlesource.com/platform/frameworks/native/+/refs/tags/android-11.0.0_r28/services/surfaceflinger/surfaceflinger.rc

Where is the surfaceflinger service started in Android?


Solution

  • There is a surfaceflinger.rc file in the Surface Flinger directory but I couldn t find any file that includes it: https://android.googlesource.com/platform/frameworks/native/+/refs/tags/android-11.0.0_r28/services/surfaceflinger/surfaceflinger.rc

    It is here: https://android.googlesource.com/platform/frameworks/native/+/refs/tags/android-11.0.0_r28/services/surfaceflinger/Android.bp#253 init_rc:["surfaceflinger.rc"]:

    cc_binary {
        name: "surfaceflinger",
        defaults: ["libsurfaceflinger_binary"],
        init_rc: ["surfaceflinger.rc"],
        srcs: [":surfaceflinger_binary_sources"],
        shared_libs: [
            "libsurfaceflinger",
            "libSurfaceFlingerProp",
        ],
    }