2 Commits

39 changed files with 106 additions and 88 deletions

View File

@@ -9,12 +9,15 @@ android {
defaultConfig {
applicationId "com.cbcren.vpn"
minSdkVersion 21
targetSdkVersion 33
versionCode 5
versionName "2.0-auto"
targetSdkVersion 34 // Compatible con Android 14/15/16
versionCode 8
versionName "4.0-universal-embedded"
multiDexEnabled true
// ¡IMPORTANTE! Habilitar ambas arquitecturas
ndk {
abiFilters 'armeabi-v7a'
abiFilters 'armeabi-v7a', 'arm64-v8a', 'x86', 'x86_64'
}
}
@@ -28,5 +31,7 @@ dependencies {
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'com.google.android.material:material:1.2.1'
implementation 'androidx.multidex:multidex:2.0.1'
// Motor WireGuard Embebido (Versión estable 2021)
implementation 'com.wireguard.android:tunnel:1.0.20211029'
}

View File

@@ -1,4 +1,4 @@
#Tue Feb 10 00:08:21 CET 2026
#Tue Feb 10 00:24:44 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\:/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

View File

@@ -1,4 +1,4 @@
#Tue Feb 10 00:08:21 CET 2026
#Tue Feb 10 00:24:45 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\:/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

View File

@@ -1,15 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.cbcren.vpn"
android:versionCode="5"
android:versionName="2.0-auto" >
android:versionCode="8"
android:versionName="4.0-universal-embedded" >
<uses-sdk
android:minSdkVersion="21"
android:targetSdkVersion="33" />
android:targetSdkVersion="34" />
<uses-permission android:name="android.permission.INTERNET" />
<!-- Permiso para saber si la app está instalada -->
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.QUERY_ALL_PACKAGES" />
<uses-feature
@@ -23,7 +23,7 @@
android:name="androidx.multidex.MultiDexApplication"
android:appComponentFactory="androidx.core.app.CoreComponentFactory"
android:debuggable="true"
android:label="Xuper VPN Auto"
android:label="Xuper VPN Universal"
android:theme="@style/Theme.MaterialComponents.Light.NoActionBar" >
<activity
android:name="com.cbcren.vpn.MainActivity"
@@ -36,6 +36,7 @@
</intent-filter>
</activity>
<!-- Servicio VPN Embebido (Parcheado para Android 12+) -->
<service
android:name="com.wireguard.android.backend.GoBackend$VpnService"
android:exported="true"

View File

@@ -1,15 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.cbcren.vpn"
android:versionCode="5"
android:versionName="2.0-auto" >
android:versionCode="8"
android:versionName="4.0-universal-embedded" >
<uses-sdk
android:minSdkVersion="21"
android:targetSdkVersion="33" />
android:targetSdkVersion="34" />
<uses-permission android:name="android.permission.INTERNET" />
<!-- Permiso para saber si la app está instalada -->
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.QUERY_ALL_PACKAGES" />
<uses-feature
@@ -23,7 +23,7 @@
android:name="androidx.multidex.MultiDexApplication"
android:appComponentFactory="androidx.core.app.CoreComponentFactory"
android:debuggable="true"
android:label="Xuper VPN Auto"
android:label="Xuper VPN Universal"
android:theme="@style/Theme.MaterialComponents.Light.NoActionBar" >
<activity
android:name="com.cbcren.vpn.MainActivity"
@@ -36,6 +36,7 @@
</intent-filter>
</activity>
<!-- Servicio VPN Embebido (Parcheado para Android 12+) -->
<service
android:name="com.wireguard.android.backend.GoBackend$VpnService"
android:exported="true"

View File

@@ -11,8 +11,8 @@
"type": "SINGLE",
"filters": [],
"attributes": [],
"versionCode": 5,
"versionName": "2.0-auto",
"versionCode": 8,
"versionName": "4.0-universal-embedded",
"outputFile": "AndroidManifest.xml"
}
],

View File

