Compare commits
2 Commits
v3.0-unive
...
v4.0-unive
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bba61b68d6 | ||
|
|
157bf7db2e |
@@ -9,12 +9,15 @@ android {
|
|||||||
defaultConfig {
|
defaultConfig {
|
||||||
applicationId "com.cbcren.vpn"
|
applicationId "com.cbcren.vpn"
|
||||||
minSdkVersion 21
|
minSdkVersion 21
|
||||||
targetSdkVersion 33
|
targetSdkVersion 34 // Compatible con Android 14/15/16
|
||||||
versionCode 5
|
versionCode 8
|
||||||
versionName "2.0-auto"
|
versionName "4.0-universal-embedded"
|
||||||
|
|
||||||
multiDexEnabled true
|
multiDexEnabled true
|
||||||
|
|
||||||
|
// ¡IMPORTANTE! Habilitar ambas arquitecturas
|
||||||
ndk {
|
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 '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: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\:/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: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\:/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="5"
|
android:versionCode="8"
|
||||||
android:versionName="2.0-auto" >
|
android:versionName="4.0-universal-embedded" >
|
||||||
|
|
||||||
<uses-sdk
|
<uses-sdk
|
||||||
android:minSdkVersion="21"
|
android:minSdkVersion="21"
|
||||||
android:targetSdkVersion="33" />
|
android:targetSdkVersion="34" />
|
||||||
|
|
||||||
<uses-permission android:name="android.permission.INTERNET" />
|
<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-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 Auto"
|
android:label="Xuper VPN Universal"
|
||||||
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,6 +36,7 @@
|
|||||||
</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="5"
|
android:versionCode="8"
|
||||||
android:versionName="2.0-auto" >
|
android:versionName="4.0-universal-embedded" >
|
||||||
|
|
||||||
<uses-sdk
|
<uses-sdk
|
||||||
android:minSdkVersion="21"
|
android:minSdkVersion="21"
|
||||||
android:targetSdkVersion="33" />
|
android:targetSdkVersion="34" />
|
||||||
|
|
||||||
<uses-permission android:name="android.permission.INTERNET" />
|
<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-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 Auto"
|
android:label="Xuper VPN Universal"
|
||||||
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,6 +36,7 @@
|
|||||||
</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": 5,
|
"versionCode": 8,
|
||||||
"versionName": "2.0-auto",
|
"versionName": "4.0-universal-embedded",
|
||||||
"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="5"
|
android:versionCode="8"
|
||||||
android:versionName="2.0-auto" >
|
android:versionName="4.0-universal-embedded" >
|
||||||
|
|
||||||
<uses-sdk
|
<uses-sdk
|
||||||
android:minSdkVersion="21"
|
android:minSdkVersion="21"
|
||||||
android:targetSdkVersion="33" />
|
android:targetSdkVersion="34" />
|
||||||
|
|
||||||
<uses-permission android:name="android.permission.INTERNET" />
|
<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-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 Auto"
|
android:label="Xuper VPN Universal"
|
||||||
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,6 +36,7 @@
|
|||||||
</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": 5,
|
"versionCode": 8,
|
||||||
"versionName": "2.0-auto",
|
"versionName": "4.0-universal-embedded",
|
||||||
"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="VPN + XUPER TV"
|
android:text="XUPER VPN UNIVERSAL"
|
||||||
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/actionButton"
|
android:id="@+id/connectBtn"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="ACTIVAR Y ABRIR TV"
|
android:text="INICIAR"
|
||||||
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": 5,
|
"versionCode": 8,
|
||||||
"versionName": "2.0-auto",
|
"versionName": "4.0-universal-embedded",
|
||||||
"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": 5,
|
"versionCode": 8,
|
||||||
"versionName": "2.0-auto",
|
"versionName": "4.0-universal-embedded",
|
||||||
"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" />
|
||||||
<!-- 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-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 Auto"
|
android:label="Xuper VPN Universal"
|
||||||
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,6 +23,7 @@
|
|||||||
</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,36 +5,39 @@ 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 ---
|
// --- CONFIGURACIÓN WIREGUARD ---
|
||||||
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";
|
||||||
|
|
||||||
// App a lanzar
|
// --- CONFIGURACIÓN APP OBJETIVO ---
|
||||||
private static final String TARGET_PACKAGE = "com.android.mgstv";
|
private static final String TARGET_PACKAGE = "com.android.mgstv"; // XuperTV
|
||||||
// ---------------------
|
// ----------------------------------
|
||||||
|
|
||||||
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 actionButton;
|
private Button connectBtn;
|
||||||
private CountDownTimer timer;
|
private CountDownTimer timer;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -43,53 +46,33 @@ 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);
|
||||||
actionButton = findViewById(R.id.actionButton);
|
connectBtn = findViewById(R.id.connectBtn);
|
||||||
|
connectBtn.setText("ACTIVAR Y ABRIR TV");
|
||||||
|
|
||||||
// Inicializar Backend
|
// 1. Inicializar Motor VPN
|
||||||
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 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)) {
|
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
|
@Override
|
||||||
public void onClick(View v) {
|
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 {
|
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);
|
||||||
@@ -107,7 +90,8 @@ public class MainActivity extends Activity {
|
|||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void startVpn() {
|
private void startVpnSequence() {
|
||||||
|
// 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);
|
||||||
@@ -121,29 +105,30 @@ public class MainActivity extends Activity {
|
|||||||
if (resultCode == RESULT_OK) {
|
if (resultCode == RESULT_OK) {
|
||||||
connectTunnel();
|
connectTunnel();
|
||||||
} else {
|
} else {
|
||||||
statusText.setText("Permiso denegado");
|
statusText.setText("Permiso de VPN 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 - LANZANDO TV...");
|
statusText.setText("CONECTADO.\nLanzando TV en 2s...");
|
||||||
actionButton.setEnabled(false);
|
connectBtn.setEnabled(false);
|
||||||
|
|
||||||
// Lanzar la app con un pequeño retraso para asegurar que el túnel esté listo
|
// Auto-Launch XuperTV
|
||||||
new Handler().postDelayed(new Runnable() {
|
new Handler().postDelayed(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
launchTargetApp();
|
launchTargetApp();
|
||||||
}
|
}
|
||||||
}, 2000); // 2 segundos de espera
|
}, 2000);
|
||||||
|
|
||||||
// Iniciar temporizador
|
// Temporizador 60s
|
||||||
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");
|
||||||
@@ -155,18 +140,42 @@ public class MainActivity extends Activity {
|
|||||||
}.start();
|
}.start();
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
statusText.setText("Error al conectar: " + e.getMessage());
|
statusText.setText("Error Conexión: " + e.getMessage());
|
||||||
|
connectBtn.setEnabled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void disconnectTunnel() {
|
private void disconnectTunnel() {
|
||||||
try {
|
try {
|
||||||
backend.setState(tunnel, Tunnel.State.DOWN, null);
|
if (backend != null) {
|
||||||
statusText.setText("DESCONECTADO. Disfruta!");
|
backend.setState(tunnel, Tunnel.State.DOWN, null);
|
||||||
actionButton.setEnabled(true);
|
}
|
||||||
actionButton.setText("RECONECTAR");
|
statusText.setText("DESCONECTADO.\nListo.");
|
||||||
|
connectBtn.setEnabled(true);
|
||||||
|
connectBtn.setText("REINICIAR");
|
||||||
} catch (Exception e) {
|
} 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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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="VPN + XUPER TV"
|
android:text="XUPER VPN UNIVERSAL"
|
||||||
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/actionButton"
|
android:id="@+id/connectBtn"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="ACTIVAR Y ABRIR TV"
|
android:text="INICIAR"
|
||||||
android:padding="20dp"
|
android:padding="20dp"
|
||||||
android:textSize="18sp"/>
|
android:textSize="18sp"/>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user