Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
E
echo-adr-Deprecated
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
echo
echo-adr-Deprecated
Commits
3a6f2345
Commit
3a6f2345
authored
Jul 01, 2020
by
Administrator
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加代理框架代码
parent
1c1b2221
Pipeline
#1743
failed with stages
Changes
7
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
196 additions
and
5 deletions
+196
-5
build.gradle
app/build.gradle
+26
-5
AndroidManifest.xml
app/src/main/AndroidManifest.xml
+46
-0
HttpProxyService.java
app/src/main/java/com/virjar/echo/adr/HttpProxyService.java
+102
-0
MainActivity.java
app/src/main/java/com/virjar/echo/adr/MainActivity.java
+3
-0
StartOnBootBroadcastReceiver.java
...ava/com/virjar/echo/adr/StartOnBootBroadcastReceiver.java
+19
-0
hermes_key
deploy/hermes_key
+0
-0
reward.jpg
deploy/reward.jpg
+0
-0
No files found.
app/build.gradle
View file @
3a6f2345
...
...
@@ -11,16 +11,33 @@ android {
versionCode
1
versionName
"1.0"
testInstrumentationRunner
"androidx.test.runner.AndroidJUnitRunner"
multiDexEnabled
true
}
signingConfigs
{
release
{
storeFile
rootProject
.
file
(
'deploy/hermes_key'
)
storePassword
"hermes"
keyAlias
"hermes"
keyPassword
"hermes"
}
}
buildTypes
{
release
{
minifyEnabled
false
proguardFiles
getDefaultProguardFile
(
'proguard-android-optimize.txt'
),
'proguard-rules.pro'
proguardFiles
getDefaultProguardFile
(
'proguard-android.txt'
),
'proguard-rules.pro'
signingConfig
signingConfigs
.
release
}
debug
{
signingConfig
signingConfigs
.
release
}
}
packagingOptions
{
exclude
'META-INF/INDEX.LIST'
exclude
'META-INF/io.netty.versions.properties'
}
}
dependencies
{
...
...
@@ -28,7 +45,11 @@ dependencies {
implementation
'androidx.appcompat:appcompat:1.1.0'
implementation
'androidx.constraintlayout:constraintlayout:1.1.3'
testImplementation
'junit:junit:4.12'
androidTestImplementation
'androidx.test.ext:junit:1.1.1'
androidTestImplementation
'androidx.test.espresso:espresso-core:3.2.0'
api
project
(
':echo-lib'
)
//引入netty之后,class直接就爆炸了。考虑实现API精简
implementation
'com.android.support:multidex:1.0.3'
annotationProcessor
'org.projectlombok:lombok:1.18.2'
}
app/src/main/AndroidManifest.xml
View file @
3a6f2345
<?xml version="1.0" encoding="utf-8"?>
<manifest
xmlns:android=
"http://schemas.android.com/apk/res/android"
xmlns:tools=
"http://schemas.android.com/tools"
package=
"com.virjar.echo.adr"
>
<uses-permission
android:name=
"android.permission.SYSTEM_ALERT_WINDOW"
/>
<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"
/>
<application
android:allowBackup=
"true"
...
...
@@ -16,6 +21,47 @@
<category
android:name=
"android.intent.category.LAUNCHER"
/>
</intent-filter>
</activity>
<service
android:name=
"com.virjar.echo.adr.HttpProxyService"
android:enabled=
"true"
android:exported=
"true"
tools:ignore=
"ExportedService"
>
<intent-filter
android:priority=
"1000"
>
<action
android:name=
"com.virjar.g4proxy.service"
/>
<category
android:name=
"android.intent.category.DEFAULT"
/>
</intent-filter>
</service>
<!--开机自启服务-->
<receiver
android:name=
"com.virjar.echo.adr.StartOnBootBroadcastReceiver"
android:enabled=
"true"
android:exported=
"true"
>
<intent-filter
android:priority=
"1000"
>
<action
android:name=
"android.intent.action.BOOT_COMPLETED"
/>
<!-- <category android:name="android.intent.category.DEFAULT" /> -->
<category
android:name=
"android.intent.category.LAUNCHER"
/>
</intent-filter>
<intent-filter>
<action
android:name=
"android.intent.action.MEDIA_MOUNTED"
/>
<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"
/>
<action
android:name=
"android.intent.action.PACKAGE_REMOVED"
/>
<data
android:scheme=
"package"
/>
</intent-filter>
</receiver>
</application>
</manifest>
\ No newline at end of file
app/src/main/java/com/virjar/echo/adr/HttpProxyService.java
0 → 100644
View file @
3a6f2345
package
com
.
virjar
.
echo
.
adr
;
import
android.app.Notification
;
import
android.app.NotificationChannel
;
import
android.app.NotificationManager
;
import
android.app.PendingIntent
;
import
android.app.Service
;
import
android.content.Intent
;
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
java.util.UUID
;
import
java.util.concurrent.atomic.AtomicBoolean
;
import
static
android
.
app
.
PendingIntent
.
FLAG_UPDATE_CURRENT
;
public
class
HttpProxyService
extends
Service
{
private
EchoClient
echoClient
;
@Nullable
@android
.
support
.
annotation
.
Nullable
@Override
public
IBinder
onBind
(
Intent
intent
)
{
startService
();
return
null
;
}
@Override
public
int
onStartCommand
(
Intent
intent
,
int
flags
,
int
startId
)
{
startService
();
return
START_STICKY
;
}
private
AtomicBoolean
serviceStarted
=
new
AtomicBoolean
(
false
);
private
void
startService
()
{
if
(
serviceStarted
.
compareAndSet
(
false
,
true
))
{
startServiceInternal
();
}
}
private
void
setNotifyChannel
()
{
if
(
Build
.
VERSION
.
SDK_INT
<
Build
.
VERSION_CODES
.
O
)
{
return
;
}
NotificationChannel
notificationChannel
=
new
NotificationChannel
(
BuildConfig
.
APPLICATION_ID
,
"channel"
,
NotificationManager
.
IMPORTANCE_HIGH
);
notificationChannel
.
enableLights
(
true
);
notificationChannel
.
setLightColor
(
Color
.
YELLOW
);
notificationChannel
.
setShowBadge
(
true
);
notificationChannel
.
setLockscreenVisibility
(
Notification
.
VISIBILITY_PUBLIC
);
NotificationManager
manager
=
(
NotificationManager
)
getSystemService
(
NOTIFICATION_SERVICE
);
if
(
manager
==
null
)
{
return
;
}
manager
.
createNotificationChannel
(
notificationChannel
);
}
private
void
startServiceInternal
()
{
setNotifyChannel
();
Notification
.
Builder
builder
=
new
Notification
.
Builder
(
this
.
getApplicationContext
());
//获取一个Notification构造器
// 设置PendingIntent
Intent
nfIntent
=
new
Intent
(
this
,
MainActivity
.
class
);
builder
.
setContentIntent
(
PendingIntent
.
getActivity
(
this
,
0
,
nfIntent
,
FLAG_UPDATE_CURRENT
))
.
setLargeIcon
(
BitmapFactory
.
decodeResource
(
this
.
getResources
(),
R
.
mipmap
.
ic_launcher
))
// 设置下拉列表中的图标(大图标)
.
setContentTitle
(
"EchoProxy"
)
.
setSmallIcon
(
R
.
mipmap
.
ic_launcher
)
.
setContentText
(
"代理服务agent"
)
.
setWhen
(
System
.
currentTimeMillis
());
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
O
)
{
builder
.
setChannelId
(
BuildConfig
.
APPLICATION_ID
);
}
Notification
notification
=
builder
.
build
();
notification
.
defaults
=
Notification
.
DEFAULT_SOUND
;
startForeground
(
110
,
notification
);
//TODO 设备ID生成算法
String
clientKey
=
UUID
.
randomUUID
().
toString
();
Log
.
i
(
"weijia"
,
"start EchoProxy front service"
);
//TODO 设置服务器信息
echoClient
=
new
EchoClient
(
"echo.virjar.com"
,
5698
,
clientKey
);
echoClient
.
startUp
();
}
}
app/src/main/java/com/virjar/echo/adr/MainActivity.java
View file @
3a6f2345
package
com
.
virjar
.
echo
.
adr
;
import
android.content.Intent
;
import
android.os.Bundle
;
import
androidx.appcompat.app.AppCompatActivity
;
...
...
@@ -10,5 +11,7 @@ public class MainActivity extends AppCompatActivity {
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
setContentView
(
R
.
layout
.
activity_main
);
startService
(
new
Intent
(
this
,
HttpProxyService
.
class
));
}
}
app/src/main/java/com/virjar/echo/adr/StartOnBootBroadcastReceiver.java
0 → 100644
View file @
3a6f2345
package
com
.
virjar
.
echo
.
adr
;
import
android.annotation.SuppressLint
;
import
android.content.BroadcastReceiver
;
import
android.content.Context
;
import
android.content.Intent
;
import
android.util.Log
;
public
class
StartOnBootBroadcastReceiver
extends
BroadcastReceiver
{
@SuppressLint
(
"UnsafeProtectedBroadcastReceiver"
)
@Override
public
void
onReceive
(
Context
context
,
Intent
intent
)
{
Log
.
i
(
"weijia"
,
"receive start service broadcast"
);
context
.
startService
(
new
Intent
(
context
,
HttpProxyService
.
class
));
// clearAbortBroadcast();
}
}
deploy/hermes_key
0 → 100644
View file @
3a6f2345
File added
deploy/reward.jpg
0 → 100644
View file @
3a6f2345
163 KB
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment