
class ISurfaceComposerClient : public IInterface
class SurfaceComposerClient : public RefBase
{
inline sp<ISurfaceComposerClient> getClient() { return mClient; }
};
// android_view_SurfaceSession.cpp START
sp<SurfaceComposerClient> android_view_SurfaceSession_getClient(
JNIEnv* env, jobject surfaceSessionObj) {
return reinterpret_cast<SurfaceComposerClient*>(
env->GetLongField(surfaceSessionObj, gSurfaceSessionClassInfo.mNativeClient));
}
static jlong nativeCreate(JNIEnv* env, jclass clazz) {
SurfaceComposerClient* client = new SurfaceComposerClient();
client->incStrong((void*)nativeCreate);
return reinterpret_cast<jlong>(client);
}
// android_view_SurfaceSession.cpp END
class Client : public BnSurfaceComposerClient
{
sp<SurfaceFlinger> mFlinger;
};
class ISurfaceComposer: public IInterface {
virtual sp<ISurfaceComposerClient> createConnection() = 0;
};
class SurfaceFlinger : public BnSurfaceComposer
// main_surfaceflinger.cpp START
sp<SurfaceFlinger> flinger = surfaceflinger::createSurfaceFlinger();
sp<IServiceManager> sm(defaultServiceManager());
sm->addService(String16(SurfaceFlinger::getServiceName()), flinger, false,
IServiceManager::DUMP_FLAG_PRIORITY_CRITICAL | IServiceManager::DUMP_FLAG_PROTO);
// main_surfaceflinger.cpp END
class ComposerService : public Singleton<ComposerService>
{
sp<ISurfaceComposer> mComposerService;
static sp<ISurfaceComposer> getComposerService();
};
// SurfaceComposerClient.cpp START
/*static*/ sp<ISurfaceComposer> ComposerService::getComposerService() {
ComposerService& instance = ComposerService::getInstance();
if (instance.mComposerService == nullptr) {
ComposerService::getInstance().connectLocked();
}
return instance.mComposerService;
}
void ComposerService::connectLocked() {
const String16 name("SurfaceFlinger");
while (getService(name, &mComposerService) != NO_ERROR) {
usleep(250000);
}
}
// SurfaceComposerClient.cpp END