maemo.org - Talk

maemo.org - Talk (https://talk.maemo.org/index.php)
-   MeeGo / Harmattan (https://talk.maemo.org/forumdisplay.php?f=45)
-   -   N9. Lock-unlock in my software, how? (https://talk.maemo.org/showthread.php?t=80477)

unreg 2011-11-29 09:29

N9. Lock-unlock in my software, how?
 
In n900 i use d-bus

Code:

dbus-send --system --type=method_call --dest=com.nokia.mce /com/nokia/mce/request com.nokia.mce.request.req_tklock_mode_change string:"locked"
But on n9 it does not work.

Why?

Aegis rule:
Code:

<aegis>
    <request policy="add">
        <credential name="dsme::DeviceStateControl" />
        <credential name="mce::DeviceModeControl" />
       
        <for path="applauncherd-launcher::/usr/bin/applauncherd.bin" />
    </request>
</aegis>

Also it is possible emulation button power pressed?

SPARTAN563 2011-11-29 18:49

Re: N9. Lock-unlock in my software, how?
 
The issue is that aegis won't grant you access to mce:DeviceModeControl without a valid certificate.

You will have to check me on this, since I haven't actually tested it, but I'm pretty certain you can use mce:DeviceControlMode when you install from the Ovi store. So the idea is to write your code up using a debug call or something like that whenever you want to lock, and then when you want to publish it you change that for the actual call.

More info on how to implement the lock interfaces can be found in the Harmattan documentation:
http://harmattan-dev.nokia.com/docs/...cks.html?tab=0

As for emulating a power key press, I don't think that is possible without knowing the low level hardware and coding some stuff up in Assembly.

unreg 2011-11-30 09:54

Re: N9. Lock-unlock in my software, how?
 
Ok, thx.
How to install "MeeGo 1.2 Harmattan API" manually?
Qt SDK package manager say:
Can't find missing dependency (com.nokia.ndk.tools.madde.qemu.system-=0.13.52)

SPARTAN563 2011-11-30 10:09

Re: N9. Lock-unlock in my software, how?
 
Hmm, I downloaded the redistributable SDK from Nokia's website (developer.nokia.com) and that seemed to work fine. I don't really used the SDK Package Manager since it never seemed to work for me.

unreg 2011-11-30 10:34

Re: N9. Lock-unlock in my software, how?
 
And I have downloaded Qt_SDK_Lin64_1.1.4 from developer.nokia.com, and "Harmattan API" not checked ant not installed.

unreg 2011-11-30 11:09

Re: N9. Lock-unlock in my software, how?
 
Unresolved via 09 nov

https://bugreports.qt.nokia.com/brow...ream-issue-tab

wolke 2012-01-24 22:32

Re: N9. Lock-unlock in my software, how?
 
Quote:

Originally Posted by unreg (Post 1130462)
In n900 i use d-bus

Code:

dbus-send --system --type=method_call --dest=com.nokia.mce /com/nokia/mce/request com.nokia.mce.request.req_tklock_mode_change string:"locked"
But on n9 it does not work.

Why?

Aegis rule:
Code:

<aegis>
    <request policy="add">
        <credential name="dsme::DeviceStateControl" />
        <credential name="mce::DeviceModeControl" />
       
        <for path="applauncherd-launcher::/usr/bin/applauncherd.bin" />
    </request>
</aegis>

Also it is possible emulation button power pressed?


Code:

#!/bin/sh

EVENT_POWER_KEY="\x74\x00"
POWERBUTTON_EVENT_FILE=/dev/input/pwrbutton
EVENT_TIMESTAMP="\x48\x67\x98\x45\x5f\x16\x0b\x00"
EVENT_KEY_TYPE="\x01\x00"
EVENT_PRESS_VALUE="\x01\x00\x00\x00"
EVENT_RELEASE_VALUE="\x00\x00\x00\x00"

printf "$EVENT_TIMESTAMP$EVENT_KEY_TYPE$EVENT_POWER_KEY$EVENT_PRESS_VALUE$EVENT_TIMESTAMP$EVENT_KEY_TYPE$EVENT_POWER_KEY$EVENT_RELEASE_VALUE" > $POWERBUTTON_EVENT_FILE

EDIT:
note that this probably {certainly?} requires an open kernel.

taken from:
https://meego.gitorious.org/meego-mi...sts/mcetorture

wolke 2012-01-26 18:01

Re: N9. Lock-unlock in my software, how?
 
here is my script, which i stick at /usr/local/bin/lock

Code:

#!/usr/bin/perl
#Copyright 2012 Elliot Wolk
#License: GNU GENERAL PUBLIC LICENSE v3 or later, at your choice
use strict;
use warnings;

my $usage = "Usage:
  $0 or $0 [-t|--toggle|toggle]
    simulates pushing the power-button
  $0 [-g|--get|get]
    prints locked or unlocked, or exits with error code
    determined by dbus method com.nokia.mce.request.get_tklock_mode
  $0 [-l|--lock|lock]
    if 'get' returns unlocked, simulates pushing the power-button
  $0 [-u|--unlock|lock]
    if 'get' returns locked, simulates pushing the power-button
";

sub getLock(){
  my @cmd = qw(dbus-send
    --system
    --print-reply
    --type=method_call
    --dest=com.nokia.mce
    /com/nokia/mce/request
    com.nokia.mce.request.get_tklock_mode
  );

  my $tklockMode = `@cmd`;
  if($tklockMode =~ /string "(locked|unlocked)"/){
    return $1;
  }else{
    die "Error- couldnt understand dbus reply '$tklockMode'\n";
  }
}

sub powerButton(){
  my $EVENT_POWER_KEY='\x74\x00';
  my $POWERBUTTON_EVENT_FILE='/dev/input/pwrbutton';
  my $EVENT_TIMESTAMP='\x48\x67\x98\x45\x5f\x16\x0b\x00';
  my $EVENT_KEY_TYPE='\x01\x00';
  my $EVENT_PRESS_VALUE='\x01\x00\x00\x00';
  my $EVENT_RELEASE_VALUE='\x00\x00\x00\x00'

  my $bytes = join '', (
    $EVENT_TIMESTAMP,
    $EVENT_KEY_TYPE,
    $EVENT_POWER_KEY,
    $EVENT_PRESS_VALUE,
    $EVENT_TIMESTAMP,
    $EVENT_KEY_TYPE,
    $EVENT_POWER_KEY,
    $EVENT_RELEASE_VALUE,
  );

  system "printf \"$bytes\" > $POWERBUTTON_EVENT_FILE";
}

sub main(@){
  my $arg = shift;
  $arg = '--toggle' if not defined $arg;
  die $usage if @_ > 0;
  if($arg =~ /^(-t|--toggle|toggle)$/){
    powerButton;
  }elsif($arg =~ /^(-l|--lock|lock)$/){
    powerButton if getLock eq 'unlocked';
  }elsif($arg =~ /^(-l|--unlock|unlock)$/){
    powerButton if getLock eq 'locked';
  }elsif($arg =~ /^(-g|--get|get)$/){
    print getLock() . "\n";
  }else{
    die $usage;
  }
}

&main(@ARGV);



All times are GMT. The time now is 00:41.

vBulletin® Version 3.8.8