make expanded notif off by default; handle exceptions better

- some devices seem to not like these new expanded/remoteviews notifications, so we are turning them off by default. This will also help with load issues on onionoo servers
This commit is contained in:
Nathan Freitas 2014-08-11 10:10:18 -04:00
parent 11d3f59543
commit 0d424797a2
4 changed files with 46 additions and 52 deletions

View File

@ -55,20 +55,7 @@
android:textStyle="bold"
android:textAppearance="@style/NotificationTitle"
/>
<ViewStub android:id="@+id/time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0"
android:visibility="gone"
android:layout="@layout/notification_template_part_time"
/>
<ViewStub android:id="@+id/chronometer"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0"
android:visibility="gone"
android:layout="@layout/notification_template_part_chronometer"
/>
</LinearLayout>
<LinearLayout
android:id="@+id/line3"
@ -131,13 +118,5 @@
android:layout_marginStart="8dp"
android:fadingEdge="horizontal"
/>
<ProgressBar
android:id="@android:id/progress"
android:layout_width="match_parent"
android:layout_height="12dp"
android:layout_marginStart="8dp"
android:visibility="gone"
style="?android:attr/progressBarStyleHorizontal"
/>
</LinearLayout>
</FrameLayout>

View File

@ -227,9 +227,15 @@
<string name="unable_to_start_tor">Unable to start Tor:</string>
<string name="pref_use_sys_iptables_title">Use Default Iptables</string>
<string name="pref_use_sys_iptables_summary">use the built-in iptables binary instead of the one bundled with Orbot</string>
<string name="error_installing_binares">The Tor binaries were not able to be installed or upgraded.</string>
<string name="pref_use_persistent_notifications">Always keep the icon in toolbar when Orbot is connected</string>
<string name="pref_use_persistent_notifications_title">Always-On Notifications</string>
<string name="pref_use_expanded_notifications">Show expanded notification with Tor exit country and IP</string>
<string name="pref_use_expanded_notifications_title">Expanded Notifications</string>
<string name="notification_using_bridges">Bridges enabled!</string>
<string name="default_bridges"/>
<string name="set_locale_title">Set Locale</string>

View File

@ -23,6 +23,13 @@ android:summary="@string/pref_use_persistent_notifications"
android:enabled="true"
android:title="@string/pref_use_persistent_notifications_title"/>
<CheckBoxPreference
android:defaultValue="false"
android:key="pref_expanded_notifications"
android:summary="@string/pref_use_expanded_notifications"
android:enabled="true"
android:title="@string/pref_use_expanded_notifications_title"/>
<ListPreference android:title="@string/set_locale_title"
android:key="pref_default_locale"

View File

