* Implementation of hideAllBut() than hides all contents except one
Also, clicking on the active content will invert its visibility. * Massive cleanup/rewrote of Log.* calls * Fix: clickable ServerPage's infosmaster
parent
e94df3c7c6
commit
a4f2354f99
|
@ -243,7 +243,7 @@
|
|||
style="@style/list_item_single"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:clickable="true"
|
||||
android:clickable="false"
|
||||
android:orientation="horizontal"
|
||||
android:visibility="gone" >
|
||||
|
||||
|
|
|
@ -13,12 +13,12 @@ import android.util.Log;
|
|||
|
||||
public class BootReceiver extends BroadcastReceiver {
|
||||
|
||||
private static final String TAG = "BootReceiver";
|
||||
private static final String TAG = "DropBearServer";
|
||||
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
if (intent.getAction().equals(android.content.Intent.ACTION_BOOT_COMPLETED)) {
|
||||
Log.d(TAG, "onReceive(ACTION_BOOT_COMPLETED)");
|
||||
Log.d(TAG, "BootReceiver: onReceive(ACTION_BOOT_COMPLETED)");
|
||||
|
||||
Boolean hasPid = (ServerUtils.getServerPidFromFile(context) > 0 ? true : false);
|
||||
Boolean startAtBoot = SettingsHelper.getInstance(context).getStartAtBoot();
|
||||
|
@ -30,7 +30,7 @@ public class BootReceiver extends BroadcastReceiver {
|
|||
|
||||
if (startAtBoot) {
|
||||
if (!onlyIfRunningbefore || (onlyIfRunningbefore && hasPid)) {
|
||||
Log.i(TAG, "Dropbear server starting at boot");
|
||||
Log.i(TAG, "BootReceiver: DropBear Server starting at boot");
|
||||
// ServerStarter
|
||||
ServerStarter serverStarter = new ServerStarter(null, null);
|
||||
serverStarter.execute();
|
||||
|
|
|
@ -5,8 +5,6 @@ package me.shkschneider.dropbearserver;
|
|||
|
||||
import com.markupartist.android.widget.ActionBar.Action;
|
||||
|
||||
import me.shkschneider.dropbearserver.R;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.View;
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ import android.util.Log;
|
|||
|
||||
public class MainActivity extends Activity implements CheckerCallback<Boolean> {
|
||||
|
||||
private static final String TAG = "MainActivity";
|
||||
private static final String TAG = "DropBearServer";
|
||||
|
||||
private static Boolean needToCheckDependencies = true;
|
||||
|
||||
|
@ -31,8 +31,6 @@ public class MainActivity extends Activity implements CheckerCallback<Boolean> {
|
|||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
Log.d(TAG, "onCreate()");
|
||||
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.main);
|
||||
|
||||
|
@ -45,7 +43,7 @@ public class MainActivity extends Activity implements CheckerCallback<Boolean> {
|
|||
appVersion = packageInfo.versionName.toString();
|
||||
}
|
||||
catch (Exception e) {
|
||||
Log.e(TAG, "onCreate(): " + e.getMessage());
|
||||
Log.e(TAG, "MainActivity: onCreate(): " + e.getMessage());
|
||||
}
|
||||
Log.i(TAG, appName + " v" + appVersion + " (" + packageName + ") Android " + Build.VERSION.RELEASE + " (API-" + Build.VERSION.SDK + ")");
|
||||
|
||||
|
@ -66,14 +64,19 @@ public class MainActivity extends Activity implements CheckerCallback<Boolean> {
|
|||
|
||||
@Override
|
||||
public void onResume() {
|
||||
Log.d(TAG, "onResume()");
|
||||
|
||||
super.onResume();
|
||||
if (needToCheckDependencies == true) {
|
||||
// Root dependencies
|
||||
check();
|
||||
needToCheckDependencies = false;
|
||||
}
|
||||
|
||||
if (SettingsHelper.getInstance(getBaseContext()).getKeepScreenOn() == true) {
|
||||
this.getWindow().addFlags(android.view.WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
|
||||
}
|
||||
else {
|
||||
this.getWindow().clearFlags(android.view.WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
|
||||
}
|
||||
}
|
||||
|
||||
public static Intent createIntent(Context context) {
|
||||
|
@ -87,7 +90,6 @@ public class MainActivity extends Activity implements CheckerCallback<Boolean> {
|
|||
}
|
||||
|
||||
public void check() {
|
||||
Log.d(TAG, "check()");
|
||||
// Checker
|
||||
Checker checker = new Checker(this, this);
|
||||
checker.execute();
|
||||
|
@ -98,7 +100,6 @@ public class MainActivity extends Activity implements CheckerCallback<Boolean> {
|
|||
}
|
||||
|
||||
public void update() {
|
||||
Log.d(TAG, "update()");
|
||||
mAdapter.update();
|
||||
}
|
||||
}
|
|
@ -18,8 +18,7 @@ import android.view.View;
|
|||
|
||||
public class MainAdapter extends PagerAdapter implements ViewPagerTabProvider {
|
||||
|
||||
private static final String TAG = "MainAdapter";
|
||||
|
||||
private static final String TAG = "DropBearServer";
|
||||
public static final int DEFAULT_PAGE = 1;
|
||||
|
||||
private static final int SETTINGS_INDEX = 0;
|
||||
|
@ -41,8 +40,6 @@ public class MainAdapter extends PagerAdapter implements ViewPagerTabProvider {
|
|||
};
|
||||
|
||||
public MainAdapter(Context context) {
|
||||
Log.d(TAG, "MainAdapter()");
|
||||
|
||||
mContext = context;
|
||||
mSettingsPage = new SettingsPage(mContext);
|
||||
mServerPage = new ServerPage(mContext);
|
||||
|
@ -75,6 +72,9 @@ public class MainAdapter extends PagerAdapter implements ViewPagerTabProvider {
|
|||
//mAboutPage.update();
|
||||
v = mAboutPage.getView();
|
||||
break;
|
||||
default:
|
||||
Log.e(TAG, "MainAdapter: instanciateItem(): default");
|
||||
break;
|
||||
}
|
||||
((ViewPager) container).addView(v, 0);
|
||||
return v;
|
||||
|
|
|
@ -39,8 +39,6 @@ public class AboutPage implements OnClickListener {
|
|||
mVisitMyWebsite.setOnClickListener(this);
|
||||
}
|
||||
|
||||
// TODO: hideAll
|
||||
|
||||
public View getView() {
|
||||
return mView;
|
||||
}
|
||||
|
|
|
@ -33,6 +33,14 @@ public class HelpPage implements OnClickListener {
|
|||
mWhatIsDropbear.setOnClickListener(this);
|
||||
mWhatIsDropbearContent = (LinearLayout) mView.findViewById(R.id.what_is_dropbear_content);
|
||||
}
|
||||
|
||||
public void hideAllBut(LinearLayout oneLinearLayout) {
|
||||
if (mWhatIsRootContent != oneLinearLayout)
|
||||
mWhatIsRootContent.setVisibility(View.GONE);
|
||||
if (mWhatIsDropbearContent != oneLinearLayout)
|
||||
mWhatIsDropbearContent.setVisibility(View.GONE);
|
||||
oneLinearLayout.setVisibility(oneLinearLayout.getVisibility() == View.VISIBLE ? View.GONE : View.VISIBLE);
|
||||
}
|
||||
|
||||
public View getView() {
|
||||
return mView;
|
||||
|
@ -40,10 +48,10 @@ public class HelpPage implements OnClickListener {
|
|||
|
||||
public void onClick(View v) {
|
||||
if (v == mWhatIsRoot) {
|
||||
mWhatIsRootContent.setVisibility(mWhatIsRootContent.getVisibility() == View.VISIBLE ? View.GONE : View.VISIBLE);
|
||||
hideAllBut(mWhatIsRootContent);
|
||||
}
|
||||
else if (v == mWhatIsDropbear) {
|
||||
mWhatIsDropbearContent.setVisibility(mWhatIsDropbearContent.getVisibility() == View.VISIBLE ? View.GONE : View.VISIBLE);
|
||||
hideAllBut(mWhatIsDropbearContent);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -30,13 +30,13 @@ import android.widget.Toast;
|
|||
|
||||
public class ServerPage implements OnClickListener, DropbearInstallerCallback<Boolean>, ServerStarterCallback<Boolean>, ServerStopperCallback<Boolean>, CheckerCallback<Boolean>
|
||||
{
|
||||
private static final String TAG = "ServerPage";
|
||||
private static final String TAG = "DropBearServer";
|
||||
|
||||
private static final int STATUS_ERROR = 0x00;
|
||||
private static final int STATUS_STOPPED = 0x01;
|
||||
private static final int STATUS_STARTING = 0x02;
|
||||
private static final int STATUS_STARTED = 0x03;
|
||||
private static final int STATUS_STOPPING = 0x04;
|
||||
private static final int STATUS_ERROR = 0x00;
|
||||
private static final int STATUS_STOPPED = 0x01;
|
||||
private static final int STATUS_STARTING = 0x02;
|
||||
private static final int STATUS_STARTED = 0x03;
|
||||
private static final int STATUS_STOPPING = 0x04;
|
||||
|
||||
private Context mContext;
|
||||
private View mView;
|
||||
|
@ -258,7 +258,7 @@ public class ServerPage implements OnClickListener, DropbearInstallerCallback<Bo
|
|||
}
|
||||
else if (v == mGetSuperuser) {
|
||||
try {
|
||||
Log.i(TAG, "market://details?id=" + mContext.getResources().getString(R.string.superuser_package));
|
||||
Log.i(TAG, "ServerPage: onClick(): market://details?id=" + mContext.getResources().getString(R.string.superuser_package));
|
||||
mContext.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + mContext.getResources().getString(R.string.superuser_package))));
|
||||
}
|
||||
catch (ActivityNotFoundException e) {
|
||||
|
@ -269,7 +269,7 @@ public class ServerPage implements OnClickListener, DropbearInstallerCallback<Bo
|
|||
}
|
||||
else if (v == mGetBusybox) {
|
||||
try {
|
||||
Log.i(TAG, "market://details?id=" + mContext.getResources().getString(R.string.busybox_package));
|
||||
Log.i(TAG, "ServerPage: onClick(): market://details?id=" + mContext.getResources().getString(R.string.busybox_package));
|
||||
mContext.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + mContext.getResources().getString(R.string.busybox_package))));
|
||||
}
|
||||
catch (ActivityNotFoundException e) {
|
||||
|
@ -279,7 +279,6 @@ public class ServerPage implements OnClickListener, DropbearInstallerCallback<Bo
|
|||
updateRootStatus();
|
||||
}
|
||||
else if (v == mGetDropbear) {
|
||||
Log.i(TAG, "DropbearInstaller");
|
||||
// DropbearInstaller
|
||||
DropbearInstaller dropbearInstaller = new DropbearInstaller(mContext, this);
|
||||
dropbearInstaller.execute();
|
||||
|
@ -287,34 +286,37 @@ public class ServerPage implements OnClickListener, DropbearInstallerCallback<Bo
|
|||
}
|
||||
|
||||
public void onDropbearInstallerComplete(Boolean result) {
|
||||
if (result == true) {
|
||||
RootUtils.checkDropbear(mContext);
|
||||
((MainActivity) mContext).update();
|
||||
Log.i(TAG, "ServerPage: onDropbearInstallerComplete(" + result + ")");
|
||||
if (result == false) {
|
||||
Toast.makeText(mContext, "DropBear could not be installed", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
else {
|
||||
Toast.makeText(mContext, "Dropbear failed to get installed", Toast.LENGTH_SHORT).show();
|
||||
RootUtils.checkDropbear(mContext);
|
||||
((MainActivity) mContext).update();
|
||||
Toast.makeText(mContext, "DropBear successfully installed", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
|
||||
public void onServerStarterComplete(Boolean result) {
|
||||
Log.i(TAG, "onStartServerComplete(" + result + ")");
|
||||
Log.i(TAG, "ServerPage: onStartServerComplete(" + result + ")");
|
||||
if (result == false) {
|
||||
Toast.makeText(mContext, "Dropbear failed to start", Toast.LENGTH_SHORT).show();
|
||||
Toast.makeText(mContext, "DropBear could not be started", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
updateServerStatusCode();
|
||||
updateServerStatus();
|
||||
}
|
||||
|
||||
public void onServerStopperComplete(Boolean result) {
|
||||
Log.i(TAG, "onStopServerComplete(" + result + ")");
|
||||
Log.i(TAG, "ServerPage: onStopServerComplete(" + result + ")");
|
||||
if (result == false) {
|
||||
Toast.makeText(mContext, "Dropbear failed to stop", Toast.LENGTH_SHORT).show();
|
||||
Toast.makeText(mContext, "DropBear could not be stopped", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
updateServerStatusCode();
|
||||
updateServerStatus();
|
||||
}
|
||||
|
||||
public void onCheckerComplete(Boolean result) {
|
||||
Log.i(TAG, "ServerPage: onCheckerComplete(" + result + ")");
|
||||
if (result == true) {
|
||||
update();
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@ import android.widget.LinearLayout;
|
|||
|
||||
public class SettingsPage implements OnClickListener, OnCheckedChangeListener, DialogInterface.OnClickListener, DropbearRemoverCallback<Boolean> {
|
||||
|
||||
private static final String TAG = "SettingsPage";
|
||||
private static final String TAG = "DropBearServer";
|
||||
|
||||
private Context mContext;
|
||||
private LayoutInflater mLayoutInflater;
|
||||
|
@ -34,7 +34,7 @@ public class SettingsPage implements OnClickListener, OnCheckedChangeListener, D
|
|||
private LinearLayout mGeneral;
|
||||
private LinearLayout mGeneralContent;
|
||||
|
||||
// TODO: disable root checks
|
||||
// TODO: assume root access
|
||||
private CheckBox mStartAtBoot;
|
||||
private CheckBox mOnlyIfRunningBefore;
|
||||
private CheckBox mKeepScreenOn;
|
||||
|
@ -187,6 +187,14 @@ public class SettingsPage implements OnClickListener, OnCheckedChangeListener, D
|
|||
// mPublicKeys
|
||||
// TODO: setPublicKeys
|
||||
}
|
||||
|
||||
public void hideAllBut(LinearLayout oneLinearLayout) {
|
||||
if (mGeneralContent != oneLinearLayout)
|
||||
mGeneralContent.setVisibility(View.GONE);
|
||||
if (mDropbearContent != oneLinearLayout)
|
||||
mDropbearContent.setVisibility(View.GONE);
|
||||
oneLinearLayout.setVisibility(oneLinearLayout.getVisibility() == View.VISIBLE ? View.GONE : View.VISIBLE);
|
||||
}
|
||||
|
||||
public View getView() {
|
||||
return mView;
|
||||
|
@ -195,7 +203,7 @@ public class SettingsPage implements OnClickListener, OnCheckedChangeListener, D
|
|||
public void onClick(View v) {
|
||||
// mGeneral
|
||||
if (v == mGeneral) {
|
||||
mGeneralContent.setVisibility(mGeneralContent.getVisibility() == View.VISIBLE ? View.GONE : View.VISIBLE);
|
||||
hideAllBut(mGeneralContent);
|
||||
}
|
||||
else if (v == mCompleteRemoval) {
|
||||
new AlertDialog.Builder(mContext)
|
||||
|
@ -209,7 +217,7 @@ public class SettingsPage implements OnClickListener, OnCheckedChangeListener, D
|
|||
|
||||
// mDropbear
|
||||
else if (v == mDropbear) {
|
||||
mDropbearContent.setVisibility(mDropbearContent.getVisibility() == View.VISIBLE ? View.GONE : View.VISIBLE);
|
||||
hideAllBut(mDropbearContent);
|
||||
}
|
||||
else if (v == mBanner) {
|
||||
EditText editText = (EditText) mBannerView.findViewById(R.id.settings_banner);
|
||||
|
@ -224,13 +232,13 @@ public class SettingsPage implements OnClickListener, OnCheckedChangeListener, D
|
|||
|
||||
// mAccounts
|
||||
else if (v == mAccounts) {
|
||||
mAccountsContent.setVisibility(mAccountsContent.getVisibility() == View.VISIBLE ? View.GONE : View.VISIBLE);
|
||||
hideAllBut(mAccountsContent);
|
||||
// TODO: changeAccounts
|
||||
}
|
||||
|
||||
// mPublicKeys
|
||||
else if (v == mPublicKeys) {
|
||||
mPublicKeysContent.setVisibility(mPublicKeysContent.getVisibility() == View.VISIBLE ? View.GONE : View.VISIBLE);
|
||||
hideAllBut(mPublicKeysContent);
|
||||
// TODO: changePublicKeys
|
||||
}
|
||||
}
|
||||
|
@ -286,12 +294,12 @@ public class SettingsPage implements OnClickListener, OnCheckedChangeListener, D
|
|||
SettingsHelper.getInstance(mContext).setListeningPort(port);
|
||||
}
|
||||
else {
|
||||
Log.d(TAG, "Wrong value for listeningPort: " + port);
|
||||
Toast.makeText(mContext, "Wrong value", Toast.LENGTH_SHORT).show();
|
||||
Log.d(TAG, "SettingsPage: onClick(): Wrong TCP port value [listeningPort=" + port + "]");
|
||||
Toast.makeText(mContext, "Wrong TCP port value", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
else {
|
||||
Log.d(TAG, "Wrong type for listeningPort: " + settings_listening_port);
|
||||
Log.d(TAG, "SettingsPage: onClick(): Wrong type [listeningPort: " + settings_listening_port + "]");
|
||||
}
|
||||
mListeningPortInfos.setText(settings_listening_port);
|
||||
}
|
||||
|
@ -304,7 +312,7 @@ public class SettingsPage implements OnClickListener, OnCheckedChangeListener, D
|
|||
}
|
||||
|
||||
public void onDropbearRemoverComplete(Boolean result) {
|
||||
Log.i(TAG, "onDropbearRemoverComplete(" + result + ")");
|
||||
Log.i(TAG, "SettingsPage: onDropbearRemoverComplete(" + result + ")");
|
||||
if (result == true) {
|
||||
// do not check for dropbear
|
||||
RootUtils.hasDropbear = false;
|
||||
|
|
|
@ -11,7 +11,7 @@ import android.util.Log;
|
|||
|
||||
public class SettingsHelper {
|
||||
|
||||
private static final String TAG = "SettingsHelper";
|
||||
private static final String TAG = "DropBearServer";
|
||||
|
||||
private static final String PREF_START_AT_BOOT = "startAtBoot";
|
||||
private static final String PREF_ONLY_IF_RUNNING_BEFORE = "onlyIfRunningBefore";
|
||||
|
@ -48,7 +48,7 @@ public class SettingsHelper {
|
|||
mSharedPreferences = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
}
|
||||
else {
|
||||
Log.e(TAG, "Context is null");
|
||||
Log.e(TAG, "SettingsHelper: SettingsHelper(): Context is null");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -58,7 +58,7 @@ public class SettingsHelper {
|
|||
}
|
||||
|
||||
public void setStartAtBoot(Boolean b) {
|
||||
Log.d(TAG, "setStartAtBoot(" + b + ")");
|
||||
Log.d(TAG, "SettingsHelper: setStartAtBoot(" + b + ")");
|
||||
Editor editor = mSharedPreferences.edit();
|
||||
editor.putBoolean(PREF_START_AT_BOOT, b);
|
||||
editor.commit();
|
||||
|
@ -70,7 +70,7 @@ public class SettingsHelper {
|
|||
}
|
||||
|
||||
public void setOnlyIfRunningBefore(Boolean b) {
|
||||
Log.d(TAG, "setOnlyIfRunningBefore(" + b + ")");
|
||||
Log.d(TAG, "SettingsHelper: setOnlyIfRunningBefore(" + b + ")");
|
||||
Editor editor = mSharedPreferences.edit();
|
||||
editor.putBoolean(PREF_ONLY_IF_RUNNING_BEFORE, b);
|
||||
editor.commit();
|
||||
|
@ -82,7 +82,7 @@ public class SettingsHelper {
|
|||
}
|
||||
|
||||
public void setKeepScreenOn(Boolean b) {
|
||||
Log.d(TAG, "setKeepScreenOn(" + b + ")");
|
||||
Log.d(TAG, "SettingsHelper: setKeepScreenOn(" + b + ")");
|
||||
Editor editor = mSharedPreferences.edit();
|
||||
editor.putBoolean(PREF_KEEP_SCREEN_ON, b);
|
||||
editor.commit();
|
||||
|
@ -94,7 +94,7 @@ public class SettingsHelper {
|
|||
}
|
||||
|
||||
public void setOnlyOverWifi(Boolean b) {
|
||||
Log.d(TAG, "setOnlyOverWifi(" + b + ")");
|
||||
Log.d(TAG, "SettingsHelper: setOnlyOverWifi(" + b + ")");
|
||||
Editor editor = mSharedPreferences.edit();
|
||||
editor.putBoolean(PREF_ONLY_OVER_WIFI, b);
|
||||
editor.commit();
|
||||
|
@ -106,7 +106,7 @@ public class SettingsHelper {
|
|||
}
|
||||
|
||||
public void setBanner(String s) {
|
||||
Log.d(TAG, "setBanner(" + s + ")");
|
||||
Log.d(TAG, "SettingsHelper: setBanner(" + s + ")");
|
||||
Editor editor = mSharedPreferences.edit();
|
||||
editor.putString(PREF_BANNER, s);
|
||||
editor.commit();
|
||||
|
@ -118,7 +118,7 @@ public class SettingsHelper {
|
|||
}
|
||||
|
||||
public void setDisallowRootLogins(Boolean b) {
|
||||
Log.d(TAG, "setDisallowRootLogins(" + b + ")");
|
||||
Log.d(TAG, "SettingsHelper: setDisallowRootLogins(" + b + ")");
|
||||
Editor editor = mSharedPreferences.edit();
|
||||
editor.putBoolean(PREF_DISALLOW_ROOT_LOGINS, b);
|
||||
editor.commit();
|
||||
|
@ -130,7 +130,7 @@ public class SettingsHelper {
|
|||
}
|
||||
|
||||
public void setDisablePasswordLogins(Boolean b) {
|
||||
Log.d(TAG, "setDisablePasswordLogins(" + b + ")");
|
||||
Log.d(TAG, "SettingsHelper: setDisablePasswordLogins(" + b + ")");
|
||||
Editor editor = mSharedPreferences.edit();
|
||||
editor.putBoolean(PREF_DISABLE_PASSWORD_LOGINS, b);
|
||||
editor.commit();
|
||||
|
@ -142,7 +142,7 @@ public class SettingsHelper {
|
|||
}
|
||||
|
||||
public void setDisablePasswordLoginsForRoot(Boolean b) {
|
||||
Log.d(TAG, "setDisablePasswordLoginsForRoot(" + b + ")");
|
||||
Log.d(TAG, "SettingsHelper: setDisablePasswordLoginsForRoot(" + b + ")");
|
||||
Editor editor = mSharedPreferences.edit();
|
||||
editor.putBoolean(PREF_DISABLE_PASSWORD_LOGINS_FOR_ROOT, b);
|
||||
editor.commit();
|
||||
|
@ -154,7 +154,7 @@ public class SettingsHelper {
|
|||
}
|
||||
|
||||
public void setListeningPort(Integer i) {
|
||||
Log.d(TAG, "setListeningPort(" + i + ")");
|
||||
Log.d(TAG, "SettingsHelper: setListeningPort(" + i + ")");
|
||||
Editor editor = mSharedPreferences.edit();
|
||||
editor.putInt(PREF_LISTENING_PORT, i);
|
||||
editor.commit();
|
||||
|
|
|
@ -5,9 +5,12 @@ import me.shkschneider.dropbearserver.Utils.RootUtils;
|
|||
import android.app.ProgressDialog;
|
||||
import android.content.Context;
|
||||
import android.os.AsyncTask;
|
||||
import android.util.Log;
|
||||
|
||||
public class Checker extends AsyncTask<Void, String, Boolean> {
|
||||
|
||||
private static final String TAG = "DropBearServer";
|
||||
|
||||
private Context mContext = null;
|
||||
private ProgressDialog mProgressDialog = null;
|
||||
|
||||
|
@ -47,6 +50,8 @@ public class Checker extends AsyncTask<Void, String, Boolean> {
|
|||
|
||||
@Override
|
||||
protected Boolean doInBackground(Void... params) {
|
||||
Log.i(TAG, "Checker: doInBackground()");
|
||||
|
||||
int step = 0;
|
||||
int steps = 3;
|
||||
|
||||
|
|
|
@ -8,9 +8,12 @@ import me.shkschneider.dropbearserver.R;
|
|||
import android.app.ProgressDialog;
|
||||
import android.content.Context;
|
||||
import android.os.AsyncTask;
|
||||
import android.util.Log;
|
||||
|
||||
public class DropbearInstaller extends AsyncTask<Void, String, Boolean> {
|
||||
|
||||
private static final String TAG = "DropBearServer";
|
||||
|
||||
private Context mContext = null;
|
||||
private ProgressDialog mProgressDialog = null;
|
||||
|
||||
|
@ -47,9 +50,13 @@ public class DropbearInstaller extends AsyncTask<Void, String, Boolean> {
|
|||
mProgressDialog.setMessage(progress[2]);
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: log error
|
||||
|
||||
@Override
|
||||
protected Boolean doInBackground(Void... params) {
|
||||
Log.i(TAG, "DropbearInstaller: doInBackground()");
|
||||
|
||||
int step = 0;
|
||||
int steps = 20;
|
||||
|
||||
|
|
|
@ -7,9 +7,12 @@ import me.shkschneider.dropbearserver.Utils.Utils;
|
|||
import android.app.ProgressDialog;
|
||||
import android.content.Context;
|
||||
import android.os.AsyncTask;
|
||||
import android.util.Log;
|
||||
|
||||
public class DropbearRemover extends AsyncTask<Void, String, Boolean> {
|
||||
|
||||
private static final String TAG = "DropBearServer";
|
||||
|
||||
private Context mContext = null;
|
||||
private ProgressDialog mProgressDialog = null;
|
||||
|
||||
|
@ -51,9 +54,13 @@ public class DropbearRemover extends AsyncTask<Void, String, Boolean> {
|
|||
mProgressDialog.setMessage(progress[2]);
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: log errors
|
||||
|
||||
@Override
|
||||
protected Boolean doInBackground(Void... params) {
|
||||
Log.i(TAG, "DropbearRemover: doInBackground()");
|
||||
|
||||
int step = 0;
|
||||
int steps = 9;
|
||||
|
||||
|
|
|
@ -7,9 +7,12 @@ import me.shkschneider.dropbearserver.Utils.Utils;
|
|||
import android.app.ProgressDialog;
|
||||
import android.content.Context;
|
||||
import android.os.AsyncTask;
|
||||
import android.util.Log;
|
||||
|
||||
public class ServerStarter extends AsyncTask<Void, String, Boolean> {
|
||||
|
||||
private static final String TAG = "DropBearServer";
|
||||
|
||||
public Context mContext = null;
|
||||
public ProgressDialog mProgressDialog = null;
|
||||
|
||||
|
@ -39,6 +42,8 @@ public class ServerStarter extends AsyncTask<Void, String, Boolean> {
|
|||
|
||||
@Override
|
||||
protected Boolean doInBackground(Void... params) {
|
||||
Log.i(TAG, "ServerStarter: doInBackground()");
|
||||
|
||||
if (SettingsHelper.getInstance(mContext).getOnlyOverWifi() == true && Utils.isConnectedToWiFi(mContext) == false) {
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -9,7 +9,7 @@ import android.util.Log;
|
|||
|
||||
public class ServerStopper extends AsyncTask<Void, String, Boolean> {
|
||||
|
||||
private static final String TAG = "ServerStopper";
|
||||
private static final String TAG = "DropBearServer";
|
||||
|
||||
public Context mContext = null;
|
||||
public ProgressDialog mProgressDialog = null;
|
||||
|
@ -38,8 +38,12 @@ public class ServerStopper extends AsyncTask<Void, String, Boolean> {
|
|||
}
|
||||
}
|
||||
|
||||
// TODO: log errors (in a better way)
|
||||
|
||||
@Override
|
||||
protected Boolean doInBackground(Void... params) {
|
||||
Log.i(TAG, "ServerStopper: doInBackground()");
|
||||
|
||||
String pidFile = ServerUtils.getLocalDir(mContext) + "/pid";
|
||||
if (ShellUtils.echoToFile("0", pidFile) == false)
|
||||
Log.d(TAG, "echoToFile(0, " + pidFile + ")");
|
||||
|
|
|
@ -9,7 +9,7 @@ import com.stericson.RootTools.RootTools;
|
|||
|
||||
public abstract class RootUtils {
|
||||
|
||||
private static final String TAG = "RootUtils";
|
||||
private static final String TAG = "DropBearServer";
|
||||
|
||||
public static Boolean hasRootAccess = false;
|
||||
public static Boolean hasBusybox = false;
|
||||
|
@ -23,15 +23,15 @@ public abstract class RootUtils {
|
|||
hasRootAccess = true;
|
||||
}
|
||||
else {
|
||||
Log.w(TAG, "checkRootAccess(): access rejected");
|
||||
Log.w(TAG, "RootUtils: checkRootAccess(): access rejected");
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
Log.e(TAG, "checkRootAccess(): " + e.getMessage());
|
||||
Log.e(TAG, "RootUtils: checkRootAccess(): " + e.getMessage());
|
||||
}
|
||||
}
|
||||
else {
|
||||
Log.w(TAG, "checkRootAccess(): su not found");
|
||||
Log.w(TAG, "RootUtils: checkRootAccess(): su not found");
|
||||
}
|
||||
return hasRootAccess;
|
||||
}
|
||||
|
@ -42,7 +42,7 @@ public abstract class RootUtils {
|
|||
hasBusybox = true;
|
||||
}
|
||||
else {
|
||||
Log.w(TAG, "checkBusybox(): busybox not found");
|
||||
Log.w(TAG, "RootUtils: checkBusybox(): busybox not found");
|
||||
}
|
||||
return hasBusybox;
|
||||
}
|
||||
|
@ -53,17 +53,17 @@ public abstract class RootUtils {
|
|||
|
||||
f = new File(ServerUtils.getLocalDir(context) + "/dropbearmulti");
|
||||
if (f.exists() == false || f.isFile() == false || f.canExecute() == false) {
|
||||
Log.w(TAG, "checkDropear(): dropbearmulti");
|
||||
Log.w(TAG, "RootUtils: checkDropear(): dropbearmulti");
|
||||
return false;
|
||||
}
|
||||
f = new File("/data/dropbear/host_rsa");
|
||||
if (f.exists() == false || f.isFile() == false || f.canRead() == false) {
|
||||
Log.w(TAG, "checkDropear(): host_rsa");
|
||||
Log.w(TAG, "RootUtils: checkDropear(): host_rsa");
|
||||
return false;
|
||||
}
|
||||
f = new File("/data/dropbear/host_dss");
|
||||
if (f.exists() == false || f.isFile() == false || f.canRead() == false) {
|
||||
Log.w(TAG, "checkDropear(): host_dss");
|
||||
Log.w(TAG, "RootUtils: checkDropear(): host_dss");
|
||||
return false;
|
||||
}
|
||||
if (RootTools.checkUtil("dropbear")) {
|
||||
|
@ -71,11 +71,11 @@ public abstract class RootUtils {
|
|||
hasDropbear = true;
|
||||
}
|
||||
else {
|
||||
Log.w(TAG, "checkDropbear(): dropbearkey");
|
||||
Log.w(TAG, "RootUtils: checkDropbear(): dropbearkey");
|
||||
}
|
||||
}
|
||||
else {
|
||||
Log.w(TAG, "checkDropbear(): dropbear");
|
||||
Log.w(TAG, "RootUtils: checkDropbear(): dropbear");
|
||||
}
|
||||
return hasDropbear;
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@ import android.util.Log;
|
|||
|
||||
public abstract class ServerUtils {
|
||||
|
||||
private static final String TAG = "ServerUtils";
|
||||
private static final String TAG = "DropBearServer";
|
||||
|
||||
public static String localDir = null;
|
||||
public static String ipAddress = null;
|
||||
|
@ -50,7 +50,7 @@ public abstract class ServerUtils {
|
|||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
Log.e(TAG, "getLocalIpAddress(): " + e.getMessage());
|
||||
Log.e(TAG, "ServerUtils: getLocalIpAddress(): " + e.getMessage());
|
||||
}
|
||||
ipAddress = null;
|
||||
}
|
||||
|
@ -71,11 +71,11 @@ public abstract class ServerUtils {
|
|||
if (line != null) {
|
||||
try {
|
||||
Integer pid = Integer.parseInt(line);
|
||||
Log.i(TAG, "PID #" + pid);
|
||||
Log.i(TAG, "ServerUtils: PID #" + pid);
|
||||
return pid;
|
||||
}
|
||||
catch (Exception e) {
|
||||
Log.e(TAG, "getServerPidFromFile(): " + e.getMessage());
|
||||
Log.e(TAG, "ServerUtils: getServerPidFromFile(): " + e.getMessage());
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
@ -93,7 +93,7 @@ public abstract class ServerUtils {
|
|||
|
||||
// stdin
|
||||
DataOutputStream stdin = new DataOutputStream(suProcess.getOutputStream());
|
||||
Log.d(TAG, "# ps dropbear");
|
||||
Log.d(TAG, "ServerUtils: getServerPidFromPs(): # ps dropbear");
|
||||
stdin.writeBytes("ps dropbear\n");
|
||||
stdin.flush();
|
||||
stdin.writeBytes("exit\n");
|
||||
|
@ -122,14 +122,14 @@ public abstract class ServerUtils {
|
|||
line = line.replaceFirst("^^\\S+\\s+([0-9]+)\\s+.+\\sdropbear(\\s.+)?$", "$1");
|
||||
if (Utils.isNumeric(line)) {
|
||||
Integer pid = Integer.parseInt(line);
|
||||
Log.i(TAG, "PID #" + pid);
|
||||
Log.i(TAG, "ServerUtils: PID #" + pid);
|
||||
return pid;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
Log.e(TAG, "getServerPidFromPs(): " + e.getMessage());
|
||||
Log.e(TAG, "ServerUtils: getServerPidFromPs(): " + e.getMessage());
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
|
|
|
@ -13,7 +13,7 @@ import com.stericson.RootTools.RootTools;
|
|||
|
||||
public abstract class ShellUtils {
|
||||
|
||||
private static final String TAG = "ShellUtils";
|
||||
private static final String TAG = "DropBearServer";
|
||||
|
||||
public static ArrayList<String> commands = new ArrayList<String>();
|
||||
|
||||
|
@ -114,7 +114,7 @@ public abstract class ShellUtils {
|
|||
Process suProcess = Runtime.getRuntime().exec("su");
|
||||
DataOutputStream os = new DataOutputStream(suProcess.getOutputStream());
|
||||
for (String currCommand : ShellUtils.commands) {
|
||||
Log.d(TAG, "# " + currCommand);
|
||||
Log.d(TAG, "ShellUtils: execute(): # " + currCommand);
|
||||
os.writeBytes(currCommand + "\n");
|
||||
os.flush();
|
||||
}
|
||||
|
@ -135,7 +135,7 @@ public abstract class ShellUtils {
|
|||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
Log.e(TAG, e.getMessage());
|
||||
Log.e(TAG, "ShellUtils: execute(): " + e.getMessage());
|
||||
}
|
||||
|
||||
ShellUtils.commands.clear();
|
||||
|
|
|
@ -15,7 +15,7 @@ import com.stericson.RootTools.RootTools;
|
|||
|
||||
public abstract class Utils {
|
||||
|
||||
private static final String TAG = "Utils";
|
||||
private static final String TAG = "DropBearServer";
|
||||
|
||||
public static void marketNotFound(Context context) {
|
||||
Toast.makeText(context, "Google Play could not be found", Toast.LENGTH_SHORT).show();
|
||||
|
@ -34,7 +34,7 @@ public abstract class Utils {
|
|||
out.flush();
|
||||
out.close();
|
||||
} catch(Exception e) {
|
||||
Log.e(TAG, "copyRawFile(): " + e.getMessage());
|
||||
Log.e(TAG, "Utils: copyRawFile(): " + e.getMessage());
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
|
Loading…
Reference in New Issue