Skip to content
Snippets Groups Projects
Commit 834c86f2 authored by Augusto Bott's avatar Augusto Bott
Browse files

Added TODO entries throughout the code

parent 6bbae7a9
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -2,8 +2,7 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="br.com.bott.droidsshd"
android:versionCode="5"
android:versionName="0.5"
android:installLocation="auto">
android:versionName="0.5" android:installLocation="internalOnly">
 
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
Loading
Loading
@@ -18,7 +17,7 @@
 
<application android:icon="@drawable/ssh_icon"
android:label="@string/app_label"
android:persistent="true">
android:persistent="true" android:debuggable="true">
<service
android:name="br.com.bott.droidsshd.system.DroidSSHdService">
<intent-filter>
Loading
Loading
Loading
Loading
@@ -80,48 +80,27 @@ public class DroidSSHd extends Activity {
}
}
 
// DAEMON HANDLER
private ServiceConnection mDaemonHandlerConnection = new ServiceConnection() {
@Override
public void onServiceConnected(ComponentName className, IBinder service) {
mBoundDaemonHandlerService = ((br.com.bott.droidsshd.system.DroidSSHdService.DropbearDaemonHandlerBinder)service).getService();
if(Base.debug) {
Log.d(TAG, "onServiceConnected DroidSSHdService called");
if (mBoundDaemonHandlerService==null){
Log.d(TAG, "Failed to bind to DroidSSHdService (mBoundDaemonHandlerService is NULL)");
} else {
Log.d(TAG, "mBoundDaemonHandlerService = " + mBoundDaemonHandlerService.toString());
}
}
}
@Override
public void onServiceDisconnected(ComponentName className) {
mBoundDaemonHandlerService = null;
if(Base.debug) {
Log.d(TAG, "onServiceDisconnected called (mBoundDaemonHandlerService set to NULL)");
}
}
};
private void doBindDaemonHandlerService(Intent intent) {
mDaemonHandlerIsBound = bindService(intent, mDaemonHandlerConnection, Context.BIND_AUTO_CREATE);
@Override
protected void onStart() {
super.onStart();
doBindDaemonHandlerService(mDropbearDaemonHandlerService);
}
private void doUnbindDaemonHandlerService(Intent intent) {
if (mDaemonHandlerIsBound) {
unbindService(mDaemonHandlerConnection);
mDaemonHandlerIsBound = false;
@Override
protected void onResume() {
super.onResume();
Base.refresh();
mHandler.postDelayed(mUpdateUI, mUpdateUIdelay);
// updateStatus();
if(Base.debug) {
Log.d(TAG, "onResume() called");
}
}
 
protected void startInitialSetupActivity() {
Util.showMsg("Initial/basic setup required");
Intent setup = new Intent(this, br.com.bott.droidsshd.activity.InitialSetup.class);
setup.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
// setup.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
startActivityForResult(setup, R.string.activity_initial_setup);
@Override
protected void onDestroy() {
super.onDestroy();
doUnbindDaemonHandlerService(mDropbearDaemonHandlerService);
}
 
@Override
Loading
Loading
@@ -150,6 +129,14 @@ public class DroidSSHd extends Activity {
}*/
}
 
protected void startInitialSetupActivity() {
Util.showMsg("Initial/basic setup required");
Intent setup = new Intent(this, br.com.bott.droidsshd.activity.InitialSetup.class);
setup.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
// setup.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
startActivityForResult(setup, R.string.activity_initial_setup);
}
protected void setUpUiListeners() {
status_content = (EditText) findViewById(R.id.status_content);
status_ip_address = (EditText) findViewById(R.id.status_ip_address);
Loading
Loading
@@ -200,29 +187,6 @@ public class DroidSSHd extends Activity {
});
}
 
@Override
protected void onStart() {
super.onStart();
doBindDaemonHandlerService(mDropbearDaemonHandlerService);
}
@Override
protected void onStop() {
super.onStop();
doUnbindDaemonHandlerService(mDropbearDaemonHandlerService);
}
@Override
protected void onResume() {
super.onResume();
Base.refresh();
mHandler.postDelayed(mUpdateUI, mUpdateUIdelay);
// updateStatus();
if(Base.debug) {
Log.d(TAG, "onResume() called");
}
}
public void updateStatus() {
String tmp = "";
Iterator<String> ipAddr = Util.getLocalIpAddress();
Loading
Loading
@@ -400,7 +364,8 @@ public class DroidSSHd extends Activity {
}
}
/* final protected Handler mLogviewHandler = new Handler() {
/*
final protected Handler mLogviewHandler = new Handler() {
@Override
public void handleMessage(Message msg){
// mStdOut.append(msg.getData().getString("line"));
Loading
Loading
@@ -413,6 +378,40 @@ public class DroidSSHd extends Activity {
};
*/
 
// DAEMON HANDLER
private ServiceConnection mDaemonHandlerConnection = new ServiceConnection() {
@Override
public void onServiceConnected(ComponentName className, IBinder service) {
mBoundDaemonHandlerService = ((br.com.bott.droidsshd.system.DroidSSHdService.DropbearDaemonHandlerBinder)service).getService();
if(Base.debug) {
Log.d(TAG, "onServiceConnected DroidSSHdService called");
if (mBoundDaemonHandlerService==null){
Log.d(TAG, "Failed to bind to DroidSSHdService (mBoundDaemonHandlerService is NULL)");
} else {
Log.d(TAG, "mBoundDaemonHandlerService = " + mBoundDaemonHandlerService.toString());
}
}
}
@Override
public void onServiceDisconnected(ComponentName className) {
mBoundDaemonHandlerService = null;
if(Base.debug) {
Log.d(TAG, "onServiceDisconnected called (mBoundDaemonHandlerService set to NULL)");
}
}
};
private void doBindDaemonHandlerService(Intent intent) {
mDaemonHandlerIsBound = bindService(intent, mDaemonHandlerConnection, Context.BIND_AUTO_CREATE);
}
private void doUnbindDaemonHandlerService(Intent intent) {
if (mDaemonHandlerIsBound) {
unbindService(mDaemonHandlerConnection);
mDaemonHandlerIsBound = false;
}
}
}
 
 
Loading
Loading
@@ -3,8 +3,6 @@
*/
package br.com.bott.droidsshd.system;
 
//import br.com.bott.droidsshd.lixo.MonitoringService;
//import br.com.bott.droidsshd.R;
import java.io.File;
 
import android.content.BroadcastReceiver;
Loading
Loading
@@ -14,19 +12,11 @@ import android.content.Intent;
//import android.preference.PreferenceManager;
import android.util.Log;
 
/*
import android.app.AlarmManager;
import android.app.PendingIntent;
import android.os.SystemClock;
import android.preference.PreferenceManager;
*/
/**
* Receives a broadcast message when the device completes
* booting/starting up and checks if anything needs to be
* done. Also used to manually start/stop monitoring services
* and alarms.
*
* done.
*
* @author mestre
*
*/
Loading
Loading
@@ -54,7 +44,7 @@ public class BootReceiver extends BroadcastReceiver {
if (Base.debug) {
Log.d(TAG, "Removing stale PID file");
}
// Util.doRun("rm " + Base.getDropbearPidFilePath(), Base.runDaemonAsRoot(), null);
// remove our stale PID file as root (just in case), no output handler (null)
Util.doRun("rm " + Base.getDropbearPidFilePath(), true, null);
}
 
Loading
Loading
@@ -72,33 +62,7 @@ public class BootReceiver extends BroadcastReceiver {
}
}
}
// startAlarm(context);
}
/* private static AlarmManager mgr;
private static PendingIntent pi = null;
public static void cancelAlarm(){
if (mgr != null) {
mgr.cancel(pi);
}
}
public static void startAlarm(Context context){
AlarmSettings settings = Preferences.ReadAlarmSettings(PreferenceManager.getDefaultSharedPreferences(context));
if (settings.isAlarmEnabled()) {
// Set up PendingIntent for the alarm service
mgr = (AlarmManager)context.getSystemService(Context.ALARM_SERVICE);
Intent i = new Intent(context, AlarmReceiver.class);
pi = PendingIntent.getBroadcast(context, 0, i, 0);
// First intent after a small (2 second) delay and repeat at the user-set intervals
mgr.setRepeating(AlarmManager.ELAPSED_REALTIME, SystemClock.elapsedRealtime() + 2000, settings.getAlarmIntervalInMilliseconds(), pi);
}
}
*/
}
 
