Compare commits
2 Commits
v4.0-unive
...
v1.3-potat
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c97f5c909f | ||
|
|
273b917096 |
@@ -9,15 +9,13 @@ android {
|
|||||||
defaultConfig {
|
defaultConfig {
|
||||||
applicationId "com.cbcren.vpn"
|
applicationId "com.cbcren.vpn"
|
||||||
minSdkVersion 21
|
minSdkVersion 21
|
||||||
targetSdkVersion 34 // Compatible con Android 14/15/16
|
targetSdkVersion 33
|
||||||
versionCode 8
|
versionCode 4
|
||||||
versionName "4.0-universal-embedded"
|
versionName "1.3-potato"
|
||||||
|
|
||||||
multiDexEnabled true
|
multiDexEnabled true
|
||||||
|
|
||||||
// ¡IMPORTANTE! Habilitar ambas arquitecturas
|
|
||||||
ndk {
|
ndk {
|
||||||
abiFilters 'armeabi-v7a', 'arm64-v8a', 'x86', 'x86_64'
|
// Forzar solo 32 bits (ARMv7). Muchas cajas chinas crashean si intentan cargar 64 bits o x86.
|
||||||
|
abiFilters 'armeabi-v7a'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -31,7 +29,5 @@ dependencies {
|
|||||||
implementation 'androidx.appcompat:appcompat:1.2.0'
|
implementation 'androidx.appcompat:appcompat:1.2.0'
|
||||||
implementation 'com.google.android.material:material:1.2.1'
|
implementation 'com.google.android.material:material:1.2.1'
|
||||||
implementation 'androidx.multidex:multidex:2.0.1'
|
implementation 'androidx.multidex:multidex:2.0.1'
|
||||||
|
|
||||||
// Motor WireGuard Embebido (Versión estable 2021)
|
|
||||||
implementation 'com.wireguard.android:tunnel:1.0.20211029'
|
implementation 'com.wireguard.android:tunnel:1.0.20211029'
|
||||||
}
|
}
|
||||||
|
|||||||
Binary file not shown.
@@ -1,4 +1,4 @@
|
|||||||
#Tue Feb 10 00:24:44 CET 2026
|
#Mon Feb 09 23:07:19 CET 2026
|
||||||
com.cbcren.vpn.app-main-15\:/mipmap-anydpi-v26/ic_launcher.xml=/home/ren/androidtv/app/build/intermediates/merged_res/debug/mipmap-anydpi-v26_ic_launcher.xml.flat
|
com.cbcren.vpn.app-main-15\:/mipmap-anydpi-v26/ic_launcher.xml=/home/ren/androidtv/app/build/intermediates/merged_res/debug/mipmap-anydpi-v26_ic_launcher.xml.flat
|
||||||
com.cbcren.vpn.app-main-15\:/layout/activity_main.xml=/home/ren/androidtv/app/build/intermediates/merged_res/debug/layout_activity_main.xml.flat
|
com.cbcren.vpn.app-main-15\:/layout/activity_main.xml=/home/ren/androidtv/app/build/intermediates/merged_res/debug/layout_activity_main.xml.flat
|
||||||
com.cbcren.vpn.app-main-15\:/drawable/ic_launcher_foreground.xml=/home/ren/androidtv/app/build/intermediates/merged_res/debug/drawable_ic_launcher_foreground.xml.flat
|
com.cbcren.vpn.app-main-15\:/drawable/ic_launcher_foreground.xml=/home/ren/androidtv/app/build/intermediates/merged_res/debug/drawable_ic_launcher_foreground.xml.flat
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
#Tue Feb 10 00:24:45 CET 2026
|
#Mon Feb 09 23:07:20 CET 2026
|
||||||
com.cbcren.vpn.app-main-5\:/drawable/ic_launcher_foreground.xml=/home/ren/androidtv/app/build/intermediates/packaged_res/debug/drawable/ic_launcher_foreground.xml
|
com.cbcren.vpn.app-main-5\:/drawable/ic_launcher_foreground.xml=/home/ren/androidtv/app/build/intermediates/packaged_res/debug/drawable/ic_launcher_foreground.xml
|
||||||
com.cbcren.vpn.app-main-5\:/layout/activity_main.xml=/home/ren/androidtv/app/build/intermediates/packaged_res/debug/layout/activity_main.xml
|
com.cbcren.vpn.app-main-5\:/layout/activity_main.xml=/home/ren/androidtv/app/build/intermediates/packaged_res/debug/layout/activity_main.xml
|
||||||
com.cbcren.vpn.app-main-5\:/mipmap-anydpi-v26/ic_launcher.xml=/home/ren/androidtv/app/build/intermediates/packaged_res/debug/mipmap-anydpi-v26/ic_launcher.xml
|
com.cbcren.vpn.app-main-5\:/mipmap-anydpi-v26/ic_launcher.xml=/home/ren/androidtv/app/build/intermediates/packaged_res/debug/mipmap-anydpi-v26/ic_launcher.xml
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1,16 +1,14 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
package="com.cbcren.vpn"
|
package="com.cbcren.vpn"
|
||||||
android:versionCode="8"
|
android:versionCode="4"
|
||||||
android:versionName="4.0-universal-embedded" >
|
android:versionName="1.3-potato" >
|
||||||
|
|
||||||
<uses-sdk
|
<uses-sdk
|
||||||
android:minSdkVersion="21"
|
android:minSdkVersion="21"
|
||||||
android:targetSdkVersion="34" />
|
android:targetSdkVersion="33" />
|
||||||
|
|
||||||
<uses-permission android:name="android.permission.INTERNET" />
|
<uses-permission android:name="android.permission.INTERNET" />
|
||||||
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
|
|
||||||
<uses-permission android:name="android.permission.QUERY_ALL_PACKAGES" />
|
|
||||||
|
|
||||||
<uses-feature
|
<uses-feature
|
||||||
android:name="android.software.leanback"
|
android:name="android.software.leanback"
|
||||||
@@ -23,7 +21,7 @@
|
|||||||
android:name="androidx.multidex.MultiDexApplication"
|
android:name="androidx.multidex.MultiDexApplication"
|
||||||
android:appComponentFactory="androidx.core.app.CoreComponentFactory"
|
android:appComponentFactory="androidx.core.app.CoreComponentFactory"
|
||||||
android:debuggable="true"
|
android:debuggable="true"
|
||||||
android:label="Xuper VPN Universal"
|
android:label="Xuper VPN"
|
||||||
android:theme="@style/Theme.MaterialComponents.Light.NoActionBar" >
|
android:theme="@style/Theme.MaterialComponents.Light.NoActionBar" >
|
||||||
<activity
|
<activity
|
||||||
android:name="com.cbcren.vpn.MainActivity"
|
android:name="com.cbcren.vpn.MainActivity"
|
||||||
@@ -36,7 +34,6 @@
|
|||||||
</intent-filter>
|
</intent-filter>
|
||||||
</activity>
|
</activity>
|
||||||
|
|
||||||
<!-- Servicio VPN Embebido (Parcheado para Android 12+) -->
|
|
||||||
<service
|
<service
|
||||||
android:name="com.wireguard.android.backend.GoBackend$VpnService"
|
android:name="com.wireguard.android.backend.GoBackend$VpnService"
|
||||||
android:exported="true"
|
android:exported="true"
|
||||||
|
|||||||
@@ -1,16 +1,14 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
package="com.cbcren.vpn"
|
package="com.cbcren.vpn"
|
||||||
android:versionCode="8"
|
android:versionCode="4"
|
||||||
android:versionName="4.0-universal-embedded" >
|
android:versionName="1.3-potato" >
|
||||||
|
|
||||||
<uses-sdk
|
<uses-sdk
|
||||||
android:minSdkVersion="21"
|
android:minSdkVersion="21"
|
||||||
android:targetSdkVersion="34" />
|
android:targetSdkVersion="33" />
|
||||||
|
|
||||||
<uses-permission android:name="android.permission.INTERNET" />
|
<uses-permission android:name="android.permission.INTERNET" />
|
||||||
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
|
|
||||||
<uses-permission android:name="android.permission.QUERY_ALL_PACKAGES" />
|
|
||||||
|
|
||||||
<uses-feature
|
<uses-feature
|
||||||
android:name="android.software.leanback"
|
android:name="android.software.leanback"
|
||||||
@@ -23,7 +21,7 @@
|
|||||||
android:name="androidx.multidex.MultiDexApplication"
|
android:name="androidx.multidex.MultiDexApplication"
|
||||||
android:appComponentFactory="androidx.core.app.CoreComponentFactory"
|
android:appComponentFactory="androidx.core.app.CoreComponentFactory"
|
||||||
android:debuggable="true"
|
android:debuggable="true"
|
||||||
android:label="Xuper VPN Universal"
|
android:label="Xuper VPN"
|
||||||
android:theme="@style/Theme.MaterialComponents.Light.NoActionBar" >
|
android:theme="@style/Theme.MaterialComponents.Light.NoActionBar" >
|
||||||
<activity
|
<activity
|
||||||
android:name="com.cbcren.vpn.MainActivity"
|
android:name="com.cbcren.vpn.MainActivity"
|
||||||
@@ -36,7 +34,6 @@
|
|||||||
</intent-filter>
|
</intent-filter>
|
||||||
</activity>
|
</activity>
|
||||||
|
|
||||||
<!-- Servicio VPN Embebido (Parcheado para Android 12+) -->
|
|
||||||
<service
|
<service
|
||||||
android:name="com.wireguard.android.backend.GoBackend$VpnService"
|
android:name="com.wireguard.android.backend.GoBackend$VpnService"
|
||||||
android:exported="true"
|
android:exported="true"
|
||||||
|
|||||||
@@ -11,8 +11,8 @@
|
|||||||
"type": "SINGLE",
|
"type": "SINGLE",
|
||||||
"filters": [],
|
"filters": [],
|
||||||
"attributes": [],
|
"attributes": [],
|
||||||
"versionCode": 8,
|
"versionCode": 4,
|
||||||
"versionName": "4.0-universal-embedded",
|
"versionName": "1.3-potato",
|
||||||
"outputFile": "AndroidManifest.xml"
|
"outputFile": "AndroidManifest.xml"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|||||||
Binary file not shown.
@@ -1,16 +1,14 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
package="com.cbcren.vpn"
|
package="com.cbcren.vpn"
|
||||||
android:versionCode="8"
|
android:versionCode="4"
|
||||||
android:versionName="4.0-universal-embedded" >
|
android:versionName="1.3-potato" >
|
||||||
|
|
||||||
<uses-sdk
|
<uses-sdk
|
||||||
android:minSdkVersion="21"
|
android:minSdkVersion="21"
|
||||||
android:targetSdkVersion="34" />
|
android:targetSdkVersion="33" />
|
||||||
|
|
||||||
<uses-permission android:name="android.permission.INTERNET" />
|
<uses-permission android:name="android.permission.INTERNET" />
|
||||||
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
|
|
||||||
<uses-permission android:name="android.permission.QUERY_ALL_PACKAGES" />
|
|
||||||
|
|
||||||
<uses-feature
|
<uses-feature
|
||||||
android:name="android.software.leanback"
|
android:name="android.software.leanback"
|
||||||
@@ -23,7 +21,7 @@
|
|||||||
android:name="androidx.multidex.MultiDexApplication"
|
android:name="androidx.multidex.MultiDexApplication"
|
||||||
android:appComponentFactory="androidx.core.app.CoreComponentFactory"
|
android:appComponentFactory="androidx.core.app.CoreComponentFactory"
|
||||||
android:debuggable="true"
|
android:debuggable="true"
|
||||||
android:label="Xuper VPN Universal"
|
android:label="Xuper VPN"
|
||||||
android:theme="@style/Theme.MaterialComponents.Light.NoActionBar" >
|
android:theme="@style/Theme.MaterialComponents.Light.NoActionBar" >
|
||||||
<activity
|
<activity
|
||||||
android:name="com.cbcren.vpn.MainActivity"
|
android:name="com.cbcren.vpn.MainActivity"
|
||||||
@@ -36,7 +34,6 @@
|
|||||||
</intent-filter>
|
</intent-filter>
|
||||||
</activity>
|
</activity>
|
||||||
|
|
||||||
<!-- Servicio VPN Embebido (Parcheado para Android 12+) -->
|
|
||||||
<service
|
<service
|
||||||
android:name="com.wireguard.android.backend.GoBackend$VpnService"
|
android:name="com.wireguard.android.backend.GoBackend$VpnService"
|
||||||
android:exported="true"
|
android:exported="true"
|
||||||
|
|||||||
@@ -11,8 +11,8 @@
|
|||||||
"type": "SINGLE",
|
"type": "SINGLE",
|
||||||
"filters": [],
|
"filters": [],
|
||||||
"attributes": [],
|
"attributes": [],
|
||||||
"versionCode": 8,
|
"versionCode": 4,
|
||||||
"versionName": "4.0-universal-embedded",
|
"versionName": "1.3-potato",
|
||||||
"outputFile": "AndroidManifest.xml"
|
"outputFile": "AndroidManifest.xml"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -5,13 +5,13 @@
|
|||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:gravity="center"
|
android:gravity="center"
|
||||||
android:padding="32dp"
|
android:padding="32dp"
|
||||||
android:background="#222222">
|
android:background="#121212">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/statusText"
|
android:id="@+id/statusText"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="XUPER VPN UNIVERSAL"
|
android:text="Listo para conectar"
|
||||||
android:textColor="#FFFFFF"
|
android:textColor="#FFFFFF"
|
||||||
android:textSize="24sp"
|
android:textSize="24sp"
|
||||||
android:textStyle="bold"
|
android:textStyle="bold"
|
||||||
@@ -19,10 +19,9 @@
|
|||||||
|
|
||||||
<Button
|
<Button
|
||||||
android:id="@+id/connectBtn"
|
android:id="@+id/connectBtn"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="200dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="INICIAR"
|
android:text="ACTIVAR (60s)"
|
||||||
android:padding="20dp"
|
android:padding="16dp"/>
|
||||||
android:textSize="18sp"/>
|
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|||||||
@@ -11,8 +11,8 @@
|
|||||||
"type": "SINGLE",
|
"type": "SINGLE",
|
||||||
"filters": [],
|
"filters": [],
|
||||||
"attributes": [],
|
"attributes": [],
|
||||||
"versionCode": 8,
|
"versionCode": 4,
|
||||||
"versionName": "4.0-universal-embedded",
|
"versionName": "1.3-potato",
|
||||||
"outputFile": "resources-debug.ap_"
|
"outputFile": "resources-debug.ap_"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -11,8 +11,8 @@
|
|||||||
"type": "SINGLE",
|
"type": "SINGLE",
|
||||||
"filters": [],
|
"filters": [],
|
||||||
"attributes": [],
|
"attributes": [],
|
||||||
"versionCode": 8,
|
"versionCode": 4,
|
||||||
"versionName": "4.0-universal-embedded",
|
"versionName": "1.3-potato",
|
||||||
"outputFile": "app-debug.apk"
|
"outputFile": "app-debug.apk"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|||||||
Binary file not shown.
@@ -3,14 +3,12 @@
|
|||||||
xmlns:tools="http://schemas.android.com/tools">
|
xmlns:tools="http://schemas.android.com/tools">
|
||||||
|
|
||||||
<uses-permission android:name="android.permission.INTERNET" />
|
<uses-permission android:name="android.permission.INTERNET" />
|
||||||
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
|
|
||||||
<uses-permission android:name="android.permission.QUERY_ALL_PACKAGES" tools:ignore="QueryAllPackagesPermission" />
|
|
||||||
|
|
||||||
<uses-feature android:name="android.software.leanback" android:required="false" />
|
<uses-feature android:name="android.software.leanback" android:required="false" />
|
||||||
<uses-feature android:name="android.hardware.touchscreen" android:required="false" />
|
<uses-feature android:name="android.hardware.touchscreen" android:required="false" />
|
||||||
|
|
||||||
<application
|
<application
|
||||||
android:label="Xuper VPN Universal"
|
android:label="Xuper VPN"
|
||||||
android:name="androidx.multidex.MultiDexApplication"
|
android:name="androidx.multidex.MultiDexApplication"
|
||||||
android:theme="@style/Theme.MaterialComponents.Light.NoActionBar">
|
android:theme="@style/Theme.MaterialComponents.Light.NoActionBar">
|
||||||
|
|
||||||
@@ -23,7 +21,6 @@
|
|||||||
</intent-filter>
|
</intent-filter>
|
||||||
</activity>
|
</activity>
|
||||||
|
|
||||||
<!-- Servicio VPN Embebido (Parcheado para Android 12+) -->
|
|
||||||
<service android:name="com.wireguard.android.backend.GoBackend$VpnService"
|
<service android:name="com.wireguard.android.backend.GoBackend$VpnService"
|
||||||
android:exported="true"
|
android:exported="true"
|
||||||
android:permission="android.permission.BIND_VPN_SERVICE"
|
android:permission="android.permission.BIND_VPN_SERVICE"
|
||||||
|
|||||||
@@ -1,17 +1,15 @@
|
|||||||
package com.cbcren.vpn;
|
package com.cbcren.vpn;
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.content.Intent;
|
|
||||||
import android.content.pm.PackageManager;
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.CountDownTimer;
|
import android.os.CountDownTimer;
|
||||||
import android.os.Handler;
|
import android.view.View;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
import android.view.View;
|
import android.content.Intent;
|
||||||
|
|
||||||
// Imports del Motor Embebido
|
// Imports de WireGuard
|
||||||
import com.wireguard.android.backend.Backend;
|
import com.wireguard.android.backend.Backend;
|
||||||
import com.wireguard.android.backend.GoBackend;
|
import com.wireguard.android.backend.GoBackend;
|
||||||
import com.wireguard.android.backend.Tunnel;
|
import com.wireguard.android.backend.Tunnel;
|
||||||
@@ -21,24 +19,23 @@ import com.wireguard.config.Peer;
|
|||||||
import com.wireguard.config.InetEndpoint;
|
import com.wireguard.config.InetEndpoint;
|
||||||
import com.wireguard.config.InetNetwork;
|
import com.wireguard.config.InetNetwork;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
|
|
||||||
public class MainActivity extends Activity {
|
public class MainActivity extends Activity {
|
||||||
|
|
||||||
// --- CONFIGURACIÓN WIREGUARD ---
|
private TextView statusText;
|
||||||
|
private Button connectBtn;
|
||||||
|
private Backend backend;
|
||||||
|
private Config config;
|
||||||
|
private Tunnel tunnel;
|
||||||
|
private CountDownTimer timer;
|
||||||
|
|
||||||
|
// --- CONFIGURACIÓN QUEMADA ---
|
||||||
private static final String CLIENT_PRIV_KEY = "ULfX2KspqzSv9cgfvYxGjbL/3FkOS27iCVCyL+LWGmE=";
|
private static final String CLIENT_PRIV_KEY = "ULfX2KspqzSv9cgfvYxGjbL/3FkOS27iCVCyL+LWGmE=";
|
||||||
private static final String SERVER_PUB_KEY = "44dNaTOCc/nY6vkqy3fJ+L1RqWDqFqEaEq1IBL/InRM=";
|
private static final String SERVER_PUB_KEY = "44dNaTOCc/nY6vkqy3fJ+L1RqWDqFqEaEq1IBL/InRM=";
|
||||||
private static final String SERVER_ENDPOINT = "194.163.191.200:51820";
|
private static final String SERVER_ENDPOINT = "194.163.191.200:51820";
|
||||||
private static final String CLIENT_IP = "10.66.66.2/32";
|
private static final String CLIENT_IP = "10.66.66.2/32";
|
||||||
|
// -----------------------------
|
||||||
// --- CONFIGURACIÓN APP OBJETIVO ---
|
|
||||||
private static final String TARGET_PACKAGE = "com.android.mgstv"; // XuperTV
|
|
||||||
// ----------------------------------
|
|
||||||
|
|
||||||
private Backend backend;
|
|
||||||
private Tunnel tunnel;
|
|
||||||
private Config config;
|
|
||||||
private TextView statusText;
|
|
||||||
private Button connectBtn;
|
|
||||||
private CountDownTimer timer;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
@@ -47,30 +44,17 @@ public class MainActivity extends Activity {
|
|||||||
|
|
||||||
statusText = findViewById(R.id.statusText);
|
statusText = findViewById(R.id.statusText);
|
||||||
connectBtn = findViewById(R.id.connectBtn);
|
connectBtn = findViewById(R.id.connectBtn);
|
||||||
connectBtn.setText("ACTIVAR Y ABRIR TV");
|
|
||||||
|
|
||||||
// 1. Inicializar Motor VPN
|
// Inicializar Backend
|
||||||
try {
|
try {
|
||||||
backend = new GoBackend(getApplicationContext());
|
backend = new GoBackend(getApplicationContext());
|
||||||
tunnel = new SimpleTunnel("XuperVPN");
|
tunnel = new SimpleTunnel("XuperTunnel");
|
||||||
config = createConfig();
|
config = createConfig();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
statusText.setText("Error Motor VPN: " + e.getMessage());
|
statusText.setText("Error Init: " + e.getMessage());
|
||||||
connectBtn.setEnabled(false);
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 2. Verificar XuperTV
|
connectBtn.setOnClickListener(v -> startVpnSequence());
|
||||||
if (!isPackageInstalled(TARGET_PACKAGE)) {
|
|
||||||
Toast.makeText(this, "Aviso: XuperTV no detectada", Toast.LENGTH_LONG).show();
|
|
||||||
}
|
|
||||||
|
|
||||||
connectBtn.setOnClickListener(new View.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View v) {
|
|
||||||
startVpnSequence();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private Config createConfig() throws Exception {
|
private Config createConfig() throws Exception {
|
||||||
@@ -82,7 +66,7 @@ public class MainActivity extends Activity {
|
|||||||
Peer.Builder peerBuilder = new Peer.Builder();
|
Peer.Builder peerBuilder = new Peer.Builder();
|
||||||
peerBuilder.parsePublicKey(SERVER_PUB_KEY);
|
peerBuilder.parsePublicKey(SERVER_PUB_KEY);
|
||||||
peerBuilder.parseEndpoint(SERVER_ENDPOINT);
|
peerBuilder.parseEndpoint(SERVER_ENDPOINT);
|
||||||
peerBuilder.parseAllowedIPs("0.0.0.0/0");
|
peerBuilder.parseAllowedIPs("0.0.0.0/0"); // Todo por el tunel
|
||||||
|
|
||||||
return new Config.Builder()
|
return new Config.Builder()
|
||||||
.setInterface(interfaceBuilder.build())
|
.setInterface(interfaceBuilder.build())
|
||||||
@@ -91,13 +75,19 @@ public class MainActivity extends Activity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void startVpnSequence() {
|
private void startVpnSequence() {
|
||||||
// Pedir permiso de VPN al sistema (Android dialog)
|
if (backend == null) return;
|
||||||
|
|
||||||
|
connectBtn.setEnabled(false);
|
||||||
|
statusText.setText("Conectando...");
|
||||||
|
|
||||||
|
// Lanzar Intent de VPN (El sistema pedirá permiso la primera vez)
|
||||||
Intent intent = GoBackend.VpnService.prepare(this);
|
Intent intent = GoBackend.VpnService.prepare(this);
|
||||||
if (intent != null) {
|
if (intent != null) {
|
||||||
startActivityForResult(intent, 0);
|
startActivityForResult(intent, 0);
|
||||||
} else {
|
return;
|
||||||
onActivityResult(0, RESULT_OK, null);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
connectTunnel();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -105,80 +95,52 @@ public class MainActivity extends Activity {
|
|||||||
if (resultCode == RESULT_OK) {
|
if (resultCode == RESULT_OK) {
|
||||||
connectTunnel();
|
connectTunnel();
|
||||||
} else {
|
} else {
|
||||||
statusText.setText("Permiso de VPN denegado");
|
statusText.setText("Permiso denegado");
|
||||||
|
connectBtn.setEnabled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void connectTunnel() {
|
private void connectTunnel() {
|
||||||
try {
|
try {
|
||||||
// Asegurar limpieza
|
// Si ya está corriendo, apagar primero
|
||||||
try { backend.setState(tunnel, Tunnel.State.DOWN, null); } catch (Exception e) {}
|
backend.setState(tunnel, Tunnel.State.DOWN, null);
|
||||||
|
|
||||||
// CONECTAR
|
// Encender
|
||||||
backend.setState(tunnel, Tunnel.State.UP, config);
|
backend.setState(tunnel, Tunnel.State.UP, config);
|
||||||
|
|
||||||
statusText.setText("CONECTADO.\nLanzando TV en 2s...");
|
startTimer();
|
||||||
connectBtn.setEnabled(false);
|
|
||||||
|
|
||||||
// Auto-Launch XuperTV
|
|
||||||
new Handler().postDelayed(new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
launchTargetApp();
|
|
||||||
}
|
|
||||||
}, 2000);
|
|
||||||
|
|
||||||
// Temporizador 60s
|
|
||||||
timer = new CountDownTimer(60000, 1000) {
|
|
||||||
public void onTick(long millisUntilFinished) {
|
|
||||||
statusText.setText("VPN ACTIVA: " + millisUntilFinished / 1000 + "s");
|
|
||||||
}
|
|
||||||
|
|
||||||
public void onFinish() {
|
|
||||||
disconnectTunnel();
|
|
||||||
}
|
|
||||||
}.start();
|
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
statusText.setText("Error Conexión: " + e.getMessage());
|
statusText.setText("Error Conexión: " + e.getMessage());
|
||||||
connectBtn.setEnabled(true);
|
connectBtn.setEnabled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void startTimer() {
|
||||||
|
timer = new CountDownTimer(60000, 1000) {
|
||||||
|
public void onTick(long millisUntilFinished) {
|
||||||
|
statusText.setText("VPN ACTIVA\n" + (millisUntilFinished / 1000) + " segundos");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onFinish() {
|
||||||
|
disconnectTunnel();
|
||||||
|
}
|
||||||
|
}.start();
|
||||||
|
}
|
||||||
|
|
||||||
private void disconnectTunnel() {
|
private void disconnectTunnel() {
|
||||||
try {
|
try {
|
||||||
if (backend != null) {
|
if (backend != null) {
|
||||||
backend.setState(tunnel, Tunnel.State.DOWN, null);
|
backend.setState(tunnel, Tunnel.State.DOWN, null);
|
||||||
}
|
}
|
||||||
statusText.setText("DESCONECTADO.\nListo.");
|
statusText.setText("Desconectado.\nAbre XuperTV.");
|
||||||
connectBtn.setEnabled(true);
|
connectBtn.setEnabled(true);
|
||||||
connectBtn.setText("REINICIAR");
|
connectBtn.setText("RECONECTAR");
|
||||||
} catch (Exception e) {
|
|
||||||
// Ignorar
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean isPackageInstalled(String packageName) {
|
|
||||||
try {
|
|
||||||
getPackageManager().getPackageInfo(packageName, 0);
|
|
||||||
return true;
|
|
||||||
} catch (PackageManager.NameNotFoundException e) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void launchTargetApp() {
|
|
||||||
try {
|
|
||||||
Intent launchIntent = getPackageManager().getLaunchIntentForPackage(TARGET_PACKAGE);
|
|
||||||
if (launchIntent != null) {
|
|
||||||
startActivity(launchIntent);
|
|
||||||
Toast.makeText(this, "Abriendo XuperTV...", Toast.LENGTH_SHORT).show();
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
// Ignorar
|
// Ignorar
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Clase auxiliar simple para identificar el tunel
|
||||||
private static class SimpleTunnel implements Tunnel {
|
private static class SimpleTunnel implements Tunnel {
|
||||||
private final String name;
|
private final String name;
|
||||||
SimpleTunnel(String name) { this.name = name; }
|
SimpleTunnel(String name) { this.name = name; }
|
||||||
|
|||||||
@@ -5,13 +5,13 @@
|
|||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:gravity="center"
|
android:gravity="center"
|
||||||
android:padding="32dp"
|
android:padding="32dp"
|
||||||
android:background="#222222">
|
android:background="#121212">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/statusText"
|
android:id="@+id/statusText"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="XUPER VPN UNIVERSAL"
|
android:text="Listo para conectar"
|
||||||
android:textColor="#FFFFFF"
|
android:textColor="#FFFFFF"
|
||||||
android:textSize="24sp"
|
android:textSize="24sp"
|
||||||
android:textStyle="bold"
|
android:textStyle="bold"
|
||||||
@@ -19,10 +19,9 @@
|
|||||||
|
|
||||||
<Button
|
<Button
|
||||||
android:id="@+id/connectBtn"
|
android:id="@+id/connectBtn"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="200dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="INICIAR"
|
android:text="ACTIVAR (60s)"
|
||||||
android:padding="20dp"
|
android:padding="16dp"/>
|
||||||
android:textSize="18sp"/>
|
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|||||||
Reference in New Issue
Block a user