Left Soft Key Unresponsive After SMS Interrupt on Nokia 5500d

This is an old issue I hoped I would never have to deal with again as it is caused by a Nokia application distributed with some of their devices. The application in question is the SMS reader which uses a speech synthesizer to read any unread messages when the user holds the left soft key.

During compatibility testing an issue was occasionally reported among a variety of applications regarding the left soft key becoming unresponsive. This is normally a very rare bug to find as all key groups (numerical, directional and softkeys) are treated the same in most application and each group either all work, or all don`t. After some investigation by QA a finger was very quickly pointed in the direction of the SMS reader application.

It did not take long to realize that the issue lay in the calling of keyPressed and keyReleased. A small test application later and it became apparent that the underlying OS was hogging the LSK looking for an extended key press so it could start the SMS reader. The result in the JVM was that keyPressed and keyReleased were being called on the same tick, so in the application nothing happened.

The fix is to detect if keyPressed and keyReleased are called on the same tick when the LSK is pressed. If this condition occurs, keyReleased returns to allow the application to detect and handle the key press. A tick counter is something that many applications have and is handy to fix such bugs. An example is shown:

int lskPressedTick = 0;
protected final void keyPressed(int nCode) {
    if( nCode == Device.KEY_LSK ) {        // -6 on Nokia devices
        lskPressedTick = tickCounter;
    }
    .
    .
    .
}
protected final void keyReleased(int nCode) {
    if( nCode == Device.KEY_LSK
        && lskPressedTick == tickCounter ) {
            return;
    }
    .
    .
    .
}

- FIN -


About this entry