Commit 162d2054 authored by Administrator's avatar Administrator

first startup

parent 00d4ea80
apply plugin: 'com.android.application'
android {
compileSdkVersion 29
buildToolsVersion "29.0.3"
compileSdkVersion 28
defaultConfig {
applicationId "com.virjar.echo.adr"
minSdkVersion 21
targetSdkVersion 29
targetSdkVersion 28
versionCode 1
versionName "1.0"
......@@ -45,6 +44,7 @@ dependencies {
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
//compile 'com.android.support:support-v4:24.2.0'
api project(':echo-lib')
......
......@@ -6,6 +6,7 @@
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE"/>
<application
android:allowBackup="true"
......@@ -48,11 +49,6 @@
<action android:name="android.intent.action.MEDIA_UNMOUNTED" />
<action android:name="android.intent.action.MEDIA_EJECT" />
</intent-filter>
</receiver>
<!--覆盖安装后唤醒service-->
<!--有些机器会报错-->
<receiver android:name="com.virjar.echo.adr.StartOnBootBroadcastReceiver">
<intent-filter>
<action android:name="android.intent.action.PACKAGE_REPLACED" />
<action android:name="android.intent.action.PACKAGE_ADDED" />
......
......@@ -10,12 +10,12 @@ import android.graphics.BitmapFactory;
import android.graphics.Color;
import android.os.Build;
import android.os.IBinder;
import android.util.Log;
import androidx.annotation.Nullable;
import androidx.multidex.BuildConfig;
import com.virjar.echo.nat.client.EchoClient;
import com.virjar.echo.nat.log.EchoLogger;
import java.util.UUID;
import java.util.concurrent.atomic.AtomicBoolean;
......@@ -27,7 +27,6 @@ public class HttpProxyService extends Service {
private EchoClient echoClient;
@Nullable
@android.support.annotation.Nullable
@Override
public IBinder onBind(Intent intent) {
startService();
......@@ -89,14 +88,20 @@ public class HttpProxyService extends Service {
//TODO 设备ID生成算法
String clientKey = UUID.randomUUID().toString();
Log.i("weijia", "start EchoProxy front service");
EchoLogger.getLogger().info("start EchoProxy front service");
//TODO 设置服务器信息
echoClient = new EchoClient(
"echo.virjar.com", 5698,
clientKey);
echoClient.startUp();
new Thread() {
@Override
public void run() {
//因为会访问网络,所以需要在新线程
echoClient.startUp();
}
}.start();
}
}
......@@ -4,16 +4,15 @@ import android.annotation.SuppressLint;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.util.Log;
import com.virjar.echo.nat.log.EchoLogger;
public class StartOnBootBroadcastReceiver extends BroadcastReceiver {
@SuppressLint("UnsafeProtectedBroadcastReceiver")
@Override
public void onReceive(Context context, Intent intent) {
Log.i("weijia", "receive start service broadcast");
EchoLogger.getLogger().info("receive start service broadcast");
context.startService(new Intent(context, HttpProxyService.class));
// clearAbortBroadcast();
}
}
Subproject commit 1e4d718969d9c279870925eb5587c1ac7e7e02a8
Subproject commit e4a64e1d6ceea7e83da893c439ae1198aba1d73d
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment