show warning about removal of transproxy support

- also make app selection more streamlining
This commit is contained in:
n8fr8 2017-10-25 00:07:11 -04:00
parent 9140ba6a47
commit 440290e9d7
8 changed files with 238 additions and 238 deletions

View File

@ -1,21 +1,32 @@
package org.torproject.android; package org.torproject.android;
import android.annotation.SuppressLint;
import android.annotation.TargetApi; import android.annotation.TargetApi;
import android.app.Activity; import android.app.Activity;
import android.app.Application; import android.app.Application;
import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.content.pm.PackageManager;
import android.content.res.Configuration; import android.content.res.Configuration;
import android.net.VpnService; import android.net.VpnService;
import android.os.Build; import android.os.Build;
import android.support.v4.app.NotificationCompat;
import android.util.Log; import android.util.Log;
import android.widget.RemoteViews;
import org.torproject.android.service.OrbotConstants; import org.torproject.android.service.OrbotConstants;
import org.torproject.android.service.TorEventHandler;
import org.torproject.android.service.TorService;
import org.torproject.android.service.util.Prefs; import org.torproject.android.service.util.Prefs;
import org.torproject.android.settings.Languages; import org.torproject.android.settings.Languages;
import java.util.Locale; import java.util.Locale;
import java.util.Set;
public class OrbotApp extends Application implements OrbotConstants public class OrbotApp extends Application implements OrbotConstants
{ {
@ -30,6 +41,7 @@ public class OrbotApp extends Application implements OrbotConstants
Languages.setup(OrbotMainActivity.class, R.string.menu_settings); Languages.setup(OrbotMainActivity.class, R.string.menu_settings);
Languages.setLanguage(this, Prefs.getDefaultLocale(), true); Languages.setLanguage(this, Prefs.getDefaultLocale(), true);
checkTransparentProxyingLegacy();
} }
@Override @Override
@ -53,4 +65,47 @@ public class OrbotApp extends Application implements OrbotConstants
public static Languages getLanguages(Activity activity) { public static Languages getLanguages(Activity activity) {
return Languages.get(activity); return Languages.get(activity);
} }
private void checkTransparentProxyingLegacy ()
{
if (Prefs.useTransparentProxying())
{
showToolbarNotification(getString(R.string.no_transproxy_warning_short),getString(R.string.no_transproxy_warning), 9999, org.torproject.android.service.R.drawable.ic_stat_notifyerr);
}
}
@SuppressLint("NewApi")
protected void showToolbarNotification (String shortMsg, String notifyMsg, int notifyId, int icon)
{
NotificationCompat.Builder notifyBuilder;
//Reusable code.
PackageManager pm = getPackageManager();
Intent intent = pm.getLaunchIntentForPackage(getPackageName());
PendingIntent pendIntent = PendingIntent.getActivity(this, 0, intent, 0);
NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
notifyBuilder = new NotificationCompat.Builder(this)
.setContentTitle(getString(org.torproject.android.service.R.string.app_name));
notifyBuilder.setContentIntent(pendIntent);
notifyBuilder.setContentText(shortMsg);
notifyBuilder.setSmallIcon(icon);
notifyBuilder.setTicker(notifyMsg);
notifyBuilder.setOngoing(false);
notifyBuilder.setStyle(new NotificationCompat.BigTextStyle()
.bigText(notifyMsg).setBigContentTitle(getString(org.torproject.android.service.R.string.app_name)));
Notification notification = notifyBuilder.build();
notificationManager.notify(notifyId, notification);
}
} }

View File

@ -852,10 +852,6 @@ public class OrbotMainActivity extends AppCompatActivity
//use the system browser since VPN is on //use the system browser since VPN is on
startIntent(null,Intent.ACTION_VIEW, Uri.parse(browserLaunchUrl)); startIntent(null,Intent.ACTION_VIEW, Uri.parse(browserLaunchUrl));
} }
else if (Prefs.useTransparentProxying())
{
startIntent(null,Intent.ACTION_VIEW, Uri.parse(browserLaunchUrl));
}
else else
{ {
AlertDialog aDialog = new AlertDialog.Builder(OrbotMainActivity.this) AlertDialog aDialog = new AlertDialog.Builder(OrbotMainActivity.this)
@ -1173,6 +1169,13 @@ public class OrbotMainActivity extends AppCompatActivity
updateStatus(null); updateStatus(null);
if (Prefs.useTransparentProxying())
{
showAlert(getString(R.string.no_transproxy_warning_short),getString(R.string.no_transproxy_warning),true);
Prefs.disableTransparentProxying();
}
} }
AlertDialog aDialog = null; AlertDialog aDialog = null;

