View Single Post
Posts: 96 | Thanked: 51 times | Joined on Jul 2010 @ India
#23
Originally Posted by SPARTAN563 View Post
Okay, SIMLock is now in the autobuilder que, will let you all know if/when it is in extras-devel.

As for the idea of locking your phone when an app is started, it isn't the actual UI part that would chew battery power (since that would only be visible for as long as it took you to enter your code in the first place) but rather the background daemon which would have to do something like this (since there doesn't appear to be a DBus signal for "app launched"):

Code:
QList<QString> runningUnlocked;

while(!exit) {
  //Get a list of all the running apps on the phone
  QList<QString> runningApps = GetRunningApps();

  //Loop through them and find out if they are locked, and if they have been unlocked by the person unlocking the phone
  for(int i = 0; i < runningApps.length(); i++) {
    if(IsLockedApp(runningApps[i]) && !runningUnlocked.contains(runningApps[i])) {
        LockPhone();
        WaitForUnlock(); //We don't want to keep calling the lock function while the phone is locked, so wait for it to unlock
        runningUnlocked << runningApps[i]; //Add the app to the list of unlocked ones (temporary)
        continue;
    }

    //Remove any of the apps that were running unlocked but have been closed
    for(int i = 0; i < runningUnlocked.length(); i++) {
       if(!runningApps.contains(runningUnlocked[i]))
          runningUnlocked.removeAt(i);
    }
  }
  sleep(5);
}
Which means that every 5 seconds (less if you wanted to reduce the chance of someone performing that race hack I spoke about) it is gonna have to grab all your running apps, check them against a database of your locked apps, and then if it finds a locked app that is busy running it locks the phone. But each time it has to do that it will be chowing CPU cycles. So in order to lower that you would make it only check while the phone is in an "active" state (i.e. unlocked, the kind that is done with the lock switch). But that still will chew power while the phone is in an active state.

If you'd like though, I'll code it up in Qt, should make it a little less power hungry than if it were in Python.

As for keeping it running after a killall command, you could just use an event.d script that would restart it continually until the phone was turned off.

EDIT: Okay, package has been built by the Autobuilder and should appear in extras-devel relatively soon. I will update this and the first post when it has been uploaded there correctly.

EDIT2: Package is now available in extras-devel
Wow..thanks for your quick response. So if Qt is more CPU or battery efficient. Could you code it in qt and release it for testing?
I'm sorry if I seem too desperate, but this is an application I really wanted on Maemo. All other platforms have apps like this and I've been requesting for such an app since I bought my N900 last year. I never got a satisfactory response till now. But when you said you could do it, my hopes are up high again. I'm patiently waiting for a release.
Thanks again. Cheers!