Merge branch 'eighthave-the-big-start-stop-makeover'

This commit is contained in:
Nathan Freitas 2015-06-22 12:39:17 -04:00
commit a8384bde74
26 changed files with 1034 additions and 1526 deletions

View File

@ -7,4 +7,17 @@ file_filter = res/values-<lang>/strings.xml
host = https://www.transifex.com
source_file = res/values/strings.xml
source_lang = en
type = ANDROID
[orbot.description]
file_filter = description/<lang>.xlf
host = https://www.transifex.com
source_file = description/source.xlf
source_lang = en
type = XLIFF
[orbot.olddescription]
file_filter = releases/assets/<lang>-description.txt
host = https://www.transifex.com
source_file = releases/assets/description.txt
source_lang = en

View File

@ -57,12 +57,6 @@
</activity>
<activity android:name=".ui.OrbotLogActivity"
android:configChanges="orientation|screenSize"
android:exported="false"
/>
<!--
This is for ensuring the background service still runs when/if the app is swiped away
-->
@ -81,24 +75,27 @@
/>
<activity android:name="org.torproject.android.ui.wizard.PromoAppsActivity" android:exported="false"/>
<activity android:name="org.torproject.android.ui.wizard.ChooseLocaleWizardActivity" android:exported="false"/>
<activity android:name="org.torproject.android.ui.PromoAppsActivity" android:exported="false"/>
<activity android:name=".settings.SettingsPreferences" android:label="@string/app_name"/>
<activity android:name=".settings.AppManager" android:label="@string/app_name"/>
<service android:enabled="true"
<service
android:name=".service.TorService"
android:enabled="true"
android:permission="org.torproject.android.MANAGE_TOR"
android:stopWithTask="false"
>
<intent-filter>
<action android:name="org.torproject.android.service.ITorService" />
<action android:name="org.torproject.android.service.TOR_SERVICE" />
</intent-filter>
android:stopWithTask="false" >
</service>
<receiver
android:name=".service.StartTorReceiver"
android:exported="true">
<intent-filter>
<action android:name="org.torproject.android.intent.action.START" />
</intent-filter>
</receiver>
<receiver android:name="org.torproject.android.service.OnBootReceiver"
android:enabled="true" android:exported="true"

86
description/source.xlf Normal file
View File

@ -0,0 +1,86 @@
<?xml version="1.0" encoding="UTF-8"?>
<xliff version="1.2">
<file datatype="plaintext" original="source.xlf" source-language="en">
<header>
<note from="developer">Google places strick character limits on the various text fields in Google Play. The title is 30 characters, the short description is 80 characters, and the rest of the strings, which all go together in the description, are limited to 4000 characters.</note>
</header>
<body>
<trans-unit id="title" size-unit="char" maxwidth="30">
<source>Orbot</source>
<note from="developer">This is limited by Google to 30 characters</note>
</trans-unit>
<trans-unit id="shortdescription" size-unit="char" maxwidth="80">
<source>Protect your privacy with this proxy with Tor</source>
<note from="developer">This is limited by Google to 80 characters</note>
</trans-unit>
<trans-unit id="intro">
<source>Orbot is a free proxy app that empowers other apps to use the internet more securely. Orbot uses Tor to encrypt your Internet traffic and then hides it by bouncing through a series of computers around the world. Tor is free software and an open network that helps you defend against a form of network surveillance that threatens personal freedom and privacy, confidential business activities and relationships, and state security known as traffic analysis.</source>
</trans-unit>
<trans-unit id="intro2">
<source>Orbot is the only app that creates a truly private internet connection. As the New York Times writes, “when a communication arrives from Tor, you can never know where or whom its from.” Tor won the 2012 Electronic Frontier Foundation (EFF) Pioneer Award.</source>
</trans-unit>
<trans-unit id="intro2">
<source>ACCEPT NO SUBSTITUTES: Orbot is the safest way to use the Internet on Android. Period. Orbot bounces your encrypted traffic several times through computers around the world, instead of connecting you directly like VPNs and proxies. This process takes a little longer, but the strongest privacy and identity protection available is worth the wait.</source>
</trans-unit>
<trans-unit id="intro2">
<source>PRIVATE WEB SURFING: Use with Orweb, the most anonymous way to access any website, even if its normally blocked, monitored, or on the hidden web. Get Orweb: https://goo.gl/s3mLa</source>
</trans-unit>
<trans-unit id="intro2">
<source>PRIVATE CHAT MESSAGING: Use Gibberbot with Orbot to chat confidentially with anyone, anywhere for free. Get Gibberbot: https://goo.gl/O3FfS</source>
</trans-unit>
<trans-unit id="intro2">
<source>PRIVACY FOR APPS: Any installed app can use Tor if it has a proxy feature, using the settings found here: https://goo.gl/2OA1y Use Orbot with Twitter, or try private web searching with DuckDuckGo: https://goo.gl/lgh1p</source>
</trans-unit>
<trans-unit id="intro2">
<source>PRIVACY FOR EVERYONE: Tor can help you confidentially research a competitor, get around the Facebook block at school, or circumvent a firewall to watch sports at work.
PRIVACY MADE EASY: Check out our fun, interactive walkthrough: https://guardianproject.info/howto/browsefreely
ITS OFFICIAL: This is the official version of the Tor onion routing service for Android.</source>
</trans-unit>
<trans-unit id="expertrootmode">
<source>***Expert Root Mode***</source>
</trans-unit>
<trans-unit id="universalmode">
<source>UNIVERSAL MODE: Orbot can be configured to transparently proxy all of your Internet traffic through Tor. You can also choose which specific apps you want to use through Tor.</source>
</trans-unit>
<trans-unit id="wespeakyourlanguage">
<source>★ WE SPEAK YOUR LANGUAGE: Orbot is available for friends who speak:</source>
</trans-unit>
<trans-unit id="languagelist" translate="no">
<source>العربية, azərbaycanca, български, català, Čeština, dansk, Deutsch, Ελληνικά, English, español, eesti, euskara, فارسی, suomi, français, galego, hrvatski, magyar, עברית, íslenska, italiano, 日本語, 한국어, lietuvių, latviešu, Македонци, Bahasa Melayu, Nederlands, norsk, polski, português, Русский, slovenčina, slovenščina, српски, svenska, Türkçe, українська, Tagalog, Tiếng Việt, 中文(简体), 中文(台灣)</source>
<note from="developer">Do not translate the names of the languages, leave them just like this.</note>
</trans-unit>
<trans-unit id="helptranslate">
<source>Dont see your language? Join us and help translate the app:</source>
</trans-unit>
<trans-unit id="helptranslateurl" translate="no">
<source>https://www.transifex.com/projects/p/orbot</source>
<note from="developer">Do not translate this.</note>
</trans-unit>
<trans-unit id="learnmore">
<source>***Learn More***</source>
</trans-unit>
<trans-unit id="aboutus">
<source>★ ABOUT US: Guardian Project is a group of developers that make secure mobile apps and open-source code for a better tomorrow</source>
</trans-unit>
<trans-unit id="ourwebsite">
<source>★ OUR WEBSITE: https://GuardianProject.info</source>
</trans-unit>
<trans-unit id="abouttor">
<source>★ ABOUT TOR: https://TorProject.org</source>
</trans-unit>
<trans-unit id="ontwitter">
<source>★ ON TWITTER: https://twitter.com/guardianproject</source>
</trans-unit>
<trans-unit id="freesoftware">
<source>★ FREE SOFTWARE: Orbot is free software. Take a look at our source code, or join the community to make it better:</source>
</trans-unit>
<trans-unit id="gitrepo" translate="no">
<source>https://gitweb.torproject.org/orbot.git</source>
<note from="developer">Do not translate this.</note>
</trans-unit>
<trans-unit id="messageus">
<source>★ MESSAGE US: Are we missing your favorite feature? Found an annoying bug? Please tell us! Wed love to hear from you. Send us an email: support@guardianproject.info or find us in our chat room https://guardianproject.info/contact</source>
</trans-unit>
</body>
</file>
</xliff>

15
external/.tx/config vendored
View File

