Skip to content

Commit 5248749

Browse files
author
jpkrause
committed
Added support for Marshmallow on Android Emulators using new build type that is signed with the platform keystore
1 parent 3dc0321 commit 5248749

File tree

8 files changed

+60
-50
lines changed

8 files changed

+60
-50
lines changed

README.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
11
# AndroidProxySetter
2-
An android app that sets the proxy settings for a wifi access point by using adb.
3-
This DOES NOT require root and will work with any device that has USB debugging on or any simulator (including Genymotion).
2+
An android app that sets the proxy settings for a wifi access point by using adb.
3+
This DOES NOT require root and will work with any device that has USB debugging on or any emulator (including Genymotion).
44

55
This app uses the Android Proxy Library from [here](https://github.com/shouldit/android-proxy/tree/master/android-proxy-library)
66

7+
#NOTE
8+
This app now works on Android Emulators and Genymotion Emulators on Android Marshmallow 6.0 if you build/install the `emulator` build variant or APK.
9+
The `emulator` variant is signed with the Android Emulator platform keystore and thus has permissions to modify the wifi access points again.
10+
The `emulator` apk will only work on emulators, not real devices.
11+
712
# Usage
813

914
Build (or [download](https://github.com/jpkrause/AndroidProxySetter/releases)) and install the apk to your device, then perform the following actions.

app/build.gradle

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -20,27 +20,33 @@
2020
apply plugin: 'com.android.application'
2121

2222
android {
23-
compileSdkVersion 23
24-
buildToolsVersion "23.0.3"
23+
compileSdkVersion 24
24+
buildToolsVersion '23.0.3'
2525
defaultConfig {
2626
applicationId 'tk.elevenk.proxysetter'
2727
minSdkVersion 15
28-
targetSdkVersion 22
29-
versionCode 4
30-
versionName "0.1.4"
28+
targetSdkVersion 24
29+
versionCode 5
30+
versionName "0.2"
3131
}
32-
buildTypes {
33-
release {
34-
minifyEnabled false
35-
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
32+
signingConfigs {
33+
emulatorSystemKeystore {
34+
storeFile file("keystore/platform.keystore")
35+
keyAlias "platform"
36+
37+
storePassword "android"
38+
keyPassword "android"
3639
}
3740
}
38-
productFlavors {
41+
buildTypes {
42+
emulator {
43+
signingConfig signingConfigs.emulatorSystemKeystore
44+
}
3945
}
4046
}
4147

4248
dependencies {
43-
compile fileTree(dir: 'libs', include: ['*.jar'])
44-
compile 'com.android.support:appcompat-v7:23.2.1'
45-
compile 'be.shouldit:android-proxy-library:4.2.6'
49+
compile fileTree(include: ['*.jar'], dir: 'libs')
50+
compile 'com.android.support:appcompat-v7:24.2.0'
51+
compile 'be.shouldit:android-proxy-library:4.2.6'
4652
}

app/keystore/platform.keystore

2.49 KB
Binary file not shown.
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!--
3+
~ Copyright (c) 2016 John Paul Krause.
4+
~ AndroidManifest.xml is part of AndroidProxySetter.
5+
~
6+
~ AndroidProxySetter is free software: you can redistribute it and/or modify
7+
~ iit under the terms of the GNU General Public License as published by
8+
~ the Free Software Foundation, either version 3 of the License, or
9+
~ (at your option) any later version.
10+
~
11+
~ AndroidProxySetter is distributed in the hope that it will be useful,
12+
~ but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
~ GNU General Public License for more details.
15+
~
16+
~ You should have received a copy of the GNU General Public License
17+
~ along with AndroidProxySetter. If not, see <http://www.gnu.org/licenses/>.
18+
~
19+
-->
20+
21+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
22+
package="tk.elevek.proxysetter"
23+
android:sharedUserId="android.uid.system">
24+
</manifest>

app/src/main/java/tk/elevenk/proxysetter/MainActivity.java

Lines changed: 3 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -20,38 +20,15 @@
2020
package tk.elevenk.proxysetter;
2121

2222
import android.app.Activity;
23-
import android.content.BroadcastReceiver;
24-
import android.content.Context;
2523
import android.content.Intent;
26-
import android.content.IntentFilter;
27-
import android.net.ConnectivityManager;
28-
import android.net.NetworkInfo;
29-
import android.net.wifi.WifiConfiguration;
30-
import android.net.wifi.WifiManager;
31-
import android.os.AsyncTask;
3224
import android.os.Bundle;
33-
import android.os.Looper;
3425
import android.util.Log;
3526
import android.widget.Toast;
36-
import be.shouldit.proxy.lib.APL;
37-
import be.shouldit.proxy.lib.APLNetworkId;
38-
import be.shouldit.proxy.lib.WiFiApConfig;
39-
import be.shouldit.proxy.lib.enums.SecurityType;
40-
import be.shouldit.proxy.lib.reflection.android.ProxySetting;
41-
42-
import java.util.BitSet;
43-
import java.util.Map;
44-
import java.util.concurrent.TimeoutException;
4527

4628

4729
public class MainActivity extends Activity {
4830

4931
private static final String TAG = "ProxySetterApp";
50-
private static Activity thisActivity;
51-
52-
public MainActivity(){
53-
thisActivity = this;
54-
}
5532

5633
@Override
5734
protected void onCreate(Bundle savedInstanceState) {
@@ -80,13 +57,12 @@ private boolean validateIntent(Intent intent) {
8057
*
8158
* @param msg Message to show/log
8259
*/
83-
public static void showPopup(final String msg) {
84-
thisActivity.runOnUiThread(new Runnable() {
60+
public void showPopup(final String msg) {
61+
this.runOnUiThread(new Runnable() {
8562
@Override
8663
public void run() {
87-
Toast.makeText(thisActivity.getBaseContext(), msg, Toast.LENGTH_SHORT).show();
64+
Toast.makeText(getBaseContext(), msg, Toast.LENGTH_SHORT).show();
8865
Log.d(TAG, msg);
89-
9066
}
9167
});
9268
}

app/src/main/java/tk/elevenk/proxysetter/ProxyChangeAsync.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,12 @@
3232
*/
3333
public class ProxyChangeAsync extends AsyncTask<Object, String, Void> {
3434

35-
private Activity activity;
35+
private MainActivity activity;
3636
private ProxyChangeExecutor executor;
3737

3838
private static final String TAG = "ProxySetterApp";
3939

40-
public ProxyChangeAsync(Activity activity) {
40+
public ProxyChangeAsync(MainActivity activity) {
4141
this.activity = activity;
4242
}
4343

@@ -47,12 +47,11 @@ protected void onPreExecute() {
4747
// init executor and register it to receive wifi state change broadcasts
4848
executor = new ProxyChangeExecutor(activity, this);
4949
activity.getApplicationContext().registerReceiver(executor, new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION));
50+
onProgressUpdate("Executing proxy change request...");
5051
}
5152

5253
@Override
5354
protected Void doInBackground(Object... params) {
54-
onProgressUpdate("Executing proxy change request...");
55-
5655
// Looper is needed to handle broadcast messages
5756
try {
5857
Looper.prepare();
@@ -68,7 +67,7 @@ protected Void doInBackground(Object... params) {
6867
public void onProgressUpdate(String... values) {
6968
super.onProgressUpdate(values);
7069
final String msg = values[0];
71-
MainActivity.showPopup(msg);
70+
activity.showPopup(msg);
7271
}
7372

7473
@Override

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ buildscript {
2424
jcenter()
2525
}
2626
dependencies {
27-
classpath 'com.android.tools.build:gradle:1.0.0'
27+
classpath 'com.android.tools.build:gradle:2.2.0-beta1'
2828

2929
// NOTE: Do not place your application dependencies here; they belong
3030
// in the individual module build.gradle files
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
#Wed Apr 10 15:27:10 PDT 2013
1+
#Tue Aug 23 14:17:23 PDT 2016
22
distributionBase=GRADLE_USER_HOME
33
distributionPath=wrapper/dists
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists
6-
distributionUrl=https\://services.gradle.org/distributions/gradle-2.2.1-all.zip
6+
distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip

0 commit comments

Comments
 (0)