View File

@ -15,16 +15,20 @@ import org.torproject.android.R;
import org.torproject.android.service.util.TorServiceUtils; import org.torproject.android.service.util.TorServiceUtils;
import org.torproject.android.service.vpn.TorifiedApp; import org.torproject.android.service.vpn.TorifiedApp;
import android.app.Activity;
import android.content.Context; import android.content.Context;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor; import android.content.SharedPreferences.Editor;
import android.content.pm.ApplicationInfo; import android.content.pm.ApplicationInfo;
import android.content.pm.PackageInfo; import android.content.pm.PackageInfo;
import android.content.pm.PackageManager; import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.os.Bundle; import android.os.Bundle;
import android.support.v7.app.AppCompatActivity; import android.support.v7.app.AppCompatActivity;
import android.util.Log; import android.util.Log;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem; import android.view.MenuItem;
import android.view.View; import android.view.View;
import android.view.View.OnClickListener; import android.view.View.OnClickListener;
@ -34,6 +38,7 @@ import android.widget.Button;
import android.widget.CheckBox; import android.widget.CheckBox;
import android.widget.CompoundButton; import android.widget.CompoundButton;
import android.widget.CompoundButton.OnCheckedChangeListener; import android.widget.CompoundButton.OnCheckedChangeListener;
import android.widget.GridView;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.ListAdapter; import android.widget.ListAdapter;
import android.widget.ListView; import android.widget.ListView;
@ -41,27 +46,22 @@ import android.widget.TextView;
public class AppManager extends AppCompatActivity implements OnCheckedChangeListener, OnClickListener, OrbotConstants { public class AppManager extends AppCompatActivity implements OnCheckedChangeListener, OnClickListener, OrbotConstants {
private ListView listApps; private GridView listApps;
private final static String TAG = "Orbot"; private final static String TAG = "Orbot";
PackageManager pMgr = null;
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
pMgr = getPackageManager();
this.setContentView(R.layout.layout_apps); this.setContentView(R.layout.layout_apps);
setTitle(R.string.apps_mode); setTitle(R.string.apps_mode);
getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setDisplayHomeAsUpEnabled(true);
View buttonSelectAll, buttonSelectNone, buttonInvert;
buttonSelectAll = findViewById(R.id.button_proxy_all);
buttonSelectNone = findViewById(R.id.button_proxy_none);
buttonInvert = findViewById(R.id.button_invert_selection);
buttonSelectAll.setOnClickListener(new OnAutoClickListener(0));
buttonSelectNone.setOnClickListener(new OnAutoClickListener(1));
buttonInvert.setOnClickListener(new OnAutoClickListener(2));
} }
/**
class OnAutoClickListener implements Button.OnClickListener { class OnAutoClickListener implements Button.OnClickListener {
private int status; private int status;
public OnAutoClickListener(int status){ public OnAutoClickListener(int status){
@ -69,7 +69,7 @@ public class AppManager extends AppCompatActivity implements OnCheckedChangeList
} }
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public void onClick(View button){ public void onClick(View button){
ListView listView; GridView listView;
ViewGroup viewGroup; ViewGroup viewGroup;
View parentView, currentView; View parentView, currentView;
ArrayAdapter<TorifiedApp> adapter; ArrayAdapter<TorifiedApp> adapter;
@ -80,7 +80,7 @@ public class AppManager extends AppCompatActivity implements OnCheckedChangeList
int posI, selectedI, lvSz; int posI, selectedI, lvSz;
buttonId = button.getId(); buttonId = button.getId();
listView = (ListView) findViewById(R.id.applistview); listView = (GridView) findViewById(R.id.applistview);
lvSz = listView.getCount(); lvSz = listView.getCount();
isSelected = new boolean[lvSz]; isSelected = new boolean[lvSz];
@ -127,26 +127,14 @@ public class AppManager extends AppCompatActivity implements OnCheckedChangeList
saveAppSettings(context); saveAppSettings(context);
loadApps(prefs); loadApps(prefs);
} }
} }**/
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case android.R.id.home:
setResult(RESULT_OK);
finish();
return true;
}
return false;
}
@Override @Override
protected void onResume() { protected void onResume() {
super.onResume(); super.onResume();
listApps = (ListView)findViewById(R.id.applistview); listApps = (GridView)findViewById(R.id.applistview);
mPrefs = TorServiceUtils.getSharedPrefs(getApplicationContext()); mPrefs = TorServiceUtils.getSharedPrefs(getApplicationContext());
loadApps(mPrefs); loadApps(mPrefs);
@ -198,16 +186,23 @@ public class AppManager extends AppCompatActivity implements OnCheckedChangeList
final TorifiedApp app = mApps.get(position); final TorifiedApp app = mApps.get(position);
if (entry.icon != null) { if (entry.icon != null) {
if (app.getIcon() != null)
entry.icon.setImageDrawable(app.getIcon()); try {
else entry.icon.setImageDrawable(pMgr.getApplicationIcon(app.getPackageName()));
entry.icon.setVisibility(View.GONE); entry.icon.setOnClickListener(AppManager.this);
if (entry.box != null)
entry.icon.setTag(entry.box);
}
catch (Exception e)
{
e.printStackTrace();
}
} }
if (entry.text != null) { if (entry.text != null) {
entry.text.setText(app.getName()); entry.text.setText(app.getName());
entry.text.setOnClickListener(AppManager.this); entry.text.setOnClickListener(AppManager.this);
entry.text.setOnClickListener(AppManager.this);
if (entry.box != null) if (entry.box != null)
entry.text.setTag(entry.box); entry.text.setTag(entry.box);
@ -219,7 +214,6 @@ public class AppManager extends AppCompatActivity implements OnCheckedChangeList
entry.box.setTag(app); entry.box.setTag(app);
entry.box.setChecked(app.isTorified()); entry.box.setChecked(app.isTorified());
} }
return convertView; return convertView;
@ -246,7 +240,7 @@ public class AppManager extends AppCompatActivity implements OnCheckedChangeList
} }
public static ArrayList<TorifiedApp> getApps (Context context, SharedPreferences prefs) public ArrayList<TorifiedApp> getApps (Context context, SharedPreferences prefs)
{ {
String tordAppString = prefs.getString(PREFS_KEY_TORIFIED, ""); String tordAppString = prefs.getString(PREFS_KEY_TORIFIED, "");
@ -263,7 +257,6 @@ public class AppManager extends AppCompatActivity implements OnCheckedChangeList
Arrays.sort(tordApps); Arrays.sort(tordApps);
//else load the apps up //else load the apps up
PackageManager pMgr = context.getPackageManager();
List<ApplicationInfo> lAppInfo = pMgr.getInstalledApplications(0); List<ApplicationInfo> lAppInfo = pMgr.getInstalledApplications(0);
@ -304,10 +297,22 @@ public class AppManager extends AppCompatActivity implements OnCheckedChangeList
e.printStackTrace(); e.printStackTrace();
} }
/**
if ((aInfo.flags & ApplicationInfo.FLAG_SYSTEM) == 1) if ((aInfo.flags & ApplicationInfo.FLAG_SYSTEM) == 1)
{ {
//System app //System app
app.setUsesInternet(true); app.setUsesInternet(true);
}**/
try
{
app.setName(pMgr.getApplicationLabel(aInfo).toString());
}
catch (Exception e)
{
// no name
continue; //we only show apps with names
} }
@ -318,24 +323,12 @@ public class AppManager extends AppCompatActivity implements OnCheckedChangeList
apps.add(app); apps.add(app);
} }
app.setEnabled(aInfo.enabled); app.setEnabled(aInfo.enabled);
app.setUid(aInfo.uid); app.setUid(aInfo.uid);
app.setUsername(pMgr.getNameForUid(app.getUid())); app.setUsername(pMgr.getNameForUid(app.getUid()));
app.setProcname(aInfo.processName); app.setProcname(aInfo.processName);
app.setPackageName(aInfo.packageName); app.setPackageName(aInfo.packageName);
try
{
app.setName(pMgr.getApplicationLabel(aInfo).toString());
}
catch (Exception e)
{
app.setName(aInfo.packageName);
}
//app.setIcon(pMgr.getApplicationIcon(aInfo));
// check if this application is allowed // check if this application is allowed
if (Arrays.binarySearch(tordApps, app.getUsername()) >= 0) { if (Arrays.binarySearch(tordApps, app.getUsername()) >= 0) {

View File

@ -5,65 +5,13 @@
xmlns:android="http://schemas.android.com/apk/res/android" xmlns:android="http://schemas.android.com/apk/res/android"
android:duplicateParentState="true"> android:duplicateParentState="true">
<!-- <GridView
<TextView android:text="Select apps to use with Tor:"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textSize="16sp"
android:padding="3px"
android:layout_above="@+id/applistview"
/>
-->
<ListView
android:id="@+id/applistview" android:id="@+id/applistview"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_above="@+id/layout_button_filters" android:numColumns="3"
android:layout_alignParentTop="true" > android:layout_alignParentTop="true" >
</ListView> </GridView>
<LinearLayout
android:id="@+id/layout_button_filters"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:orientation="horizontal" >
<android.support.v7.widget.AppCompatImageButton
android:id="@+id/button_proxy_all"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_toLeftOf="@+id/button_proxy_none"
android:layout_toStartOf="@+id/button_proxy_none"
android:layout_weight="1"
android:src="@drawable/ic_playlist_add_check_black_36dp"/>
<android.support.v7.widget.AppCompatImageButton
android:id="@+id/button_invert_selection"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:layout_alignParentTop="true"
android:layout_weight="1"
android:src="@drawable/ic_autorenew_black_36dp"/>
<android.support.v7.widget.AppCompatImageButton
android:id="@+id/button_proxy_none"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_weight="1"
android:layout_toLeftOf="@+id/button_invert_selection"
android:layout_toStartOf="@+id/button_invert_selection"
android:src='@drawable/ic_filter_none_black_36dp' />
</LinearLayout>
</RelativeLayout> </RelativeLayout>

View File

@ -1,18 +1,15 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_width="120dp"
android:layout_height="40dp" android:layout_height="120dp"
android:stretchColumns="1"> android:orientation="vertical"
<TableRow> android:gravity="center_horizontal"
>
<ImageView android:id="@+id/itemicon" android:layout_width="50dp" android:layout_height="50dp" android:padding="3dp" android:visibility="gone"></ImageView> <ImageView android:id="@+id/itemicon" android:layout_width="50dp" android:layout_height="50dp" android:padding="3dp" ></ImageView>
<TextView android:layout_height="20dp" android:layout_width="120dp" android:lines="1" android:id="@+id/itemtext"
<TextView android:layout_height="wrap_content" android:layout_width="150dp" android:id="@+id/itemtext" android:text="uid:packages" android:textSize="18sp" android:padding="3dip"></TextView> android:text="uid:packages" android:textSize="12sp" android:gravity="center_horizontal" android:padding="3dip"></TextView>
<CheckBox android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/itemcheck" ></CheckBox> <CheckBox android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/itemcheck" ></CheckBox>
</TableRow> </LinearLayout>
</TableLayout>

View File

@ -380,4 +380,7 @@
<string name="enable">Enable</string> <string name="enable">Enable</string>
<string name="consider_disable_battery_optimizations">Consider disable battery optimizations</string> <string name="consider_disable_battery_optimizations">Consider disable battery optimizations</string>
<string name="consider_enable_battery_optimizations">Consider enable battery optimizations</string> <string name="consider_enable_battery_optimizations">Consider enable battery optimizations</string>
<string name="no_transproxy_warning_short">WARNING: Transproxying no longer supported</string>
<string name="no_transproxy_warning">WARNING: Transparent proxying not supported. Use Orbot Apps VPN instead.</string>
</resources> </resources>

View File

@ -143,9 +143,6 @@ public interface TorServiceConstants {
// public static final String MEEK_ASSET_KEY = "meek-client"; // public static final String MEEK_ASSET_KEY = "meek-client";
//name of the iptables binary
public final static String IPTABLES_ASSET_KEY = "xtables";
//DNS daemon for TCP DNS over TOr //DNS daemon for TCP DNS over TOr
public final static String PDNSD_ASSET_KEY = "pdnsd"; public final static String PDNSD_ASSET_KEY = "pdnsd";

View File

@ -76,6 +76,10 @@ public class Prefs {
return prefs.getBoolean(PREF_TRANSPARENT, false); return prefs.getBoolean(PREF_TRANSPARENT, false);
} }
public static void disableTransparentProxying() {
prefs.getBoolean(PREF_TRANSPARENT, false);
}
public static boolean transparentProxyAll() { public static boolean transparentProxyAll() {
return prefs.getBoolean(PREF_TRANSPARENT_ALL, false); return prefs.getBoolean(PREF_TRANSPARENT_ALL, false);
} }