feat: 初始化XMBOX项目

This commit is contained in:
Tosencen
2025-07-03 06:16:21 +08:00
commit 0a10f73143
914 changed files with 71817 additions and 0 deletions
+1
View File
@@ -0,0 +1 @@
/build
+19
View File
@@ -0,0 +1,19 @@
plugins {
id 'com.android.library'
}
android {
namespace 'com.forcetech'
compileSdk 35
defaultConfig {
minSdk 21
targetSdk 28
ndk { abiFilters "armeabi-v7a" }
}
}
dependencies {
implementation project(':catvod')
}
+22
View File
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<application>
<service
android:name="com.forcetech.service.P2PService"
android:exported="false"
android:process=":p2p" />
<service
android:name="com.forcetech.service.P3PService"
android:exported="false"
android:process=":p3p" />
<service
android:name="com.gsoft.mitv.MainActivity"
android:exported="false"
android:process=":mitv" />
</application>
</manifest>
Binary file not shown.
@@ -0,0 +1,15 @@
package com.anymediacloud.iptv.standard;
public class ForceTV {
public void start(int port) {
try {
start(port, 20 * 1024 * 1024);
} catch (Throwable ignored) {
}
}
public native int start(int port, int size);
public native int stop();
}
@@ -0,0 +1,59 @@
package com.forcetech;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import com.forcetech.service.P2PService;
import com.forcetech.service.P3PService;
import com.gsoft.mitv.MainActivity;
public class Util {
public static int MTV = 9002;
public static int P2P = 9906;
public static int P3P = 9907;
public static String scheme(String url) {
String scheme = Uri.parse(url).getScheme();
if ("P2p".equals(scheme)) scheme = "mitv";
return scheme.toLowerCase();
}
public static String trans(ComponentName o) {
String name = o.getClassName();
name = name.substring(name.lastIndexOf(".") + 1);
name = name.replace("Service", "");
name = name.replace("MainActivity", "mitv");
return name.toLowerCase();
}
public static Intent intent(Context context, String scheme) {
Intent intent = new Intent(context, clz(scheme));
intent.putExtra("scheme", scheme);
return intent;
}
private static Class<?> clz(String scheme) {
switch (scheme) {
case "p2p":
return P2PService.class;
case "p3p":
return P3PService.class;
default:
return MainActivity.class;
}
}
public static int port(String scheme) {
switch (scheme) {
case "p2p":
return P2P;
case "p3p":
return P3P;
default:
return MTV;
}
}
}
@@ -0,0 +1,16 @@
package com.forcetech.android;
public class ForceTV {
public void start(String lib, int port) {
try {
System.loadLibrary(lib);
start(port, 20 * 1024 * 1024);
} catch (Throwable ignored) {
}
}
public native int start(int port, int size);
public native int stop();
}
@@ -0,0 +1,11 @@
package com.forcetech.service;
import com.forcetech.Util;
public class P2PService extends PxPService {
@Override
public int getPort() {
return Util.P2P;
}
}
@@ -0,0 +1,11 @@
package com.forcetech.service;
import com.forcetech.Util;
public class P3PService extends PxPService {
@Override
public int getPort() {
return Util.P3P;
}
}
@@ -0,0 +1,35 @@
package com.forcetech.service;
import android.app.Service;
import android.content.Intent;
import android.os.IBinder;
import com.forcetech.android.ForceTV;
import com.gsoft.mitv.LocalBinder;
public abstract class PxPService extends Service {
private ForceTV forceTV;
private IBinder binder;
public abstract int getPort();
@Override
public void onCreate() {
super.onCreate();
binder = new LocalBinder();
}
@Override
public IBinder onBind(Intent intent) {
forceTV = new ForceTV();
forceTV.start(intent.getStringExtra("scheme"), getPort());
return binder;
}
@Override
public boolean onUnbind(Intent intent) {
if (forceTV != null) forceTV.stop();
return false;
}
}
@@ -0,0 +1,6 @@
package com.gsoft.mitv;
import android.os.Binder;
public class LocalBinder extends Binder {
}
@@ -0,0 +1,58 @@
package com.gsoft.mitv;
import android.app.Service;
import android.content.Intent;
import android.os.IBinder;
import com.anymediacloud.iptv.standard.ForceTV;
import com.forcetech.Util;
import com.github.catvod.utils.Asset;
import com.github.catvod.utils.Path;
import java.io.File;
public class MainActivity extends Service {
private ForceTV forceTV;
private IBinder binder;
public MainActivity() {
try {
checkLibrary();
System.loadLibrary("mitv");
} catch (Throwable t) {
t.printStackTrace();
}
}
private void checkLibrary() {
String name = "libmitv.so";
File file = Path.cache(name);
if (!file.exists()) Path.copy(Asset.open(name), file);
}
@Override
public void onCreate() {
super.onCreate();
try {
binder = new LocalBinder();
loadLibrary(1);
} catch (Throwable ignored) {
}
}
@Override
public IBinder onBind(Intent intent) {
forceTV = new ForceTV();
forceTV.start(Util.MTV);
return binder;
}
@Override
public boolean onUnbind(Intent intent) {
if (forceTV != null) forceTV.stop();
return false;
}
private native void loadLibrary(int type);
}
Binary file not shown.
Binary file not shown.
Binary file not shown.