
6 changed files with 23 additions and 178 deletions
@ -1,57 +0,0 @@ |
|||
#!/system/bin/sh |
|||
|
|||
exit_with_log() { |
|||
echo Pipe kill $$ >> /data/data/com.pep.pepjniaaractivity/files/pinentry.log |
|||
exit |
|||
} |
|||
trap "exit_with_log" 13 |
|||
|
|||
echo Start $$ >> /data/data/com.pep.pepjniaaractivity/files/pinentry.log |
|||
echo OK |
|||
while read cmd rest |
|||
do |
|||
echo $cmd $rest >> /data/data/com.pep.pepjniaaractivity/files/pinentry.log |
|||
case $cmd in |
|||
SETDESC) |
|||
DESC=$rest |
|||
echo OK |
|||
;; |
|||
SETPROMPT) |
|||
PROMPT=$rest |
|||
echo OK |
|||
;; |
|||
SETOK) |
|||
OK=$rest |
|||
echo OK |
|||
;; |
|||
SETERROR) |
|||
ERROR=$rest |
|||
echo OK |
|||
;; |
|||
GETPIN) |
|||
|
|||
echo "D " |
|||
echo OK |
|||
;; |
|||
OPTION) |
|||
echo OK |
|||
;; |
|||
GETINFO) |
|||
case $rest in |
|||
pid*) |
|||
echo D $$ |
|||
echo OK |
|||
echo D $$ >> /data/data/com.pep.pepjniaaractivity/files/pinentry.log |
|||
;; |
|||
esac |
|||
;; |
|||
BYE) |
|||
echo OK |
|||
exit |
|||
;; |
|||
*) |
|||
echo OK |
|||
;; |
|||
esac |
|||
done |
|||
|
@ -1,66 +0,0 @@ |
|||
package org.pEp.jniadapter; |
|||
|
|||
import java.io.File; |
|||
|
|||
import android.content.Intent; |
|||
import android.app.Service; |
|||
import android.util.Log; |
|||
import android.os.IBinder; |
|||
|
|||
public class GPGAgentService extends Service { |
|||
public static final String TAG = "GPGAgentService"; |
|||
private AgentProcessThread process; |
|||
|
|||
class AgentProcessThread extends Thread { |
|||
|
|||
@Override |
|||
public void run() { |
|||
Log.i(TAG, "execute GPG agent"); |
|||
try { |
|||
Runtime.getRuntime().exec( |
|||
"gpg-agent" + |
|||
" --pinentry-program " + |
|||
new File(AndroidHelper.binDir, "pinentry.sh").getAbsolutePath() + |
|||
//" --no-detach" +
|
|||
" --daemon" + |
|||
//" --write-env-file" +
|
|||
//" --batch" +
|
|||
" --homedir " + AndroidHelper.gnupgHomeDir.getAbsolutePath() + |
|||
" --debug-level basic --log-file " + |
|||
new File(GPGAgentService.this.getFilesDir(), "gpg-agent.log")).waitFor(); |
|||
Log.i(TAG, "execution terminated"); |
|||
} catch (Exception e) { |
|||
Log.e(TAG, "could not execute process", e); |
|||
} finally { |
|||
stopSelf(); |
|||
// eradicate process in critical section
|
|||
synchronized (GPGAgentService.this) { |
|||
process = null; |
|||
} |
|||
} |
|||
} |
|||
} |
|||
|
|||
@Override |
|||
public void onCreate() { |
|||
Log.d(TAG, "onCreate"); |
|||
// Prepare environment for agent
|
|||
AndroidHelper.envSetup(this); |
|||
} |
|||
|
|||
public int onStartCommand(Intent intent, int flags, int startId) { |
|||
Log.d(TAG, "onStartCommand"); |
|||
// use critical section to avoid race conditions
|
|||
synchronized (this) { |
|||
process = new AgentProcessThread(); |
|||
process.start(); |
|||
} |
|||
return START_STICKY; |
|||
} |
|||
|
|||
@Override |
|||
public IBinder onBind(Intent arg0) { |
|||
// onBind() must return null, even if binder unused
|
|||
return null; |
|||
} |
|||
} |
Loading…
Reference in new issue