Commit 162d2054 authored by Administrator's avatar Administrator

first startup

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