@@ -1,15 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.cbcren.vpn"
android:versionCode="5"
android:versionName="2.0-auto" >
android:versionCode="8"
android:versionName="4.0-universal-embedded" >
<uses-sdk
android:minSdkVersion="21"
android:targetSdkVersion="33" />
android:targetSdkVersion="34" />
<uses-permission android:name="android.permission.INTERNET" />
<!-- Permiso para saber si la app está instalada -->
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.QUERY_ALL_PACKAGES" />
<uses-feature
@@ -23,7 +23,7 @@
android:name="androidx.multidex.MultiDexApplication"
android:appComponentFactory="androidx.core.app.CoreComponentFactory"
android:debuggable="true"
android:label="Xuper VPN Auto"
android:label="Xuper VPN Universal"
android:theme="@style/Theme.MaterialComponents.Light.NoActionBar" >
<activity
android:name="com.cbcren.vpn.MainActivity"
@@ -36,6 +36,7 @@
</intent-filter>
</activity>
<!-- Servicio VPN Embebido (Parcheado para Android 12+) -->
<service
android:name="com.wireguard.android.backend.GoBackend$VpnService"
android:exported="true"

View File

@@ -11,8 +11,8 @@
"type": "SINGLE",
"filters": [],
"attributes": [],
"versionCode": 5,
"versionName": "2.0-auto",
"versionCode": 8,
"versionName": "4.0-universal-embedded",
"outputFile": "AndroidManifest.xml"
}
],

View File

@@ -11,17 +11,17 @@
android:id="@+id/statusText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="VPN + XUPER TV"
android:text="XUPER VPN UNIVERSAL"
android:textColor="#FFFFFF"
android:textSize="24sp"
android:textStyle="bold"
android:layout_marginBottom="32dp"/>
<Button
android:id="@+id/actionButton"
android:id="@+id/connectBtn"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="ACTIVAR Y ABRIR TV"
android:text="INICIAR"
android:padding="20dp"
android:textSize="18sp"/>

View File

@@ -11,8 +11,8 @@
"type": "SINGLE",
"filters": [],
"attributes": [],
"versionCode": 5,
"versionName": "2.0-auto",
"versionCode": 8,
"versionName": "4.0-universal-embedded",
"outputFile": "resources-debug.ap_"
}
],

View File

@@ -11,8 +11,8 @@
"type": "SINGLE",
"filters": [],
"attributes": [],
"versionCode": 5,
"versionName": "2.0-auto",
"versionCode": 8,
"versionName": "4.0-universal-embedded",
"outputFile": "app-debug.apk"
}
],

View File

@@ -3,14 +3,14 @@
xmlns:tools="http://schemas.android.com/tools">
<uses-permission android:name="android.permission.INTERNET" />
<!-- Permiso para saber si la app está instalada -->
<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.hardware.touchscreen" android:required="false" />
<application
android:label="Xuper VPN Auto"
android:label="Xuper VPN Universal"
android:name="androidx.multidex.MultiDexApplication"
android:theme="@style/Theme.MaterialComponents.Light.NoActionBar">
@@ -23,6 +23,7 @@
</intent-filter>
</activity>
<!-- Servicio VPN Embebido (Parcheado para Android 12+) -->
<service android:name="com.wireguard.android.backend.GoBackend$VpnService"
android:exported="true"
android:permission="android.permission.BIND_VPN_SERVICE"

View File