@ -1,15 +0,0 @@
[main]
host = https://www.transifex.com
lang_map = af_ZA: af-rZA, am_ET: am-rET, ar_AE: ar-rAE, ar_BH: ar-rBH, ar_DZ: ar-rDZ, ar_EG: ar-rEG, ar_IQ: ar-rIQ, ar_JO: ar-rJO, ar_KW: ar-rKW, ar_LB: ar-rLB, ar_LY: ar-rLY, ar_MA: ar-rMA, ar_OM: ar-rOM, ar_QA: ar-rQA, ar_SA: ar-rSA, ar_SY: ar-rSY, ar_TN: ar-rTN, ar_YE: ar-rYE, arn_CL: arn-rCL, as_IN: as-rIN, az_AZ: az-rAZ, ba_RU: ba-rRU, be_BY: be-rBY, bg_BG: bg-rBG, bn_BD: bn-rBD, bn_IN: bn-rIN, bo_CN: bo-rCN, br_FR: br-rFR, bs_BA: bs-rBA, ca_ES: ca-rES, co_FR: co-rFR, cs_CZ: cs-rCZ, cy_GB: cy-rGB, da_DK: da-rDK, de_AT: de-rAT, de_CH: de-rCH, de_DE: de-rDE, de_LI: de-rLI, de_LU: de-rLU, dsb_DE: dsb-rDE, dv_MV: dv-rMV, el_GR: el-rGR, en_AU: en-rAU, en_BZ: en-rBZ, en_CA: en-rCA, en_GB: en-rGB, en_IE: en-rIE, en_IN: en-rIN, en_JM: en-rJM, en_MY: en-rMY, en_NZ: en-rNZ, en_PH: en-rPH, en_SG: en-rSG, en_TT: en-rTT, en_US: en-rUS, en_ZA: en-rZA, en_ZW: en-rZW, es_AR: es-rAR, es_BO: es-rBO, es_CL: es-rCL, es_CO: es-rCO, es_CR: es-rCR, es_DO: es-rDO, es_EC: es-rEC, es_ES: es-rES, es_GT: es-rGT, es_HN: es-rHN, es_MX: es-rMX, es_NI: es-rNI, es_PA: es-rPA, es_PE: es-rPE, es_PR: es-rPR, es_PY: es-rPY, es_SV: es-rSV, es_US: es-rUS, es_UY: es-rUY, es_VE: es-rVE, et_EE: et-rEE, eu_ES: eu-rES, fa_IR: fa-rIR, fi_FI: fi-rFI, fil_PH: tl-rPH, fil: tl, fo_FO: fo-rFO, fr_BE: fr-rBE, fr_CA: fr-rCA, fr_CH: fr-rCH, fr_FR: fr-rFR, fr_LU: fr-rLU, fr_MC: fr-rMC, fy_NL: fy-rNL, ga_IE: ga-rIE, gd_GB: gd-rGB, gl_ES: gl-rES, gsw_FR: gsw-rFR, gu_IN: gu-rIN, ha_NG: ha-rNG, he_IL: he-rIL, hi_IN: hi-rIN, hr_BA: hr-rBA, hr_HR: hr-rHR, hsb_DE: hsb-rDE, hu_HU: hu-rHU, hy_AM: hy-rAM, id_ID: id-rID, ig_NG: ig-rNG, ii_CN: ii-rCN, is_IS: is-rIS, it_CH: it-rCH, it_IT: it-rIT, iu_CA: iu-rCA, ja_JP: ja-rJP, ka_GE: ka-rGE, kk_KZ: kk-rKZ, kl_GL: kl-rGL, km_KH: km-rKH, kn_IN: kn-rIN, ko_KR: ko-rKR, kok_IN: kok-rIN, ky_KG: ky-rKG, lb_LU: lb-rLU, lo_LA: lo-rLA, lt_LT: lt-rLT, lv_LV: lv-rLV, mi_NZ: mi-rNZ, mk_MK: mk-rMK, ml_IN: ml-rIN, mn_CN: mn-rCN, mn_MN: mn-rMN, moh_CA: moh-rCA, mr_IN: mr-rIN, ms_BN: ms-rBN, ms_MY: ms-rMY, mt_MT: mt-rMT, nb_NO: nb-rNO, ne_NP: ne-rNP, nl_BE: nl-rBE, nl_NL: nl-rNL, nn_NO: nn-rNO, nso_ZA: nso-rZA, oc_FR: oc-rFR, or_IN: or-rIN, pa_IN: pa-rIN, pl_PL: pl-rPL, prs_AF: prs-rAF, ps_AF: ps-rAF, pt_BR: pt-rBR, pt_PT: pt-rPT, qut_GT: qut-rGT, quz_BO: quz-rBO, quz_EC: quz-rEC, quz_PE: quz-rPE, rm_CH: rm-rCH, ro_RO: ro-rRO, ru_RU: ru-rRU, rw_RW: rw-rRW, sa_IN: sa-rIN, sah_RU: sah-rRU, se_FI: se-rFI, se_NO: se-rNO, se_SE: se-rSE, si_LK: si-rLK, sk_SK: sk-rSK, sl_SI: sl-rSI, sma_NO: sma-rNO, sma_SE: sma-rSE, smj_NO: smj-rNO, smj_SE: smj-rSE, smn_FI: smn-rFI, sms_FI: sms-rFI, sq_AL: sq-rAL, sr_BA: sr-rBA, sr_CS: sr-rCS, sr_ME: sr-rME, sr_RS: sr-rRS, sv_FI: sv-rFI, sv_SE: sv-rSE, sw_KE: sw-rKE, syr_SY: syr-rSY, ta_IN: ta-rIN, te_IN: te-rIN, tg_TJ: tg-rTJ, th_TH: th-rTH, tk_TM: tk-rTM, tn_ZA: tn-rZA, tr_TR: tr-rTR, tt_RU: tt-rRU, tzm_DZ: tzm-rDZ, ug_CN: ug-rCN, uk_UA: uk-rUA, ur_PK: ur-rPK, uz_UZ: uz-rUZ, vi_VN: vi-rVN, wo_SN: wo-rSN, xh_ZA: xh-rZA, yo_NG: yo-rNG, zh_CN: zh-rCN, zh_HK: zh-rHK, zh_MO: zh-rMO, zh_SG: zh-rSG, zh_TW: zh-rTW, zu_ZA: zu-rZA
[orbot.stringsxml]
file_filter = ../res/values-<lang>/strings.xml
host = https://www.transifex.com
source_file = ../res/values/strings.xml
source_lang = en
[orbot.description]
file_filter = ../releases/assets/<lang>-description.txt
host = https://www.transifex.com
source_file = ../releases/assets/description.txt
source_lang = en

2
external/tor vendored

@ -1 +1 @@
Subproject commit 9ccf019b168909ef6674c71aebda9f90516bb6a1
Subproject commit d41ab97294ec69c748566f4cb610f899d9976572

View File

@ -4,6 +4,8 @@
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/panel_background_main"
>
<android.support.v7.widget.Toolbar
@ -123,45 +125,58 @@
</RelativeLayout>
</LinearLayout>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:background="@color/panel_background_main"
<ProgressBar
android:id="@+id/pbConnecting"
style="?android:attr/progressBarStyleLarge"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="60dp"
android:visibility="gone"
android:layout_gravity="center_horizontal|center_vertical"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/frameMain"
android:visibility="visible"
android:orientation="vertical"
android:layout_gravity="center_horizontal|center_vertical"
>
<org.torproject.android.ui.ImageProgressView
android:id="@+id/imgStatus"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:padding="0dp"
android:layout_height="0dp"
android:layout_weight=".8"
android:src="@drawable/toroff"
android:layout_gravity="center_horizontal|center_vertical" />
android:padding="0dp"
android:layout_margin="0dp"
android:src="@drawable/toroff" />
<TextView
android:id="@+id/lblStatus"
android:textColor="@android:color/white"
android:layout_width="wrap_content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="16sp"
android:gravity="center_vertical"
android:textSize="14sp"
android:gravity="center_horizontal"
android:fontFamily="sans-serif-light"
android:text=""
android:layout_gravity="center_horizontal|bottom"
android:layout_margin="10dp"
android:lines="2"
android:maxLines="2"
android:layout_gravity="center_horizontal"
android:layout_margin="0dp"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
/>
</FrameLayout>
<LinearLayout android:gravity="center_horizontal"
android:orientation="horizontal" android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="5dp"
android:background="@color/panel_background_dark"
android:layout_gravity="bottom"
>
<Button
@ -204,7 +219,10 @@
</LinearLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="320dp"
android:layout_height="match_parent"

View File

@ -1,22 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<ScrollView android:id="@+id/helpscrollview"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TextView android:text=""
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textColor="#ffffff" />
</LinearLayout>
</ScrollView>
</LinearLayout>

View File

@ -1,57 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/relativeLayout1"
android:layout_gravity="center_horizontal"
android:background="#000000">
<TextView android:textSize="10pt"
android:textColor="#FFFFFF"
android:layout_alignParentTop="true"
android:layout_height="wrap_content"
android:id="@+id/WizardLocaleTitle"
android:layout_width="wrap_content"
android:fadingEdge="vertical"
android:text="@string/wizard_locale_title"
android:singleLine="true"
android:padding="20px" android:layout_centerInParent="true">
</TextView>
</RelativeLayout>
<TableLayout android:id="@+id/TableLayout01" android:stretchColumns="*" android:layout_height="fill_parent" android:layout_width="wrap_content">
<TableRow android:layout_margin="10dip" android:id="@+id/TableRow01" android:layout_weight="1" android:layout_width="fill_parent" android:layout_height="fill_parent">
<LinearLayout
android:background="#575757"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:padding="3px">
<TextView android:text="@string/wizard_locale_msg" android:layout_width="wrap_content" android:textColor="#ffffff" android:layout_height="wrap_content" android:textSize="8pt" android:id="@+id/WizardTextBody1" android:padding="20dip"></TextView>
<ListView
android:id="@+id/wizard_locale_list"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
>
</ListView>
</LinearLayout>
</TableRow>
<TableRow android:background="#000000" android:layout_marginTop="10dip" android:paddingTop="10dip" android:id="@+id/TableRow01" android:textColor="#00ff00" android:layout_width="fill_parent" android:layout_height="30px">
<Button android:text="@string/btn_next" android:id="@+id/btnWizard2" android:layout_weight="1" android:layout_width="fill_parent" android:layout_height="wrap_content"></Button>
</TableRow>
</TableLayout>
</LinearLayout>

View File

@ -57,8 +57,8 @@
-->
<item android:id="@+id/menu_wizard"
android:title="@string/menu_wizard"
<item android:id="@+id/menu_promo_apps"
android:title="@string/menu_promo_apps"
android:icon="@drawable/ic_menu_goto"
yourapp:showAsAction="never"

View File

@ -11,7 +11,7 @@
<string name="status_starting_up">Orbot is starting&#8230;</string>
<string name="status_activated">Connected to the Tor network</string>
<string name="status_disabled">Orbot is deactivated</string>
<string name="status_shutting_down">Orbot is shutting down</string>
<string name="status_shutting_down">TorService is shutting down</string>
<string name="tor_process_starting">Starting Tor client&#8230;</string>
<string name="tor_process_complete">complete.</string>
<string name="tor_process_waiting">waiting.</string>
@ -25,7 +25,7 @@
<string name="menu_start">Start</string>
<string name="menu_stop">Stop</string>
<string name="menu_about">About</string>
<string name="menu_wizard">Wizard</string>
<string name="menu_promo_apps">Get apps…</string>
<string name="main_layout_download">Download</string>
<string name="main_layout_upload">Upload</string>
<string name="button_help">Help</string>
@ -126,6 +126,8 @@
<string name="pref_entrance_node">Entrance Nodes</string>
<string name="pref_entrance_node_summary">Fingerprints, nicks, countries and addresses for the first hop</string>
<string name="pref_entrance_node_dialog">Enter Entrance Nodes</string>
<string name="pref_allow_background_starts_title">Allow Background Starts</string>
<string name="pref_allow_background_starts_summary">Let any app tell Orbot to start Tor and related services</string>
<string name="button_proxy_all">Proxy All</string>
<string name="button_proxy_none">Proxy None</string>

