mirror of
https://github.com/AceDroidX/frp-Android.git
synced 2024-11-16 03:32:20 +08:00
更改全局常量位置
This commit is contained in:
parent
b02ed4f508
commit
010860ddcd
|
@ -32,6 +32,11 @@ android {
|
|||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
|
||||
signingConfig signingConfigs.AceKeystore
|
||||
|
||||
buildConfigField("String", "FrpVersion", '"0.56.0"')
|
||||
buildConfigField("String", "FrpcFileName", '"libfrpc.so"')
|
||||
buildConfigField("String", "LogFileName", '"frpc.log"')
|
||||
buildConfigField("String", "ConfigFileName", '"config.ini"')
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
|
|
|
@ -8,8 +8,6 @@ import android.widget.Button
|
|||
import android.widget.EditText
|
||||
|
||||
class ConfigActivity : AppCompatActivity() {
|
||||
val configname = "config.ini"
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_config)
|
||||
|
@ -25,8 +23,8 @@ class ConfigActivity : AppCompatActivity() {
|
|||
fun readConfig() {
|
||||
val files: Array<String> = this.fileList()
|
||||
val configEditText = findViewById<EditText>(R.id.configEditText)
|
||||
if (files.contains(configname)) {
|
||||
val mReader = this.openFileInput(configname).bufferedReader()
|
||||
if (files.contains(BuildConfig.ConfigFileName)) {
|
||||
val mReader = this.openFileInput(BuildConfig.ConfigFileName).bufferedReader()
|
||||
val mRespBuff = StringBuffer()
|
||||
val buff = CharArray(1024)
|
||||
var ch = 0
|
||||
|
@ -42,7 +40,7 @@ class ConfigActivity : AppCompatActivity() {
|
|||
|
||||
fun saveConfig() {
|
||||
val configEditText = findViewById<EditText>(R.id.configEditText)
|
||||
this.openFileOutput(configname, Context.MODE_PRIVATE).use {
|
||||
this.openFileOutput(BuildConfig.ConfigFileName, Context.MODE_PRIVATE).use {
|
||||
it.write(configEditText.text.toString().toByteArray())
|
||||
// Log.d("adx",configEditText.text.toString())
|
||||
}
|
||||
|
|
|
@ -23,11 +23,6 @@ import java.io.File
|
|||
|
||||
|
||||
class MainActivity : AppCompatActivity() {
|
||||
val filename = "libfrpc.so"
|
||||
val frpver = "0.56.0"
|
||||
val logname = "frpc.log"
|
||||
val configname = "config.ini"
|
||||
|
||||
private lateinit var state_switch: SwitchCompat
|
||||
private lateinit var auto_start_switch: SwitchCompat
|
||||
|
||||
|
@ -58,7 +53,7 @@ class MainActivity : AppCompatActivity() {
|
|||
|
||||
val versionName = packageManager.getPackageInfo(packageName, 0).versionName
|
||||
val titleText = findViewById<TextView>(R.id.titleText)
|
||||
titleText.text = "frp for Android - ${versionName}/${frpver}"
|
||||
titleText.text = "frp for Android - ${versionName}/${BuildConfig.FrpVersion}"
|
||||
|
||||
checkConfig()
|
||||
checkNotificationPermission()
|
||||
|
@ -100,7 +95,7 @@ class MainActivity : AppCompatActivity() {
|
|||
}
|
||||
val deleteButton = findViewById<Button>(R.id.deleteButton)
|
||||
deleteButton.setOnClickListener {
|
||||
val logfile = File(this.filesDir.toString() + "/$logname")
|
||||
val logfile = File(this.filesDir.toString() + "/${BuildConfig.LogFileName}")
|
||||
Log.d("adx", logfile.absoluteFile.toString())
|
||||
logfile.delete()
|
||||
readLog()
|
||||
|
@ -110,8 +105,8 @@ class MainActivity : AppCompatActivity() {
|
|||
fun readLog() {
|
||||
val files: Array<String> = this.fileList()
|
||||
val logTextView = findViewById<TextView>(R.id.logTextView)
|
||||
if (files.contains(logname)) {
|
||||
val mReader = this.openFileInput(logname).bufferedReader()
|
||||
if (files.contains(BuildConfig.LogFileName)) {
|
||||
val mReader = this.openFileInput(BuildConfig.LogFileName).bufferedReader()
|
||||
val mRespBuff = StringBuffer()
|
||||
val buff = CharArray(1024)
|
||||
var ch = 0
|
||||
|
@ -128,17 +123,17 @@ class MainActivity : AppCompatActivity() {
|
|||
fun checkConfig() {
|
||||
val files: Array<String> = this.fileList()
|
||||
Log.d("adx", files.joinToString(","))
|
||||
if (!files.contains(configname)) {
|
||||
if (!files.contains(BuildConfig.ConfigFileName)) {
|
||||
val assetmanager = resources.assets
|
||||
this.openFileOutput(configname, Context.MODE_PRIVATE).use {
|
||||
it.write(assetmanager.open((configname)).readBytes())
|
||||
this.openFileOutput(BuildConfig.ConfigFileName, Context.MODE_PRIVATE).use {
|
||||
it.write(assetmanager.open((BuildConfig.ConfigFileName)).readBytes())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun startShell() {
|
||||
val intent = Intent(this, ShellService::class.java)
|
||||
intent.putExtra("filename", filename)
|
||||
intent.putExtra("filename", BuildConfig.FrpcFileName)
|
||||
startService(intent)
|
||||
// Bind to LocalService
|
||||
bindService(intent, connection, Context.BIND_AUTO_CREATE)
|
||||
|
|
|
@ -62,7 +62,7 @@ class ShellService : Service() {
|
|||
Log.d("adx", "native library dir ${ainfo.nativeLibraryDir}")
|
||||
try {
|
||||
p = Runtime.getRuntime().exec(
|
||||
"${ainfo.nativeLibraryDir}/${filename} -c config.ini", arrayOf(""), this.filesDir
|
||||
"${ainfo.nativeLibraryDir}/${filename} -c ${BuildConfig.ConfigFileName}", arrayOf(""), this.filesDir
|
||||
)
|
||||
} catch (e: Exception) {
|
||||
Log.e("adx", e.stackTraceToString())
|
||||
|
|
Loading…
Reference in New Issue
Block a user