diff --git a/app/build.gradle b/app/build.gradle index 086d999..6ed2f14 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -16,15 +16,15 @@ android { storePassword keystoreProperties['storePassword'] } } - compileSdkVersion 29 - buildToolsVersion "30.0.3" + compileSdkVersion 31 + buildToolsVersion "32.1.0-rc1" defaultConfig { applicationId "io.github.acedroidx.frp" minSdkVersion 22 - targetSdkVersion 29 - versionCode 1 - versionName "1.0" + targetSdkVersion 31 + versionCode 2 + versionName "1.0.1" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" @@ -42,22 +42,21 @@ android { } } compileOptions { - sourceCompatibility JavaVersion.VERSION_1_8 - targetCompatibility JavaVersion.VERSION_1_8 + sourceCompatibility JavaVersion.VERSION_11 + targetCompatibility JavaVersion.VERSION_11 } kotlinOptions { - jvmTarget = '1.8' + jvmTarget = '11' } } dependencies { - implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" - implementation 'androidx.core:core-ktx:1.3.2' - implementation 'androidx.appcompat:appcompat:1.2.0' - implementation 'com.google.android.material:material:1.2.1' - implementation 'androidx.constraintlayout:constraintlayout:2.0.4' + implementation 'androidx.core:core-ktx:1.7.0' + implementation 'androidx.appcompat:appcompat:1.4.1' + implementation 'com.google.android.material:material:1.5.0' + implementation 'androidx.constraintlayout:constraintlayout:2.1.3' testImplementation 'junit:junit:4.13.1' - androidTestImplementation 'androidx.test.ext:junit:1.1.2' - androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0' + androidTestImplementation 'androidx.test.ext:junit:1.1.3' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0' } \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index fffe159..c898a67 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -27,7 +27,8 @@ + android:launchMode="singleInstance" + android:exported="true"> diff --git a/app/src/main/java/io/github/acedroidx/frp/MainActivity.kt b/app/src/main/java/io/github/acedroidx/frp/MainActivity.kt index eaf2f0d..c067921 100644 --- a/app/src/main/java/io/github/acedroidx/frp/MainActivity.kt +++ b/app/src/main/java/io/github/acedroidx/frp/MainActivity.kt @@ -11,16 +11,14 @@ import android.os.IBinder import android.util.Log import android.widget.Button import android.widget.TextView -import android.widget.Toast import androidx.appcompat.app.AppCompatActivity import androidx.appcompat.widget.SwitchCompat -import androidx.core.app.NotificationCompat import java.io.File -import kotlin.math.log class MainActivity : AppCompatActivity() { - val filename = "frpc_0.34.3_linux_arm64" + val filename = "frpc" + val frpver = "0.41.0" val logname = "frpc.log" val configname = "config.ini" @@ -51,7 +49,10 @@ class MainActivity : AppCompatActivity() { super.onCreate(savedInstanceState) setContentView(R.layout.activity_main) - checkBinary() + val versionName = packageManager.getPackageInfo(packageName, 0).versionName + val titleText = findViewById(R.id.titleText) + titleText.text = "frp for Android - ${versionName}/${frpver}" + checkConfig() createBGNotificationChannel() @@ -107,19 +108,6 @@ class MainActivity : AppCompatActivity() { } } - fun checkBinary() { - val files: Array = this.fileList() - Log.d("adx", files.joinToString(",")) - if (!files.contains(filename)) { - val assetmanager = resources.assets - this.openFileOutput(filename, Context.MODE_PRIVATE).use { - it.write(assetmanager.open((filename)).readBytes()) - } - val file = File(this.filesDir.toString() + "/$filename") - file.setExecutable(true) - } - } - fun checkConfig() { val files: Array = this.fileList() Log.d("adx", files.joinToString(",")) diff --git a/app/src/main/java/io/github/acedroidx/frp/ShellService.kt b/app/src/main/java/io/github/acedroidx/frp/ShellService.kt index ed1b60f..dc55751 100644 --- a/app/src/main/java/io/github/acedroidx/frp/ShellService.kt +++ b/app/src/main/java/io/github/acedroidx/frp/ShellService.kt @@ -4,13 +4,12 @@ import android.app.Notification import android.app.PendingIntent import android.app.Service import android.content.Intent +import android.content.pm.PackageManager import android.os.Binder import android.os.IBinder import android.util.Log import android.widget.Toast import androidx.core.app.NotificationCompat -import java.io.BufferedReader -import java.io.InputStreamReader import java.util.* class ShellService : Service() { @@ -57,7 +56,11 @@ class ShellService : Service() { stopSelf() return START_NOT_STICKY } - p = Runtime.getRuntime().exec("./$filename -c config.ini", arrayOf(""), this.filesDir) + val ainfo = + packageManager.getApplicationInfo(packageName, PackageManager.GET_SHARED_LIBRARY_FILES) + Log.d("adx", "native library dir ${ainfo.nativeLibraryDir}") + p = Runtime.getRuntime() + .exec("${ainfo.nativeLibraryDir}/${filename} -c config.ini", arrayOf(""), this.filesDir) Toast.makeText(this, "已启动服务", Toast.LENGTH_SHORT).show() startForeground(1, showMotification()); return START_NOT_STICKY diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index 66e1c6d..b19da0b 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -17,7 +17,7 @@ android:orientation="vertical" >