View File

@ -22,6 +22,11 @@ android:summary="@string/pref_use_expanded_notifications"
android:enabled="true"
android:title="@string/pref_use_expanded_notifications_title"/>
<CheckBoxPreference
android:defaultValue="false"
android:key="pref_allow_background_starts"
android:summary="@string/pref_allow_background_starts_summary"
android:title="@string/pref_allow_background_starts_title"/>
<ListPreference android:title="@string/set_locale_title"
android:key="pref_default_locale"

View File

@ -5,8 +5,6 @@ import android.annotation.TargetApi;
import android.app.Activity;
import android.app.Application;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.content.res.Configuration;
import android.os.Build;
import android.text.TextUtils;
@ -14,29 +12,26 @@ import android.util.Log;
import info.guardianproject.util.Languages;
import org.torproject.android.service.TorServiceUtils;
import java.util.Locale;
public class OrbotApp extends Application implements OrbotConstants
{
private Locale locale;
private SharedPreferences prefs;
@Override
public void onCreate() {
super.onCreate();
Prefs.setContext(this);
prefs = TorServiceUtils.getSharedPrefs(getApplicationContext());
setNewLocale(prefs.getString(PREF_DEFAULT_LOCALE, Locale.getDefault().getLanguage()));
setNewLocale(Prefs.getDefaultLocale());
}
@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
Log.i(TAG, "onConfigurationChanged " + newConfig.locale.getLanguage());
setNewLocale(prefs.getString(PREF_DEFAULT_LOCALE, Locale.getDefault().getLanguage()));
setNewLocale(Prefs.getDefaultLocale());
}
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
@ -65,10 +60,7 @@ public class OrbotApp extends Application implements OrbotConstants
* wrong. If setting the locale causes an Exception, it should be set in
* the preferences, otherwise ChatSecure will be stuck in a crash loop.
*/
SharedPreferences prefs = TorServiceUtils.getSharedPrefs(this);
Editor prefEdit = prefs.edit();
prefEdit.putString(PREF_DEFAULT_LOCALE, language);
prefEdit.apply();
Prefs.setDefaultLocale(language);
Log.i(TAG, "setNewLocale complete: locale: " + locale.getLanguage()
+ " Locale.getDefault: " + Locale.getDefault().getLanguage());
}

View File

