Compare commits
2 Commits
v2.0-auto
...
v1.3-potat
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c97f5c909f | ||
|
|
273b917096 |
@@ -10,10 +10,11 @@ android {
|
||||
applicationId "com.cbcren.vpn"
|
||||
minSdkVersion 21
|
||||
targetSdkVersion 33
|
||||
versionCode 5
|
||||
versionName "2.0-auto"
|
||||
versionCode 4
|
||||
versionName "1.3-potato"
|
||||
multiDexEnabled true
|
||||
ndk {
|
||||
// Forzar solo 32 bits (ARMv7). Muchas cajas chinas crashean si intentan cargar 64 bits o x86.
|
||||
abiFilters 'armeabi-v7a'
|
||||
}
|
||||
}
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1,4 +1,4 @@
|
||||
#Tue Feb 10 00:08:21 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\:/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
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#Tue Feb 10 00:08:21 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\:/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
|
||||
|
||||
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"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.cbcren.vpn"
|
||||
android:versionCode="5"
|
||||
android:versionName="2.0-auto" >
|
||||
android:versionCode="4"
|
||||
android:versionName="1.3-potato" >
|
||||
|
||||
<uses-sdk
|
||||
android:minSdkVersion="21"
|
||||
android:targetSdkVersion="33" />
|
||||
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
<!-- Permiso para saber si la app está instalada -->
|
||||
<uses-permission android:name="android.permission.QUERY_ALL_PACKAGES" />
|
||||
|
||||
<uses-feature
|
||||
android:name="android.software.leanback"
|
||||
@@ -23,7 +21,7 @@
|
||||
android:name="androidx.multidex.MultiDexApplication"
|
||||
android:appComponentFactory="androidx.core.app.CoreComponentFactory"
|
||||
android:debuggable="true"
|
||||
android:label="Xuper VPN Auto"
|
||||
android:label="Xuper VPN"
|
||||
android:theme="@style/Theme.MaterialComponents.Light.NoActionBar" >
|
||||
<activity
|
||||
android:name="com.cbcren.vpn.MainActivity"
|
||||
|
||||
@@ -1,16 +1,14 @@
|
||||
<?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="4"
|
||||
android:versionName="1.3-potato" >
|
||||
|
||||
<uses-sdk
|
||||
android:minSdkVersion="21"
|
||||
android:targetSdkVersion="33" />
|
||||
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
<!-- Permiso para saber si la app está instalada -->
|
||||
<uses-permission android:name="android.permission.QUERY_ALL_PACKAGES" />
|
||||
|
||||
<uses-feature
|
||||
android:name="android.software.leanback"
|
||||
@@ -23,7 +21,7 @@
|
||||
android:name="androidx.multidex.MultiDexApplication"
|
||||
android:appComponentFactory="androidx.core.app.CoreComponentFactory"
|
||||
android:debuggable="true"
|
||||
android:label="Xuper VPN Auto"
|
||||
android:label="Xuper VPN"
|
||||
android:theme="@style/Theme.MaterialComponents.Light.NoActionBar" >
|
||||
<activity
|
||||
android:name="com.cbcren.vpn.MainActivity"
|
||||
|
||||
@@ -11,8 +11,8 @@
|
||||
"type": "SINGLE",
|
||||
"filters": [],
|
||||
"attributes": [],
|
||||
"versionCode": 5,
|
||||
"versionName": "2.0-auto",
|
||||
"versionCode": 4,
|
||||
"versionName": "1.3-potato",
|
||||
"outputFile": "AndroidManifest.xml"
|
||||
}
|
||||
],
|
||||
|
||||
Binary file not shown.
@@ -1,16 +1,14 @@
|
||||
<?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="4"
|
||||
android:versionName="1.3-potato" >
|
||||
|
||||
<uses-sdk
|
||||
android:minSdkVersion="21"
|
||||
android:targetSdkVersion="33" />
|
||||
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
<!-- Permiso para saber si la app está instalada -->
|
||||
<uses-permission android:name="android.permission.QUERY_ALL_PACKAGES" />
|
||||
|
||||
<uses-feature
|
||||
android:name="android.software.leanback"
|
||||
@@ -23,7 +21,7 @@
|
||||
android:name="androidx.multidex.MultiDexApplication"
|
||||
android:appComponentFactory="androidx.core.app.CoreComponentFactory"
|
||||
android:debuggable="true"
|
||||
android:label="Xuper VPN Auto"
|
||||
android:label="Xuper VPN"
|
||||
android:theme="@style/Theme.MaterialComponents.Light.NoActionBar" >
|
||||
<activity
|
||||
android:name="com.cbcren.vpn.MainActivity"
|
||||
|
||||
@@ -11,8 +11,8 @@
|
||||
"type": "SINGLE",
|
||||
"filters": [],
|
||||
"attributes": [],
|
||||
"versionCode": 5,
|
||||
"versionName": "2.0-auto",
|
||||
"versionCode": 4,
|
||||
"versionName": "1.3-potato",
|
||||
"outputFile": "AndroidManifest.xml"
|
||||
}
|
||||
],
|
||||
|
||||
@@ -5,24 +5,23 @@
|
||||
android:orientation="vertical"
|
||||
android:gravity="center"
|
||||
android:padding="32dp"
|
||||
android:background="#222222">
|
||||
android:background="#121212">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/statusText"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="VPN + XUPER TV"
|
||||
android:text="Listo para conectar"
|
||||
android:textColor="#FFFFFF"
|
||||
android:textSize="24sp"
|
||||
android:textStyle="bold"
|
||||
android:layout_marginBottom="32dp"/>
|
||||
|
||||
<Button
|
||||
android:id="@+id/actionButton"
|
||||
android:layout_width="match_parent"
|
||||
android:id="@+id/connectBtn"
|
||||
android:layout_width="200dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="ACTIVAR Y ABRIR TV"
|
||||
android:padding="20dp"
|
||||
android:textSize="18sp"/>
|
||||
android:text="ACTIVAR (60s)"
|
||||
android:padding="16dp"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
@@ -11,8 +11,8 @@
|
||||
"type": "SINGLE",
|
||||
"filters": [],
|
||||
"attributes": [],
|
||||
"versionCode": 5,
|
||||
"versionName": "2.0-auto",
|
||||
"versionCode": 4,
|
||||
"versionName": "1.3-potato",
|
||||
"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.
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",
|
||||
"filters": [],
|
||||
"attributes": [],
|
||||
"versionCode": 5,
|
||||
"versionName": "2.0-auto",
|
||||
"versionCode": 4,
|
||||
"versionName": "1.3-potato",
|
||||
"outputFile": "app-debug.apk"
|
||||
}
|
||||
],
|
||||
|
||||
Binary file not shown.
@@ -3,14 +3,12 @@
|
||||
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.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"
|
||||
android:name="androidx.multidex.MultiDexApplication"
|
||||
android:theme="@style/Theme.MaterialComponents.Light.NoActionBar">
|
||||
|
||||
|
||||
@@ -1,41 +1,41 @@
|
||||
package com.cbcren.vpn;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.os.Bundle;
|
||||
import android.os.CountDownTimer;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
import android.view.View;
|
||||
import android.os.Handler;
|
||||
import android.content.Intent;
|
||||
|
||||
// Imports de WireGuard
|
||||
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;
|
||||
|
||||
import java.util.Collections;
|
||||
|
||||
public class MainActivity extends Activity {
|
||||
|
||||
// --- CONFIGURACIÓN ---
|
||||
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 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";
|
||||
// ---------------------
|
||||
|
||||
private Backend backend;
|
||||
private Tunnel tunnel;
|
||||
private Config config;
|
||||
private TextView statusText;
|
||||
private Button actionButton;
|
||||
private CountDownTimer timer;
|
||||
// -----------------------------
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
@@ -43,51 +43,18 @@ 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);
|
||||
|
||||
// Inicializar Backend
|
||||
try {
|
||||
backend = new GoBackend(getApplicationContext());
|
||||
tunnel = new SimpleTunnel("XuperVPN");
|
||||
tunnel = new SimpleTunnel("XuperTunnel");
|
||||
config = createConfig();
|
||||
} catch (Exception e) {
|
||||
statusText.setText("Error Backend: " + e.getMessage());
|
||||
statusText.setText("Error Init: " + e.getMessage());
|
||||
}
|
||||
|
||||
// Verificar si XuperTV está instalada
|
||||
if (!isPackageInstalled(TARGET_PACKAGE)) {
|
||||
Toast.makeText(this, "Aviso: XuperTV no encontrada (" + TARGET_PACKAGE + ")", Toast.LENGTH_LONG).show();
|
||||
}
|
||||
|
||||
actionButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
startVpn();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
connectBtn.setOnClickListener(v -> startVpnSequence());
|
||||
}
|
||||
|
||||
private Config createConfig() throws Exception {
|
||||
@@ -99,7 +66,7 @@ public class MainActivity extends Activity {
|
||||
Peer.Builder peerBuilder = new Peer.Builder();
|
||||
peerBuilder.parsePublicKey(SERVER_PUB_KEY);
|
||||
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()
|
||||
.setInterface(interfaceBuilder.build())
|
||||
@@ -107,13 +74,20 @@ public class MainActivity extends Activity {
|
||||
.build();
|
||||
}
|
||||
|
||||
private void startVpn() {
|
||||
private void startVpnSequence() {
|
||||
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);
|
||||
if (intent != null) {
|
||||
startActivityForResult(intent, 0);
|
||||
} else {
|
||||
onActivityResult(0, RESULT_OK, null);
|
||||
return;
|
||||
}
|
||||
|
||||
connectTunnel();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -122,54 +96,51 @@ public class MainActivity extends Activity {
|
||||
connectTunnel();
|
||||
} else {
|
||||
statusText.setText("Permiso denegado");
|
||||
connectBtn.setEnabled(true);
|
||||
}
|
||||
}
|
||||
|
||||
private void connectTunnel() {
|
||||
try {
|
||||
try { backend.setState(tunnel, Tunnel.State.DOWN, null); } catch (Exception e) {}
|
||||
// Si ya está corriendo, apagar primero
|
||||
backend.setState(tunnel, Tunnel.State.DOWN, null);
|
||||
|
||||
// Conectar
|
||||
// Encender
|
||||
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
|
||||
new Handler().postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
launchTargetApp();
|
||||
}
|
||||
}, 2000); // 2 segundos de espera
|
||||
|
||||
// Iniciar temporizador
|
||||
timer = new CountDownTimer(60000, 1000) {
|
||||
public void onTick(long millisUntilFinished) {
|
||||
statusText.setText("VPN ACTIVA: " + millisUntilFinished / 1000 + "s");
|
||||
}
|
||||
|
||||
public void onFinish() {
|
||||
disconnectTunnel();
|
||||
}
|
||||
}.start();
|
||||
|
||||
startTimer();
|
||||
} catch (Exception e) {
|
||||
statusText.setText("Error al conectar: " + e.getMessage());
|
||||
statusText.setText("Error Conexión: " + e.getMessage());
|
||||
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() {
|
||||
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.\nAbre XuperTV.");
|
||||
connectBtn.setEnabled(true);
|
||||
connectBtn.setText("RECONECTAR");
|
||||
} catch (Exception e) {
|
||||
statusText.setText("Error desconexión: " + e.getMessage());
|
||||
// Ignorar
|
||||
}
|
||||
}
|
||||
|
||||
// Clase auxiliar simple para identificar el tunel
|
||||
private static class SimpleTunnel implements Tunnel {
|
||||
private final String name;
|
||||
SimpleTunnel(String name) { this.name = name; }
|
||||
|
||||
@@ -5,24 +5,23 @@
|
||||
android:orientation="vertical"
|
||||
android:gravity="center"
|
||||
android:padding="32dp"
|
||||
android:background="#222222">
|
||||
android:background="#121212">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/statusText"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="VPN + XUPER TV"
|
||||
android:text="Listo para conectar"
|
||||
android:textColor="#FFFFFF"
|
||||
android:textSize="24sp"
|
||||
android:textStyle="bold"
|
||||
android:layout_marginBottom="32dp"/>
|
||||
|
||||
<Button
|
||||
android:id="@+id/actionButton"
|
||||
android:layout_width="match_parent"
|
||||
android:id="@+id/connectBtn"
|
||||
android:layout_width="200dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="ACTIVAR Y ABRIR TV"
|
||||
android:padding="20dp"
|
||||
android:textSize="18sp"/>
|
||||
android:text="ACTIVAR (60s)"
|
||||
android:padding="16dp"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
Reference in New Issue
Block a user