From 4998d9ed31ba276cb64d9bfa9046d1ef147d5898 Mon Sep 17 00:00:00 2001 From: Steve Slaven Date: Mon, 10 Jan 2011 10:44:49 -0800 Subject: Add keydown/up methods diff --git a/src/net/hoopajoo/android/SoftKeys/Globals.java b/src/net/hoopajoo/android/SoftKeys/Globals.java index 6607ff4..607e9a3 100644 --- a/src/net/hoopajoo/android/SoftKeys/Globals.java +++ b/src/net/hoopajoo/android/SoftKeys/Globals.java @@ -104,6 +104,32 @@ public class Globals extends Application { return 0; } + public int sendKeyDown( int keyid ) { + try { + Globals.RootContext cmd = getRootContext(); + cmd.runCommand( "keycodedown " + keyid ); + }catch( Exception e ) { + Log.e( LOG, "Error: " + e.getMessage() ); + Toast.makeText( this, "Unable to execute as root", Toast.LENGTH_LONG ).show(); + return 1; + } + + return 0; + } + + public int sendKeyUp( int keyid ) { + try { + Globals.RootContext cmd = getRootContext(); + cmd.runCommand( "keycodeup " + keyid ); + }catch( Exception e ) { + Log.e( LOG, "Error: " + e.getMessage() ); + Toast.makeText( this, "Unable to execute as root", Toast.LENGTH_LONG ).show(); + return 1; + } + + return 0; + } + public class RootContext { Process p; OutputStream o; @@ -116,6 +142,7 @@ public class Globals extends Application { // spawn our context system( "export CLASSPATH=" + workingDir + "/RemoteContext.jar" ); system( "exec app_process " + workingDir + " net.hoopajoo.android.RemoteContext" ); + runCommand( "" ); } private void system( String cmd ) throws Exception { -- cgit v0.10.2