opt persistent notifications & geoip not default
This commit is contained in:
parent
63c4e97355
commit
1e3f6bbddf
|
@ -28,6 +28,7 @@ import org.torproject.android.TorConstants;
|
||||||
import org.torproject.android.Utils;
|
import org.torproject.android.Utils;
|
||||||
import org.torproject.android.settings.AppManager;
|
import org.torproject.android.settings.AppManager;
|
||||||
|
|
||||||
|
import android.app.Application;
|
||||||
import android.app.Notification;
|
import android.app.Notification;
|
||||||
import android.app.NotificationManager;
|
import android.app.NotificationManager;
|
||||||
import android.app.PendingIntent;
|
import android.app.PendingIntent;
|
||||||
|
@ -59,6 +60,7 @@ public class TorService extends Service implements TorServiceConstants, TorConst
|
||||||
private static final int ERROR_NOTIFY_ID = 3;
|
private static final int ERROR_NOTIFY_ID = 3;
|
||||||
private static final int HS_NOTIFY_ID = 3;
|
private static final int HS_NOTIFY_ID = 3;
|
||||||
|
|
||||||
|
private boolean prefPersistNotifications = true;
|
||||||
|
|
||||||
private static final int MAX_START_TRIES = 3;
|
private static final int MAX_START_TRIES = 3;
|
||||||
|
|
||||||
|
@ -178,7 +180,7 @@ public class TorService extends Service implements TorServiceConstants, TorConst
|
||||||
|
|
||||||
Notification notification = new Notification(icon, tickerText, when);
|
Notification notification = new Notification(icon, tickerText, when);
|
||||||
|
|
||||||
if (flags != -1)
|
if (prefPersistNotifications && flags != -1)
|
||||||
notification.flags |= flags;
|
notification.flags |= flags;
|
||||||
|
|
||||||
Context context = getApplicationContext();
|
Context context = getApplicationContext();
|
||||||
|
@ -204,11 +206,11 @@ public class TorService extends Service implements TorServiceConstants, TorConst
|
||||||
|
|
||||||
initTorPaths();
|
initTorPaths();
|
||||||
|
|
||||||
|
//if Tor was deleted for some reason, do this again!
|
||||||
if (!fileTor.exists())
|
if (!fileTor.exists())
|
||||||
{
|
{
|
||||||
new Thread ()
|
new Thread ()
|
||||||
{
|
{
|
||||||
|
|
||||||
public void run ()
|
public void run ()
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
|
@ -272,6 +274,8 @@ public class TorService extends Service implements TorServiceConstants, TorConst
|
||||||
public void run ()
|
public void run ()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
if (currentStatus == STATUS_CONNECTING)
|
||||||
|
{
|
||||||
boolean isRunning = _torInstance.findExistingProc ();
|
boolean isRunning = _torInstance.findExistingProc ();
|
||||||
|
|
||||||
if (!isRunning)
|
if (!isRunning)
|
||||||
|
@ -289,6 +293,13 @@ public class TorService extends Service implements TorServiceConstants, TorConst
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (currentStatus == STATUS_OFF)
|
||||||
|
{
|
||||||
|
|
||||||
|
_torInstance.stopTor();
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public void onDestroy ()
|
public void onDestroy ()
|
||||||
|
@ -453,7 +464,7 @@ public class TorService extends Service implements TorServiceConstants, TorConst
|
||||||
private void initTorPaths ()
|
private void initTorPaths ()
|
||||||
{
|
{
|
||||||
|
|
||||||
appBinHome = getDir("bin",0);
|
appBinHome = getDir("bin",Application.MODE_PRIVATE);
|
||||||
appDataHome = getCacheDir();
|
appDataHome = getCacheDir();
|
||||||
|
|
||||||
fileTor = new File(appBinHome, TOR_BINARY_ASSET_KEY);
|
fileTor = new File(appBinHome, TOR_BINARY_ASSET_KEY);
|
||||||
|
@ -976,7 +987,8 @@ public class TorService extends Service implements TorServiceConstants, TorConst
|
||||||
currentStatus = STATUS_OFF;
|
currentStatus = STATUS_OFF;
|
||||||
sendCallbackStatusMessage (getString(R.string.status_shutting_down));
|
sendCallbackStatusMessage (getString(R.string.status_shutting_down));
|
||||||
|
|
||||||
_torInstance.stopTor();
|
Thread thread = new Thread(this);
|
||||||
|
thread.start();
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1346,9 +1358,12 @@ public class TorService extends Service implements TorServiceConstants, TorConst
|
||||||
private boolean applyPreferences () throws RemoteException
|
private boolean applyPreferences () throws RemoteException
|
||||||
{
|
{
|
||||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
|
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
|
||||||
|
|
||||||
ENABLE_DEBUG_LOG = prefs.getBoolean("pref_enable_logging",false);
|
ENABLE_DEBUG_LOG = prefs.getBoolean("pref_enable_logging",false);
|
||||||
Log.i(TAG,"debug logging:" + ENABLE_DEBUG_LOG);
|
Log.i(TAG,"debug logging:" + ENABLE_DEBUG_LOG);
|
||||||
|
|
||||||
|
prefPersistNotifications = prefs.getBoolean(TorConstants.PREF_PERSIST_NOTIFICATIONS, true);
|
||||||
|
|
||||||
boolean useBridges = prefs.getBoolean(TorConstants.PREF_BRIDGES_ENABLED, false);
|
boolean useBridges = prefs.getBoolean(TorConstants.PREF_BRIDGES_ENABLED, false);
|
||||||
|
|
||||||
//boolean autoUpdateBridges = prefs.getBoolean(TorConstants.PREF_BRIDGES_UPDATED, false);
|
//boolean autoUpdateBridges = prefs.getBoolean(TorConstants.PREF_BRIDGES_UPDATED, false);
|
||||||
|
@ -1378,8 +1393,24 @@ public class TorService extends Service implements TorServiceConstants, TorConst
|
||||||
{
|
{
|
||||||
//only apple GeoIP if you need it
|
//only apple GeoIP if you need it
|
||||||
File fileGeoIP = new File(appBinHome,"geoip");
|
File fileGeoIP = new File(appBinHome,"geoip");
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (!fileGeoIP.exists())
|
||||||
|
{
|
||||||
|
TorBinaryInstaller installer = new TorBinaryInstaller(this, appBinHome);
|
||||||
|
boolean success = installer.installGeoIP();
|
||||||
|
}
|
||||||
|
|
||||||
mBinder.updateConfiguration("GeoIPFile", fileGeoIP.getAbsolutePath(), false);
|
mBinder.updateConfiguration("GeoIPFile", fileGeoIP.getAbsolutePath(), false);
|
||||||
}
|
}
|
||||||
|
catch (IOException e)
|
||||||
|
{
|
||||||
|
showToolbarNotification (getString(R.string.error_installing_binares),ERROR_NOTIFY_ID,R.drawable.tornotificationon, Notification.FLAG_ONGOING_EVENT);
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
mBinder.updateConfiguration("EntryNodes", entranceNodes, false);
|
mBinder.updateConfiguration("EntryNodes", entranceNodes, false);
|
||||||
mBinder.updateConfiguration("ExitNodes", exitNodes, false);
|
mBinder.updateConfiguration("ExitNodes", exitNodes, false);
|
||||||
|
|
Loading…
Reference in New Issue