@ -7,7 +7,6 @@ public interface OrbotConstants {
public final static String TAG = "Orbot";
public final static String PREFS_KEY = "OrbotPrefs";
public final static String PREFS_KEY_TORIFIED = "PrefTord";
@ -18,33 +17,15 @@ public interface OrbotConstants {
public final static String URL_TOR_BRIDGES = "https://bridges.torproject.org/bridges?transport=";
public final static String NEWLINE = "\n";
// public final static String INTENT_TOR_SERVICE = "org.torproject.android.service.TOR_SERVICE";
public final static String HANDLER_TOR_MSG = "torServiceMsg";
public final static String PREF_BRIDGES_ENABLED = "pref_bridges_enabled";
public final static String PREF_BRIDGES_UPDATED = "pref_bridges_enabled";
public final static String PREF_BRIDGES_LIST = "pref_bridges_list";
//public final static String PREF_BRIDGES_OBFUSCATED = "pref_bridges_obfuscated";
public final static String PREF_OR = "pref_or";
public final static String PREF_OR_PORT = "pref_or_port";
public final static String PREF_OR_NICKNAME = "pref_or_nickname";
public final static String PREF_REACHABLE_ADDRESSES = "pref_reachable_addresses";
public final static String PREF_REACHABLE_ADDRESSES_PORTS = "pref_reachable_addresses_ports";
public final static String PREF_TRANSPARENT = "pref_transparent";
public final static String PREF_TRANSPARENT_ALL = "pref_transparent_all";
public final static String PREF_HAS_ROOT = "has_root";
public final static int RESULT_CLOSE_ALL = 0;
public final static String PREF_USE_SYSTEM_IPTABLES = "pref_use_sys_iptables";
public final static String PREF_PERSIST_NOTIFICATIONS = "pref_persistent_notifications";
public final static String PREF_DEFAULT_LOCALE = "pref_default_locale";
public final static String PREF_DISABLE_NETWORK = "pref_disable_network";
public final static String PREF_TOR_SHARED_PREFS = "org.torproject.android_preferences";

View File

@ -14,8 +14,8 @@ import org.torproject.android.service.TorServiceConstants;
import org.torproject.android.service.TorServiceUtils;
import org.torproject.android.settings.SettingsPreferences;
import org.torproject.android.ui.ImageProgressView;
import org.torproject.android.ui.PromoAppsActivity;
import org.torproject.android.ui.Rotate3dAnimation;
import org.torproject.android.ui.wizard.PromoAppsActivity;
import android.annotation.TargetApi;
import android.app.Activity;
@ -28,11 +28,9 @@ import android.content.Intent;
import android.content.IntentFilter;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.content.res.Configuration;
import android.net.Uri;
import android.net.VpnService;
import android.os.Build;
@ -56,6 +54,7 @@ import android.view.View;
import android.view.View.OnClickListener;
import android.view.View.OnLongClickListener;
import android.view.View.OnTouchListener;
import android.view.Window;
import android.view.animation.AccelerateInterpolator;
import android.widget.Button;
import android.widget.TextView;
@ -66,13 +65,13 @@ import com.google.zxing.integration.android.IntentIntegrator;
import com.google.zxing.integration.android.IntentResult;
public class OrbotMainActivity extends Activity implements OrbotConstants, OnLongClickListener, OnTouchListener, OnSharedPreferenceChangeListener
{
public class OrbotMainActivity extends Activity
implements OrbotConstants, OnLongClickListener, OnTouchListener {
/* Useful UI bits */
private TextView lblStatus = null; //the main text display widget
private ImageProgressView imgStatus = null; //the main touchable image for activating Orbot
private MenuItem mItemOnOff = null;
private TextView downloadText = null;
private TextView uploadText = null;
private TextView mTxtOrbotLog = null;
@ -81,111 +80,109 @@ public class OrbotMainActivity extends Activity implements OrbotConstants, OnLon
private ToggleButton mBtnVPN = null;
private ToggleButton mBtnBridges = null;
private DrawerLayout mDrawer;
private ActionBarDrawerToggle mDrawerToggle;
private Toolbar mToolbar;
/* Some tracking bits */
private int torStatus = TorServiceConstants.STATUS_OFF; //latest status reported from the tor service
private String torStatus = null; //latest status reported from the tor service
private Intent lastStatusIntent; // the last ACTION_STATUS Intent received
private SharedPreferences mPrefs = null;
private boolean autoStartFromIntent = false;
private final static long INIT_DELAY = 100;
private final static int REQUEST_VPN = 8888;
private final static int REQUEST_SETTINGS = 0x9874;
// message types for mStatusUpdateHandler
private final static int STATUS_UPDATE = 1;
private static final int MESSAGE_TRAFFIC_COUNT = 2;
public final static String INTENT_ACTION_REQUEST_HIDDEN_SERVICE = "org.torproject.android.REQUEST_HS_PORT";
public final static String INTENT_ACTION_REQUEST_START_TOR = "org.torproject.android.START_TOR";
/** Called when the activity is first created. */
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mPrefs = TorServiceUtils.getSharedPrefs(getApplicationContext());
mPrefs.registerOnSharedPreferenceChangeListener(this);
/* Create the widgets before registering for broadcasts to guarantee
* that the widgets exist when the status updates try to update them */
doLayout();
// Register to receive messages.
// We are registering an observer (mMessageReceiver) to receive Intents
// with actions named "custom-event-name".
LocalBroadcastManager.getInstance(this).registerReceiver(mMessageReceiver,
new IntentFilter("status"));
LocalBroadcastManager.getInstance(this).registerReceiver(mMessageReceiver,
new IntentFilter("log"));
mHandler.postDelayed(new Runnable ()
{
public void run ()
{
startService(TorServiceConstants.CMD_INIT);
}
},INIT_DELAY);
/* receive the internal status broadcasts, which are separate from the public
* status broadcasts to prevent other apps from sending fake/wrong status
* info to this app */
LocalBroadcastManager lbm = LocalBroadcastManager.getInstance(this);
lbm.registerReceiver(mLocalBroadcastReceiver,
new IntentFilter(TorServiceConstants.ACTION_STATUS));
lbm.registerReceiver(mLocalBroadcastReceiver,
new IntentFilter(TorServiceConstants.LOCAL_ACTION_BANDWIDTH));
lbm.registerReceiver(mLocalBroadcastReceiver,
new IntentFilter(TorServiceConstants.LOCAL_ACTION_LOG));
}
private void startService (String action)
{
private void sendIntentToService(String action) {
Intent torService = new Intent(this, TorService.class);
torService.setAction(action);
startService(torService);
}
private void stopService ()
{
private void stopTor() {
imgStatus.setImageResource(R.drawable.torstarting);
Intent torService = new Intent(this, TorService.class);
stopService(torService);
}
// Our handler for received Intents. This will be called whenever an Intent
// with an action named "custom-event-name" is broadcasted.
private BroadcastReceiver mMessageReceiver = new BroadcastReceiver() {
/**
* The state and log info from {@link TorService} are sent to the UI here in
* the form of a local broadcast. Regular broadcasts can be sent by any app,
* so local ones are used here so other apps cannot interfere with Orbot's
* operation.
*/
private BroadcastReceiver mLocalBroadcastReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
// Get extra data included in the Intent
String action = intent.getAction();
if (action == null)
return;
if (intent.hasExtra("log"))
{
String log = intent.getStringExtra("log");
updateStatus(log);
}
else if (intent.hasExtra("up"))
{
long upload = intent.getLongExtra("up",0);
long download = intent.getLongExtra("down",0);
long written = intent.getLongExtra("written",0);
long read = intent.getLongExtra("read",0);
if (action.equals(TorServiceConstants.LOCAL_ACTION_LOG)) {
Message msg = mStatusUpdateHandler.obtainMessage(STATUS_UPDATE);
msg.obj = intent.getStringExtra(TorServiceConstants.LOCAL_EXTRA_LOG);
msg.getData().putString("status", intent.getStringExtra(TorServiceConstants.EXTRA_STATUS));
mStatusUpdateHandler.sendMessage(msg);
Message msg = mHandler.obtainMessage(TorServiceConstants.MESSAGE_TRAFFIC_COUNT);
} else if (action.equals(TorServiceConstants.LOCAL_ACTION_BANDWIDTH)) {
long upload = intent.getLongExtra("up", 0);
long download = intent.getLongExtra("down", 0);
long written = intent.getLongExtra("written", 0);
long read = intent.getLongExtra("read", 0);
Message msg = mStatusUpdateHandler.obtainMessage(MESSAGE_TRAFFIC_COUNT);
msg.getData().putLong("download", download);
msg.getData().putLong("upload", upload);
msg.getData().putLong("readTotal", read);
msg.getData().putLong("writeTotal", written);
mHandler.sendMessage(msg);
msg.getData().putString("status", intent.getStringExtra(TorServiceConstants.EXTRA_STATUS));
}
else if (intent.hasExtra("status"))
{
torStatus = intent.getIntExtra("status", TorServiceConstants.STATUS_OFF);
updateStatus("");
}
mStatusUpdateHandler.sendMessage(msg);
} else if (action.equals(TorServiceConstants.ACTION_STATUS)) {
lastStatusIntent = intent;
Message msg = mStatusUpdateHandler.obtainMessage(STATUS_UPDATE);
msg.getData().putString("status", intent.getStringExtra(TorServiceConstants.EXTRA_STATUS));
mStatusUpdateHandler.sendMessage(msg);
}
}
};
private void doLayout ()
{
setContentView(R.layout.layout_main);
@ -249,7 +246,7 @@ public class OrbotMainActivity extends Activity implements OrbotConstants, OnLon
mBtnVPN = (ToggleButton)findViewById(R.id.btnVPN);
boolean useVPN = mPrefs.getBoolean("pref_vpn", false);
boolean useVPN = Prefs.useVpn();
mBtnVPN.setChecked(useVPN);
if (useVPN)
@ -274,11 +271,7 @@ public class OrbotMainActivity extends Activity implements OrbotConstants, OnLon
mBtnBridges = (ToggleButton)findViewById(R.id.btnBridges);
boolean useBridges = mPrefs.getBoolean("pref_bridges_enabled", false);
mBtnBridges.setChecked(useBridges);
mBtnBridges.setChecked(Prefs.bridgesEnabled());
mBtnBridges.setOnClickListener(new View.OnClickListener ()
{
@ -322,39 +315,9 @@ public class OrbotMainActivity extends Activity implements OrbotConstants, OnLon
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.orbot_main, menu);
mItemOnOff = menu.getItem(0);
return true;
}
/**
private void appConflictChecker ()
{
SharedPreferences sprefs = TorServiceUtils.getSharedPrefs(getApplicationContext());
boolean showAppConflict = true;//sprefs.getBoolean("pref_show_conflict",true);
String[] badApps = {"com.sec.msc.nts.android.proxy:com.sec.msc.nts.android.proxy","com.sec.pcw:Samsung Link"};
for (String badApp : badApps)
{
String[] badAppParts = badApp.split(":");
if (appInstalledOrNot(badAppParts[0]))
{
String msg = getString(R.string.please_disable_this_app_in_android_settings_apps_if_you_are_having_problems_with_orbot_) + badAppParts[1];
if (showAppConflict)
showAlert(getString(R.string.app_conflict),msg,true);
// appendLogTextAndScroll(msg);
}
}
sprefs.edit().putBoolean("pref_show_conflict", false).commit();
}*/
private void showAbout ()
{
@ -392,7 +355,7 @@ public class OrbotMainActivity extends Activity implements OrbotConstants, OnLon
Intent intent = new Intent(OrbotMainActivity.this, SettingsPreferences.class);
startActivityForResult(intent, REQUEST_SETTINGS);
}
else if (item.getItemId() == R.id.menu_wizard)
else if (item.getItemId() == R.id.menu_promo_apps)
{
startActivity(new Intent(OrbotMainActivity.this, PromoAppsActivity.class));
@ -418,7 +381,7 @@ public class OrbotMainActivity extends Activity implements OrbotConstants, OnLon
else if (item.getItemId() == R.id.menu_share_bridge)
{
String bridges = mPrefs.getString(OrbotConstants.PREF_BRIDGES_LIST, null);
String bridges = Prefs.getBridgesList();
if (bridges != null && bridges.length() > 0)
{
@ -447,29 +410,16 @@ public class OrbotMainActivity extends Activity implements OrbotConstants, OnLon
/**
* This is our attempt to REALLY exit Orbot, and stop the background service
* However, Android doesn't like people "quitting" apps, and/or our code may not
* be quite right b/c no matter what we do, it seems like the TorService still exists
* However, Android doesn't like people "quitting" apps, and/or our code may
* not be quite right b/c no matter what we do, it seems like the TorService
* still exists
**/
private void doExit ()
{
try {
//one of the confusing things about all of this code is the multiple
//places where things like "stopTor" are called, both in the Activity and the Service
//not something to tackle in your first iteration, but i thin we can talk about fixing
//terminology but also making sure there are clear distinctions in control
private void doExit() {
stopTor();
stopService ();
} catch (RemoteException e) {
Log.w(TAG, e);
}
//Kill all the wizard activities
// Kill all the wizard activities
setResult(RESULT_CLOSE_ALL);
finish();
}
protected void onPause() {
@ -517,12 +467,10 @@ public class OrbotMainActivity extends Activity implements OrbotConstants, OnLon
if (onionHostname == null || onionHostname.length() == 0)
{
stopTor();
startTor();
requestTorRereadConfig();
new Thread () {
public void run ()
{
String onionHostname = mPrefs.getString("pref_hs_hostname","");
@ -558,7 +506,6 @@ public class OrbotMainActivity extends Activity implements OrbotConstants, OnLon
}
private synchronized void handleIntents ()
{
if (getIntent() == null)
@ -567,14 +514,14 @@ public class OrbotMainActivity extends Activity implements OrbotConstants, OnLon
// Get intent, action and MIME type
Intent intent = getIntent();
String action = intent.getAction();
Log.e(TAG, "handleIntents " + action);
Log.d(TAG, "handleIntents " + action);
String type = intent.getType();
//String type = intent.getType();
if (action == null)
return;
if (action.equals("org.torproject.android.REQUEST_HS_PORT"))
if (action.equals(INTENT_ACTION_REQUEST_HIDDEN_SERVICE))
{
final int hiddenServicePortRequest = getIntent().getIntExtra("hs_port", -1);
@ -614,25 +561,23 @@ public class OrbotMainActivity extends Activity implements OrbotConstants, OnLon
return; //don't null the setIntent() as we need it later
}
else if (action.equals("org.torproject.android.START_TOR"))
else if (action.equals(INTENT_ACTION_REQUEST_START_TOR))
{
autoStartFromIntent = true;
try {
Log.i(TAG, "action equals org.torproject.android.START_TOR");
startTor();
Intent resultIntent = new Intent(intent);
resultIntent.putExtra("socks_proxy", "socks://127.0.0.1:" + TorServiceConstants.PORT_SOCKS_DEFAULT);
resultIntent.putExtra("socks_proxy_host", "127.0.0.1");
resultIntent.putExtra("socks_proxy_port", TorServiceConstants.PORT_SOCKS_DEFAULT);
resultIntent.putExtra("http_proxy", "http://127.0.0.1" + TorServiceConstants.PORT_HTTP);
resultIntent.putExtra("http_proxy_host", "127.0.0.1");
resultIntent.putExtra("http_proxy_port", TorServiceConstants.PORT_HTTP);
if (Prefs.allowBackgroundStarts())
{
Intent resultIntent;
if (lastStatusIntent == null) {
resultIntent = new Intent(intent);
} else {
resultIntent = lastStatusIntent;
}
resultIntent.putExtra(TorServiceConstants.EXTRA_STATUS, torStatus);
setResult(RESULT_OK, resultIntent);
finish();
} catch (RemoteException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
@ -653,28 +598,8 @@ public class OrbotMainActivity extends Activity implements OrbotConstants, OnLon
}
}
}
else
{
showWizard = mPrefs.getBoolean("show_wizard",showWizard);
//let's not show the wizard now for new users
if (showWizard)
{
Editor pEdit = mPrefs.edit();
pEdit.putBoolean("show_wizard",false);
pEdit.commit();
showWizard = false;
showAlert(getString(R.string.app_name),getString(R.string.wizard_final_msg),true);
}
}
updateStatus("");
updateStatus(null);
setIntent(null);
@ -686,12 +611,8 @@ public class OrbotMainActivity extends Activity implements OrbotConstants, OnLon
showAlert(getString(R.string.bridges_updated),getString(R.string.restart_orbot_to_use_this_bridge_) + newBridgeValue,false);
Editor pEdit = mPrefs.edit();
pEdit.putString(OrbotConstants.PREF_BRIDGES_LIST,newBridgeValue); //set the string to a preference
pEdit.putBoolean(OrbotConstants.PREF_BRIDGES_ENABLED,true);
pEdit.commit();
Prefs.setBridgesList(newBridgeValue); //set the string to a preference
Prefs.putBridgesEnabled(true);
setResult(RESULT_OK);
@ -700,25 +621,12 @@ public class OrbotMainActivity extends Activity implements OrbotConstants, OnLon
enableBridges(true);
}
private boolean showWizard = true;
@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
// doLayout();
//updateStatus("");
}
/*
* Launch the system activity for Uri viewing with the provided url
*/
private void openBrowser(final String browserLaunchUrl,boolean forceExternal)
{
boolean isOrwebInstalled = appInstalledOrNot("info.guardianproject.browser");
boolean isTransProxy = mPrefs.getBoolean("pref_transparent", false);
if (mBtnVPN.isChecked()||forceExternal)
{
@ -727,7 +635,7 @@ public class OrbotMainActivity extends Activity implements OrbotConstants, OnLon
intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP|Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
}
else if (isTransProxy)
else if (Prefs.useTransparentProxying())
{
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(browserLaunchUrl));
intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP|Intent.FLAG_ACTIVITY_NEW_TASK);
@ -836,18 +744,14 @@ public class OrbotMainActivity extends Activity implements OrbotConstants, OnLon
}
else if (torStatus == TorServiceConstants.STATUS_ON)
{
updateSettings();
updateTransProxy();
Toast.makeText(this, R.string.you_may_need_to_stop_and_start_orbot_for_settings_change_to_be_enabled_, Toast.LENGTH_SHORT).show();
}
}
else if (request == REQUEST_VPN && response == RESULT_OK)
{
startService(TorServiceConstants.CMD_VPN);
// if (torStatus == TorServiceConstants.STATUS_ON)
// restartTor ();
sendIntentToService(TorServiceConstants.CMD_VPN);
}
IntentResult scanResult = IntentIntegrator.parseActivityResult(request, response, data);
@ -910,17 +814,17 @@ public class OrbotMainActivity extends Activity implements OrbotConstants, OnLon
break;
case 3: //azure
mPrefs.edit().putString(OrbotConstants.PREF_BRIDGES_LIST,"2").commit();
Prefs.setBridgesList("2");
enableBridges(true);
break;
case 4: //amazon
mPrefs.edit().putString(OrbotConstants.PREF_BRIDGES_LIST,"1").commit();
Prefs.setBridgesList("1");
enableBridges(true);
break;
case 5: //google
mPrefs.edit().putString(OrbotConstants.PREF_BRIDGES_LIST,"0").commit();
Prefs.setBridgesList("0");
enableBridges(true);
break;
@ -1017,52 +921,20 @@ public class OrbotMainActivity extends Activity implements OrbotConstants, OnLon
private void enableBridges (boolean enable)
{
Editor edit = mPrefs.edit();
edit.putBoolean(OrbotConstants.PREF_BRIDGES_ENABLED, enable);
edit.commit();
updateSettings();
Prefs.putBridgesEnabled(enable);
if (torStatus == TorServiceConstants.STATUS_ON)
{
String bridgeList = mPrefs.getString(OrbotConstants.PREF_BRIDGES_LIST,null);
String bridgeList = Prefs.getBridgesList();
if (bridgeList != null && bridgeList.length() > 0)
{
restartTor ();
requestTorRereadConfig ();
}
}
}
}
}
private void restartTor ()
{
try
{
//do auto restart
stopTor ();
mHandler.postDelayed(new Runnable () {
public void run ()
{
try
{
startTor();
}
catch (Exception e)
{
Log.e(TAG,"can't start orbot",e);
}
}
}, 2000);
}
catch (Exception e)
{
Log.e(TAG,"can't stop orbot",e);
}
private void requestTorRereadConfig() {
sendIntentToService(TorServiceConstants.CMD_SIGNAL_HUP);
}
public void promptStartVpnService ()
@ -1081,11 +953,8 @@ public class OrbotMainActivity extends Activity implements OrbotConstants, OnLon
@Override
public void onClick(DialogInterface dialog, int which) {
mPrefs.edit().putBoolean("pref_vpn", true).commit();
Prefs.putUseVpn(true);
startVpnService();
}
@ -1097,10 +966,8 @@ public class OrbotMainActivity extends Activity implements OrbotConstants, OnLon
public void onClick(DialogInterface dialog, int which) {
mBtnVPN.setChecked(false);
}
})
.show();
}
@ -1114,29 +981,24 @@ public class OrbotMainActivity extends Activity implements OrbotConstants, OnLon
}
else
{
startService(TorServiceConstants.CMD_VPN);
// if (torStatus == TorServiceConstants.STATUS_ON)
// restartTor ();
sendIntentToService(TorServiceConstants.CMD_VPN);
}
}
public void stopVpnService ()
{
startService(TorServiceConstants.CMD_VPN_CLEAR);
// restartTor ();
sendIntentToService(TorServiceConstants.CMD_VPN_CLEAR);
}
private boolean flushTransProxy ()
{
startService(TorServiceConstants.CMD_FLUSH);
sendIntentToService(TorServiceConstants.CMD_FLUSH);
return true;
}
private boolean updateSettings ()
private boolean updateTransProxy ()
{
//todo send service command
startService(TorServiceConstants.CMD_UPDATE);
sendIntentToService(TorServiceConstants.CMD_UPDATE_TRANS_PROXY);
return true;
}
@ -1146,24 +1008,13 @@ public class OrbotMainActivity extends Activity implements OrbotConstants, OnLon
if (mPrefs != null)
{
boolean useVPN = mPrefs.getBoolean("pref_vpn", false);
mBtnVPN.setChecked(useVPN);
boolean useBridges = mPrefs.getBoolean("pref_bridges_enabled", false);
mBtnBridges.setChecked(useBridges);
mBtnVPN.setChecked(Prefs.useVpn());
mBtnBridges.setChecked(Prefs.bridgesEnabled());
}
mHandler.postDelayed(new Runnable ()
{
public void run ()
{
handleIntents();
}
}
, 500);
requestTorStatus();
updateStatus(null);
}
@ -1203,75 +1054,81 @@ public class OrbotMainActivity extends Activity implements OrbotConstants, OnLon
aDialog.setCanceledOnTouchOutside(true);
}
private void updateStatus (String torServiceMsg)
{
/**
* Update the layout_main UI based on the status of {@link TorService}.
* {@code torServiceMsg} must never be {@code null}
*/
private void updateStatus(String torServiceMsg) {
//now update the layout_main UI based on the status
if (imgStatus != null)
{
if (torStatus == null)
return; //UI not init'd yet
if (torStatus == TorServiceConstants.STATUS_ON)
{
if (torStatus == TorServiceConstants.STATUS_ON) {
imgStatus.setImageResource(R.drawable.toron);
mBtnBrowser.setEnabled(true);
if (mItemOnOff != null)
mItemOnOff.setTitle(R.string.menu_stop);
if (lblStatus != null && torServiceMsg != null)
if (torServiceMsg.indexOf('%')!=-1)
if (torServiceMsg != null)
{
if (torServiceMsg.contains(TorServiceConstants.LOG_NOTICE_HEADER))
lblStatus.setText(torServiceMsg);
}
else
lblStatus.setText("");
lblStatus.setText(getString(R.string.status_activated));
boolean showFirstTime = mPrefs.getBoolean("connect_first_time",true);
boolean showFirstTime = mPrefs.getBoolean("connect_first_time", true);
if (showFirstTime)
{
Editor pEdit = mPrefs.edit();
pEdit.putBoolean("connect_first_time",false);
pEdit.putBoolean("connect_first_time", false);
pEdit.commit();
showAlert(getString(R.string.status_activated),getString(R.string.connect_first_time),true);
showAlert(getString(R.string.status_activated),
getString(R.string.connect_first_time), true);
}
if (autoStartFromIntent)
{
autoStartFromIntent = false;
Intent resultIntent = lastStatusIntent;
resultIntent.putExtra(TorServiceConstants.EXTRA_STATUS, torStatus);
setResult(RESULT_OK, resultIntent);
finish();
Log.e(TAG, "autoStartFromIntent finish");
Log.d(TAG, "autoStartFromIntent finish");
}
}
else if (torStatus == TorServiceConstants.STATUS_CONNECTING)
{
} else if (torStatus == TorServiceConstants.STATUS_STARTING) {
imgStatus.setImageResource(R.drawable.torstarting);
if (mItemOnOff != null)
mItemOnOff.setTitle(R.string.menu_stop);
if (torServiceMsg != null)
{
if (torServiceMsg.contains(TorServiceConstants.LOG_NOTICE_BOOTSTRAPPED))
lblStatus.setText(torServiceMsg);
}
else
lblStatus.setText(getString(R.string.status_starting_up));
if (lblStatus != null && torServiceMsg != null)
if (torServiceMsg.indexOf('%')!=-1)
mBtnBrowser.setEnabled(false);
} else if (torStatus == TorServiceConstants.STATUS_STOPPING) {
if (torServiceMsg != null && torServiceMsg.contains(TorServiceConstants.LOG_NOTICE_HEADER))
lblStatus.setText(torServiceMsg);
imgStatus.setImageResource(R.drawable.torstarting);
lblStatus.setText(torServiceMsg);
mBtnBrowser.setEnabled(false);
} else if (torStatus == TorServiceConstants.STATUS_OFF) {
}
else if (torStatus == TorServiceConstants.STATUS_OFF)
{
imgStatus.setImageResource(R.drawable.toroff);
lblStatus.setText(getString(R.string.press_to_start));
mBtnBrowser.setEnabled(false);
if (mItemOnOff != null)
mItemOnOff.setTitle(R.string.menu_start);
}
if (torServiceMsg != null && torServiceMsg.length() > 0)
@ -1280,119 +1137,70 @@ public class OrbotMainActivity extends Activity implements OrbotConstants, OnLon
}
}
}
// guess what? this start's Tor! actually no it just requests via the local ITorService to the remote TorService instance
// to start Tor
private void startTor () throws RemoteException
{
startService (TorServiceConstants.CMD_START);
torStatus = TorServiceConstants.STATUS_CONNECTING;
mTxtOrbotLog.setText("");
//here we update the UI which is a bit sloppy and mixed up code wise
//might be best to just call updateStatus() instead of directly manipulating UI in this method - yep makes sense
imgStatus.setImageResource(R.drawable.torstarting);
lblStatus.setText(getString(R.string.status_starting_up));
//we send a message here to the progressDialog i believe, but we can clarify that shortly
Message msg = mHandler.obtainMessage(TorServiceConstants.ENABLE_TOR_MSG);
msg.getData().putString(HANDLER_TOR_MSG, getString(R.string.status_starting_up));
mHandler.sendMessage(msg);
}
//now we stop Tor! amazing!
private void stopTor () throws RemoteException
{
startService (TorServiceConstants.CMD_STOP);
torStatus = TorServiceConstants.STATUS_OFF;
Message msg = mHandler.obtainMessage(TorServiceConstants.DISABLE_TOR_MSG);
mHandler.sendMessage(msg);
}
/*
* (non-Javadoc)
* @see android.view.View.OnClickListener#onClick(android.view.View)
/**
* Starts tor and related daemons by sending an
* {@link TorServiceConstants#ACTION_START} {@link Intent} to
* {@link TorService}
*/
private void startTor() {
sendIntentToService(TorServiceConstants.ACTION_START);
}
/**
* Request tor status without starting it
* {@link TorServiceConstants#ACTION_START} {@link Intent} to
* {@link TorService}
*/
private void requestTorStatus() {
sendIntentToService(TorServiceConstants.ACTION_STATUS);
}
public boolean onLongClick(View view) {
try
{
if (torStatus == TorServiceConstants.STATUS_OFF)
{
if (torStatus == TorServiceConstants.STATUS_OFF) {
lblStatus.setText(getString(R.string.status_starting_up));
startTor();
}
else
{
} else {
lblStatus.setText(getString(R.string.status_shutting_down));
stopTor();
stopService ();
}
return true;
}
catch (Exception e)
{
Log.d(TAG,"error onclick",e);
}
return false;
}
// this is what takes messages or values from the callback threads or other non-mainUI threads
//and passes them back into the main UI thread for display to the user
private Handler mHandler = new Handler() {
private Handler mStatusUpdateHandler = new Handler() {
private String lastServiceMsg = null;
@Override
public void handleMessage(final Message msg) {
public void handleMessage(Message msg) {
switch (msg.what) {
case TorServiceConstants.STATUS_MSG:
case TorServiceConstants.LOG_MSG:
String newTorStatus = msg.getData().getString("status");
String log = (String)msg.obj;
String torServiceMsg = (String)msg.getData().getString(HANDLER_TOR_MSG);
if (lastServiceMsg == null || !lastServiceMsg.equals(torServiceMsg))
if (torStatus == null && newTorStatus != null) //first time status
{
updateStatus(torServiceMsg);
torStatus = newTorStatus;
findViewById(R.id.pbConnecting).setVisibility(View.GONE);
findViewById(R.id.frameMain).setVisibility(View.VISIBLE);
updateStatus(log);
//now you can handle the intents properly
handleIntents();
lastServiceMsg = torServiceMsg;
}
else if (newTorStatus != null && !torStatus.equals(newTorStatus)) //status changed
{
torStatus = newTorStatus;
updateStatus(log);
}
else if (log != null) //it is just a log
updateStatus(log);
break;
case TorServiceConstants.ENABLE_TOR_MSG:
updateStatus((String)msg.getData().getString(HANDLER_TOR_MSG));
break;
case TorServiceConstants.DISABLE_TOR_MSG:
updateStatus((String)msg.getData().getString(HANDLER_TOR_MSG));
break;
case TorServiceConstants.MESSAGE_TRAFFIC_COUNT :
switch (msg.what) {
case MESSAGE_TRAFFIC_COUNT:
Bundle data = msg.getData();
DataCount datacount = new DataCount(data.getLong("upload"),data.getLong("download"));
@ -1403,24 +1211,17 @@ public class OrbotMainActivity extends Activity implements OrbotConstants, OnLon
downloadText.setText(formatCount(datacount.Download) + " / " + formatTotal(totalRead));
uploadText.setText(formatCount(datacount.Upload) + " / " + formatTotal(totalWrite));
if (torStatus != TorServiceConstants.STATUS_ON)
{
updateStatus("");
}
break;
default:
super.handleMessage(msg);
}
}
};
@Override
protected void onDestroy() {
super.onDestroy();
LocalBroadcastManager.getInstance(this).unregisterReceiver(mMessageReceiver);
LocalBroadcastManager.getInstance(this).unregisterReceiver(mLocalBroadcastReceiver);
}
@ -1462,13 +1263,6 @@ public class OrbotMainActivity extends Activity implements OrbotConstants, OnLon
return numberFormat.format(Math
.round(((float) ((int) (count * 100 / 1024 / 1024)) / 100)))
+ getString(R.string.mb);
}
@Override
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences,
String key) {
}
private static final float ROTATE_FROM = 0.0f;
@ -1476,7 +1270,7 @@ public class OrbotMainActivity extends Activity implements OrbotConstants, OnLon
public void spinOrbot (float direction)
{
startService (TorServiceConstants.CMD_NEWNYM);
sendIntentToService (TorServiceConstants.CMD_NEWNYM);
Toast.makeText(this, R.string.newnym, Toast.LENGTH_SHORT).show();

View File

@ -0,0 +1,121 @@
package org.torproject.android;
import android.content.Context;
import android.content.SharedPreferences;
import org.torproject.android.service.TorServiceUtils;
import java.util.Locale;
public class Prefs {
private final static String PREF_BRIDGES_ENABLED = "pref_bridges_enabled";
private final static String PREF_BRIDGES_LIST = "pref_bridges_list";
private final static String PREF_DEFAULT_LOCALE = "pref_default_locale";
private final static String PREF_ENABLE_LOGGING = "pref_enable_logging";
private final static String PREF_EXPANDED_NOTIFICATIONS = "pref_expanded_notifications";
private final static String PREF_HAS_ROOT = "has_root";
private final static String PREF_PERSIST_NOTIFICATIONS = "pref_persistent_notifications";
private final static String PREF_START_ON_BOOT = "pref_start_boot";
private final static String PREF_ALLOW_BACKGROUND_STARTS = "pref_allow_background_starts";
private final static String PREF_TRANSPARENT = "pref_transparent";
private final static String PREF_TRANSPARENT_ALL = "pref_transparent_all";
private final static String PREF_TRANSPARENT_TETHERING = "pref_transparent_tethering";
private final static String PREF_TRANSPROXY_REFRESH = "pref_transproxy_refresh";
private final static String PREF_USE_SYSTEM_IPTABLES = "pref_use_sys_iptables";
private final static String PREF_USE_VPN = "pref_vpn";
private static SharedPreferences prefs;
public static void setContext(Context context) {
if (prefs == null)
prefs = TorServiceUtils.getSharedPrefs(context);
}
private static void putBoolean(String key, boolean value) {
prefs.edit().putBoolean(key, value).apply();
}
private static void putString(String key, String value) {
prefs.edit().putString(key, value).apply();
}
public static boolean bridgesEnabled() {
return prefs.getBoolean(PREF_BRIDGES_ENABLED, false);
}
public static void putBridgesEnabled(boolean value) {
putBoolean(PREF_BRIDGES_ENABLED, value);
}
public static String getBridgesList() {
return prefs.getString(PREF_BRIDGES_LIST, "");
}
public static void setBridgesList(String value) {
putString(PREF_BRIDGES_LIST, value);
}
public static String getDefaultLocale() {
return prefs.getString(PREF_DEFAULT_LOCALE, Locale.getDefault().getLanguage());
}
public static void setDefaultLocale(String value) {
putString(PREF_DEFAULT_LOCALE, value);
}
public static boolean useSystemIpTables() {
return prefs.getBoolean(PREF_USE_SYSTEM_IPTABLES, false);
}
public static boolean useRoot() {
return prefs.getBoolean(PREF_HAS_ROOT, false);
}
public static boolean useTransparentProxying() {
return prefs.getBoolean(PREF_TRANSPARENT, false);
}
public static boolean transparentProxyAll() {
return prefs.getBoolean(PREF_TRANSPARENT_ALL, false);
}
public static boolean transparentTethering() {
return prefs.getBoolean(PREF_TRANSPARENT_TETHERING, false);
}
public static boolean transProxyNetworkRefresh() {
return prefs.getBoolean(PREF_TRANSPROXY_REFRESH, false);
}
public static boolean expandedNotifications() {
return prefs.getBoolean(PREF_EXPANDED_NOTIFICATIONS, false);
}
public static boolean useDebugLogging() {
return prefs.getBoolean(PREF_ENABLE_LOGGING, false);
}
public static boolean persistNotifications() {
return prefs.getBoolean(PREF_PERSIST_NOTIFICATIONS, true);
}
public static boolean allowBackgroundStarts() {
return prefs.getBoolean(PREF_ALLOW_BACKGROUND_STARTS, true);
}
public static boolean useVpn() {
return prefs.getBoolean(PREF_USE_VPN, false);
}
public static void putUseVpn(boolean value) {
putBoolean(PREF_USE_VPN, value);
}
public static boolean startOnBoot() {
return prefs.getBoolean(PREF_START_ON_BOOT, true);
}
public static void putStartOnBoot(boolean value) {
putBoolean(PREF_START_ON_BOOT, value);
}
}

View File

@ -5,30 +5,22 @@ import android.annotation.SuppressLint;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.net.VpnService;
import org.torproject.android.Prefs;
public class OnBootReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
SharedPreferences prefs = TorServiceUtils.getSharedPrefs(context.getApplicationContext());
boolean startOnBoot = prefs.getBoolean("pref_start_boot",true);
boolean useVPN = prefs.getBoolean("pref_vpn",true);
if (startOnBoot)
Prefs.setContext(context);
if (Prefs.startOnBoot())
{
startService(TorServiceConstants.ACTION_START, context);
startService(TorServiceConstants.CMD_INIT,context);
startService(TorServiceConstants.CMD_START,context);
if (useVPN)
if (Prefs.useVpn())
startVpnService(context);
}
}
@SuppressLint("NewApi")

View File

@ -0,0 +1,36 @@
package org.torproject.android.service;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.text.TextUtils;
import org.torproject.android.Prefs;
public class StartTorReceiver extends BroadcastReceiver implements TorServiceConstants {
@Override
public void onReceive(Context context, Intent intent) {
/* sanitize the Intent before forwarding it to TorService */
Prefs.setContext(context);
String action = intent.getAction();
if (TextUtils.equals(action, ACTION_START)) {
String packageName = intent.getStringExtra(EXTRA_PACKAGE_NAME);
if (Prefs.allowBackgroundStarts()) {
Intent startTorIntent = new Intent(context, TorService.class);
startTorIntent.setAction(action);
if (packageName != null)
startTorIntent.putExtra(EXTRA_PACKAGE_NAME, packageName);
context.startService(startTorIntent);
} else if (!TextUtils.isEmpty(packageName)) {
// let the requesting app know that the user has disabled
// starting via Intent
Intent startsDisabledIntent = new Intent(ACTION_STATUS);
startsDisabledIntent.putExtra(EXTRA_STATUS, STATUS_STARTS_DISABLED);
startsDisabledIntent.setPackage(packageName);
context.sendBroadcast(startsDisabledIntent);
}
}
}
}

View File

@ -8,12 +8,10 @@ import java.io.DataOutputStream;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintStream;
import java.io.PrintWriter;
import java.io.StringBufferInputStream;
import java.util.ArrayList;
import java.util.concurrent.TimeoutException;
@ -96,11 +94,13 @@ public class TorResourceInstaller implements TorServiceConstants {
outFile = new File(installFolder, OBFSCLIENT_ASSET_KEY);
shell.add(new SimpleCommand(COMMAND_RM_FORCE + outFile.getAbsolutePath())).waitForFinish();
streamToFile(is,outFile, false, true);
setExecutable(outFile);
is = context.getResources().openRawResource(R.raw.meek);
outFile = new File(installFolder, MEEK_ASSET_KEY);
shell.add(new SimpleCommand(COMMAND_RM_FORCE + outFile.getAbsolutePath())).waitForFinish();
streamToFile(is,outFile, false, true);
setExecutable(outFile);
cpuPath = "armeabi";
}
@ -111,17 +111,19 @@ public class TorResourceInstaller implements TorServiceConstants {
outFile = new File(installFolder, TOR_ASSET_KEY);
shell.add(new SimpleCommand(COMMAND_RM_FORCE + outFile.getAbsolutePath())).waitForFinish();
streamToFile(is,outFile, false, true);
setExecutable(outFile);
is = context.getAssets().open(cpuPath + "/polipo.mp3");
outFile = new File(installFolder, POLIPO_ASSET_KEY);
shell.add(new SimpleCommand(COMMAND_RM_FORCE + outFile.getAbsolutePath())).waitForFinish();
streamToFile(is,outFile, false, true);
setExecutable(outFile);
is = context.getAssets().open(cpuPath + "/xtables.mp3");
outFile = new File(installFolder, IPTABLES_ASSET_KEY);
shell.add(new SimpleCommand(COMMAND_RM_FORCE + outFile.getAbsolutePath())).waitForFinish();
streamToFile(is,outFile, false, true);
setExecutable(outFile);
return true;
}
@ -359,4 +361,11 @@ public class TorResourceInstaller implements TorServiceConstants {
}*/
private void setExecutable(File fileBin) {
fileBin.setReadable(true);
fileBin.setExecutable(true);
fileBin.setWritable(false);
fileBin.setWritable(true, true);
}
}

File diff suppressed because it is too large Load Diff

View File

@ -1,7 +1,10 @@
/* Copyright (c) 2009, Nathan Freitas, Orbot / The Guardian Project - http://openideals.com/guardian */
/* See LICENSE for licensing information */
package org.torproject.android.service;
import android.content.Intent;
public interface TorServiceConstants {
public final static String TOR_APP_USERNAME = "org.torproject.android";
@ -47,44 +50,82 @@ public interface TorServiceConstants {
public final static int FILE_WRITE_BUFFER_SIZE = 1024;
//HTTP Proxy server port
public static int PORT_HTTP = 8118; //just like Privoxy!
//Socks port client connects to, server is the Tor binary
public static String PORT_SOCKS_DEFAULT = "9050";
//what is says!
public final static String IP_LOCALHOST = "127.0.0.1";
public final static int UPDATE_TIMEOUT = 1000;
public final static int TOR_TRANSPROXY_PORT_DEFAULT = 9040;
public final static int STANDARD_DNS_PORT = 53;
public final static int TOR_DNS_PORT_DEFAULT = 5400;
public final static int CONTROL_PORT_DEFAULT = 9051;
public final static int HTTP_PROXY_PORT_DEFAULT = 8118; // like Privoxy!
public final static int SOCKS_PROXY_PORT_DEFAULT = 9050;
//path to check Tor against
public final static String URL_TOR_CHECK = "https://check.torproject.org";
//control port
public final static String TOR_CONTROL_PORT_MSG_BOOTSTRAP_DONE = "Bootstrapped 100%";
public final static String LOG_NOTICE_HEADER = "NOTICE";
public final static String LOG_NOTICE_BOOTSTRAPPED = "Bootstrapped";
public final static int STATUS_OFF = 0;
public final static int STATUS_ON = 1;
public final static int STATUS_CONNECTING = 2;
/**
* A request to Orbot to transparently start Tor services
*/
public final static String ACTION_START = "org.torproject.android.intent.action.START";
/**
* {@link Intent} send by Orbot with {@code ON/OFF/STARTING/STOPPING} status
*/
public final static String ACTION_STATUS = "org.torproject.android.intent.action.STATUS";
/**
* {@code String} that contains a status constant: {@link #STATUS_ON},
* {@link #STATUS_OFF}, {@link #STATUS_STARTING}, or
* {@link #STATUS_STOPPING}
*/
public final static String EXTRA_STATUS = "org.torproject.android.intent.extra.STATUS";
/**
* A {@link String} {@code packageName} for Orbot to direct its status reply
* to, used in {@link #ACTION_START} {@link Intent}s sent to Orbot
*/
public final static String EXTRA_PACKAGE_NAME = "org.torproject.android.intent.extra.PACKAGE_NAME";
/**
* The SOCKS proxy settings in URL form.
*/
public final static String EXTRA_SOCKS_PROXY = "org.torproject.android.intent.extra.SOCKS_PROXY";
public final static String EXTRA_SOCKS_PROXY_HOST = "org.torproject.android.intent.extra.SOCKS_PROXY_HOST";
public final static String EXTRA_SOCKS_PROXY_PORT = "org.torproject.android.intent.extra.SOCKS_PROXY_PORT";
/**
* The HTTP proxy settings in URL form.
*/
public final static String EXTRA_HTTP_PROXY = "org.torproject.android.intent.extra.HTTP_PROXY";
public final static String EXTRA_HTTP_PROXY_HOST = "org.torproject.android.intent.extra.HTTP_PROXY_HOST";
public final static String EXTRA_HTTP_PROXY_PORT = "org.torproject.android.intent.extra.HTTP_PROXY_PORT";
public static final int STATUS_MSG = 1;
public static final int ENABLE_TOR_MSG = 2;
public static final int DISABLE_TOR_MSG = 3;
public static final int LOG_MSG = 4;
public final static String LOCAL_ACTION_LOG = "log";
public final static String LOCAL_ACTION_BANDWIDTH = "bandwidth";
public final static String LOCAL_EXTRA_LOG = "log";
public static final String CMD_START = "start";
public static final String CMD_STOP = "stop";
/**
* All tor-related services and daemons are stopped
*/
public final static String STATUS_OFF = "OFF";
/**
* All tor-related services and daemons have completed starting
*/
public final static String STATUS_ON = "ON";
public final static String STATUS_STARTING = "STARTING";
public final static String STATUS_STOPPING = "STOPPING";
/**
* The user has disabled the ability for background starts triggered by
* apps. Fallback to the old Intent that brings up Orbot.
*/
public final static String STATUS_STARTS_DISABLED = "STARTS_DISABLED";
// actions for internal command Intents
public static final String CMD_SIGNAL_HUP = "signal_hup";
public static final String CMD_FLUSH = "flush";
public static final String CMD_NEWNYM = "newnym";
public static final String CMD_INIT = "init";
public static final String CMD_VPN = "vpn";
public static final String CMD_VPN_CLEAR = "vpnclear";
public static final String CMD_UPDATE = "update";
public static final String CMD_UPDATE_TRANS_PROXY = "update";
public static final String BINARY_TOR_VERSION = "0.2.6.7";
public static final String PREF_BINARY_TOR_VERSION_INSTALLED = "BINARY_TOR_VERSION_INSTALLED";
@ -93,15 +134,7 @@ public interface TorServiceConstants {
public static final String OBFSCLIENT_ASSET_KEY = "obfs4proxy";
public static final String MEEK_ASSET_KEY = "meek-client";
public static final int MESSAGE_TRAFFIC_COUNT = 5;
//name of the iptables binary
public final static String IPTABLES_ASSET_KEY = "xtables";
public final static int DEFAULT_CONTROL_PORT = 9051;
}

View File

@ -3,20 +3,17 @@ package org.torproject.android.service;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.concurrent.TimeoutException;
import org.sufficientlysecure.rootcommands.Shell;
import org.sufficientlysecure.rootcommands.command.SimpleCommand;
import org.torproject.android.OrbotConstants;
import org.torproject.android.Prefs;
import org.torproject.android.settings.TorifiedApp;
import android.content.Context;
import android.content.SharedPreferences;
import android.util.Log;
public class TorTransProxy implements TorServiceConstants {
private boolean useSystemIpTables = false;
private String mSysIptables = null;
private TorService mTorService = null;
private File mFileXtables = null;
@ -47,11 +44,7 @@ public class TorTransProxy implements TorServiceConstants {
String ipTablesPath = null;
SharedPreferences prefs = TorServiceUtils.getSharedPrefs(context);
useSystemIpTables = prefs.getBoolean(OrbotConstants.PREF_USE_SYSTEM_IPTABLES, false);
if (useSystemIpTables)
if (Prefs.useSystemIpTables())
{
ipTablesPath = findSystemIPTables();
}
@ -70,11 +63,7 @@ public class TorTransProxy implements TorServiceConstants {
String ipTablesPath = null;
SharedPreferences prefs = TorServiceUtils.getSharedPrefs(context);
useSystemIpTables = prefs.getBoolean(OrbotConstants.PREF_USE_SYSTEM_IPTABLES, false);
if (useSystemIpTables)
if (Prefs.useSystemIpTables())
{
ipTablesPath = findSystemIP6Tables();
}
@ -335,7 +324,7 @@ public class TorTransProxy implements TorServiceConstants {
return code;
}*/
public int setTransparentProxyingByApp(Context context, ArrayList<TorifiedApp> apps, boolean enableRule, Shell shell) throws Exception
public int setTransparentProxyingByApp(Context context, ArrayList<TorifiedApp> apps, boolean enableRule, Shell shell)
{
String ipTablesPath = getIpTablesPath(context);
@ -439,10 +428,13 @@ public class TorTransProxy implements TorServiceConstants {
return lastExit;
}
private int executeCommand (Shell shell, String cmdString) throws IOException, TimeoutException
{
private int executeCommand (Shell shell, String cmdString) {
SimpleCommand cmd = new SimpleCommand(cmdString);
try {
shell.add(cmd);
} catch (IOException e) {
e.printStackTrace();
}
int exitCode = cmd.getExitCode();
String output = cmd.getOutput();
@ -524,8 +516,7 @@ public class TorTransProxy implements TorServiceConstants {
}
public int dropAllIPv6Traffic (Context context, int appUid, boolean enableDrop, Shell shell) throws Exception
{
public int dropAllIPv6Traffic (Context context, int appUid, boolean enableDrop, Shell shell) {
String action = " -A ";
String chain = "OUTPUT";
@ -575,8 +566,7 @@ public class TorTransProxy implements TorServiceConstants {
return lastExit;
}*/
public int flushTransproxyRules (Context context) throws Exception
{
public int flushTransproxyRules (Context context) throws IOException {
int exit = -1;
String ipTablesPath = getIpTablesPath(context);
@ -676,7 +666,7 @@ public class TorTransProxy implements TorServiceConstants {
script = new StringBuilder();
if (TorService.ENABLE_DEBUG_LOG)
if (Prefs.useDebugLogging())
{
//XXX: Comment the following rules for non-debug builds
script.append(ipTablesPath);

View File

@ -1,75 +0,0 @@
/* Copyright (c) 2009, Nathan Freitas, Orbot / The Guardian Project - https://guardianproject.info */
/* See LICENSE for licensing information */
package org.torproject.android.ui;
import org.torproject.android.OrbotConstants;
import android.app.Activity;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Bundle;
import android.support.v4.content.LocalBroadcastManager;
public class OrbotLogActivity extends Activity implements OrbotConstants
{
/** Called when the activity is first created. */
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
doLayout();
LocalBroadcastManager.getInstance(this).registerReceiver(mMessageReceiver,
new IntentFilter("log"));
}
// Our handler for received Intents. This will be called whenever an Intent
// with an action named "custom-event-name" is broadcasted.
private BroadcastReceiver mMessageReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
// Get extra data included in the Intent
if (intent.hasExtra("log"))
{
String log = intent.getStringExtra("log");
updateStatus(log);
}
}
};
private void doLayout ()
{
}
private void updateStatus(String log)
{
}
@Override
protected void onDestroy() {
super.onDestroy();
LocalBroadcastManager.getInstance(this).unregisterReceiver(mMessageReceiver);
}
}

View File

@ -1,4 +1,4 @@
package org.torproject.android.ui.wizard;
package org.torproject.android.ui;
import android.app.Activity;
import android.content.Intent;
@ -10,14 +10,12 @@ import android.net.Uri;
import android.os.Bundle;
import android.text.TextUtils;
import android.util.Log;
import android.view.KeyEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import org.torproject.android.OrbotConstants;
import org.torproject.android.R;
import java.util.List;
public class PromoAppsActivity extends Activity implements OrbotConstants {
@ -42,7 +40,7 @@ public class PromoAppsActivity extends Activity implements OrbotConstants {
protected void onStart() {
super.onStart();
setContentView(R.layout.layout_wizard_tips);
setContentView(R.layout.layout_promo_apps);
stepFive();
@ -169,43 +167,16 @@ public class PromoAppsActivity extends Activity implements OrbotConstants {
}
});
// Button back = ((Button)findViewById(R.id.btnWizard1));
Button next = ((Button)findViewById(R.id.btnWizard2));
/*
back.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
finish();
startActivityForResult(new Intent(PromoAppsActivity.this, ChooseLocaleWizardActivity.class), 1);
}
});*/
next.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
//showWizardFinal();
finish();
}
});
}
//Code to override the back button!
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if(keyCode == KeyEvent.KEYCODE_BACK){
finish();
startActivity(new Intent(getBaseContext(), ChooseLocaleWizardActivity.class));
return true;
}
return false;
}
boolean isAppInstalled(PackageManager pm, String packageName) {
try {
pm.getPackageInfo(packageName, PackageManager.GET_ACTIVITIES);
@ -239,32 +210,4 @@ public class PromoAppsActivity extends Activity implements OrbotConstants {
}
return intent;
}
/*
private void showWizardFinal ()
{
String title = null;
String msg = null;
title = context.getString(R.string.wizard_final);
msg = context.getString(R.string.wizard_final_msg);
DialogInterface.OnClickListener ocListener = new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
context.startActivity(new Intent(context, Orbot.class));
}
};
new AlertDialog.Builder(context)
.setIcon(R.drawable.icon)
.setTitle(title)
.setPositiveButton(R.string.button_close, ocListener)
.setMessage(msg)
.show();
}*/
}

View File

@ -1,108 +0,0 @@
package org.torproject.android.ui.wizard;
import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.content.res.Configuration;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.ListView;
import android.widget.Toast;
import info.guardianproject.util.Languages;
import org.torproject.android.OrbotApp;
import org.torproject.android.OrbotConstants;
import org.torproject.android.R;
import org.torproject.android.service.TorServiceUtils;
import java.util.Locale;
public class ChooseLocaleWizardActivity extends Activity implements OrbotConstants {
private ListView listLocales;
private String[] localeValues;
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.layout_wizard_locale);
listLocales = (ListView)findViewById(R.id.wizard_locale_list);
Button next = ((Button)findViewById(R.id.btnWizard2));
// next.setEnabled(false);
Languages languages = OrbotApp.getLanguages(this);
localeValues = languages.getSupportedLocales();
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
android.R.layout.simple_list_item_1, android.R.id.text1,
languages.getAllNames());
listLocales.setAdapter(adapter);
listLocales.setSelection(0);
listLocales.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> arg0, View arg1,
int arg2, long arg3) {
setLocalePref(arg2);
finish();
startActivity(new Intent(ChooseLocaleWizardActivity.this, PromoAppsActivity.class));
}
});
next.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
setLocalePref(0);
finish();
startActivity(new Intent(ChooseLocaleWizardActivity.this, PromoAppsActivity.class));
}
});
}
private void setLocalePref(int selId)
{
SharedPreferences prefs = TorServiceUtils.getSharedPrefs(getApplicationContext());
Configuration config = getResources().getConfiguration();
String lang = localeValues[selId];
Editor pEdit = prefs.edit();
pEdit.putString(PREF_DEFAULT_LOCALE, lang);
pEdit.commit();
Locale locale = null;
if (lang.equals("xx"))
{
locale = Locale.getDefault();
}
else
locale = new Locale(lang);
Locale.setDefault(locale);
config.locale = locale;
getResources().updateConfiguration(config, getResources().getDisplayMetrics());
}
//Code to override the back button!
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if(keyCode == KeyEvent.KEYCODE_BACK){
Toast.makeText(getApplicationContext(), R.string.wizard_exit_at_first_screen_toast, Toast.LENGTH_SHORT).show();
return true;
}
return false;
}
}

View File

@ -241,7 +241,8 @@ public class OrbotVpnService extends VpnService implements Handler.Callback {
final String virtualGateway = "10.0.0.1";
final String virtualIP = "10.0.0.2";
final String virtualNetMask = "255.255.255.0";
final String localSocks = "127.0.0.1:" + TorServiceConstants.PORT_SOCKS_DEFAULT;
final String localSocks = "127.0.0.1:"
+ String.valueOf(TorServiceConstants.SOCKS_PROXY_PORT_DEFAULT);
final String localDNS = "10.0.0.1:" + TorServiceConstants.TOR_DNS_PORT_DEFAULT;
Builder builder = new Builder();