Compare commits
1 Commits
v4.0-unive
...
v3.0-unive
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f1a4923437 |
@@ -9,15 +9,12 @@ 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 5
|
||||||
versionName "4.0-universal-embedded"
|
versionName "2.0-auto"
|
||||||
|
|
||||||
multiDexEnabled true
|
multiDexEnabled true
|
||||||
|
|
||||||
// ¡IMPORTANTE! Habilitar ambas arquitecturas
|
|
||||||
ndk {
|
ndk {
|
||||||
abiFilters 'armeabi-v7a', 'arm64-v8a', 'x86', 'x86_64'
|
abiFilters 'armeabi-v7a'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -31,7 +28,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.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1,4 +1,4 @@
|
|||||||
#Tue Feb 10 00:24:44 CET 2026
|
#Tue Feb 10 00:08:21 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
|
#Tue Feb 10 00:08:21 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,15 +1,15 @@
|
|||||||
<?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="5"
|
||||||
android:versionName="4.0-universal-embedded" >
|
android:versionName="2.0-auto" >
|
||||||
|
|
||||||
<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" />
|
<!-- Permiso para saber si la app está instalada -->
|
||||||
<uses-permission android:name="android.permission.QUERY_ALL_PACKAGES" />
|
<uses-permission android:name="android.permission.QUERY_ALL_PACKAGES" />
|
||||||
|
|
||||||
<uses-feature
|
<uses-feature
|
||||||
@@ -23,7 +23,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 Auto"
|
||||||
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 +36,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,15 +1,15 @@
|
|||||||
<?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="5"
|
||||||
android:versionName="4.0-universal-embedded" >
|
android:versionName="2.0-auto" >
|
||||||
|
|
||||||
<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" />
|
<!-- Permiso para saber si la app está instalada -->
|
||||||
<uses-permission android:name="android.permission.QUERY_ALL_PACKAGES" />
|
<uses-permission android:name="android.permission.QUERY_ALL_PACKAGES" />
|
||||||
|
|
||||||
<uses-feature
|
<uses-feature
|
||||||
@@ -23,7 +23,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 Auto"
|
||||||
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 +36,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": 5,
|
||||||
"versionName": "4.0-universal-embedded",
|
"versionName": "2.0-auto",
|
||||||
"outputFile": "AndroidManifest.xml"
|
"outputFile": "AndroidManifest.xml"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|||||||
Binary file not shown.
@@ -1,15 +1,15 @@
|
|||||||
<?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="5"
|
||||||
android:versionName="4.0-universal-embedded" >
|
android:versionName="2.0-auto" >
|
||||||
|
|
||||||
<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" />
|
<!-- Permiso para saber si la app está instalada -->
|
||||||
<uses-permission android:name="android.permission.QUERY_ALL_PACKAGES" />
|
<uses-permission android:name="android.permission.QUERY_ALL_PACKAGES" />
|
||||||
|
|
||||||
<uses-feature
|
<uses-feature
|
||||||
@@ -23,7 +23,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 Auto"
|
||||||
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 +36,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": 5,
|
||||||
"versionName": "4.0-universal-embedded",
|
"versionName": "2.0-auto",
|
||||||
"outputFile": "AndroidManifest.xml"
|
"outputFile": "AndroidManifest.xml"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -11,17 +11,17 @@
|
|||||||
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="VPN + XUPER TV"
|
||||||
android:textColor="#FFFFFF"
|
android:textColor="#FFFFFF"
|
||||||
android:textSize="24sp"
|
android:textSize="24sp"
|
||||||
android:textStyle="bold"
|
android:textStyle="bold"
|
||||||
android:layout_marginBottom="32dp"/>
|
android:layout_marginBottom="32dp"/>
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
android:id="@+id/connectBtn"
|
android:id="@+id/actionButton"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="INICIAR"
|
android:text="ACTIVAR Y ABRIR TV"
|
||||||
android:padding="20dp"
|
android:padding="20dp"
|
||||||
android:textSize="18sp"/>
|
android:textSize="18sp"/>
|
||||||
|
|
||||||
|
|||||||
@@ -11,8 +11,8 @@
|
|||||||
"type": "SINGLE",
|
"type": "SINGLE",
|
||||||
"filters": [],
|
"filters": [],
|
||||||
"attributes": [],
|
"attributes": [],
|
||||||
"versionCode": 8,
|
"versionCode": 5,
|
||||||
"versionName": "4.0-universal-embedded",
|
"versionName": "2.0-auto",
|
||||||
"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.
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": 5,
|
||||||
"versionName": "4.0-universal-embedded",
|
"versionName": "2.0-auto",
|
||||||
"outputFile": "app-debug.apk"
|
"outputFile": "app-debug.apk"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|||||||
Binary file not shown.
@@ -3,14 +3,14 @@
|
|||||||
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" />
|
<!-- Permiso para saber si la app está instalada -->
|
||||||
<uses-permission android:name="android.permission.QUERY_ALL_PACKAGES" tools:ignore="QueryAllPackagesPermission" />
|
<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 Auto"
|
||||||
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 +23,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"
|
||||||
|
|||||||
@@ -5,39 +5,36 @@ import android.content.Intent;
|
|||||||
import android.content.pm.PackageManager;
|
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.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.view.View;
|
||||||
|
import android.os.Handler;
|
||||||
|
|
||||||
// Imports del Motor Embebido
|
|
||||||
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;
|
||||||
import com.wireguard.config.Config;
|
import com.wireguard.config.Config;
|
||||||
import com.wireguard.config.Interface;
|
import com.wireguard.config.Interface;
|
||||||
import com.wireguard.config.Peer;
|
import com.wireguard.config.Peer;
|
||||||
import com.wireguard.config.InetEndpoint;
|
|
||||||
import com.wireguard.config.InetNetwork;
|
|
||||||
|
|
||||||
public class MainActivity extends Activity {
|
public class MainActivity extends Activity {
|
||||||
|
|
||||||
// --- CONFIGURACIÓN WIREGUARD ---
|
// --- CONFIGURACIÓN ---
|
||||||
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 ---
|
// App a lanzar
|
||||||
private static final String TARGET_PACKAGE = "com.android.mgstv"; // XuperTV
|
private static final String TARGET_PACKAGE = "com.android.mgstv";
|
||||||
// ----------------------------------
|
// ---------------------
|
||||||
|
|
||||||
private Backend backend;
|
private Backend backend;
|
||||||
private Tunnel tunnel;
|
private Tunnel tunnel;
|
||||||
private Config config;
|
private Config config;
|
||||||
private TextView statusText;
|
private TextView statusText;
|
||||||
private Button connectBtn;
|
private Button actionButton;
|
||||||
private CountDownTimer timer;
|
private CountDownTimer timer;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -46,33 +43,53 @@ public class MainActivity extends Activity {
|
|||||||
setContentView(R.layout.activity_main);
|
setContentView(R.layout.activity_main);
|
||||||
|
|
||||||
statusText = findViewById(R.id.statusText);
|
statusText = findViewById(R.id.statusText);
|
||||||
connectBtn = findViewById(R.id.connectBtn);
|
actionButton = findViewById(R.id.actionButton);
|
||||||
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("XuperVPN");
|
||||||
config = createConfig();
|
config = createConfig();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
statusText.setText("Error Motor VPN: " + e.getMessage());
|
statusText.setText("Error Backend: " + e.getMessage());
|
||||||
connectBtn.setEnabled(false);
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 2. Verificar XuperTV
|
// Verificar si XuperTV está instalada
|
||||||
if (!isPackageInstalled(TARGET_PACKAGE)) {
|
if (!isPackageInstalled(TARGET_PACKAGE)) {
|
||||||
Toast.makeText(this, "Aviso: XuperTV no detectada", Toast.LENGTH_LONG).show();
|
Toast.makeText(this, "Aviso: XuperTV no encontrada (" + TARGET_PACKAGE + ")", Toast.LENGTH_LONG).show();
|
||||||
}
|
}
|
||||||
|
|
||||||
connectBtn.setOnClickListener(new View.OnClickListener() {
|
actionButton.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
startVpnSequence();
|
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
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private Config createConfig() throws Exception {
|
private Config createConfig() throws Exception {
|
||||||
Interface.Builder interfaceBuilder = new Interface.Builder();
|
Interface.Builder interfaceBuilder = new Interface.Builder();
|
||||||
interfaceBuilder.parsePrivateKey(CLIENT_PRIV_KEY);
|
interfaceBuilder.parsePrivateKey(CLIENT_PRIV_KEY);
|
||||||
@@ -90,8 +107,7 @@ public class MainActivity extends Activity {
|
|||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void startVpnSequence() {
|
private void startVpn() {
|
||||||
// Pedir permiso de VPN al sistema (Android dialog)
|
|
||||||
Intent intent = GoBackend.VpnService.prepare(this);
|
Intent intent = GoBackend.VpnService.prepare(this);
|
||||||
if (intent != null) {
|
if (intent != null) {
|
||||||
startActivityForResult(intent, 0);
|
startActivityForResult(intent, 0);
|
||||||
@@ -105,30 +121,29 @@ 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");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void connectTunnel() {
|
private void connectTunnel() {
|
||||||
try {
|
try {
|
||||||
// Asegurar limpieza
|
|
||||||
try { backend.setState(tunnel, Tunnel.State.DOWN, null); } catch (Exception e) {}
|
try { backend.setState(tunnel, Tunnel.State.DOWN, null); } catch (Exception e) {}
|
||||||
|
|
||||||
// CONECTAR
|
// Conectar
|
||||||
backend.setState(tunnel, Tunnel.State.UP, config);
|
backend.setState(tunnel, Tunnel.State.UP, config);
|
||||||
|
|
||||||
statusText.setText("CONECTADO.\nLanzando TV en 2s...");
|
statusText.setText("CONECTADO - LANZANDO TV...");
|
||||||
connectBtn.setEnabled(false);
|
actionButton.setEnabled(false);
|
||||||
|
|
||||||
// Auto-Launch XuperTV
|
// Lanzar la app con un pequeño retraso para asegurar que el túnel esté listo
|
||||||
new Handler().postDelayed(new Runnable() {
|
new Handler().postDelayed(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
launchTargetApp();
|
launchTargetApp();
|
||||||
}
|
}
|
||||||
}, 2000);
|
}, 2000); // 2 segundos de espera
|
||||||
|
|
||||||
// Temporizador 60s
|
// Iniciar temporizador
|
||||||
timer = new CountDownTimer(60000, 1000) {
|
timer = new CountDownTimer(60000, 1000) {
|
||||||
public void onTick(long millisUntilFinished) {
|
public void onTick(long millisUntilFinished) {
|
||||||
statusText.setText("VPN ACTIVA: " + millisUntilFinished / 1000 + "s");
|
statusText.setText("VPN ACTIVA: " + millisUntilFinished / 1000 + "s");
|
||||||
@@ -140,42 +155,18 @@ public class MainActivity extends Activity {
|
|||||||
}.start();
|
}.start();
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
statusText.setText("Error Conexión: " + e.getMessage());
|
statusText.setText("Error al conectar: " + e.getMessage());
|
||||||
connectBtn.setEnabled(true);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void disconnectTunnel() {
|
private void disconnectTunnel() {
|
||||||
try {
|
try {
|
||||||
if (backend != null) {
|
backend.setState(tunnel, Tunnel.State.DOWN, null);
|
||||||
backend.setState(tunnel, Tunnel.State.DOWN, null);
|
statusText.setText("DESCONECTADO. Disfruta!");
|
||||||
}
|
actionButton.setEnabled(true);
|
||||||
statusText.setText("DESCONECTADO.\nListo.");
|
actionButton.setText("RECONECTAR");
|
||||||
connectBtn.setEnabled(true);
|
|
||||||
connectBtn.setText("REINICIAR");
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
// Ignorar
|
statusText.setText("Error desconexión: " + e.getMessage());
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
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
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -11,17 +11,17 @@
|
|||||||
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="VPN + XUPER TV"
|
||||||
android:textColor="#FFFFFF"
|
android:textColor="#FFFFFF"
|
||||||
android:textSize="24sp"
|
android:textSize="24sp"
|
||||||
android:textStyle="bold"
|
android:textStyle="bold"
|
||||||
android:layout_marginBottom="32dp"/>
|
android:layout_marginBottom="32dp"/>
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
android:id="@+id/connectBtn"
|
android:id="@+id/actionButton"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="INICIAR"
|
android:text="ACTIVAR Y ABRIR TV"
|
||||||
android:padding="20dp"
|
android:padding="20dp"
|
||||||
android:textSize="18sp"/>
|
android:textSize="18sp"/>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user