Loading
Loading
@@ -25,6 +25,9 @@ import android.util.Log;
*/
public class DroidSSHdService extends Service{
 
// TODO - investigate about Service#startForeground();
// http://developer.android.com/reference/android/app/Service.html#startForeground%28int,%20android.app.Notification%29
private static final String TAG = "DroidSSHdService";
 
private static NotificationManager mNotificationManager;
Loading
Loading
@@ -144,8 +147,9 @@ public class DroidSSHdService extends Service{
if (debug) {
Log.v(tag, "cmd = '" + cmd + "'");
}
// cmd("export HOME=/mnt/sdcard");
// cmd("cd $HOME");
// TODO - currently, HOME is hard-coded on dropbearmulti
// cmd("export HOME=/mnt/sdcard");
// cmd("cd $HOME");
cmd(cmd);
}
@Override
Loading
Loading
@@ -174,6 +178,8 @@ public class DroidSSHdService extends Service{
}
 
private FileObserver createPidWatchdog(String path,int mask) {
// TODO - perhaps move this object to Util and make it static
// since we shall have at most one FileObserver active at any time
FileObserver observer = new FileObserver(path, mask) {
@Override
public void onEvent(int event, String path) {
Loading
Loading
package br.com.bott.droidsshd.tools;
 
import java.io.File;
//import java.io.File;
import java.io.IOException;
import java.io.PrintStream;
 
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment