javauis/lcdui_akn/javalcdui/src/CMIDToolkit.cpp
changeset 23 98ccebc37403
parent 21 2a9601315dfc
child 25 9ac0a0a7da70
equal deleted inserted replaced
21:2a9601315dfc 23:98ccebc37403
    25 #include <eikappui.h>
    25 #include <eikappui.h>
    26 #include <apgtask.h>
    26 #include <apgtask.h>
    27 #include <bautils.h>
    27 #include <bautils.h>
    28 #include <s32stor.h>
    28 #include <s32stor.h>
    29 #include <s32file.h>
    29 #include <s32file.h>
       
    30 #include <e32property.h>
       
    31 #include <centralrepository.h>
       
    32 #include <settingsinternalcrkeys.h>
       
    33 #include <screensaverinternalpskeys.h>      // to work with screensaver
    30 #include <gfxtranseffect/gfxtranseffect.h>  // For transition effects
    34 #include <gfxtranseffect/gfxtranseffect.h>  // For transition effects
    31 #include <akntranseffect.h>                                 // For transition effects
    35 #include <akntranseffect.h>                                 // For transition effects
    32 //
    36 //
    33 #include "lcdui.h"
    37 #include "lcdui.h"
    34 #include "lcdgr.h"
    38 #include "lcdgr.h"
   425     {
   429     {
   426         ASSERT(oldDisplayable);
   430         ASSERT(oldDisplayable);
   427         ASSERT(oldDisplayable->Component()->Type() == MMIDComponent::EAlert);
   431         ASSERT(oldDisplayable->Component()->Type() == MMIDComponent::EAlert);
   428     }
   432     }
   429 
   433 
       
   434     ResetInactivityTimeL();
       
   435 
   430     // Set it, revert will rollback if required.
   436     // Set it, revert will rollback if required.
   431     iCurrentDisplayable = newDisplayable;
   437     iCurrentDisplayable = newDisplayable;
   432 
   438 
   433     // Activate new displayable first. If this leaves the java toolkit
   439     // Activate new displayable first. If this leaves the java toolkit
   434     // will have to cope with an unwanted pending switch event.
   440     // will have to cope with an unwanted pending switch event.
   485     }
   491     }
   486 
   492 
   487     CleanupStack::Pop();    // revert
   493     CleanupStack::Pop();    // revert
   488 }
   494 }
   489 
   495 
       
   496 void CMIDToolkit::ResetInactivityTimeL()
       
   497 {
       
   498     TInt status = KErrNotFound;
       
   499     RProperty::Get(KPSUidScreenSaver, KScreenSaverAllowScreenSaver,status);
       
   500 
       
   501     // If Screen Saver is enabled and is inactive reset timers
       
   502     // Keep lights on and screensaver disabled. When status is >0 it means
       
   503     // that screen saver is not allowed to be activated
       
   504     if (!status)
       
   505     {
       
   506         TInt isTimeoutEnabled = KErrNone;
       
   507         TInt errPCenrep = KErrNone;
       
   508         CRepository* pCenrep = CRepository::NewLC(KCRUidPersonalizationSettings);
       
   509         if (pCenrep)
       
   510         {
       
   511             errPCenrep = pCenrep->Get(
       
   512                              KSettingsScreensaverTimeoutItemVisibility,
       
   513                              isTimeoutEnabled);
       
   514         }
       
   515         CleanupStack::PopAndDestroy(pCenrep);
       
   516 
       
   517 #if defined(__WINSCW__)
       
   518         if (!isTimeoutEnabled)
       
   519         {
       
   520             isTimeoutEnabled = 1;
       
   521         }
       
   522 #endif
       
   523 
       
   524         // Screen Saver Time out value
       
   525         TInt screenSaverTimeout = KErrNone;
       
   526         TInt errSCenrep = KErrNone;
       
   527         CRepository* securityCenrep = CRepository::NewLC(KCRUidSecuritySettings);
       
   528         if (securityCenrep)
       
   529         {
       
   530             errSCenrep = securityCenrep->Get(
       
   531                              KSettingsAutomaticKeyguardTime, screenSaverTimeout);
       
   532         }
       
   533         CleanupStack::PopAndDestroy(securityCenrep);
       
   534 
       
   535         // Inactivity time in seconds
       
   536         TInt userInactivity = User::InactivityTime().Int();
       
   537 
       
   538         // Check if screen saver is inactive, if so reset timers
       
   539         if (errPCenrep == KErrNone && errSCenrep == KErrNone &&
       
   540                 isTimeoutEnabled && userInactivity < screenSaverTimeout)
       
   541         {
       
   542             User::ResetInactivityTime();
       
   543         }
       
   544     }
       
   545 }
       
   546 
   490 void CMIDToolkit::BringToForeground()
   547 void CMIDToolkit::BringToForeground()
   491 {
   548 {
   492     LCDUI_DEBUG("**RF**");
   549     LCDUI_DEBUG("**RF**");
   493 
   550 
   494     // Block the foreground granting to MIDlet immediately after user has switched
   551     // Block the foreground granting to MIDlet immediately after user has switched
   511         {
   568         {
   512             java::ui::CoreUiAvkonAppUi* appUi = java::ui::CoreUiAvkonLcdui::getInstance().getJavaUiAppUi();
   569             java::ui::CoreUiAvkonAppUi* appUi = java::ui::CoreUiAvkonLcdui::getInstance().getJavaUiAppUi();
   513             if (appUi && appUi->hasStartScreen())
   570             if (appUi && appUi->hasStartScreen())
   514             {
   571             {
   515                 MMIDComponent* content = iCurrentDisplayable ? iCurrentDisplayable->Component() : NULL;
   572                 MMIDComponent* content = iCurrentDisplayable ? iCurrentDisplayable->Component() : NULL;
   516                 if (!content || content->Type() != MMIDComponent::ECanvas)
   573 
       
   574                 TBool isCanvas = EFalse;
       
   575                 TBool isCanvasReadyToBlit = EFalse;
       
   576                 if (content)
       
   577                 {
       
   578                     if (content->Type() == MMIDComponent::ECanvas)
       
   579                     {
       
   580                         isCanvas = ETrue;
       
   581                         MMIDCanvas* canvas = static_cast<MMIDCanvas*>(content);
       
   582                         isCanvasReadyToBlit = canvas->ReadyToBlit();
       
   583                     }
       
   584                 }
       
   585 
       
   586                 if (!content || !isCanvas || isCanvasReadyToBlit)
   517                 {
   587                 {
   518                     if (iCurrentDisplayable)
   588                     if (iCurrentDisplayable)
       
   589                     {
   519                         iCurrentDisplayable->DrawNow();
   590                         iCurrentDisplayable->DrawNow();
       
   591                     }
   520                     appUi->stopStartScreen();
   592                     appUi->stopStartScreen();
   521                 }
   593                 }
   522             }
   594             }
   523 
   595 
   524             mFirst = EFalse;
   596             mFirst = EFalse;