初始化项目
This commit is contained in:
@@ -0,0 +1,4 @@
|
||||
.gradle/
|
||||
.idea/
|
||||
.svn/
|
||||
app/release/
|
||||
@@ -0,0 +1 @@
|
||||
/build
|
||||
@@ -0,0 +1,109 @@
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.Date
|
||||
import java.util.Locale
|
||||
|
||||
plugins {
|
||||
alias(libs.plugins.android.application)
|
||||
alias(libs.plugins.jetbrains.kotlin.android)
|
||||
}
|
||||
|
||||
android {
|
||||
namespace = "com.bbitcn.bbit_frp2"
|
||||
compileSdk = 34
|
||||
|
||||
defaultConfig {
|
||||
applicationId = "com.bbitcn.bbit_frp2"
|
||||
minSdk = 25
|
||||
//noinspection ExpiredTargetSdkVersion
|
||||
targetSdk = 32
|
||||
versionCode = 15
|
||||
versionName = "1.15"
|
||||
|
||||
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
||||
vectorDrawables {
|
||||
useSupportLibrary = true
|
||||
}
|
||||
ndk {
|
||||
abiFilters.addAll(listOf("armeabi", "armeabi-v7a", "x86"))
|
||||
}
|
||||
buildConfigField("String", "FrpVersion", "\"0.56.0\"")
|
||||
buildConfigField("String", "FrpcFileName", "\"libfrpc.so\"")
|
||||
buildConfigField("String", "LogFileName", "\"frpc.log\"")
|
||||
buildConfigField("String", "ConfigFileName", "\"config.toml\"")
|
||||
}
|
||||
|
||||
packagingOptions {
|
||||
jniLibs {
|
||||
useLegacyPackaging = true
|
||||
}
|
||||
}
|
||||
|
||||
compileOptions {
|
||||
sourceCompatibility = JavaVersion.VERSION_1_8
|
||||
targetCompatibility = JavaVersion.VERSION_1_8
|
||||
}
|
||||
kotlinOptions {
|
||||
jvmTarget = "1.8"
|
||||
}
|
||||
buildFeatures {
|
||||
compose = true
|
||||
buildConfig = true
|
||||
}
|
||||
composeOptions {
|
||||
kotlinCompilerExtensionVersion = "1.5.1"
|
||||
}
|
||||
packaging {
|
||||
resources {
|
||||
excludes += "/META-INF/{AL2.0,LGPL2.1}"
|
||||
}
|
||||
}
|
||||
|
||||
signingConfigs {
|
||||
// create("config") {
|
||||
// keyAlias = "key0"
|
||||
// keyPassword = "123456"
|
||||
// storeFile = file("../key/key.jks")
|
||||
// storePassword = "123456"
|
||||
// }
|
||||
getByName("debug") {
|
||||
keyAlias = "key0"
|
||||
keyPassword = "123456"
|
||||
storeFile = file("../key/store.jks")
|
||||
storeType = "jks"
|
||||
storePassword = "123456"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation(libs.androidx.core.ktx)
|
||||
implementation(libs.androidx.lifecycle.runtime.ktx)
|
||||
implementation(libs.androidx.activity.compose)
|
||||
implementation(platform(libs.androidx.compose.bom))
|
||||
implementation(libs.androidx.ui)
|
||||
implementation(libs.androidx.ui.graphics)
|
||||
implementation(libs.androidx.ui.tooling.preview)
|
||||
implementation(libs.androidx.material3)
|
||||
testImplementation(libs.junit)
|
||||
androidTestImplementation(libs.androidx.junit)
|
||||
androidTestImplementation(libs.androidx.espresso.core)
|
||||
androidTestImplementation(platform(libs.androidx.compose.bom))
|
||||
androidTestImplementation(libs.androidx.ui.test.junit4)
|
||||
debugImplementation(libs.androidx.ui.tooling)
|
||||
debugImplementation(libs.androidx.ui.test.manifest)
|
||||
//GSON
|
||||
implementation(libs.com.google.code.gson.gson2)
|
||||
//util
|
||||
implementation("com.blankj:utilcodex:1.31.1")
|
||||
//网络请求库
|
||||
implementation("org.xutils:xutils:3.9.0")
|
||||
//RxJava
|
||||
implementation("io.reactivex.rxjava2:rxjava:2.2.20")
|
||||
implementation("io.reactivex.rxjava2:rxandroid:2.1.1")
|
||||
implementation("com.jakewharton.rxbinding2:rxbinding:2.2.0")
|
||||
implementation("com.github.xuexiangjys:RxUtil2:1.2.1")
|
||||
//lifecycle-viewmodel-compose
|
||||
implementation(libs.androidx.lifecycle.viewmodel.compose)
|
||||
//权限库
|
||||
// implementation ("com.github.getActivity:XXPermissions:18.5")
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<issues format="6" by="lint 8.7.0-alpha02" type="baseline" client="gradle" dependencies="false" name="AGP (8.7.0-alpha02)" variant="fatal" version="8.7.0-alpha02">
|
||||
|
||||
<issue
|
||||
id="ExpiredTargetSdkVersion"
|
||||
message="Google Play requires that apps target API level 33 or higher."
|
||||
errorLine1=" targetSdk = 30"
|
||||
errorLine2=" ~~~~~~~~~~~~~~">
|
||||
<location
|
||||
file="build.gradle.kts"
|
||||
line="14"
|
||||
column="9"/>
|
||||
</issue>
|
||||
|
||||
</issues>
|
||||
Vendored
+21
@@ -0,0 +1,21 @@
|
||||
# Add project specific ProGuard rules here.
|
||||
# You can control the set of applied configuration files using the
|
||||
# proguardFiles setting in build.gradle.
|
||||
#
|
||||
# For more details, see
|
||||
# http://developer.android.com/guide/developing/tools/proguard.html
|
||||
|
||||
# If your project uses WebView with JS, uncomment the following
|
||||
# and specify the fully qualified class name to the JavaScript interface
|
||||
# class:
|
||||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
|
||||
# public *;
|
||||
#}
|
||||
|
||||
# Uncomment this to preserve the line number information for
|
||||
# debugging stack traces.
|
||||
#-keepattributes SourceFile,LineNumberTable
|
||||
|
||||
# If you keep the line number information, uncomment this to
|
||||
# hide the original source file name.
|
||||
#-renamesourcefileattribute SourceFile
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.bbitcn.bbit_frp2
|
||||
|
||||
import androidx.test.platform.app.InstrumentationRegistry
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
|
||||
import org.junit.Assert.*
|
||||
|
||||
/**
|
||||
* Instrumented test, which will execute on an Android device.
|
||||
*
|
||||
* See [testing documentation](http://d.android.com/tools/testing).
|
||||
*/
|
||||
@RunWith(AndroidJUnit4::class)
|
||||
class ExampleInstrumentedTest {
|
||||
@Test
|
||||
fun useAppContext() {
|
||||
// Context of the app under test.
|
||||
val appContext = InstrumentationRegistry.getInstrumentation().targetContext
|
||||
assertEquals("com.bbitcn.bbit_frp", appContext.packageName)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools">
|
||||
|
||||
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
|
||||
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_SPECIAL_USE" />
|
||||
|
||||
<application
|
||||
android:name=".MyApp"
|
||||
android:allowBackup="true"
|
||||
android:dataExtractionRules="@xml/data_extraction_rules"
|
||||
android:fullBackupContent="@xml/backup_rules"
|
||||
android:icon="@drawable/logo"
|
||||
android:label="@string/app_name"
|
||||
android:roundIcon="@drawable/logo"
|
||||
android:supportsRtl="true"
|
||||
android:theme="@style/Theme.BBIT_FRP"
|
||||
android:usesCleartextTraffic="true"
|
||||
android:requestLegacyExternalStorage="true"
|
||||
tools:targetApi="31">
|
||||
<activity
|
||||
android:name=".ui.MainActivity"
|
||||
android:exported="true"
|
||||
android:theme="@style/Theme.BBIT_FRP">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
<service
|
||||
android:name=".service.ShellService"
|
||||
android:enabled="true"
|
||||
android:exported="false"
|
||||
android:foregroundServiceType="specialUse">
|
||||
<property
|
||||
android:name="android.app.PROPERTY_SPECIAL_USE_FGS_SUBTYPE"
|
||||
android:value="explanation_for_special_use" />
|
||||
</service>
|
||||
<receiver
|
||||
android:name=".receiver.BootReceiver"
|
||||
android:enabled="true"
|
||||
android:exported="false">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.BOOT_COMPLETED" />
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
</intent-filter>
|
||||
</receiver>
|
||||
<receiver android:name=".receiver.FrpStartReceiver"
|
||||
android:exported="true">
|
||||
<intent-filter>
|
||||
<action android:name="receiver_control" />
|
||||
</intent-filter>
|
||||
</receiver>
|
||||
<provider
|
||||
android:name="androidx.core.content.FileProvider"
|
||||
android:authorities="com.bbitcn.bbit_frp2.fileprovider"
|
||||
android:exported="false"
|
||||
android:grantUriPermissions="true">
|
||||
<meta-data
|
||||
android:name="android.support.FILE_PROVIDER_PATHS"
|
||||
android:resource="@xml/provider_paths" />
|
||||
</provider>
|
||||
<meta-data android:name="ScopedStorage" android:value="true" />
|
||||
</application>
|
||||
</manifest>
|
||||
@@ -0,0 +1,51 @@
|
||||
package com.bbitcn.bbit_frp2
|
||||
|
||||
import android.app.Application
|
||||
import android.content.Context
|
||||
import android.provider.Settings
|
||||
import android.util.Log
|
||||
import androidx.lifecycle.ViewModelProvider.NewInstanceFactory.Companion.instance
|
||||
import com.bbitcn.bbit_frp2.utils.net.Url
|
||||
import org.xutils.x
|
||||
import java.net.Inet6Address
|
||||
import java.net.NetworkInterface
|
||||
|
||||
fun getIPv6Addresses(): List<String> {
|
||||
val ipv6Addresses = mutableListOf<String>()
|
||||
|
||||
val networkInterfaces = NetworkInterface.getNetworkInterfaces()
|
||||
while (networkInterfaces.hasMoreElements()) {
|
||||
val networkInterface = networkInterfaces.nextElement()
|
||||
val inetAddresses = networkInterface.inetAddresses
|
||||
while (inetAddresses.hasMoreElements()) {
|
||||
val inetAddress = inetAddresses.nextElement()
|
||||
// 只添加IPv6地址
|
||||
if (inetAddress is Inet6Address) {
|
||||
ipv6Addresses.add(inetAddress.hostAddress)
|
||||
}
|
||||
}
|
||||
}
|
||||
return ipv6Addresses
|
||||
}
|
||||
|
||||
class MyApp : Application() {
|
||||
override fun onCreate() {
|
||||
super.onCreate()
|
||||
instance = this
|
||||
// 初始化网络请求地址
|
||||
Url.initUrl()
|
||||
// 初始化网络请求库
|
||||
x.Ext.init(this)
|
||||
getIPv6Addresses().forEach {
|
||||
println(it)
|
||||
}
|
||||
Log.e("设备唯一码", Settings.Secure.getString(contentResolver, Settings.Secure.ANDROID_ID))
|
||||
}
|
||||
|
||||
companion object {
|
||||
private var instance: MyApp? = null
|
||||
|
||||
val appContext: Context
|
||||
get() = instance!!.applicationContext
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package com.bbitcn.bbit_frp2.model;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
/**
|
||||
* 通用网络请求
|
||||
* Data值为唯一值的
|
||||
*/
|
||||
public class CommonResponse {
|
||||
|
||||
@SerializedName("Code")
|
||||
private Integer code;
|
||||
@SerializedName("Message")
|
||||
private String message;
|
||||
@SerializedName("Data")
|
||||
private Object data;
|
||||
|
||||
public Integer getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public void setCode(Integer code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
public void setMessage(String message) {
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
public Object getData() {
|
||||
return data;
|
||||
}
|
||||
|
||||
public void setData(Object data) {
|
||||
this.data = data;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.bbitcn.bbit_frp2.model
|
||||
import com.google.gson.annotations.SerializedName
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @Description TODO
|
||||
* @Author DuanKaiji
|
||||
* @CreateTime 2024年06月03日 15:55:00
|
||||
*/
|
||||
data class FrpConfig(
|
||||
@SerializedName("Code")
|
||||
val code: String = "",
|
||||
@SerializedName("Data")
|
||||
val `data`: Data = Data()
|
||||
) {
|
||||
data class Data(
|
||||
@SerializedName("DownloadUrl")
|
||||
val downloadUrl: String = "",
|
||||
@SerializedName("HostName")
|
||||
val hostName: String = "",
|
||||
@SerializedName("LocalPort")
|
||||
val localPort: String = "",
|
||||
@SerializedName("ServicePort")
|
||||
val servicePort: String = "",
|
||||
@SerializedName("ServiceUrl")
|
||||
val serviceUrl: String = ""
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package com.bbitcn.bbit_frp2.model
|
||||
|
||||
import com.google.gson.annotations.SerializedName
|
||||
|
||||
data class FrpNewVersion(
|
||||
@SerializedName("Code")
|
||||
val code: String = "",
|
||||
@SerializedName("Data")
|
||||
val `data`: Data = Data(),
|
||||
@SerializedName("Message")
|
||||
val message: String = ""
|
||||
) {
|
||||
data class Data(
|
||||
@SerializedName("Url")
|
||||
val url: String = "",
|
||||
@SerializedName("VersionDescription")
|
||||
val versionDescription: String = "",
|
||||
@SerializedName("VersionName")
|
||||
val versionName: String = "",
|
||||
@SerializedName("VersionNumber")
|
||||
val versionNumber: String = ""
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.bbitcn.bbit_frp2.receiver;
|
||||
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
|
||||
public class BootReceiver extends BroadcastReceiver {
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
if (Intent.ACTION_BOOT_COMPLETED.equals(intent.getAction())) {
|
||||
Intent launchIntent = context.getPackageManager().getLaunchIntentForPackage(context.getPackageName());
|
||||
if (launchIntent != null) {
|
||||
launchIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
context.startActivity(launchIntent);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.bbitcn.bbit_frp2.receiver
|
||||
|
||||
import android.content.BroadcastReceiver
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import com.bbitcn.bbit_frp2.utils.MyUtils.senBroadcast
|
||||
import com.blankj.utilcode.util.AppUtils
|
||||
|
||||
class FrpStartReceiver : BroadcastReceiver() {
|
||||
override fun onReceive(context: Context, intent: Intent) {
|
||||
if (intent.action == "receiver_control") {
|
||||
val control = intent.getIntExtra("control", 0)
|
||||
if (control == -1) {
|
||||
// 退出应用
|
||||
AppUtils.exitApp()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,151 @@
|
||||
package com.bbitcn.bbit_frp2.service
|
||||
|
||||
import android.app.Notification
|
||||
import android.app.NotificationChannel
|
||||
import android.app.NotificationManager
|
||||
import android.app.Service
|
||||
import android.content.Intent
|
||||
import android.content.pm.PackageManager
|
||||
import android.os.Binder
|
||||
import android.os.Build
|
||||
import android.os.IBinder
|
||||
import android.util.Log
|
||||
import androidx.core.app.NotificationCompat
|
||||
import com.bbitcn.bbit_frp2.utils.Global
|
||||
import com.bbitcn.bbit_frp2.utils.MyUtils
|
||||
import com.blankj.utilcode.util.AppUtils
|
||||
import com.blankj.utilcode.util.SPUtils
|
||||
import java.io.BufferedReader
|
||||
import java.io.File
|
||||
import java.io.IOException
|
||||
import java.io.InputStreamReader
|
||||
|
||||
class ShellService : Service(), ShellThreadListener {
|
||||
|
||||
private var processThread: Thread? = null
|
||||
private val outputBuilder = StringBuilder()
|
||||
private val CHANNEL_ID = "ForegroundServiceChannel"
|
||||
private var notificationManager: NotificationManager? = null
|
||||
|
||||
override fun onCreate() {
|
||||
super.onCreate()
|
||||
notificationManager = getSystemService(NotificationManager::class.java)
|
||||
createNotificationChannel()
|
||||
}
|
||||
|
||||
private val binder = LocalBinder()
|
||||
|
||||
inner class LocalBinder : Binder() {
|
||||
fun getService(): ShellService = this@ShellService
|
||||
}
|
||||
|
||||
override fun onBind(intent: Intent): IBinder = binder
|
||||
|
||||
private fun createNotificationChannel() {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
val serviceChannel = NotificationChannel(
|
||||
CHANNEL_ID,
|
||||
"Foreground Service Channel",
|
||||
NotificationManager.IMPORTANCE_DEFAULT
|
||||
)
|
||||
notificationManager?.createNotificationChannel(serviceChannel)
|
||||
startForeground(1, createNotification("服务已启动"))
|
||||
}
|
||||
}
|
||||
|
||||
private fun createNotification(contentText: String): Notification {
|
||||
return NotificationCompat.Builder(this, CHANNEL_ID)
|
||||
.setContentTitle("BBIT远程协助服务")
|
||||
.setContentText(contentText)
|
||||
.setSmallIcon(android.R.drawable.ic_lock_lock)
|
||||
.build()
|
||||
}
|
||||
|
||||
fun updateNotification(newText: String) {
|
||||
Log.e("updateNotification", newText)
|
||||
MyUtils.senBroadcast(this, newText)
|
||||
val updatedNotification = createNotification(newText)
|
||||
notificationManager?.notify(1, updatedNotification)
|
||||
}
|
||||
|
||||
override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int {
|
||||
when (intent?.action) {
|
||||
"RESTART" -> restartService()
|
||||
else -> startFrpService()
|
||||
}
|
||||
return START_REDELIVER_INTENT
|
||||
}
|
||||
|
||||
private fun restartService() {
|
||||
stopSelf()
|
||||
startService(Intent(this, ShellService::class.java))
|
||||
}
|
||||
|
||||
private fun startFrpService() {
|
||||
try {
|
||||
if (processThread != null) return
|
||||
val ainfo = packageManager.getApplicationInfo(
|
||||
packageName, PackageManager.GET_SHARED_LIBRARY_FILES
|
||||
)
|
||||
// System.loadLibrary("frpc") //调试时使用
|
||||
runCommand(
|
||||
"${ainfo.nativeLibraryDir}/libfrpc.so -c config.toml",
|
||||
arrayOf(""), filesDir
|
||||
)
|
||||
updateNotification("远程协助已启动:${AppUtils.getAppVersionCode()}:${SPUtils.getInstance().getString(Global.CLIENT_PORT)}")
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
Global.frpIsRunning = false
|
||||
updateNotification("远程协助启动失败")
|
||||
stopSelf()
|
||||
}
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
processThread?.interrupt()
|
||||
Global.frpIsRunning = false
|
||||
updateNotification("远程协助关闭")
|
||||
}
|
||||
|
||||
private fun runCommand(command: String, envp: Array<String>, dir: File) {
|
||||
processThread = ShellThread(command, envp, dir, this) { outputBuilder.append(it).append("\n") }
|
||||
processThread?.start()
|
||||
}
|
||||
|
||||
class ShellThread(
|
||||
private val command: String,
|
||||
private val envp: Array<String>,
|
||||
private val dir: File,
|
||||
private val listener: ShellThreadListener,
|
||||
private val outputCallback: (text: String) -> Unit
|
||||
) : Thread() {
|
||||
override fun run() {
|
||||
try {
|
||||
Log.d("ShellService", "FRP线程启动")
|
||||
val process = Runtime.getRuntime().exec(command, envp, dir)
|
||||
val reader = BufferedReader(InputStreamReader(process.inputStream))
|
||||
var line: String?
|
||||
Global.frpIsRunning = true
|
||||
while (reader.readLine().also { line = it } != null && !isInterrupted) {
|
||||
line?.let { outputCallback(it) }
|
||||
}
|
||||
reader.close()
|
||||
process.destroy()
|
||||
} catch (e: IOException) {
|
||||
e.printStackTrace()
|
||||
} finally {
|
||||
listener.onThreadClosed()
|
||||
Log.d("ShellService", "FRP线程关闭")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onThreadClosed() {
|
||||
updateNotification("远程协助服务已断开")
|
||||
Global.frpIsRunning = false
|
||||
}
|
||||
}
|
||||
|
||||
interface ShellThreadListener {
|
||||
fun onThreadClosed()
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
package com.bbitcn.bbit_frp2.ui
|
||||
|
||||
import android.content.Intent
|
||||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
import android.util.Log
|
||||
import android.view.View
|
||||
import android.view.WindowInsets
|
||||
import androidx.activity.ComponentActivity
|
||||
import com.bbitcn.bbit_frp2.utils.FrpUtils
|
||||
import com.bbitcn.bbit_frp2.utils.Global
|
||||
import com.bbitcn.bbit_frp2.utils.MyUtils
|
||||
import com.bbitcn.bbit_frp2.utils.MyUtils.sentVersion
|
||||
import com.blankj.utilcode.util.AppUtils
|
||||
import com.blankj.utilcode.util.SPUtils
|
||||
import com.blankj.utilcode.util.StringUtils
|
||||
|
||||
class MainActivity : ComponentActivity() {
|
||||
val presenter: FrpUtils = FrpUtils()
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
MyUtils.sentVersion(this)
|
||||
handleIntent(intent)
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
moveTaskToBack(true)
|
||||
}
|
||||
|
||||
override fun onNewIntent(intent: Intent?) {
|
||||
super.onNewIntent(intent)
|
||||
setIntent(intent) // 更新当前 Intent
|
||||
handleIntent(intent)
|
||||
}
|
||||
|
||||
private fun handleIntent(intent: Intent?) {
|
||||
val data = intent?.getStringExtra("host_id")
|
||||
Log.e("host_id", data.toString())
|
||||
if (StringUtils.isEmpty(Global.getHostId())) {
|
||||
if (data != null) {
|
||||
SPUtils.getInstance().put(Global.HOST_ID, data)
|
||||
presenter.init()
|
||||
} else {
|
||||
// 启动原应用(再自动自己)
|
||||
MyUtils.sentReboot(this)
|
||||
// 关闭当前应用 只有关闭后 才能在其他应用启动自己时获得host_id
|
||||
AppUtils.exitApp()
|
||||
}
|
||||
} else {
|
||||
presenter.init()
|
||||
}
|
||||
Log.e("frp_host_id_mine", Global.getHostId())
|
||||
}
|
||||
override fun onWindowFocusChanged(hasFocus: Boolean) {
|
||||
super.onWindowFocusChanged(hasFocus)
|
||||
if (hasFocus) {
|
||||
hideNavigationBar()
|
||||
}
|
||||
}
|
||||
|
||||
private fun hideNavigationBar() {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
|
||||
// Android 11 及以上 (API 30+)
|
||||
window.setDecorFitsSystemWindows(false)
|
||||
window.insetsController?.hide(WindowInsets.Type.navigationBars())
|
||||
} else {
|
||||
// Android 7.1 - 10 (API 25 - 29)
|
||||
window.decorView.systemUiVisibility =
|
||||
View.SYSTEM_UI_FLAG_HIDE_NAVIGATION or // 隐藏导航栏
|
||||
View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY or // 沉浸模式
|
||||
View.SYSTEM_UI_FLAG_FULLSCREEN // 全屏
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,204 @@
|
||||
package com.bbitcn.bbit_frp2.utils
|
||||
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.os.Build
|
||||
import android.util.Log
|
||||
import com.bbitcn.bbit_frp2.MyApp
|
||||
import com.bbitcn.bbit_frp2.model.FrpConfig
|
||||
import com.bbitcn.bbit_frp2.model.FrpNewVersion
|
||||
import com.bbitcn.bbit_frp2.service.ShellService
|
||||
import com.bbitcn.bbit_frp2.utils.net.Url
|
||||
import com.bbitcn.bbit_frp2.utils.net.XHttpManager
|
||||
import com.bbitcn.bbit_frp2.utils.net.XHttpShorthand
|
||||
import com.blankj.utilcode.util.AppUtils
|
||||
import com.blankj.utilcode.util.SPUtils
|
||||
import com.blankj.utilcode.util.StringUtils
|
||||
import org.xutils.http.RequestParams
|
||||
import org.xutils.x
|
||||
import java.io.IOException
|
||||
|
||||
class FrpUtils {
|
||||
var mService: ShellService? = null
|
||||
|
||||
private fun updateNotification(content: String) {
|
||||
mService?.updateNotification(content)
|
||||
}
|
||||
|
||||
fun init() {
|
||||
updateNotification("正在初始化远程协助服务")
|
||||
checkConfig()
|
||||
// checkVersion(MyApp.appContext)
|
||||
}
|
||||
/**
|
||||
* 刷新配置文件
|
||||
*/
|
||||
fun checkConfig(){
|
||||
val params = XHttpManager.getInstance().getRequestParams(Url.getConfigInfo)
|
||||
params.addParameter("hostcode", Global.getHostId())
|
||||
x.http().get(params, object : XHttpShorthand<FrpConfig>() {
|
||||
override fun success(model: FrpConfig) {
|
||||
val data = model.data
|
||||
Log.e("host_server_ip", data.serviceUrl)
|
||||
SPUtils.getInstance().apply {
|
||||
put(Global.SERVER_IP, data.serviceUrl)
|
||||
put(Global.SERVER_PORT, data.servicePort)
|
||||
put(Global.CLIENT_NAME, data.hostName)
|
||||
put(Global.CLIENT_PORT, data.localPort)
|
||||
}
|
||||
updateNotification("已请求配置信息")
|
||||
}
|
||||
|
||||
override fun error(e: Throwable) {
|
||||
updateNotification("配置信息请求错误,尝试启动中")
|
||||
}
|
||||
|
||||
override fun onFinish() {
|
||||
super.onFinish()
|
||||
updateNotification("初始化远程协助配置文件")
|
||||
initFrpConfig()
|
||||
PollingTask.getInstance().startPollingTaskOnIOThread("check", 10) {
|
||||
if (!Global.frpIsRunning) {
|
||||
updateNotification("正在启动远程协助服务")
|
||||
restart()
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查是否下载
|
||||
*
|
||||
* @param mContext 上下文
|
||||
* @param needNotice 是否需要提示
|
||||
*/
|
||||
fun checkVersion(mContext: Context) {
|
||||
val params = XHttpManager.getInstance().getRequestParams(Url.getNewVersion)
|
||||
params.addParameter("HostCode", Global.getHostId())
|
||||
params.addParameter("VersionNumber", "0")
|
||||
params.addParameter("VersionName", "0")
|
||||
x.http().get(params, object : XHttpShorthand<FrpNewVersion>() {
|
||||
override fun success(model: FrpNewVersion) {
|
||||
if(model.code == "200"){
|
||||
val versionCode = AppUtils.getAppVersionCode()
|
||||
Log.i("","当前版本号$versionCode,最新版本号${model.data.versionNumber}")
|
||||
updateNotification("即将下载新版本")
|
||||
if(versionCode < model.data.versionNumber.toInt()){
|
||||
downFile(mContext, model.data.url)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun error(e: Throwable) {
|
||||
|
||||
}
|
||||
|
||||
})
|
||||
}
|
||||
|
||||
fun initFrpConfig() {
|
||||
try {
|
||||
val outputStream = MyApp.appContext
|
||||
.openFileOutput("config.toml", Context.MODE_PRIVATE)
|
||||
val content = """
|
||||
serverAddr = "${Global.getServerIp()}"
|
||||
serverPort = ${Global.getServerPort()}
|
||||
auth.token = "csa&kc?1cfC>DS4.D=2D%Ac"
|
||||
|
||||
[[proxies]]
|
||||
name = "${Global.getClientName()}"
|
||||
type = "tcp"
|
||||
localIP = "127.0.0.1"
|
||||
localPort = 5555
|
||||
remotePort = ${Global.getClientPort()}
|
||||
""".trimIndent()
|
||||
outputStream.write(content.toByteArray())
|
||||
outputStream.close()
|
||||
} catch (e: IOException) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
|
||||
fun restart() {
|
||||
if (StringUtils.isEmpty(Global.getServerIp())) {
|
||||
updateNotification("远程端口号未配置,请尝试重新启动SOS")
|
||||
return
|
||||
}
|
||||
val context = MyApp.appContext
|
||||
val intent = Intent(context, ShellService::class.java).apply {
|
||||
action = "RESTART"
|
||||
}
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
context.startForegroundService(intent)
|
||||
} else {
|
||||
context.startService(intent)
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 下载APK
|
||||
*
|
||||
* @param path 下载地址
|
||||
*/
|
||||
fun downFile(context:Context, path: String?) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R && !android.os.Environment.isExternalStorageManager()) {
|
||||
var intent: Intent? = Intent(android.provider.Settings.ACTION_MANAGE_ALL_FILES_ACCESS_PERMISSION)
|
||||
context.startActivity(intent)
|
||||
return
|
||||
}
|
||||
var fileName: String? = android.os.Environment.getExternalStoragePublicDirectory(android.os.Environment.DIRECTORY_DOWNLOADS).getAbsolutePath() + java.io.File.separator + "BBIT_FRP.apk"
|
||||
com.blankj.utilcode.util.FileUtils.delete(fileName)
|
||||
var params = RequestParams(path)
|
||||
params.setSaveFilePath(fileName)
|
||||
params.setAutoRename(true)
|
||||
x.http().get<java.io.File?>(params, object : org.xutils.common.Callback.ProgressCallback<java.io.File?> {
|
||||
override fun onStarted() {
|
||||
Log.i("","onStarted")
|
||||
}
|
||||
|
||||
override fun onLoading(total: Long, current: Long, isDownloading: kotlin.Boolean) {
|
||||
Log.i("", "downing$current/$total")
|
||||
}
|
||||
|
||||
override fun onSuccess(result: java.io.File?) {
|
||||
installAPK(context, fileName)
|
||||
}
|
||||
|
||||
override fun onError(ex: kotlin.Throwable?, isOnCallback: kotlin.Boolean) {
|
||||
ex?.printStackTrace()
|
||||
}
|
||||
|
||||
override fun onWaiting() {
|
||||
}
|
||||
|
||||
override fun onCancelled(cex: org.xutils.common.Callback.CancelledException?) {
|
||||
}
|
||||
|
||||
override fun onFinished() {
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 安装程序
|
||||
*
|
||||
* @param context 上下文
|
||||
* @param filePath 安装的文件路径
|
||||
*/
|
||||
fun installAPK(context: Context, filePath: String?) {
|
||||
try {
|
||||
var apkFile: java.io.File = java.io.File(filePath)
|
||||
if (apkFile.exists()) {
|
||||
var intent = Intent(Intent.ACTION_VIEW)
|
||||
var apkUri: android.net.Uri? = androidx.core.content.FileProvider.getUriForFile(context, context.getPackageName() + ".fileprovider", apkFile)
|
||||
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION)
|
||||
intent.setDataAndType(apkUri, "application/vnd.android.package-archive")
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
||||
context.startActivity(intent)
|
||||
}
|
||||
}catch (e: java.lang.Exception) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
package com.bbitcn.bbit_frp2.utils;
|
||||
|
||||
import com.blankj.utilcode.util.SPUtils;
|
||||
|
||||
/**
|
||||
* 配置
|
||||
*/
|
||||
public class Global {
|
||||
/**
|
||||
* FRP是否正在运行
|
||||
*/
|
||||
public static boolean frpIsRunning = false;
|
||||
/**
|
||||
* 主机码(设备唯一码)
|
||||
*/
|
||||
public static final String HOST_ID = "HOST_ID";
|
||||
/**
|
||||
* FRP服务器-IP
|
||||
*/
|
||||
public static final String SERVER_IP = "SERVER_IP";
|
||||
/**
|
||||
* FRP服务器-端口
|
||||
*/
|
||||
public static final String SERVER_PORT = "SERVER_PORT";
|
||||
/**
|
||||
* FRP客户端-名称
|
||||
*/
|
||||
public static final String CLIENT_NAME = "CLIENT_NAME";
|
||||
/**
|
||||
* FRP客户端-端口
|
||||
*/
|
||||
public static final String CLIENT_PORT = "CLIENT_PORT";
|
||||
|
||||
public static String getServerIp() {
|
||||
return SPUtils.getInstance().getString(SERVER_IP);//171.212.101.201
|
||||
}
|
||||
|
||||
public static String getServerPort() {
|
||||
return SPUtils.getInstance().getString(SERVER_PORT);//65533
|
||||
}
|
||||
|
||||
public static String getClientName(){
|
||||
return SPUtils.getInstance().getString(CLIENT_NAME);
|
||||
}
|
||||
|
||||
public static String getClientPort() {
|
||||
return SPUtils.getInstance().getString(CLIENT_PORT);//6001
|
||||
}
|
||||
|
||||
public static String getHostId() {
|
||||
return SPUtils.getInstance().getString(HOST_ID);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
package com.bbitcn.bbit_frp2.utils
|
||||
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import com.blankj.utilcode.util.AppUtils
|
||||
|
||||
object MyUtils {
|
||||
|
||||
val appList = listOf(
|
||||
"com.bbitcn.f8.pad",
|
||||
"com.example.iot_controlhost",
|
||||
"com.bbitcn.sericulture",
|
||||
)
|
||||
|
||||
fun baseSend(intent: Intent,context: Context){
|
||||
appList.forEach {
|
||||
intent.setPackage(it)
|
||||
context.sendBroadcast(intent)
|
||||
}
|
||||
}
|
||||
|
||||
fun senBroadcast(context: Context, msg: String) {
|
||||
val intent = Intent()
|
||||
intent.setAction("receiver_frp_info")
|
||||
intent.putExtra("info", msg)
|
||||
baseSend(intent,context)
|
||||
}
|
||||
|
||||
fun sentVersion(context: Context){
|
||||
val intent = Intent()
|
||||
intent.setAction("receiver_frp_version")
|
||||
intent.putExtra("version", AppUtils.getAppVersionCode())
|
||||
baseSend(intent,context)
|
||||
}
|
||||
|
||||
fun sentReboot(context: Context){
|
||||
val intent = Intent()
|
||||
intent.setAction("receiver_start_frp")
|
||||
intent.setPackage("com.bbitcn.f8.pad")
|
||||
intent.putExtra("start_frp", true)
|
||||
baseSend(intent,context)
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,94 @@
|
||||
package com.bbitcn.bbit_frp2.utils;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
public class PollingTask {
|
||||
|
||||
private static Map<String, PollingTask> instances = new HashMap<>();
|
||||
private ScheduledExecutorService scheduler;
|
||||
private Map<String, ScheduledFuture<?>> taskMap;
|
||||
|
||||
// 私有化构造函数,确保外部不能直接实例化
|
||||
private PollingTask() {
|
||||
createNewScheduler();
|
||||
}
|
||||
|
||||
// 创建新的 ScheduledExecutorService 实例
|
||||
private void createNewScheduler() {
|
||||
if (scheduler != null && !scheduler.isShutdown()) {
|
||||
scheduler.shutdown();
|
||||
}
|
||||
scheduler = Executors.newScheduledThreadPool(3);
|
||||
taskMap = new HashMap<>();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取单例实例-用户正常运行时的任务
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static synchronized PollingTask getInstance() {
|
||||
return getInstance("MAIN");
|
||||
}
|
||||
|
||||
// 获取基于ID的单例实例
|
||||
public static synchronized PollingTask getInstance(String id) {
|
||||
if (!instances.containsKey(id)) {
|
||||
instances.put(id, new PollingTask());
|
||||
}
|
||||
return instances.get(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 启动IO线程的轮询任务
|
||||
*
|
||||
* @param taskId 任务ID,用于唯一标识该任务 唯一!! 不可重复,否则会覆盖之前的任务
|
||||
* @param intervalSeconds 轮询间隔时间(以秒为单位)
|
||||
* @param task 需要在IO线程中执行的任务
|
||||
*/
|
||||
public void startPollingTaskOnIOThread(String taskId, long intervalSeconds, @NonNull final Runnable task) {
|
||||
startPollingTask(taskId, intervalSeconds, () -> task.run());
|
||||
}
|
||||
/**
|
||||
* 启动基础轮询任务,供内部使用
|
||||
*
|
||||
* @param taskId 任务ID,用于唯一标识该任务
|
||||
* @param intervalSeconds 轮询间隔时间(以秒为单位)
|
||||
* @param task 需要执行的任务
|
||||
*/
|
||||
private void startPollingTask(String taskId, long intervalSeconds, @NonNull final Runnable task) {
|
||||
stopPollingTask(taskId); // 如果已有相同ID的任务,先停止
|
||||
ScheduledFuture<?> future = scheduler.scheduleAtFixedRate(task, 0, intervalSeconds, TimeUnit.SECONDS);
|
||||
taskMap.put(taskId, future); // 保存任务的ScheduledFuture
|
||||
}
|
||||
|
||||
// 停止所有轮询任务
|
||||
public void stopAllPollingTasks() {
|
||||
if (scheduler != null && !scheduler.isShutdown()) {
|
||||
scheduler.shutdownNow(); // 超时后强制停止
|
||||
taskMap.clear(); // 清空任务映射
|
||||
}
|
||||
// 从实例映射中移除当前实例
|
||||
instances.values().remove(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* 停止轮询任务
|
||||
*
|
||||
* @param taskId 任务ID
|
||||
*/
|
||||
public void stopPollingTask(String taskId) {
|
||||
ScheduledFuture<?> future = taskMap.get(taskId);
|
||||
if (future != null) {
|
||||
future.cancel(true); // 取消任务,中断正在执行的任务
|
||||
taskMap.remove(taskId); // 从任务列表中移除
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package com.bbitcn.bbit_frp2.utils.net;
|
||||
|
||||
public class Url {
|
||||
/**
|
||||
* Environment 当前环境 true 生产环境 false 测试环境
|
||||
*/
|
||||
private static final boolean userProduct = true;
|
||||
|
||||
private static String baseUrls;
|
||||
|
||||
public static void initUrl() {
|
||||
if (userProduct) {
|
||||
// 生产环境
|
||||
baseUrls = "https://iot.api.bbitcn.net/";
|
||||
} else {
|
||||
// 测试环境
|
||||
baseUrls = "http://wechat.lkstc.com/";
|
||||
}
|
||||
getConfigInfo = baseUrls + "api/Host/GetHostFrpConfig";
|
||||
getNewVersion = baseUrls + "api/UpgradeFrp/GetNewVersion";
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取FRP配置信息
|
||||
*/
|
||||
public static String getConfigInfo;
|
||||
/**
|
||||
* 获取新版本
|
||||
*/
|
||||
public static String getNewVersion;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package com.bbitcn.bbit_frp2.utils.net;
|
||||
|
||||
|
||||
import org.xutils.http.RequestParams;
|
||||
|
||||
/**
|
||||
* @Author:BinJianXin
|
||||
* @Date:2022/5/30/9:34
|
||||
* @Declaration:
|
||||
*/
|
||||
public class XHttpManager {
|
||||
private static XHttpManager xHttpManager;
|
||||
|
||||
public static XHttpManager getInstance() {
|
||||
if (xHttpManager == null) {
|
||||
synchronized (XHttpManager.class) {
|
||||
if (xHttpManager == null) {
|
||||
xHttpManager = new XHttpManager();
|
||||
}
|
||||
}
|
||||
}
|
||||
return xHttpManager;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获得网络请求头
|
||||
*
|
||||
* @param url 地址
|
||||
*/
|
||||
public RequestParams getRequestParams(String url) {
|
||||
RequestParams params = new RequestParams(url);
|
||||
params.setReadTimeout(10000);
|
||||
params.setConnectTimeout(10000);
|
||||
params.addHeader("Content-Type", "application/json,charset=UTF-8");
|
||||
params.setUseCookie(false);
|
||||
params.setAsJsonContent(true);
|
||||
return params;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,110 @@
|
||||
package com.bbitcn.bbit_frp2.utils.net;
|
||||
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.os.Message;
|
||||
import android.util.Log;
|
||||
|
||||
import com.bbitcn.bbit_frp2.model.CommonResponse;
|
||||
import com.blankj.utilcode.util.GsonUtils;
|
||||
|
||||
import org.json.JSONException;
|
||||
import org.xutils.common.Callback;
|
||||
|
||||
import java.lang.reflect.ParameterizedType;
|
||||
|
||||
/**
|
||||
* @Author:BinJianXin
|
||||
* @Date:2022/5/30/9:49
|
||||
* @Declaration:用于减少逻辑界面xhttp需要实现的方法数
|
||||
*/
|
||||
public abstract class XHttpShorthand<T> implements Callback.CommonCallback<String> {
|
||||
|
||||
public abstract void success(T result) throws JSONException;
|
||||
|
||||
private Class<T> clazz;
|
||||
|
||||
public XHttpShorthand() {
|
||||
try {
|
||||
ParameterizedType genericSuperclass = (ParameterizedType) getClass().getGenericSuperclass();
|
||||
clazz = (Class<T>) genericSuperclass.getActualTypeArguments()[0];
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public abstract void error(Throwable e);
|
||||
|
||||
@Override
|
||||
public void onSuccess(String result) {
|
||||
Message message = new Message();
|
||||
try {
|
||||
CommonResponse temp = GsonUtils.fromJson(result, CommonResponse.class);
|
||||
if (temp != null) {
|
||||
// MyLog.network("Code == 200");
|
||||
message.what = 0;
|
||||
message.obj = GsonUtils.fromJson(result, clazz);
|
||||
} else {
|
||||
// MyLog.network("Code != 200");
|
||||
message.what = 2;
|
||||
message.obj = temp;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
message.what = 1;
|
||||
message.obj = e;
|
||||
}
|
||||
handler.sendMessage(message);
|
||||
}
|
||||
|
||||
public void onSuccessError(CommonResponse data) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Throwable ex, boolean isOnCallback) {
|
||||
Log.e("net","网络请求失败:错误消息:" + ex.getMessage() + "\t本地化消息:" + ex.getLocalizedMessage() + "\t原因:" + ex.getCause());
|
||||
Message message = new Message();
|
||||
message.what = 1;
|
||||
message.obj = ex;
|
||||
handler.sendMessage(message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCancelled(CancelledException cex) {
|
||||
Log.e("net","网络请求取消" + cex.getMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFinished() {
|
||||
Message message = new Message();
|
||||
message.what = 3;
|
||||
handler.sendMessage(message);
|
||||
}
|
||||
|
||||
public void onFinish() {
|
||||
Log.e("net","网络请求完成");
|
||||
}
|
||||
|
||||
/**
|
||||
* 转回到主线程
|
||||
*/
|
||||
public Handler handler = new Handler(Looper.getMainLooper()) {
|
||||
@Override
|
||||
public void handleMessage(@androidx.annotation.NonNull Message msg) {
|
||||
super.handleMessage(msg);
|
||||
try {
|
||||
if (msg.what == 0) {
|
||||
success((T) msg.obj);
|
||||
} else if (msg.what == 1) {
|
||||
error((Throwable) msg.obj);
|
||||
} else if (msg.what == 2) {
|
||||
onSuccessError((CommonResponse) msg.obj);
|
||||
}else if(msg.what == 3){
|
||||
onFinish();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Log.e("net","网络请求错误:" + e.getMessage());
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,170 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="108dp"
|
||||
android:height="108dp"
|
||||
android:viewportWidth="108"
|
||||
android:viewportHeight="108">
|
||||
<path
|
||||
android:fillColor="#3DDC84"
|
||||
android:pathData="M0,0h108v108h-108z" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M9,0L9,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,0L19,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M29,0L29,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M39,0L39,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M49,0L49,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M59,0L59,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M69,0L69,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M79,0L79,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M89,0L89,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M99,0L99,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,9L108,9"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,19L108,19"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,29L108,29"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,39L108,39"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,49L108,49"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,59L108,59"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,69L108,69"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,79L108,79"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,89L108,89"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,99L108,99"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,29L89,29"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,39L89,39"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,49L89,49"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,59L89,59"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,69L89,69"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,79L89,79"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M29,19L29,89"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M39,19L39,89"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M49,19L49,89"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M59,19L59,89"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M69,19L69,89"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M79,19L79,89"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
</vector>
|
||||
@@ -0,0 +1,30 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:aapt="http://schemas.android.com/aapt"
|
||||
android:width="108dp"
|
||||
android:height="108dp"
|
||||
android:viewportWidth="108"
|
||||
android:viewportHeight="108">
|
||||
<path android:pathData="M31,63.928c0,0 6.4,-11 12.1,-13.1c7.2,-2.6 26,-1.4 26,-1.4l38.1,38.1L107,108.928l-32,-1L31,63.928z">
|
||||
<aapt:attr name="android:fillColor">
|
||||
<gradient
|
||||
android:endX="85.84757"
|
||||
android:endY="92.4963"
|
||||
android:startX="42.9492"
|
||||
android:startY="49.59793"
|
||||
android:type="linear">
|
||||
<item
|
||||
android:color="#44000000"
|
||||
android:offset="0.0" />
|
||||
<item
|
||||
android:color="#00000000"
|
||||
android:offset="1.0" />
|
||||
</gradient>
|
||||
</aapt:attr>
|
||||
</path>
|
||||
<path
|
||||
android:fillColor="#FFFFFF"
|
||||
android:fillType="nonZero"
|
||||
android:pathData="M65.3,45.828l3.8,-6.6c0.2,-0.4 0.1,-0.9 -0.3,-1.1c-0.4,-0.2 -0.9,-0.1 -1.1,0.3l-3.9,6.7c-6.3,-2.8 -13.4,-2.8 -19.7,0l-3.9,-6.7c-0.2,-0.4 -0.7,-0.5 -1.1,-0.3C38.8,38.328 38.7,38.828 38.9,39.228l3.8,6.6C36.2,49.428 31.7,56.028 31,63.928h46C76.3,56.028 71.8,49.428 65.3,45.828zM43.4,57.328c-0.8,0 -1.5,-0.5 -1.8,-1.2c-0.3,-0.7 -0.1,-1.5 0.4,-2.1c0.5,-0.5 1.4,-0.7 2.1,-0.4c0.7,0.3 1.2,1 1.2,1.8C45.3,56.528 44.5,57.328 43.4,57.328L43.4,57.328zM64.6,57.328c-0.8,0 -1.5,-0.5 -1.8,-1.2s-0.1,-1.5 0.4,-2.1c0.5,-0.5 1.4,-0.7 2.1,-0.4c0.7,0.3 1.2,1 1.2,1.8C66.5,56.528 65.6,57.328 64.6,57.328L64.6,57.328z"
|
||||
android:strokeWidth="1"
|
||||
android:strokeColor="#00000000" />
|
||||
</vector>
|
||||
@@ -0,0 +1,10 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:tint="?attr/colorPrimary"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
<path
|
||||
android:fillColor="@android:color/holo_blue_bright"
|
||||
android:pathData="M5.88,4.12L13.76,12l-7.88,7.88L8,22l10,-10L8,2z" />
|
||||
</vector>
|
||||
@@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<color name="purple_200">#FFBB86FC</color>
|
||||
<color name="purple_500">#FF6200EE</color>
|
||||
<color name="purple_700">#FF3700B3</color>
|
||||
<color name="teal_200">#FF03DAC5</color>
|
||||
<color name="teal_700">#FF018786</color>
|
||||
<color name="black">#FF000000</color>
|
||||
<color name="white">#FFFFFFFF</color>
|
||||
</resources>
|
||||
@@ -0,0 +1,3 @@
|
||||
<resources>
|
||||
<string name="app_name">BBIT远程协助</string>
|
||||
</resources>
|
||||
@@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
|
||||
<style name="Theme.BBIT_FRP" parent="android:Theme.Material.Light.NoActionBar" />
|
||||
</resources>
|
||||
@@ -0,0 +1,13 @@
|
||||
<?xml version="1.0" encoding="utf-8"?><!--
|
||||
Sample backup rules file; uncomment and customize as necessary.
|
||||
See https://developer.android.com/guide/topics/data/autobackup
|
||||
for details.
|
||||
Note: This file is ignored for devices older that API 31
|
||||
See https://developer.android.com/about/versions/12/backup-restore
|
||||
-->
|
||||
<full-backup-content>
|
||||
<!--
|
||||
<include domain="sharedpref" path="."/>
|
||||
<exclude domain="sharedpref" path="device.xml"/>
|
||||
-->
|
||||
</full-backup-content>
|
||||
@@ -0,0 +1,19 @@
|
||||
<?xml version="1.0" encoding="utf-8"?><!--
|
||||
Sample data extraction rules file; uncomment and customize as necessary.
|
||||
See https://developer.android.com/about/versions/12/backup-restore#xml-changes
|
||||
for details.
|
||||
-->
|
||||
<data-extraction-rules>
|
||||
<cloud-backup>
|
||||
<!-- TODO: Use <include> and <exclude> to control what is backed up.
|
||||
<include .../>
|
||||
<exclude .../>
|
||||
-->
|
||||
</cloud-backup>
|
||||
<!--
|
||||
<device-transfer>
|
||||
<include .../>
|
||||
<exclude .../>
|
||||
</device-transfer>
|
||||
-->
|
||||
</data-extraction-rules>
|
||||
@@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<paths xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<external-path name="sdcard_root" path="."/>
|
||||
</paths>
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.bbitcn.bbit_frp2
|
||||
|
||||
import org.junit.Test
|
||||
|
||||
import org.junit.Assert.*
|
||||
|
||||
/**
|
||||
* Example local unit test, which will execute on the development machine (host).
|
||||
*
|
||||
* See [testing documentation](http://d.android.com/tools/testing).
|
||||
*/
|
||||
class ExampleUnitTest {
|
||||
@Test
|
||||
fun addition_isCorrect() {
|
||||
assertEquals(4, 2 + 2)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
||||
plugins {
|
||||
alias(libs.plugins.android.application) apply false
|
||||
alias(libs.plugins.jetbrains.kotlin.android) apply false
|
||||
}
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,23 @@
|
||||
# Project-wide Gradle settings.
|
||||
# IDE (e.g. Android Studio) users:
|
||||
# Gradle settings configured through the IDE *will override*
|
||||
# any settings specified in this file.
|
||||
# For more details on how to configure your build environment visit
|
||||
# http://www.gradle.org/docs/current/userguide/build_environment.html
|
||||
# Specifies the JVM arguments used for the daemon process.
|
||||
# The setting is particularly useful for tweaking memory settings.
|
||||
org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
|
||||
# When configured, Gradle will run in incubating parallel mode.
|
||||
# This option should only be used with decoupled projects. For more details, visit
|
||||
# https://developer.android.com/r/tools/gradle-multi-project-decoupled-projects
|
||||
# org.gradle.parallel=true
|
||||
# AndroidX package structure to make it clearer which packages are bundled with the
|
||||
# Android operating system, and which are packaged with your app's APK
|
||||
# https://developer.android.com/topic/libraries/support-library/androidx-rn
|
||||
android.useAndroidX=true
|
||||
# Kotlin code style for this project: "official" or "obsolete":
|
||||
kotlin.code.style=official
|
||||
# Enables namespacing of each library's R class so that its R class includes only the
|
||||
# resources declared in the library itself and none from the library's dependencies,
|
||||
# thereby reducing the size of the R class for that library
|
||||
android.nonTransitiveRClass=true
|
||||
@@ -0,0 +1,34 @@
|
||||
[versions]
|
||||
agp = "8.8.2"
|
||||
kotlin = "1.9.0"
|
||||
coreKtx = "1.10.1"
|
||||
junit = "4.13.2"
|
||||
junitVersion = "1.1.5"
|
||||
espressoCore = "3.5.1"
|
||||
lifecycleRuntimeKtx = "2.6.1"
|
||||
activityCompose = "1.8.0"
|
||||
composeBom = "2023.08.00"
|
||||
googleGsonVersion = "2.10.1"
|
||||
|
||||
[libraries]
|
||||
androidx-lifecycle-viewmodel-compose = { module = "androidx.lifecycle:lifecycle-viewmodel-compose", version.ref = "lifecycleRuntimeKtx" }
|
||||
androidx-core-ktx = { group = "androidx.core", name = "core-ktx", version.ref = "coreKtx" }
|
||||
junit = { group = "junit", name = "junit", version.ref = "junit" }
|
||||
androidx-junit = { group = "androidx.test.ext", name = "junit", version.ref = "junitVersion" }
|
||||
androidx-espresso-core = { group = "androidx.test.espresso", name = "espresso-core", version.ref = "espressoCore" }
|
||||
androidx-lifecycle-runtime-ktx = { group = "androidx.lifecycle", name = "lifecycle-runtime-ktx", version.ref = "lifecycleRuntimeKtx" }
|
||||
androidx-activity-compose = { group = "androidx.activity", name = "activity-compose", version.ref = "activityCompose" }
|
||||
androidx-compose-bom = { group = "androidx.compose", name = "compose-bom", version.ref = "composeBom" }
|
||||
androidx-ui = { group = "androidx.compose.ui", name = "ui" }
|
||||
androidx-ui-graphics = { group = "androidx.compose.ui", name = "ui-graphics" }
|
||||
androidx-ui-tooling = { group = "androidx.compose.ui", name = "ui-tooling" }
|
||||
androidx-ui-tooling-preview = { group = "androidx.compose.ui", name = "ui-tooling-preview" }
|
||||
androidx-ui-test-manifest = { group = "androidx.compose.ui", name = "ui-test-manifest" }
|
||||
androidx-ui-test-junit4 = { group = "androidx.compose.ui", name = "ui-test-junit4" }
|
||||
androidx-material3 = { group = "androidx.compose.material3", name = "material3" }
|
||||
com-google-code-gson-gson2 = { module = "com.google.code.gson:gson", version.ref = "googleGsonVersion" }
|
||||
|
||||
[plugins]
|
||||
android-application = { id = "com.android.application", version.ref = "agp" }
|
||||
jetbrains-kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
|
||||
|
||||
Vendored
BIN
Binary file not shown.
+6
@@ -0,0 +1,6 @@
|
||||
#Fri May 24 17:31:36 CST 2024
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://mirrors.cloud.tencent.com/gradle/gradle-8.11.1-all.zip
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
@@ -0,0 +1,185 @@
|
||||
#!/usr/bin/env sh
|
||||
|
||||
#
|
||||
# Copyright 2015 the original author or authors.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# https://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
##############################################################################
|
||||
##
|
||||
## Gradle start up script for UN*X
|
||||
##
|
||||
##############################################################################
|
||||
|
||||
# Attempt to set APP_HOME
|
||||
# Resolve links: $0 may be a link
|
||||
PRG="$0"
|
||||
# Need this for relative symlinks.
|
||||
while [ -h "$PRG" ] ; do
|
||||
ls=`ls -ld "$PRG"`
|
||||
link=`expr "$ls" : '.*-> \(.*\)$'`
|
||||
if expr "$link" : '/.*' > /dev/null; then
|
||||
PRG="$link"
|
||||
else
|
||||
PRG=`dirname "$PRG"`"/$link"
|
||||
fi
|
||||
done
|
||||
SAVED="`pwd`"
|
||||
cd "`dirname \"$PRG\"`/" >/dev/null
|
||||
APP_HOME="`pwd -P`"
|
||||
cd "$SAVED" >/dev/null
|
||||
|
||||
APP_NAME="Gradle"
|
||||
APP_BASE_NAME=`basename "$0"`
|
||||
|
||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||
|
||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||
MAX_FD="maximum"
|
||||
|
||||
warn () {
|
||||
echo "$*"
|
||||
}
|
||||
|
||||
die () {
|
||||
echo
|
||||
echo "$*"
|
||||
echo
|
||||
exit 1
|
||||
}
|
||||
|
||||
# OS specific support (must be 'true' or 'false').
|
||||
cygwin=false
|
||||
msys=false
|
||||
darwin=false
|
||||
nonstop=false
|
||||
case "`uname`" in
|
||||
CYGWIN* )
|
||||
cygwin=true
|
||||
;;
|
||||
Darwin* )
|
||||
darwin=true
|
||||
;;
|
||||
MINGW* )
|
||||
msys=true
|
||||
;;
|
||||
NONSTOP* )
|
||||
nonstop=true
|
||||
;;
|
||||
esac
|
||||
|
||||
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||
|
||||
|
||||
# Determine the Java command to use to start the JVM.
|
||||
if [ -n "$JAVA_HOME" ] ; then
|
||||
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
||||
# IBM's JDK on AIX uses strange locations for the executables
|
||||
JAVACMD="$JAVA_HOME/jre/sh/java"
|
||||
else
|
||||
JAVACMD="$JAVA_HOME/bin/java"
|
||||
fi
|
||||
if [ ! -x "$JAVACMD" ] ; then
|
||||
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
else
|
||||
JAVACMD="java"
|
||||
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
|
||||
# Increase the maximum file descriptors if we can.
|
||||
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
|
||||
MAX_FD_LIMIT=`ulimit -H -n`
|
||||
if [ $? -eq 0 ] ; then
|
||||
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
|
||||
MAX_FD="$MAX_FD_LIMIT"
|
||||
fi
|
||||
ulimit -n $MAX_FD
|
||||
if [ $? -ne 0 ] ; then
|
||||
warn "Could not set maximum file descriptor limit: $MAX_FD"
|
||||
fi
|
||||
else
|
||||
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
|
||||
fi
|
||||
fi
|
||||
|
||||
# For Darwin, add options to specify how the application appears in the dock
|
||||
if $darwin; then
|
||||
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
|
||||
fi
|
||||
|
||||
# For Cygwin or MSYS, switch paths to Windows format before running java
|
||||
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
|
||||
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
|
||||
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
|
||||
|
||||
JAVACMD=`cygpath --unix "$JAVACMD"`
|
||||
|
||||
# We build the pattern for arguments to be converted via cygpath
|
||||
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
|
||||
SEP=""
|
||||
for dir in $ROOTDIRSRAW ; do
|
||||
ROOTDIRS="$ROOTDIRS$SEP$dir"
|
||||
SEP="|"
|
||||
done
|
||||
OURCYGPATTERN="(^($ROOTDIRS))"
|
||||
# Add a user-defined pattern to the cygpath arguments
|
||||
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
|
||||
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
|
||||
fi
|
||||
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
||||
i=0
|
||||
for arg in "$@" ; do
|
||||
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
|
||||
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
|
||||
|
||||
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
|
||||
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
|
||||
else
|
||||
eval `echo args$i`="\"$arg\""
|
||||
fi
|
||||
i=`expr $i + 1`
|
||||
done
|
||||
case $i in
|
||||
0) set -- ;;
|
||||
1) set -- "$args0" ;;
|
||||
2) set -- "$args0" "$args1" ;;
|
||||
3) set -- "$args0" "$args1" "$args2" ;;
|
||||
4) set -- "$args0" "$args1" "$args2" "$args3" ;;
|
||||
5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
|
||||
6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
|
||||
7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
|
||||
8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
|
||||
9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
|
||||
esac
|
||||
fi
|
||||
|
||||
# Escape application args
|
||||
save () {
|
||||
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
|
||||
echo " "
|
||||
}
|
||||
APP_ARGS=`save "$@"`
|
||||
|
||||
# Collect all arguments for the java command, following the shell quoting and substitution rules
|
||||
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
|
||||
|
||||
exec "$JAVACMD" "$@"
|
||||
Vendored
+89
@@ -0,0 +1,89 @@
|
||||
@rem
|
||||
@rem Copyright 2015 the original author or authors.
|
||||
@rem
|
||||
@rem Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@rem you may not use this file except in compliance with the License.
|
||||
@rem You may obtain a copy of the License at
|
||||
@rem
|
||||
@rem https://www.apache.org/licenses/LICENSE-2.0
|
||||
@rem
|
||||
@rem Unless required by applicable law or agreed to in writing, software
|
||||
@rem distributed under the License is distributed on an "AS IS" BASIS,
|
||||
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
@rem See the License for the specific language governing permissions and
|
||||
@rem limitations under the License.
|
||||
@rem
|
||||
|
||||
@if "%DEBUG%" == "" @echo off
|
||||
@rem ##########################################################################
|
||||
@rem
|
||||
@rem Gradle startup script for Windows
|
||||
@rem
|
||||
@rem ##########################################################################
|
||||
|
||||
@rem Set local scope for the variables with windows NT shell
|
||||
if "%OS%"=="Windows_NT" setlocal
|
||||
|
||||
set DIRNAME=%~dp0
|
||||
if "%DIRNAME%" == "" set DIRNAME=.
|
||||
set APP_BASE_NAME=%~n0
|
||||
set APP_HOME=%DIRNAME%
|
||||
|
||||
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
|
||||
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
|
||||
|
||||
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
|
||||
|
||||
@rem Find java.exe
|
||||
if defined JAVA_HOME goto findJavaFromJavaHome
|
||||
|
||||
set JAVA_EXE=java.exe
|
||||
%JAVA_EXE% -version >NUL 2>&1
|
||||
if "%ERRORLEVEL%" == "0" goto execute
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:findJavaFromJavaHome
|
||||
set JAVA_HOME=%JAVA_HOME:"=%
|
||||
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||
|
||||
if exist "%JAVA_EXE%" goto execute
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:execute
|
||||
@rem Setup the command line
|
||||
|
||||
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
||||
|
||||
|
||||
@rem Execute Gradle
|
||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
|
||||
|
||||
:end
|
||||
@rem End local scope for the variables with windows NT shell
|
||||
if "%ERRORLEVEL%"=="0" goto mainEnd
|
||||
|
||||
:fail
|
||||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||
rem the _cmd.exe /c_ return code!
|
||||
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
|
||||
exit /b 1
|
||||
|
||||
:mainEnd
|
||||
if "%OS%"=="Windows_NT" endlocal
|
||||
|
||||
:omega
|
||||
Binary file not shown.
@@ -0,0 +1,10 @@
|
||||
## This file is automatically generated by Android Studio.
|
||||
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
|
||||
#
|
||||
# This file should *NOT* be checked into Version Control Systems,
|
||||
# as it contains information specific to your local configuration.
|
||||
#
|
||||
# Location of the SDK. This is only used by Gradle.
|
||||
# For customization when using a Version Control System, please read the
|
||||
# header note.
|
||||
sdk.dir=C\:\\Users\\BBIT\\AppData\\Local\\Android\\Sdk
|
||||
@@ -0,0 +1,31 @@
|
||||
pluginManagement {
|
||||
repositories {
|
||||
google {
|
||||
content {
|
||||
includeGroupByRegex("com\\.android.*")
|
||||
includeGroupByRegex("com\\.google.*")
|
||||
includeGroupByRegex("androidx.*")
|
||||
}
|
||||
}
|
||||
mavenCentral()
|
||||
gradlePluginPortal()
|
||||
|
||||
}
|
||||
}
|
||||
dependencyResolutionManagement {
|
||||
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
|
||||
repositories {
|
||||
google() // 官方 Google 仓库
|
||||
mavenCentral() // Maven Central 仓库
|
||||
|
||||
// 如果你需要特定的仓库,可以保留
|
||||
maven { url = uri("https://maven.aliyun.com/repository/gradle-plugin") }
|
||||
maven { url = uri("https://maven.aliyun.com/repository/public") }
|
||||
maven { url = uri("https://jitpack.io") } // 保留一次 jitpack.io
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
rootProject.name = "BBIT_FRP"
|
||||
include(":app")
|
||||
|
||||
Reference in New Issue
Block a user