Example #1
0
std::string HmiService::Show(const std::string &unit)
{
    if (0 == unit.compare(0, 16, "PowerOff.service")) {
        sd_journal_print(LOG_DEBUG, "HmiService::Show() - %s (match)\n",
            unit.c_str());
        std::string path = gSystemdSession->StartUnit(unit, "replace");
    } else {
        sd_journal_print(LOG_DEBUG, "HmiService::Show() - %s\n",
            unit.c_str());
        for (int count = 0; count < gdp_surfaces_num; count++) {
            if (0 == unit.compare(gdp_surfaces[count].unit)) {
                if (ILM_TRUE == gdp_surfaces[count].created) {
                    extern void surface_control(const int index);
                    // bring gdp_surfaces[count].id_surface to front
                    surface_control(count);
                    sd_journal_print(LOG_DEBUG,
                        "HmiService::Show() - %s surface (%d) exists.\n",
                        unit.c_str(), gdp_surfaces[count].id_surface);
                } else {
                    // request systemd to start the unit
                    std::string path = gSystemdSession->StartUnit(unit, "replace");
                    sd_journal_print(LOG_DEBUG,
                        "systemd(session)::StartUnit() - %s\n", path.c_str());
                }
                break; // for-loop
            }
            else {
                sd_journal_print(LOG_DEBUG, "DEBUG: compare \"%s\" with \"%s\"",
                    unit.c_str(), gdp_surfaces[count].unit.c_str());
            }
        } // for-loop
    }
    return "Show unit \"" + unit + "\"!";
}
sp<Surface> SurfaceControl::getSurface() const
{
    Mutex::Autolock _l(mLock);
    if (mSurfaceData == 0) {
        sp<SurfaceControl> surface_control(const_cast<SurfaceControl*>(this));
        mSurfaceData = new Surface(surface_control);
    }
    return mSurfaceData;
}