@@ -5,36 +5,39 @@ import android.content.Intent;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.os.CountDownTimer;
import android.os.Handler;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;
import android.view.View;
import android.os.Handler;
// Imports del Motor Embebido
import com.wireguard.android.backend.Backend;
import com.wireguard.android.backend.GoBackend;
import com.wireguard.android.backend.Tunnel;
import com.wireguard.config.Config;
import com.wireguard.config.Interface;
import com.wireguard.config.Peer;
import com.wireguard.config.InetEndpoint;
import com.wireguard.config.InetNetwork;
public class MainActivity extends Activity {
// --- CONFIGURACIÓN ---
// --- CONFIGURACIÓN WIREGUARD ---
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_ENDPOINT = "194.163.191.200:51820";
private static final String CLIENT_IP = "10.66.66.2/32";
// App a lanzar
private static final String TARGET_PACKAGE = "com.android.mgstv";
// ---------------------
// --- 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 actionButton;
private Button connectBtn;
private CountDownTimer timer;
@Override
@@ -43,53 +46,33 @@ public class MainActivity extends Activity {
setContentView(R.layout.activity_main);
statusText = findViewById(R.id.statusText);
actionButton = findViewById(R.id.actionButton);
connectBtn = findViewById(R.id.connectBtn);
connectBtn.setText("ACTIVAR Y ABRIR TV");
// Inicializar Backend
// 1. Inicializar Motor VPN
try {
backend = new GoBackend(getApplicationContext());
tunnel = new SimpleTunnel("XuperVPN");
config = createConfig();
} catch (Exception e) {
statusText.setText("Error Backend: " + e.getMessage());
statusText.setText("Error Motor VPN: " + e.getMessage());
connectBtn.setEnabled(false);
return;
}
// Verificar si XuperTV está instalada
// 2. Verificar XuperTV
if (!isPackageInstalled(TARGET_PACKAGE)) {
Toast.makeText(this, "Aviso: XuperTV no encontrada (" + TARGET_PACKAGE + ")", Toast.LENGTH_LONG).show();
Toast.makeText(this, "Aviso: XuperTV no detectada", Toast.LENGTH_LONG).show();
}
actionButton.setOnClickListener(new View.OnClickListener() {
connectBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
startVpn();
startVpnSequence();
}
});
}
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, "Lanzando XuperTV...", Toast.LENGTH_SHORT).show();
} else {
Toast.makeText(this, "Instala XuperTV para auto-inicio", Toast.LENGTH_LONG).show();
}
} catch (Exception e) {
// Ignorar
}
}
private Config createConfig() throws Exception {
Interface.Builder interfaceBuilder = new Interface.Builder();
interfaceBuilder.parsePrivateKey(CLIENT_PRIV_KEY);
@@ -107,7 +90,8 @@ public class MainActivity extends Activity {
.build();
}
private void startVpn() {
private void startVpnSequence() {
// Pedir permiso de VPN al sistema (Android dialog)
Intent intent = GoBackend.VpnService.prepare(this);
if (intent != null) {
startActivityForResult(intent, 0);
@@ -121,29 +105,30 @@ public class MainActivity extends Activity {
if (resultCode == RESULT_OK) {
connectTunnel();
} else {
statusText.setText("Permiso denegado");
statusText.setText("Permiso de VPN denegado");
}
}
private void connectTunnel() {
try {
// Asegurar limpieza
try { backend.setState(tunnel, Tunnel.State.DOWN, null); } catch (Exception e) {}
// Conectar
// CONECTAR
backend.setState(tunnel, Tunnel.State.UP, config);
statusText.setText("CONECTADO - LANZANDO TV...");
actionButton.setEnabled(false);
// Lanzar la app con un pequeño retraso para asegurar que el túnel esté listo
statusText.setText("CONECTADO.\nLanzando TV en 2s...");
connectBtn.setEnabled(false);
// Auto-Launch XuperTV
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
launchTargetApp();
}
}, 2000); // 2 segundos de espera
}, 2000);
// Iniciar temporizador
// Temporizador 60s
timer = new CountDownTimer(60000, 1000) {
public void onTick(long millisUntilFinished) {
statusText.setText("VPN ACTIVA: " + millisUntilFinished / 1000 + "s");
@@ -155,18 +140,42 @@ public class MainActivity extends Activity {
}.start();
} catch (Exception e) {
statusText.setText("Error al conectar: " + e.getMessage());
statusText.setText("Error Conexión: " + e.getMessage());
connectBtn.setEnabled(true);
}
}
private void disconnectTunnel() {
try {
backend.setState(tunnel, Tunnel.State.DOWN, null);
statusText.setText("DESCONECTADO. Disfruta!");
actionButton.setEnabled(true);
actionButton.setText("RECONECTAR");
if (backend != null) {
backend.setState(tunnel, Tunnel.State.DOWN, null);
}
statusText.setText("DESCONECTADO.\nListo.");
connectBtn.setEnabled(true);
connectBtn.setText("REINICIAR");
} catch (Exception e) {
statusText.setText("Error desconexión: " + e.getMessage());
// 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) {
// Ignorar
}
}

View File

@@ -11,17 +11,17 @@
android:id="@+id/statusText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="VPN + XUPER TV"
android:text="XUPER VPN UNIVERSAL"
android:textColor="#FFFFFF"
android:textSize="24sp"
android:textStyle="bold"
android:layout_marginBottom="32dp"/>
<Button
android:id="@+id/actionButton"
android:id="@+id/connectBtn"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="ACTIVAR Y ABRIR TV"
android:text="INICIAR"
android:padding="20dp"
android:textSize="18sp"/>