show warning about removal of transproxy support
- also make app selection more streamlining
This commit is contained in:
parent
9140ba6a47
commit
440290e9d7
|
@ -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);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -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)
|
||||||
|
@ -1172,6 +1168,13 @@ public class OrbotMainActivity extends AppCompatActivity
|
||||||
requestTorStatus();
|
requestTorStatus();
|
||||||
|
|
||||||
updateStatus(null);
|
updateStatus(null);
|
||||||
|
|
||||||
|
if (Prefs.useTransparentProxying())
|
||||||
|
{
|
||||||
|
showAlert(getString(R.string.no_transproxy_warning_short),getString(R.string.no_transproxy_warning),true);
|
||||||
|
Prefs.disableTransparentProxying();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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,112 +46,95 @@ 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 {
|
/**
|
||||||
private int status;
|
class OnAutoClickListener implements Button.OnClickListener {
|
||||||
public OnAutoClickListener(int status){
|
private int status;
|
||||||
this.status = status;
|
public OnAutoClickListener(int status){
|
||||||
}
|
this.status = status;
|
||||||
@SuppressWarnings("unchecked")
|
}
|
||||||
public void onClick(View button){
|
@SuppressWarnings("unchecked")
|
||||||
ListView listView;
|
public void onClick(View button){
|
||||||
ViewGroup viewGroup;
|
GridView listView;
|
||||||
View parentView, currentView;
|
ViewGroup viewGroup;
|
||||||
ArrayAdapter<TorifiedApp> adapter;
|
View parentView, currentView;
|
||||||
TorifiedApp app;
|
ArrayAdapter<TorifiedApp> adapter;
|
||||||
CheckBox box;
|
TorifiedApp app;
|
||||||
float buttonId;
|
CheckBox box;
|
||||||
boolean[] isSelected;
|
float buttonId;
|
||||||
int posI, selectedI, lvSz;
|
boolean[] isSelected;
|
||||||
|
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];
|
||||||
|
|
||||||
selectedI = -1;
|
selectedI = -1;
|
||||||
|
|
||||||
if (this.status == 0){
|
if (this.status == 0){
|
||||||
Log.d(TAG, "Proxifying ALL");
|
Log.d(TAG, "Proxifying ALL");
|
||||||
}else if (this.status == 1){
|
}else if (this.status == 1){
|
||||||
Log.d(TAG, "Proxifying NONE");
|
Log.d(TAG, "Proxifying NONE");
|
||||||
}else {
|
}else {
|
||||||
Log.d(TAG, "Proxifying invert");
|
Log.d(TAG, "Proxifying invert");
|
||||||
}
|
}
|
||||||
|
|
||||||
Context context = getApplicationContext();
|
Context context = getApplicationContext();
|
||||||
SharedPreferences prefs = TorServiceUtils.getSharedPrefs(context);
|
SharedPreferences prefs = TorServiceUtils.getSharedPrefs(context);
|
||||||
ArrayList<TorifiedApp> apps = getApps(context, prefs);
|
ArrayList<TorifiedApp> apps = getApps(context, prefs);
|
||||||
parentView = (View) findViewById(R.id.applistview);
|
parentView = (View) findViewById(R.id.applistview);
|
||||||
viewGroup = (ViewGroup) listView;
|
viewGroup = (ViewGroup) listView;
|
||||||
|
|
||||||
adapter = (ArrayAdapter<TorifiedApp>) listApps.getAdapter();
|
adapter = (ArrayAdapter<TorifiedApp>) listApps.getAdapter();
|
||||||
if (adapter == null){
|
if (adapter == null){
|
||||||
Log.w(TAG, "List adapter is null. Getting apps.");
|
Log.w(TAG, "List adapter is null. Getting apps.");
|
||||||
loadApps(prefs);
|
loadApps(prefs);
|
||||||
adapter = (ArrayAdapter<TorifiedApp>) listApps.getAdapter();
|
adapter = (ArrayAdapter<TorifiedApp>) listApps.getAdapter();
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0 ; i < adapter.getCount(); ++i){
|
for (int i = 0 ; i < adapter.getCount(); ++i){
|
||||||
app = (TorifiedApp) adapter.getItem(i);
|
app = (TorifiedApp) adapter.getItem(i);
|
||||||
currentView = adapter.getView(i, parentView, viewGroup);
|
currentView = adapter.getView(i, parentView, viewGroup);
|
||||||
box = (CheckBox) currentView.findViewById(R.id.itemcheck);
|
box = (CheckBox) currentView.findViewById(R.id.itemcheck);
|
||||||
|
|
||||||
if (this.status == 0){
|
if (this.status == 0){
|
||||||
app.setTorified(true);
|
app.setTorified(true);
|
||||||
}else if (this.status == 1){
|
}else if (this.status == 1){
|
||||||
app.setTorified(false);
|
app.setTorified(false);
|
||||||
}else {
|
}else {
|
||||||
app.setTorified(!app.isTorified());
|
app.setTorified(!app.isTorified());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (box != null)
|
if (box != null)
|
||||||
box.setChecked(app.isTorified());
|
box.setChecked(app.isTorified());
|
||||||
|
|
||||||
}
|
}
|
||||||
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);
|
||||||
|
@ -154,12 +142,12 @@ public class AppManager extends AppCompatActivity implements OnCheckedChangeList
|
||||||
|
|
||||||
SharedPreferences mPrefs = null;
|
SharedPreferences mPrefs = null;
|
||||||
ArrayList<TorifiedApp> mApps = null;
|
ArrayList<TorifiedApp> mApps = null;
|
||||||
|
|
||||||
private void loadApps (SharedPreferences prefs)
|
private void loadApps (SharedPreferences prefs)
|
||||||
{
|
{
|
||||||
|
|
||||||
mApps = getApps(getApplicationContext(), prefs);
|
mApps = getApps(getApplicationContext(), prefs);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Arrays.sort(apps, new Comparator<TorifiedApp>() {
|
Arrays.sort(apps, new Comparator<TorifiedApp>() {
|
||||||
public int compare(TorifiedApp o1, TorifiedApp o2) {
|
public int compare(TorifiedApp o1, TorifiedApp o2) {
|
||||||
|
@ -168,9 +156,9 @@ public class AppManager extends AppCompatActivity implements OnCheckedChangeList
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
});*/
|
});*/
|
||||||
|
|
||||||
final LayoutInflater inflater = getLayoutInflater();
|
final LayoutInflater inflater = getLayoutInflater();
|
||||||
|
|
||||||
ListAdapter adapter = new ArrayAdapter<TorifiedApp>(this, R.layout.layout_apps_item, R.id.itemtext,mApps) {
|
ListAdapter adapter = new ArrayAdapter<TorifiedApp>(this, R.layout.layout_apps_item, R.id.itemtext,mApps) {
|
||||||
|
|
||||||
public View getView(int position, View convertView, ViewGroup parent) {
|
public View getView(int position, View convertView, ViewGroup parent) {
|
||||||
|
@ -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,39 +214,38 @@ 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;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
listApps.setAdapter(adapter);
|
listApps.setAdapter(adapter);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class ListEntry {
|
private static class ListEntry {
|
||||||
private CheckBox box;
|
private CheckBox box;
|
||||||
private TextView text;
|
private TextView text;
|
||||||
private ImageView icon;
|
private ImageView icon;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see android.app.Activity#onStop()
|
* @see android.app.Activity#onStop()
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected void onStop() {
|
protected void onStop() {
|
||||||
super.onStop();
|
super.onStop();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
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, "");
|
||||||
String[] tordApps;
|
String[] tordApps;
|
||||||
|
|
||||||
StringTokenizer st = new StringTokenizer(tordAppString,"|");
|
StringTokenizer st = new StringTokenizer(tordAppString,"|");
|
||||||
tordApps = new String[st.countTokens()];
|
tordApps = new String[st.countTokens()];
|
||||||
int tordIdx = 0;
|
int tordIdx = 0;
|
||||||
|
@ -259,32 +253,31 @@ public class AppManager extends AppCompatActivity implements OnCheckedChangeList
|
||||||
{
|
{
|
||||||
tordApps[tordIdx++] = st.nextToken();
|
tordApps[tordIdx++] = st.nextToken();
|
||||||
}
|
}
|
||||||
|
|
||||||
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);
|
||||||
|
|
||||||
Iterator<ApplicationInfo> itAppInfo = lAppInfo.iterator();
|
Iterator<ApplicationInfo> itAppInfo = lAppInfo.iterator();
|
||||||
|
|
||||||
ArrayList<TorifiedApp> apps = new ArrayList<TorifiedApp>();
|
ArrayList<TorifiedApp> apps = new ArrayList<TorifiedApp>();
|
||||||
|
|
||||||
ApplicationInfo aInfo = null;
|
ApplicationInfo aInfo = null;
|
||||||
|
|
||||||
int appIdx = 0;
|
int appIdx = 0;
|
||||||
TorifiedApp app = null;
|
TorifiedApp app = null;
|
||||||
|
|
||||||
while (itAppInfo.hasNext())
|
while (itAppInfo.hasNext())
|
||||||
{
|
{
|
||||||
aInfo = itAppInfo.next();
|
aInfo = itAppInfo.next();
|
||||||
|
|
||||||
app = new TorifiedApp();
|
app = new TorifiedApp();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
PackageInfo pInfo = pMgr.getPackageInfo(aInfo.packageName, PackageManager.GET_PERMISSIONS);
|
PackageInfo pInfo = pMgr.getPackageInfo(aInfo.packageName, PackageManager.GET_PERMISSIONS);
|
||||||
|
|
||||||
if (pInfo != null && pInfo.requestedPermissions != null)
|
if (pInfo != null && pInfo.requestedPermissions != null)
|
||||||
{
|
{
|
||||||
for (String permInfo:pInfo.requestedPermissions)
|
for (String permInfo:pInfo.requestedPermissions)
|
||||||
|
@ -292,51 +285,51 @@ public class AppManager extends AppCompatActivity implements OnCheckedChangeList
|
||||||
if (permInfo.equals("android.permission.INTERNET"))
|
if (permInfo.equals("android.permission.INTERNET"))
|
||||||
{
|
{
|
||||||
app.setUsesInternet(true);
|
app.setUsesInternet(true);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
// TODO Auto-generated catch block
|
// TODO Auto-generated catch block
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((aInfo.flags & ApplicationInfo.FLAG_SYSTEM) == 1)
|
/**
|
||||||
{
|
if ((aInfo.flags & ApplicationInfo.FLAG_SYSTEM) == 1)
|
||||||
//System app
|
{
|
||||||
app.setUsesInternet(true);
|
//System app
|
||||||
}
|
app.setUsesInternet(true);
|
||||||
|
}**/
|
||||||
|
|
||||||
if (!app.usesInternet())
|
|
||||||
continue;
|
|
||||||
else
|
|
||||||
{
|
|
||||||
apps.add(app);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
app.setEnabled(aInfo.enabled);
|
|
||||||
app.setUid(aInfo.uid);
|
|
||||||
app.setUsername(pMgr.getNameForUid(app.getUid()));
|
|
||||||
app.setProcname(aInfo.processName);
|
|
||||||
app.setPackageName(aInfo.packageName);
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
app.setName(pMgr.getApplicationLabel(aInfo).toString());
|
app.setName(pMgr.getApplicationLabel(aInfo).toString());
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
app.setName(aInfo.packageName);
|
// no name
|
||||||
|
continue; //we only show apps with names
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//app.setIcon(pMgr.getApplicationIcon(aInfo));
|
if (!app.usesInternet())
|
||||||
|
continue;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
apps.add(app);
|
||||||
|
}
|
||||||
|
|
||||||
|
app.setEnabled(aInfo.enabled);
|
||||||
|
app.setUid(aInfo.uid);
|
||||||
|
app.setUsername(pMgr.getNameForUid(app.getUid()));
|
||||||
|
app.setProcname(aInfo.processName);
|
||||||
|
app.setPackageName(aInfo.packageName);
|
||||||
|
|
||||||
|
|
||||||
// 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) {
|
||||||
app.setTorified(true);
|
app.setTorified(true);
|
||||||
|
@ -345,15 +338,15 @@ public class AppManager extends AppCompatActivity implements OnCheckedChangeList
|
||||||
{
|
{
|
||||||
app.setTorified(false);
|
app.setTorified(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
appIdx++;
|
appIdx++;
|
||||||
}
|
}
|
||||||
|
|
||||||
Collections.sort(apps);
|
Collections.sort(apps);
|
||||||
|
|
||||||
return apps;
|
return apps;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void saveAppSettings (Context context)
|
public void saveAppSettings (Context context)
|
||||||
{
|
{
|
||||||
|
@ -368,13 +361,13 @@ public class AppManager extends AppCompatActivity implements OnCheckedChangeList
|
||||||
tordApps.append("|");
|
tordApps.append("|");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Editor edit = mPrefs.edit();
|
Editor edit = mPrefs.edit();
|
||||||
edit.putString(PREFS_KEY_TORIFIED, tordApps.toString());
|
edit.putString(PREFS_KEY_TORIFIED, tordApps.toString());
|
||||||
edit.commit();
|
edit.commit();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called an application is check/unchecked
|
* Called an application is check/unchecked
|
||||||
|
@ -384,29 +377,29 @@ public class AppManager extends AppCompatActivity implements OnCheckedChangeList
|
||||||
if (app != null) {
|
if (app != null) {
|
||||||
app.setTorified(isChecked);
|
app.setTorified(isChecked);
|
||||||
}
|
}
|
||||||
|
|
||||||
saveAppSettings(this);
|
saveAppSettings(this);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
|
|
||||||
CheckBox cbox = (CheckBox)v.getTag();
|
CheckBox cbox = (CheckBox)v.getTag();
|
||||||
|
|
||||||
final TorifiedApp app = (TorifiedApp)cbox.getTag();
|
final TorifiedApp app = (TorifiedApp)cbox.getTag();
|
||||||
if (app != null) {
|
if (app != null) {
|
||||||
app.setTorified(!app.isTorified());
|
app.setTorified(!app.isTorified());
|
||||||
cbox.setChecked(app.isTorified());
|
cbox.setChecked(app.isTorified());
|
||||||
}
|
}
|
||||||
|
|
||||||
saveAppSettings(this);
|
saveAppSettings(this);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,69 +1,17 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<RelativeLayout
|
<RelativeLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
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
|
</RelativeLayout>
|
||||||
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>
|
|
|
@ -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" ></ImageView>
|
||||||
|
<TextView android:layout_height="20dp" android:layout_width="120dp" android:lines="1" android:id="@+id/itemtext"
|
||||||
|
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>
|
||||||
|
|
||||||
<ImageView android:id="@+id/itemicon" android:layout_width="50dp" android:layout_height="50dp" android:padding="3dp" android:visibility="gone"></ImageView>
|
</LinearLayout>
|
||||||
|
|
||||||
<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>
|
|
||||||
|
|
||||||
<CheckBox android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/itemcheck" ></CheckBox>
|
|
||||||
|
|
||||||
</TableRow>
|
|
||||||
|
|
||||||
</TableLayout>
|
|
||||||
|
|
||||||
|
|
|
@ -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>
|
||||||
|
|
|
@ -142,9 +142,6 @@ public interface TorServiceConstants {
|
||||||
public static final String OBFSCLIENT_ASSET_KEY = "obfs4proxy";
|
public static final String OBFSCLIENT_ASSET_KEY = "obfs4proxy";
|
||||||
|
|
||||||
// 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";
|
||||||
|
|
|
@ -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);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue