Uhaw Pa Sa Camel

  HITS:  
 
d'Doc
Alabang, Muntinlupa City, Philippines
Beer-loving Gunner extraordinaire, perennial vocalist, guitarist, dog person, and wet kisser in one neat li'l package.

>> VIEW MY COMPLETE PROFILE

>> Home  

Subscribe to
Posts [Atom]  

Links
Previous Posts
Archives

Powered by Blogger

 
Saturday, September 20, 2008

Locking the Keypad in UIQ for P1

 

Wow programming! Hahaha

Why don't I try my hand at this? Maybe my blog visit stats would go higher.

So how do we lock the P1 keypad? API? Nope! As far as Sony-Ericsson is concerned, their Standby Application is the only thing that knows how to lock their d*mn P1 phones. So plan B? We use the Standby App to lock the phone for us. Easy? Took me long enough to figure out!

After typing "Symbian" "UIQ" and "key lock" in the google search bar I came up with the following discussion: Querying Key Lock State

This turned out to be a very interesting discussion which was both very helpful and turned out to be almost the answer to my problem.

Following the discussion, you will eventually come up to the very neat stuff (with a sample application). Basically the gist is this:


Snippet 1.

// ...
const TUid KUidStandby = { 0x10205AB5 }; // Uid of the Standby App
RWsSession& aWs = CEikonEnv::Static()->WsSession();

TApaTaskList list(aWs);
TApaTask task = list.FindApp(KUidStandby);
if (task.Exists()) {
TKeyEvent key = {EQuartzKeyBack, EStdKeyDevice1C, 0, 1};
task.SendKey(key);
}
// ...


Would it work for you? It did not for me! It set me in the right direction though.

I finally came up with the idea to simulate keystrokes from my app that would get the attention of the Standby App and finally get my keypad locked. So I came up with the following from Simulating Key Events.


Snippet 2.

void simulateBackKey()
{
RWsSession& aWs = CEikonEnv::Static()->WsSession();

TKeyEvent keyEvent;
keyEvent.iCode = EQuartzKeyBack;
keyEvent.iScanCode = EStdKeyDevice1C;
keyEvent.iModifiers = EModifierAutorepeatable; // Simulate long keypresses??
keyEvent.iRepeats = 1; // Simulate long keypresses??
aWs.SimulateKeyEvent(keyEvent);
aWs.Flush();
}


Ok what this basicaly does is simulate a long press of the back button, found on the side of the phone just below the jog dial. Long pressing the back button sends any active application to the background and brings the Standby App up to the foreground. Long pressing the back button for a second time tells the Standby App to lock the keypad. So what we have here is a two-step process: bring up the Standby App and then lock the keypad.

To achieve this, we should have a timing mechanism to create a delay (2 seconds worked for me) between the two key simulations because the following just wouldn't work:


Snippet 3.

// ...
simulateBackKey(); // Ok, brings up the Standby App
simulateBackKey(); // FAIL! Too soon.
// ...


But I won't get into that messy detail right now, I'm sure googling(?) for "Symbian CTimer" will get you in the right direction.

So you finally managed to get this all working. Well and good! But you are too egocentric to accept the idea of your application just disappearing into the background. Well why not bring your app back up again? Of course after another (2-second) delay is in order, you could do that.


Snippet 4.

void bringMyAppBack()
{
TApaTask task(CEikonEnv::Static()->WsSession());
task.SetWgId(CEikonEnv::Static()->RootWin().Identifier());
task.BringToForeground();
}

Ok that's it! To run down:


  1. simulateBackKey();

  2. <(2-second) delay>

  3. simulateBackKey();

  4. <(2-second) delay>

  5. bringMyAppBack();


I've only tested this stuff on P1i, but feel free to try it out with other SE phones with similar interfaces and good luck!


Subscribe to
Posts [Atom]

 
 
 
Thursday, September 04, 2008

Pinoy Thriller

 
Ano ang nasa dako pa roon? Bunga ng malilikot na pag-iisip, likha ng balintataw o halaw. Di kayang ipaliwanag, ngunit alam mong magaganap. AHHHHHHHHHHHHHHHH!!!

Subscribe to
Posts [Atom]

 
 
 
Tuesday, September 02, 2008

Handling Stress (Yeah!)

 

From our Stress-Handling Seminar:



Subscribe to
Posts [Atom]