Merge branch 'master' of https://github.com/freckles-the-pirate/orbot into freckles-the-pirate-master
41
BUILD
|
@ -1,5 +1,6 @@
|
||||||
|
|
||||||
This document explains how to properly build an Android package of Orbot from source.
|
This document explains how to properly build an Android package of Orbot from
|
||||||
|
source.
|
||||||
|
|
||||||
Orbot includes, in the external directory, git repo submodules of:
|
Orbot includes, in the external directory, git repo submodules of:
|
||||||
- Tor
|
- Tor
|
||||||
|
@ -7,45 +8,53 @@ Orbot includes, in the external directory, git repo submodules of:
|
||||||
- LibEvent
|
- LibEvent
|
||||||
- JTorControl: The Tor Control Library for Java
|
- JTorControl: The Tor Control Library for Java
|
||||||
|
|
||||||
The Orbot repo also includes the Privoxy source code of a recent stable release.
|
The Orbot repo also includes the Polipo source code of a recent stable release.
|
||||||
|
|
||||||
Please install the following prerequisites (instructions for each follows):
|
Please install the following prerequisites (instructions for each follows):
|
||||||
ant: http://ant.apache.org/
|
ant: http://ant.apache.org/
|
||||||
Android Native Dev Kit or NDK (for C/C++ code): http://developer.android.com/sdk/ndk/index.html
|
Android Native Dev Kit or NDK (for C/C++ code):
|
||||||
Android Software Dev Kit or SDK (for Java code): http://developer.android.com/sdk/index.html
|
http://developer.android.com/sdk/ndk/index.html
|
||||||
|
Android Software Dev Kit or SDK (for Java code):
|
||||||
|
http://developer.android.com/sdk/index.html
|
||||||
|
|
||||||
You will need to run the 'android' command in the SDK to install the necessary Android platform supports (ICS 4.x or android-15)
|
You will need to run the 'android' command in the SDK to install the necessary
|
||||||
|
Android platform supports (ICS 4.x or android-15)
|
||||||
|
|
||||||
Be sure that you have all of the git submodules up-to-date:
|
Be sure that you have all of the git submodules up-to-date:
|
||||||
|
|
||||||
git submodule init
|
git submodule update --init --recursive
|
||||||
git submodule update
|
|
||||||
|
|
||||||
To begin building, from the Orbot root directory, you first need to build all external C/native dependencies:
|
To begin building, from the Orbot root directory, you first need to build all
|
||||||
|
external C/native dependencies:
|
||||||
|
|
||||||
export NDK_BASE={PATH TO YOUR NDK INSTALL}
|
export NDK_BASE={PATH TO YOUR NDK INSTALL}
|
||||||
make -C external
|
make -C external
|
||||||
|
|
||||||
At this point, you'll have Tor and Privoxy binaries that can be run on an Android handset.
|
At this point, you'll have Tor and Polipo binaries that can be run on an
|
||||||
You can verify the ARM binary was properly built using the following command:
|
Android handset. You can verify the ARM binary was properly built using the
|
||||||
|
following command:
|
||||||
|
|
||||||
file res/raw/tor
|
file external/bin/tor external/bin/polipo
|
||||||
file res/raw/privoxy
|
|
||||||
|
|
||||||
You should see something like:
|
You should see something like:
|
||||||
src/or/tor: ELF 32-bit LSB executable, ARM, version 1 (SYSV), dynamically linked (uses shared libs), not stripped
|
external/bin/tor: ELF 32-bit LSB executable, ARM, version 1 (SYSV),
|
||||||
|
dynamically linked (uses shared libs), not stripped
|
||||||
|
external/bin/polipo: ELF 32-bit LSB executable, ARM, version 1 (SYSV),
|
||||||
|
dynamically linked (uses shared libs), not stripped
|
||||||
|
|
||||||
This isn't enough though and we'll now sew up the binary into a small package
|
This isn't enough though and we'll now sew up the binary into a small package
|
||||||
that will handle basic Tor controlling features.
|
that will handle basic Tor controlling features.
|
||||||
|
|
||||||
android update project --name Orbot --target android-15 --path .
|
android update project --name Orbot --target android-15 --path .
|
||||||
|
|
||||||
#Now you need to split and copy the tor binary into res/raw. We split it into < 1M chunks
|
Now you need to split and copy the tor binary into external/bin. We split it
|
||||||
#because some Android devices don't like resources larger than 1M.
|
into < 1M chunks because some Android devices don't like resources larger than
|
||||||
#split --bytes=1m $DROID_ROOT/external/tor/tor/src/or/tor res/raw/tor
|
1M.
|
||||||
|
split --bytes=1m ./external/tor/src/or/tor ./external/bin/tor
|
||||||
|
|
||||||
Now build the Android app
|
Now build the Android app
|
||||||
|
|
||||||
|
./update-ant-build
|
||||||
ant release
|
ant release
|
||||||
|
|
||||||
This will produce an unsigned Tor package in ./bin/Orbot-unsigned.apk!
|
This will produce an unsigned Tor package in ./bin/Orbot-unsigned.apk!
|
||||||
|
|
|
@ -1 +0,0 @@
|
||||||
Subproject commit 99b85b7837707bd6c6d578c9328e1321fceb8082
|
|
|
@ -1 +0,0 @@
|
||||||
Subproject commit 64177777165d9684bafbfa946abd126f7ebff11f
|
|
|
@ -1 +0,0 @@
|
||||||
Subproject commit be997be8fff6dc00cd249fdfd128d6820461db99
|
|
After Width: | Height: | Size: 1010 B |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 1.0 KiB |
After Width: | Height: | Size: 1010 B |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 1.0 KiB |
After Width: | Height: | Size: 1010 B |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 1.0 KiB |
After Width: | Height: | Size: 1010 B |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 1.0 KiB |
After Width: | Height: | Size: 1010 B |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 1.0 KiB |
After Width: | Height: | Size: 1010 B |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 1.0 KiB |
After Width: | Height: | Size: 1010 B |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 1.0 KiB |
After Width: | Height: | Size: 1010 B |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 1.0 KiB |
After Width: | Height: | Size: 1010 B |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 1.0 KiB |
After Width: | Height: | Size: 1010 B |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 1.0 KiB |
After Width: | Height: | Size: 1010 B |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 1.0 KiB |
After Width: | Height: | Size: 1010 B |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 1.0 KiB |
After Width: | Height: | Size: 1010 B |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 1.0 KiB |
After Width: | Height: | Size: 1010 B |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 1.0 KiB |
After Width: | Height: | Size: 1.0 KiB |
After Width: | Height: | Size: 1010 B |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 1.0 KiB |
|
@ -1,19 +1,74 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<RelativeLayout android:layout_width="fill_parent" android:layout_height="fill_parent" xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:duplicateParentState="false">
|
<RelativeLayout
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="fill_parent"
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:duplicateParentState="true">
|
||||||
|
|
||||||
<!--
|
<!--
|
||||||
<TextView android:text="Select apps to use with Tor:"
|
<TextView android:text="Select apps to use with Tor:"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:textSize="16sp"
|
android:textSize="16sp"
|
||||||
android:padding="3px"
|
android:padding="3px"
|
||||||
android:layout_above="@+id/applistview"
|
android:layout_above="@+id/applistview"
|
||||||
/>
|
/>
|
||||||
-->
|
-->
|
||||||
|
|
||||||
<Button android:layout_width="fill_parent"
|
<ListView
|
||||||
android:layout_height="wrap_content" android:id="@+id/btnsave"
|
android:id="@+id/applistview"
|
||||||
android:text="@string/button_close" android:layout_alignParentBottom="true" />
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_above="@+id/layout_button_filters"
|
||||||
|
android:layout_alignParentTop="true" >
|
||||||
|
|
||||||
|
</ListView>
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/btnsave"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_alignParentBottom="true"
|
||||||
|
android:layout_alignParentStart="true"
|
||||||
|
android:layout_alignParentLeft="true"
|
||||||
|
android:text="@string/button_close" />
|
||||||
|
|
||||||
|
<RelativeLayout
|
||||||
|
android:id="@+id/layout_button_filters"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_above="@+id/btnsave"
|
||||||
|
android:orientation="horizontal" >
|
||||||
|
|
||||||
|
<Button
|
||||||
|
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:text="@string/button_proxy_all" />
|
||||||
|
|
||||||
|
<Button
|
||||||
|
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:text="@string/button_invert_selection" />
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/button_proxy_none"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_alignParentTop="true"
|
||||||
|
android:layout_toLeftOf="@+id/button_invert_selection"
|
||||||
|
android:layout_toStartOf="@+id/button_invert_selection"
|
||||||
|
android:text="@string/button_proxy_none" />
|
||||||
|
|
||||||
|
</RelativeLayout>
|
||||||
|
|
||||||
<ListView android:layout_above="@id/btnsave" android:layout_alignParentTop="true" android:layout_width="fill_parent" android:layout_height="fill_parent" android:id="@+id/applistview"></ListView>
|
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
|
|
@ -134,6 +134,10 @@
|
||||||
<string name="pref_entrance_node_summary">Fingerprints, nicks, countries and addresses for the first hop</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_entrance_node_dialog">Enter Entrance Nodes</string>
|
||||||
|
|
||||||
|
<string name="button_proxy_all">Proxy All</string>
|
||||||
|
<string name="button_proxy_none">Proxy None</string>
|
||||||
|
<string name="button_invert_selection">Invert Selection</string>
|
||||||
|
|
||||||
<string name="pref_proxy_title">Outbound Network Proxy (Optional)</string>
|
<string name="pref_proxy_title">Outbound Network Proxy (Optional)</string>
|
||||||
|
|
||||||
<string name="pref_proxy_type_title">Outbound Proxy Type</string>
|
<string name="pref_proxy_type_title">Outbound Proxy Type</string>
|
||||||
|
|
|
@ -11,11 +11,16 @@ import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.StringTokenizer;
|
import java.util.StringTokenizer;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
import org.torproject.android.R;
|
import org.torproject.android.R;
|
||||||
import org.torproject.android.TorConstants;
|
import org.torproject.android.TorConstants;
|
||||||
import org.torproject.android.service.TorService;
|
import org.torproject.android.service.TorService;
|
||||||
import org.torproject.android.service.TorServiceUtils;
|
import org.torproject.android.service.TorServiceUtils;
|
||||||
|
|
||||||
|
|
||||||
|
//import android.R;
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
|
@ -25,8 +30,13 @@ import android.content.pm.PackageInfo;
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.util.Log;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.MenuItem.OnMenuItemClickListener;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
import android.view.Menu;
|
||||||
|
import android.view.MenuItem;
|
||||||
|
import android.view.MenuInflater;
|
||||||
import android.view.View.OnClickListener;
|
import android.view.View.OnClickListener;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.ArrayAdapter;
|
import android.widget.ArrayAdapter;
|
||||||
|
@ -41,273 +51,347 @@ import android.widget.TextView;
|
||||||
|
|
||||||
public class AppManager extends Activity implements OnCheckedChangeListener, OnClickListener, TorConstants {
|
public class AppManager extends Activity implements OnCheckedChangeListener, OnClickListener, TorConstants {
|
||||||
|
|
||||||
private ListView listApps;
|
private ListView listApps;
|
||||||
|
private final static String TAG = "Orbot";
|
||||||
|
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
this.setContentView(R.layout.layout_apps);
|
this.setContentView(R.layout.layout_apps);
|
||||||
|
|
||||||
|
Button buttonSelectAll, buttonSelectNone, buttonInvert;
|
||||||
|
|
||||||
}
|
buttonSelectAll = (Button) findViewById(R.id.button_proxy_all);
|
||||||
|
buttonSelectNone = (Button) findViewById(R.id.button_proxy_none);
|
||||||
|
buttonInvert = (Button) findViewById(R.id.button_invert_selection);
|
||||||
|
|
||||||
|
buttonSelectAll.setOnClickListener(new OnAutoClickListener(0));
|
||||||
|
buttonSelectNone.setOnClickListener(new OnAutoClickListener(1));
|
||||||
|
buttonInvert.setOnClickListener(new OnAutoClickListener(2));
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
class OnAutoClickListener implements Button.OnClickListener {
|
||||||
protected void onResume() {
|
private int status;
|
||||||
super.onResume();
|
public OnAutoClickListener(int status){
|
||||||
listApps = (ListView)findViewById(R.id.applistview);
|
this.status = status;
|
||||||
|
}
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
public void onClick(View button){
|
||||||
|
ListView listView;
|
||||||
|
ViewGroup viewGroup;
|
||||||
|
View parentView, currentView;
|
||||||
|
ArrayAdapter<TorifiedApp> adapter;
|
||||||
|
TorifiedApp app;
|
||||||
|
CheckBox box;
|
||||||
|
float buttonId;
|
||||||
|
boolean[] isSelected;
|
||||||
|
int posI, selectedI, lvSz;
|
||||||
|
|
||||||
Button btnSave = (Button)findViewById(R.id.btnsave);
|
buttonId = button.getId();
|
||||||
btnSave.setOnClickListener(new OnClickListener()
|
listView = (ListView) findViewById(R.id.applistview);
|
||||||
{
|
lvSz = listView.getCount();
|
||||||
|
isSelected = new boolean[lvSz];
|
||||||
|
|
||||||
public void onClick(View v) {
|
selectedI = -1;
|
||||||
finish();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
mPrefs = TorServiceUtils.getSharedPrefs(getApplicationContext());
|
if (this.status == 0){
|
||||||
loadApps(mPrefs);
|
Log.d(TAG, "Proxifying ALL");
|
||||||
}
|
}else if (this.status == 1){
|
||||||
|
Log.d(TAG, "Proxifying NONE");
|
||||||
|
}else {
|
||||||
|
Log.d(TAG, "Proxifying invert");
|
||||||
|
}
|
||||||
|
|
||||||
SharedPreferences mPrefs = null;
|
Context context = getApplicationContext();
|
||||||
ArrayList<TorifiedApp> mApps = null;
|
SharedPreferences prefs = TorServiceUtils.getSharedPrefs(context);
|
||||||
|
ArrayList<TorifiedApp> apps = getApps(context, prefs);
|
||||||
|
parentView = (View) findViewById(R.layout.layout_apps);
|
||||||
|
viewGroup = (ViewGroup) listView;
|
||||||
|
|
||||||
private void loadApps (SharedPreferences prefs)
|
adapter = (ArrayAdapter<TorifiedApp>) listApps.getAdapter();
|
||||||
{
|
if (adapter == null){
|
||||||
|
Log.w(TAG, "List adapter is null. Getting apps.");
|
||||||
|
loadApps(prefs);
|
||||||
|
adapter = (ArrayAdapter<TorifiedApp>) listApps.getAdapter();
|
||||||
|
}
|
||||||
|
|
||||||
mApps = getApps(getApplicationContext(), prefs);
|
for (int i = 0 ; i < adapter.getCount(); ++i){
|
||||||
|
app = (TorifiedApp) adapter.getItem(i);
|
||||||
|
currentView = adapter.getView(i, parentView, viewGroup);
|
||||||
|
box = (CheckBox) currentView.findViewById(R.id.itemcheck);
|
||||||
|
if (this.status == 0){
|
||||||
|
if (!box.isChecked())
|
||||||
|
box.performClick();
|
||||||
|
}else if (this.status == 1){
|
||||||
|
if (box.isChecked())
|
||||||
|
box.performClick();
|
||||||
|
}else {
|
||||||
|
box.performClick();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
saveAppSettings(context);
|
||||||
|
loadApps(prefs);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onResume() {
|
||||||
|
super.onResume();
|
||||||
|
listApps = (ListView)findViewById(R.id.applistview);
|
||||||
|
|
||||||
|
Button btnSave = (Button)findViewById(R.id.btnsave);
|
||||||
|
btnSave.setOnClickListener(new OnClickListener()
|
||||||
|
{
|
||||||
|
|
||||||
|
public void onClick(View v) {
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
mPrefs = TorServiceUtils.getSharedPrefs(getApplicationContext());
|
||||||
|
loadApps(mPrefs);
|
||||||
|
}
|
||||||
|
|
||||||
|
SharedPreferences mPrefs = null;
|
||||||
|
ArrayList<TorifiedApp> mApps = null;
|
||||||
|
|
||||||
|
private void loadApps (SharedPreferences 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) {
|
||||||
if (o1.isTorified() == o2.isTorified()) return o1.getName().compareTo(o2.getName());
|
if (o1.isTorified() == o2.isTorified()) return o1.getName().compareTo(o2.getName());
|
||||||
if (o1.isTorified()) return -1;
|
if (o1.isTorified()) return -1;
|
||||||
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) {
|
||||||
ListEntry entry;
|
ListEntry entry;
|
||||||
if (convertView == null) {
|
if (convertView == null) {
|
||||||
// Inflate a new view
|
// Inflate a new view
|
||||||
convertView = inflater.inflate(R.layout.layout_apps_item, parent, false);
|
convertView = inflater.inflate(R.layout.layout_apps_item, parent, false);
|
||||||
entry = new ListEntry();
|
entry = new ListEntry();
|
||||||
entry.icon = (ImageView) convertView.findViewById(R.id.itemicon);
|
entry.icon = (ImageView) convertView.findViewById(R.id.itemicon);
|
||||||
entry.box = (CheckBox) convertView.findViewById(R.id.itemcheck);
|
entry.box = (CheckBox) convertView.findViewById(R.id.itemcheck);
|
||||||
entry.text = (TextView) convertView.findViewById(R.id.itemtext);
|
entry.text = (TextView) convertView.findViewById(R.id.itemtext);
|
||||||
|
|
||||||
entry.text.setOnClickListener(AppManager.this);
|
entry.text.setOnClickListener(AppManager.this);
|
||||||
entry.text.setOnClickListener(AppManager.this);
|
entry.text.setOnClickListener(AppManager.this);
|
||||||
|
|
||||||
convertView.setTag(entry);
|
convertView.setTag(entry);
|
||||||
|
|
||||||
entry.box.setOnCheckedChangeListener(AppManager.this);
|
entry.box.setOnCheckedChangeListener(AppManager.this);
|
||||||
} else {
|
} else {
|
||||||
// Convert an existing view
|
// Convert an existing view
|
||||||
entry = (ListEntry) convertView.getTag();
|
entry = (ListEntry) convertView.getTag();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
final TorifiedApp app = mApps.get(position);
|
final TorifiedApp app = mApps.get(position);
|
||||||
|
|
||||||
if (app.getIcon() != null)
|
if (app.getIcon() != null)
|
||||||
entry.icon.setImageDrawable(app.getIcon());
|
entry.icon.setImageDrawable(app.getIcon());
|
||||||
else
|
else
|
||||||
entry.icon.setVisibility(View.GONE);
|
entry.icon.setVisibility(View.GONE);
|
||||||
|
|
||||||
entry.text.setText(app.getName());
|
entry.text.setText(app.getName());
|
||||||
|
|
||||||
final CheckBox box = entry.box;
|
final CheckBox box = entry.box;
|
||||||
box.setTag(app);
|
box.setTag(app);
|
||||||
box.setChecked(app.isTorified());
|
box.setChecked(app.isTorified());
|
||||||
|
|
||||||
entry.text.setTag(box);
|
entry.text.setTag(box);
|
||||||
entry.icon.setTag(box);
|
entry.icon.setTag(box);
|
||||||
|
|
||||||
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 static 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;
|
||||||
while (st.hasMoreTokens())
|
while (st.hasMoreTokens())
|
||||||
{
|
{
|
||||||
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();
|
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)
|
||||||
{
|
{
|
||||||
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
|
//System app
|
||||||
app.setUsesInternet(true);
|
app.setUsesInternet(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (!app.usesInternet())
|
if (!app.usesInternet())
|
||||||
continue;
|
continue;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
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);
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
app.setName(pMgr.getApplicationLabel(aInfo).toString());
|
app.setName(pMgr.getApplicationLabel(aInfo).toString());
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
app.setName(aInfo.packageName);
|
app.setName(aInfo.packageName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//app.setIcon(pMgr.getApplicationIcon(aInfo));
|
//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) {
|
||||||
app.setTorified(true);
|
app.setTorified(true);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
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)
|
||||||
{
|
{
|
||||||
|
|
||||||
StringBuilder tordApps = new StringBuilder();
|
StringBuilder tordApps = new StringBuilder();
|
||||||
|
|
||||||
for (TorifiedApp tApp:mApps)
|
for (TorifiedApp tApp:mApps)
|
||||||
{
|
{
|
||||||
if (tApp.isTorified())
|
if (tApp.isTorified())
|
||||||
{
|
{
|
||||||
tordApps.append(tApp.getUsername());
|
tordApps.append(tApp.getUsername());
|
||||||
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
|
||||||
*/
|
*/
|
||||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||||
final TorifiedApp app = (TorifiedApp) buttonView.getTag();
|
final TorifiedApp app = (TorifiedApp) buttonView.getTag();
|
||||||
if (app != null) {
|
if (app != null) {
|
||||||
app.setTorified(isChecked);
|
app.setTorified(isChecked);
|
||||||
}
|
}
|
||||||
|
|
||||||
saveAppSettings(this);
|
saveAppSettings(this);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void onClick(View v) {
|
|
||||||
|
|
||||||
CheckBox cbox = (CheckBox)v.getTag();
|
|
||||||
|
|
||||||
final TorifiedApp app = (TorifiedApp)cbox.getTag();
|
public void onClick(View v) {
|
||||||
if (app != null) {
|
|
||||||
app.setTorified(!app.isTorified());
|
|
||||||
cbox.setChecked(app.isTorified());
|
|
||||||
}
|
|
||||||
|
|
||||||
saveAppSettings(this);
|
CheckBox cbox = (CheckBox)v.getTag();
|
||||||
|
|
||||||
}
|
final TorifiedApp app = (TorifiedApp)cbox.getTag();
|
||||||
|
if (app != null) {
|
||||||
|
app.setTorified(!app.isTorified());
|
||||||
|
cbox.setChecked(app.isTorified());
|
||||||
|
}
|
||||||
|
|
||||||
|
saveAppSettings(this);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|