master
AceDroidX 3 years ago
parent e571590b5c
commit db9d92c976

@ -16,15 +16,15 @@ android {
storePassword keystoreProperties['storePassword'] storePassword keystoreProperties['storePassword']
} }
} }
compileSdkVersion 31 compileSdkVersion 32
buildToolsVersion "32.1.0-rc1" buildToolsVersion "33.0.0-rc4"
defaultConfig { defaultConfig {
applicationId "io.github.acedroidx.frp" applicationId "io.github.acedroidx.frp"
minSdkVersion 22 minSdkVersion 23
targetSdkVersion 31 targetSdkVersion 32
versionCode 2 versionCode 3
versionName "1.0.1" versionName "1.0.2"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
@ -48,15 +48,28 @@ android {
kotlinOptions { kotlinOptions {
jvmTarget = '11' jvmTarget = '11'
} }
packagingOptions {
jniLibs {
useLegacyPackaging true
}
}
splits {
abi {
enable true
reset()
include "arm64-v8a", "x86_64"
universalApk true
}
}
} }
dependencies { dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation 'androidx.core:core-ktx:1.7.0' implementation 'androidx.core:core-ktx:1.7.0'
implementation 'androidx.appcompat:appcompat:1.4.1' implementation 'androidx.appcompat:appcompat:1.4.1'
implementation 'com.google.android.material:material:1.5.0' implementation 'com.google.android.material:material:1.6.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.3' implementation 'androidx.constraintlayout:constraintlayout:2.1.3'
testImplementation 'junit:junit:4.13.1' testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3' androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0' androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
} }

@ -23,12 +23,12 @@
<service <service
android:name=".ShellService" android:name=".ShellService"
android:enabled="true" android:enabled="true"
android:exported="true" /> android:exported="false" />
<activity <activity
android:name=".MainActivity" android:name=".MainActivity"
android:launchMode="singleInstance" android:exported="true"
android:exported="true"> android:launchMode="singleInstance">
<intent-filter> <intent-filter>
<action android:name="android.intent.action.MAIN" /> <action android:name="android.intent.action.MAIN" />

@ -17,8 +17,8 @@ import java.io.File
class MainActivity : AppCompatActivity() { class MainActivity : AppCompatActivity() {
val filename = "frpc" val filename = "libfrpc.so"
val frpver = "0.41.0" val frpver = "0.42.0"
val logname = "frpc.log" val logname = "frpc.log"
val configname = "config.ini" val configname = "config.ini"

@ -59,8 +59,19 @@ class ShellService : Service() {
val ainfo = val ainfo =
packageManager.getApplicationInfo(packageName, PackageManager.GET_SHARED_LIBRARY_FILES) packageManager.getApplicationInfo(packageName, PackageManager.GET_SHARED_LIBRARY_FILES)
Log.d("adx", "native library dir ${ainfo.nativeLibraryDir}") Log.d("adx", "native library dir ${ainfo.nativeLibraryDir}")
try {
p = Runtime.getRuntime() p = Runtime.getRuntime()
.exec("${ainfo.nativeLibraryDir}/${filename} -c config.ini", arrayOf(""), this.filesDir) .exec(
"${ainfo.nativeLibraryDir}/${filename} -c config.ini",
arrayOf(""),
this.filesDir
)
} catch (e: Exception) {
Log.e("adx", e.stackTraceToString())
Toast.makeText(this, e.message, Toast.LENGTH_LONG).show()
stopSelf()
return START_NOT_STICKY
}
Toast.makeText(this, "已启动服务", Toast.LENGTH_SHORT).show() Toast.makeText(this, "已启动服务", Toast.LENGTH_SHORT).show()
startForeground(1, showMotification()); startForeground(1, showMotification());
return START_NOT_STICKY return START_NOT_STICKY
@ -75,7 +86,7 @@ class ShellService : Service() {
private fun showMotification(): Notification { private fun showMotification(): Notification {
val pendingIntent: PendingIntent = val pendingIntent: PendingIntent =
Intent(this, MainActivity::class.java).let { notificationIntent -> Intent(this, MainActivity::class.java).let { notificationIntent ->
PendingIntent.getActivity(this, 0, notificationIntent, 0) PendingIntent.getActivity(this, 0, notificationIntent, PendingIntent.FLAG_IMMUTABLE)
} }
val notification: Notification = NotificationCompat.Builder(this, "shell_bg") val notification: Notification = NotificationCompat.Builder(this, "shell_bg")
.setSmallIcon(R.drawable.ic_launcher_foreground) .setSmallIcon(R.drawable.ic_launcher_foreground)

@ -1,12 +1,12 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules. // Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript { buildscript {
ext.kotlin_version = "1.6.10" ext.kotlin_version = "1.6.21"
repositories { repositories {
google() google()
jcenter() jcenter()
} }
dependencies { dependencies {
classpath 'com.android.tools.build:gradle:7.1.2' classpath 'com.android.tools.build:gradle:7.1.3'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
// NOTE: Do not place your application dependencies here; they belong // NOTE: Do not place your application dependencies here; they belong

Loading…
Cancel
Save