mirror of https://github.com/FongMi/TV.git
parent
0f3c5328a2
commit
8d299559fb
@ -1,10 +0,0 @@ |
||||
package com.forcetech; |
||||
|
||||
public class Port { |
||||
|
||||
public static int MTV = 9002; |
||||
|
||||
public static int get(String url) { |
||||
return MTV; |
||||
} |
||||
} |
||||
@ -0,0 +1,92 @@ |
||||
package com.forcetech; |
||||
|
||||
import android.content.Context; |
||||
import android.content.Intent; |
||||
import android.net.Uri; |
||||
|
||||
import com.forcetech.service.P2PService; |
||||
import com.forcetech.service.P3PService; |
||||
import com.forcetech.service.P4PService; |
||||
import com.forcetech.service.P5PService; |
||||
import com.forcetech.service.P6PService; |
||||
import com.forcetech.service.P7PService; |
||||
import com.forcetech.service.P8PService; |
||||
import com.forcetech.service.P9PService; |
||||
import com.gsoft.mitv.MainActivity; |
||||
|
||||
import java.io.File; |
||||
|
||||
public class Util { |
||||
|
||||
public static int MTV = 9002; |
||||
public static int P2P = 9906; |
||||
public static int P3P = 9907; |
||||
public static int P4P = 9908; |
||||
public static int P5P = 9909; |
||||
public static int P6P = 9910; |
||||
public static int P7P = 9911; |
||||
public static int P8P = 9912; |
||||
public static int P9P = 9913; |
||||
|
||||
public static String scheme(String url) { |
||||
String scheme = Uri.parse(url).getScheme(); |
||||
if (scheme.equals("P2p")) scheme = "mitv"; |
||||
return scheme.toLowerCase(); |
||||
} |
||||
|
||||
public static String so(String url) { |
||||
return "lib" + scheme(url) + ".so"; |
||||
} |
||||
|
||||
public static Intent intent(Context context, String url, File file) { |
||||
Intent intent = new Intent(context, clz(url)); |
||||
intent.putExtra("path", file.getAbsolutePath()); |
||||
return intent; |
||||
} |
||||
|
||||
private static Class<?> clz(String url) { |
||||
switch (scheme(url)) { |
||||
case "p2p": |
||||
return P2PService.class; |
||||
case "p3p": |
||||
return P3PService.class; |
||||
case "p4p": |
||||
return P4PService.class; |
||||
case "p5p": |
||||
return P5PService.class; |
||||
case "p6p": |
||||
return P6PService.class; |
||||
case "p7p": |
||||
return P7PService.class; |
||||
case "p8p": |
||||
return P8PService.class; |
||||
case "p9p": |
||||
return P9PService.class; |
||||
default: |
||||
return MainActivity.class; |
||||
} |
||||
} |
||||
|
||||
public static int port(String url) { |
||||
switch (scheme(url)) { |
||||
case "p2p": |
||||
return P2P; |
||||
case "p3p": |
||||
return P3P; |
||||
case "p4p": |
||||
return P4P; |
||||
case "p5p": |
||||
return P5P; |
||||
case "p6p": |
||||
return P6P; |
||||
case "p7p": |
||||
return P7P; |
||||
case "p8p": |
||||
return P8P; |
||||
case "p9p": |
||||
return P9P; |
||||
default: |
||||
return MTV; |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,16 @@ |
||||
package com.forcetech.android; |
||||
|
||||
public class ForceTV { |
||||
|
||||
public void start(String lib, int port) { |
||||
try { |
||||
System.load(lib); |
||||
start(port, 20 * 1024 * 1024); |
||||
} catch (Throwable ignored) { |
||||
} |
||||
} |
||||
|
||||
public native int start(int port, int size); |
||||
|
||||
public native int stop(); |
||||
} |
||||
@ -0,0 +1,34 @@ |
||||
package com.forcetech.service; |
||||
|
||||
import android.app.Service; |
||||
import android.content.Intent; |
||||
import android.os.IBinder; |
||||
|
||||
import com.forcetech.Util; |
||||
import com.forcetech.android.ForceTV; |
||||
import com.gsoft.mitv.LocalBinder; |
||||
|
||||
public class P2PService extends Service { |
||||
|
||||
private ForceTV forceTV; |
||||
private IBinder binder; |
||||
|
||||
@Override |
||||
public void onCreate() { |
||||
super.onCreate(); |
||||
binder = new LocalBinder(); |
||||
} |
||||
|
||||
@Override |
||||
public IBinder onBind(Intent intent) { |
||||
forceTV = new ForceTV(); |
||||
forceTV.start(intent.getStringExtra("path"), Util.P2P); |
||||
return binder; |
||||
} |
||||
|
||||
@Override |
||||
public boolean onUnbind(Intent intent) { |
||||
if (forceTV != null) forceTV.stop(); |
||||
return super.onUnbind(intent); |
||||
} |
||||
} |
||||
@ -0,0 +1,34 @@ |
||||
package com.forcetech.service; |
||||
|
||||
import android.app.Service; |
||||
import android.content.Intent; |
||||
import android.os.IBinder; |
||||
|
||||
import com.forcetech.Util; |
||||
import com.forcetech.android.ForceTV; |
||||
import com.gsoft.mitv.LocalBinder; |
||||
|
||||
public class P3PService extends Service { |
||||
|
||||
private ForceTV forceTV; |
||||
private IBinder binder; |
||||
|
||||
@Override |
||||
public void onCreate() { |
||||
super.onCreate(); |
||||
binder = new LocalBinder(); |
||||
} |
||||
|
||||
@Override |
||||
public IBinder onBind(Intent intent) { |
||||
forceTV = new ForceTV(); |
||||
forceTV.start(intent.getStringExtra("path"), Util.P3P); |
||||
return binder; |
||||
} |
||||
|
||||
@Override |
||||
public boolean onUnbind(Intent intent) { |
||||
if (forceTV != null) forceTV.stop(); |
||||
return super.onUnbind(intent); |
||||
} |
||||
} |
||||
@ -0,0 +1,34 @@ |
||||
package com.forcetech.service; |
||||
|
||||
import android.app.Service; |
||||
import android.content.Intent; |
||||
import android.os.IBinder; |
||||
|
||||
import com.forcetech.Util; |
||||
import com.forcetech.android.ForceTV; |
||||
import com.gsoft.mitv.LocalBinder; |
||||
|
||||
public class P4PService extends Service { |
||||
|
||||
private ForceTV forceTV; |
||||
private IBinder binder; |
||||
|
||||
@Override |
||||
public void onCreate() { |
||||
super.onCreate(); |
||||
binder = new LocalBinder(); |
||||
} |
||||
|
||||
@Override |
||||
public IBinder onBind(Intent intent) { |
||||
forceTV = new ForceTV(); |
||||
forceTV.start(intent.getStringExtra("path"), Util.P4P); |
||||
return binder; |
||||
} |
||||
|
||||
@Override |
||||
public boolean onUnbind(Intent intent) { |
||||
if (forceTV != null) forceTV.stop(); |
||||
return super.onUnbind(intent); |
||||
} |
||||
} |
||||
@ -0,0 +1,34 @@ |
||||
package com.forcetech.service; |
||||
|
||||
import android.app.Service; |
||||
import android.content.Intent; |
||||
import android.os.IBinder; |
||||
|
||||
import com.forcetech.Util; |
||||
import com.forcetech.android.ForceTV; |
||||
import com.gsoft.mitv.LocalBinder; |
||||
|
||||
public class P5PService extends Service { |
||||
|
||||
private ForceTV forceTV; |
||||
private IBinder binder; |
||||
|
||||
@Override |
||||
public void onCreate() { |
||||
super.onCreate(); |
||||
binder = new LocalBinder(); |
||||
} |
||||
|
||||
@Override |
||||
public IBinder onBind(Intent intent) { |
||||
forceTV = new ForceTV(); |
||||
forceTV.start(intent.getStringExtra("path"), Util.P5P); |
||||
return binder; |
||||
} |
||||
|
||||
@Override |
||||
public boolean onUnbind(Intent intent) { |
||||
if (forceTV != null) forceTV.stop(); |
||||
return super.onUnbind(intent); |
||||
} |
||||
} |
||||
@ -0,0 +1,34 @@ |
||||
package com.forcetech.service; |
||||
|
||||
import android.app.Service; |
||||
import android.content.Intent; |
||||
import android.os.IBinder; |
||||
|
||||
import com.forcetech.Util; |
||||
import com.forcetech.android.ForceTV; |
||||
import com.gsoft.mitv.LocalBinder; |
||||
|
||||
public class P6PService extends Service { |
||||
|
||||
private ForceTV forceTV; |
||||
private IBinder binder; |
||||
|
||||
@Override |
||||
public void onCreate() { |
||||
super.onCreate(); |
||||
binder = new LocalBinder(); |
||||
} |
||||
|
||||
@Override |
||||
public IBinder onBind(Intent intent) { |
||||
forceTV = new ForceTV(); |
||||
forceTV.start(intent.getStringExtra("path"), Util.P6P); |
||||
return binder; |
||||
} |
||||
|
||||
@Override |
||||
public boolean onUnbind(Intent intent) { |
||||
if (forceTV != null) forceTV.stop(); |
||||
return super.onUnbind(intent); |
||||
} |
||||
} |
||||
@ -0,0 +1,34 @@ |
||||
package com.forcetech.service; |
||||
|
||||
import android.app.Service; |
||||
import android.content.Intent; |
||||
import android.os.IBinder; |
||||
|
||||
import com.forcetech.Util; |
||||
import com.forcetech.android.ForceTV; |
||||
import com.gsoft.mitv.LocalBinder; |
||||
|
||||
public class P7PService extends Service { |
||||
|
||||
private ForceTV forceTV; |
||||
private IBinder binder; |
||||
|
||||
@Override |
||||
public void onCreate() { |
||||
super.onCreate(); |
||||
binder = new LocalBinder(); |
||||
} |
||||
|
||||
@Override |
||||
public IBinder onBind(Intent intent) { |
||||
forceTV = new ForceTV(); |
||||
forceTV.start(intent.getStringExtra("path"), Util.P7P); |
||||
return binder; |
||||
} |
||||
|
||||
@Override |
||||
public boolean onUnbind(Intent intent) { |
||||
if (forceTV != null) forceTV.stop(); |
||||
return super.onUnbind(intent); |
||||
} |
||||
} |
||||
@ -0,0 +1,34 @@ |
||||
package com.forcetech.service; |
||||
|
||||
import android.app.Service; |
||||
import android.content.Intent; |
||||
import android.os.IBinder; |
||||
|
||||
import com.forcetech.Util; |
||||
import com.forcetech.android.ForceTV; |
||||
import com.gsoft.mitv.LocalBinder; |
||||
|
||||
public class P8PService extends Service { |
||||
|
||||
private ForceTV forceTV; |
||||
private IBinder binder; |
||||
|
||||
@Override |
||||
public void onCreate() { |
||||
super.onCreate(); |
||||
binder = new LocalBinder(); |
||||
} |
||||
|
||||
@Override |
||||
public IBinder onBind(Intent intent) { |
||||
forceTV = new ForceTV(); |
||||
forceTV.start(intent.getStringExtra("path"), Util.P8P); |
||||
return binder; |
||||
} |
||||
|
||||
@Override |
||||
public boolean onUnbind(Intent intent) { |
||||
if (forceTV != null) forceTV.stop(); |
||||
return super.onUnbind(intent); |
||||
} |
||||
} |
||||
@ -0,0 +1,34 @@ |
||||
package com.forcetech.service; |
||||
|
||||
import android.app.Service; |
||||
import android.content.Intent; |
||||
import android.os.IBinder; |
||||
|
||||
import com.forcetech.Util; |
||||
import com.forcetech.android.ForceTV; |
||||
import com.gsoft.mitv.LocalBinder; |
||||
|
||||
public class P9PService extends Service { |
||||
|
||||
private ForceTV forceTV; |
||||
private IBinder binder; |
||||
|
||||
@Override |
||||
public void onCreate() { |
||||
super.onCreate(); |
||||
binder = new LocalBinder(); |
||||
} |
||||
|
||||
@Override |
||||
public IBinder onBind(Intent intent) { |
||||
forceTV = new ForceTV(); |
||||
forceTV.start(intent.getStringExtra("path"), Util.P9P); |
||||
return binder; |
||||
} |
||||
|
||||
@Override |
||||
public boolean onUnbind(Intent intent) { |
||||
if (forceTV != null) forceTV.stop(); |
||||
return super.onUnbind(intent); |
||||
} |
||||
} |
||||
Loading…
Reference in new issue