mirror of
https://github.com/AceDroidX/frp-Android.git
synced 2024-11-16 03:32:20 +08:00
适配Android 10及更高版本
适配API 29及以上的行为变更 更新依赖
This commit is contained in:
parent
3f80eb79bd
commit
e571590b5c
|
@ -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'
|
||||
}
|
|
@ -27,7 +27,8 @@
|
|||
|
||||
<activity
|
||||
android:name=".MainActivity"
|
||||
android:launchMode="singleInstance">
|
||||
android:launchMode="singleInstance"
|
||||
android:exported="true">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
|
||||
|
|
|
@ -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<TextView>(R.id.titleText)
|
||||
titleText.text = "frp for Android - ${versionName}/${frpver}"
|
||||
|
||||
checkConfig()
|
||||
createBGNotificationChannel()
|
||||
|
||||
|
@ -107,19 +108,6 @@ class MainActivity : AppCompatActivity() {
|
|||
}
|
||||
}
|
||||
|
||||
fun checkBinary() {
|
||||
val files: Array<String> = 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<String> = this.fileList()
|
||||
Log.d("adx", files.joinToString(","))
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
android:orientation="vertical" >
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView2"
|
||||
android:id="@+id/titleText"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="frp for Android"
|
||||
|
|
Binary file not shown.
BIN
app/src/main/resources/lib/x86_64/frpc
Normal file
BIN
app/src/main/resources/lib/x86_64/frpc
Normal file
Binary file not shown.
|
@ -1,12 +1,12 @@
|
|||
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
||||
buildscript {
|
||||
ext.kotlin_version = "1.3.72"
|
||||
ext.kotlin_version = "1.6.10"
|
||||
repositories {
|
||||
google()
|
||||
jcenter()
|
||||
}
|
||||
dependencies {
|
||||
classpath "com.android.tools.build:gradle:4.1.1"
|
||||
classpath 'com.android.tools.build:gradle:7.1.2'
|
||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
||||
|
||||
// NOTE: Do not place your application dependencies here; they belong
|
||||
|
|
6
gradle/wrapper/gradle-wrapper.properties
vendored
6
gradle/wrapper/gradle-wrapper.properties
vendored
|
@ -1,6 +1,6 @@
|
|||
#Sat Dec 12 16:31:09 CST 2020
|
||||
#Thu Mar 24 09:47:16 CST 2022
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.1-bin.zip
|
||||
distributionPath=wrapper/dists
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-bin.zip
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
|
|
4
keystore.example.properties
Normal file
4
keystore.example.properties
Normal file
|
@ -0,0 +1,4 @@
|
|||
storeFile=C:\\path\\to\\Keystore.jks
|
||||
storePassword=
|
||||
keyAlias=
|
||||
keyPassword=
|
Loading…
Reference in New Issue
Block a user