@ -128,6 +128,7 @@ public class TorService extends Service implements TorServiceConstants, TorConst
private NotificationManager mNotificationManager = null;
private Builder mNotifyBuilder;
private Notification mNotification;
private boolean mShowExpandedNotifications = false;
private boolean mHasRoot = false;
private boolean mEnableTransparentProxy = false;
@ -270,7 +271,7 @@ public class TorService extends Service implements TorServiceConstants, TorConst
mNotification = mNotifyBuilder.build();
if (Build.VERSION.SDK_INT >= 16) {
if (Build.VERSION.SDK_INT >= 16 && mShowExpandedNotifications) {
// Create remote view that needs to be set as bigContentView for the notification.
@ -317,8 +318,6 @@ public class TorService extends Service implements TorServiceConstants, TorConst
expandedView.setTextViewText(R.id.title, getString(R.string.app_name));
// expandedView.setTextViewText(R.id.info, infoMessage.toString());
// expandedView.setOnClickPendingIntent(R.id._tor_notificationBT, pendIntent);
expandedView.setImageViewResource(R.id.icon, icon);
mNotification.bigContentView = expandedView;
}
@ -723,6 +722,7 @@ public class TorService extends Service implements TorServiceConstants, TorConst
mEnableTransparentProxy = prefs.getBoolean("pref_transparent", false);
mTransProxyAll = prefs.getBoolean("pref_transparent_all", false);
mTransProxyTethering = prefs.getBoolean("pref_transparent_tethering", false);
mShowExpandedNotifications = prefs.getBoolean("pref_expanded_notifications", false);
ENABLE_DEBUG_LOG = prefs.getBoolean("pref_enable_logging",false);
Log.i(TAG,"debug logging:" + ENABLE_DEBUG_LOG);
@ -766,7 +766,7 @@ public class TorService extends Service implements TorServiceConstants, TorConst
*
* the idea is that if Tor is off then transproxy is off
*/
protected boolean enableTransparentProxy (boolean proxyAll, boolean enableTether) throws Exception
private boolean enableTransparentProxy (boolean proxyAll, boolean enableTether) throws Exception
{
if (mTransProxy == null)
@ -1124,7 +1124,7 @@ public class TorService extends Service implements TorServiceConstants, TorConst
{
logNotice("unable to get control port; file not found");
}
catch (IOException e)
catch (Exception e)
{
logNotice("unable to read control port config file");
}
@ -1170,7 +1170,7 @@ public class TorService extends Service implements TorServiceConstants, TorConst
}*/
public void addEventHandler () throws IOException
public void addEventHandler () throws Exception
{
// We extend NullEventHandler so that we don't need to provide empty
// implementations for all the events we don't care about.
@ -1386,31 +1386,33 @@ public class TorService extends Service implements TorServiceConstants, TorConst
logNotice(sb.toString());
//get IP from last nodename
if(status.equals("BUILT")){
if (node.ipAddress == null)
mExecutor.execute(new ExternalIPFetcher(node));
hmBuiltNodes.put(node.id, node);
}
if (status.equals("CLOSED"))
if (mShowExpandedNotifications)
{
hmBuiltNodes.remove(node.id);
//how check the IP's of any other nodes we have
for (String nodeId : hmBuiltNodes.keySet())
{
node = hmBuiltNodes.get(nodeId);
//get IP from last nodename
if(status.equals("BUILT")){
if (node.ipAddress == null)
mExecutor.execute(new ExternalIPFetcher(node));
hmBuiltNodes.put(node.id, node);
}
}
if (status.equals("CLOSED"))
{
hmBuiltNodes.remove(node.id);
//how check the IP's of any other nodes we have
for (String nodeId : hmBuiltNodes.keySet())
{
node = hmBuiltNodes.get(nodeId);
if (node.ipAddress == null)
mExecutor.execute(new ExternalIPFetcher(node));
}
}
}
}
@ -1585,9 +1587,9 @@ public class TorService extends Service implements TorServiceConstants, TorConst
}
}
catch(IOException ioe)
catch(Exception ioe)
{
Log.e(TAG,"Unable to get Tor information",ioe);
// Log.e(TAG,"Unable to get Tor information",ioe);
logNotice("Unable to get Tor information"+ioe.getMessage());
}
return null;
@ -1621,7 +1623,7 @@ public class TorService extends Service implements TorServiceConstants, TorConst
return result.toString();
}
}
catch (IOException ioe)
catch (Exception ioe)
{
logException("Unable to get Tor configuration: " + ioe.getMessage(),ioe);
@ -1678,7 +1680,7 @@ public class TorService extends Service implements TorServiceConstants, TorConst
//checkAddressAndCountry();
}
catch (IOException ioe){
catch (Exception ioe){
debug("error requesting newnym: " + ioe.getLocalizedMessage());
}
}
@ -1855,7 +1857,7 @@ public class TorService extends Service implements TorServiceConstants, TorConst
}
};
private boolean processSettingsImpl () throws RemoteException, IOException
private boolean processSettingsImpl () throws Exception
{
logNotice(getString(R.string.updating_settings_in_tor_service));