commit 87ebf8a4b0d8c844f0536f4c0c4098c05375ae34 Author: BBIT-Kai <2911862937@qq.com> Date: Mon May 25 15:14:00 2026 +0800 初始化项目 diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..fbf29d4 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +.gradle/ +.idea/ +.svn/ +app/release/ diff --git a/app/.gitignore b/app/.gitignore new file mode 100644 index 0000000..42afabf --- /dev/null +++ b/app/.gitignore @@ -0,0 +1 @@ +/build \ No newline at end of file diff --git a/app/build.gradle.kts b/app/build.gradle.kts new file mode 100644 index 0000000..7d5b04c --- /dev/null +++ b/app/build.gradle.kts @@ -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") +} \ No newline at end of file diff --git a/app/lint-baseline.xml b/app/lint-baseline.xml new file mode 100644 index 0000000..0610d4e --- /dev/null +++ b/app/lint-baseline.xml @@ -0,0 +1,15 @@ + + + + + + + + diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro new file mode 100644 index 0000000..481bb43 --- /dev/null +++ b/app/proguard-rules.pro @@ -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 \ No newline at end of file diff --git a/app/src/androidTest/java/com/bbitcn/bbit_frp2/ExampleInstrumentedTest.kt b/app/src/androidTest/java/com/bbitcn/bbit_frp2/ExampleInstrumentedTest.kt new file mode 100644 index 0000000..90415c2 --- /dev/null +++ b/app/src/androidTest/java/com/bbitcn/bbit_frp2/ExampleInstrumentedTest.kt @@ -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) + } +} \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..460481e --- /dev/null +++ b/app/src/main/AndroidManifest.xml @@ -0,0 +1,67 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/java/com/bbitcn/bbit_frp2/MyApp.kt b/app/src/main/java/com/bbitcn/bbit_frp2/MyApp.kt new file mode 100644 index 0000000..4dd2151 --- /dev/null +++ b/app/src/main/java/com/bbitcn/bbit_frp2/MyApp.kt @@ -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 { + val ipv6Addresses = mutableListOf() + + 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 + } +} \ No newline at end of file diff --git a/app/src/main/java/com/bbitcn/bbit_frp2/model/CommonResponse.java b/app/src/main/java/com/bbitcn/bbit_frp2/model/CommonResponse.java new file mode 100644 index 0000000..d4766af --- /dev/null +++ b/app/src/main/java/com/bbitcn/bbit_frp2/model/CommonResponse.java @@ -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; + } +} diff --git a/app/src/main/java/com/bbitcn/bbit_frp2/model/FrpConfig.kt b/app/src/main/java/com/bbitcn/bbit_frp2/model/FrpConfig.kt new file mode 100644 index 0000000..6f0d269 --- /dev/null +++ b/app/src/main/java/com/bbitcn/bbit_frp2/model/FrpConfig.kt @@ -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 = "" + ) +} \ No newline at end of file diff --git a/app/src/main/java/com/bbitcn/bbit_frp2/model/FrpNewVersion.kt b/app/src/main/java/com/bbitcn/bbit_frp2/model/FrpNewVersion.kt new file mode 100644 index 0000000..bf3d28a --- /dev/null +++ b/app/src/main/java/com/bbitcn/bbit_frp2/model/FrpNewVersion.kt @@ -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 = "" + ) +} \ No newline at end of file diff --git a/app/src/main/java/com/bbitcn/bbit_frp2/receiver/BootReceiver.java b/app/src/main/java/com/bbitcn/bbit_frp2/receiver/BootReceiver.java new file mode 100644 index 0000000..acd59c8 --- /dev/null +++ b/app/src/main/java/com/bbitcn/bbit_frp2/receiver/BootReceiver.java @@ -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); + } + } + } +} diff --git a/app/src/main/java/com/bbitcn/bbit_frp2/receiver/FrpStartReceiver.kt b/app/src/main/java/com/bbitcn/bbit_frp2/receiver/FrpStartReceiver.kt new file mode 100644 index 0000000..98bf406 --- /dev/null +++ b/app/src/main/java/com/bbitcn/bbit_frp2/receiver/FrpStartReceiver.kt @@ -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() + } + } + } +} diff --git a/app/src/main/java/com/bbitcn/bbit_frp2/service/ShellService.kt b/app/src/main/java/com/bbitcn/bbit_frp2/service/ShellService.kt new file mode 100644 index 0000000..0ad710f --- /dev/null +++ b/app/src/main/java/com/bbitcn/bbit_frp2/service/ShellService.kt @@ -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, 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, + 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() +} diff --git a/app/src/main/java/com/bbitcn/bbit_frp2/ui/MainActivity.kt b/app/src/main/java/com/bbitcn/bbit_frp2/ui/MainActivity.kt new file mode 100644 index 0000000..f73ade7 --- /dev/null +++ b/app/src/main/java/com/bbitcn/bbit_frp2/ui/MainActivity.kt @@ -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 // 全屏 + } + } + + +} diff --git a/app/src/main/java/com/bbitcn/bbit_frp2/utils/FrpUtils.kt b/app/src/main/java/com/bbitcn/bbit_frp2/utils/FrpUtils.kt new file mode 100644 index 0000000..2342167 --- /dev/null +++ b/app/src/main/java/com/bbitcn/bbit_frp2/utils/FrpUtils.kt @@ -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() { + 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() { + 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(params, object : org.xutils.common.Callback.ProgressCallback { + 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() + } + } + +} diff --git a/app/src/main/java/com/bbitcn/bbit_frp2/utils/Global.java b/app/src/main/java/com/bbitcn/bbit_frp2/utils/Global.java new file mode 100644 index 0000000..cdc5e8f --- /dev/null +++ b/app/src/main/java/com/bbitcn/bbit_frp2/utils/Global.java @@ -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); + } +} diff --git a/app/src/main/java/com/bbitcn/bbit_frp2/utils/MyUtils.kt b/app/src/main/java/com/bbitcn/bbit_frp2/utils/MyUtils.kt new file mode 100644 index 0000000..e107a7f --- /dev/null +++ b/app/src/main/java/com/bbitcn/bbit_frp2/utils/MyUtils.kt @@ -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) + } + +} \ No newline at end of file diff --git a/app/src/main/java/com/bbitcn/bbit_frp2/utils/PollingTask.java b/app/src/main/java/com/bbitcn/bbit_frp2/utils/PollingTask.java new file mode 100644 index 0000000..d10b6fd --- /dev/null +++ b/app/src/main/java/com/bbitcn/bbit_frp2/utils/PollingTask.java @@ -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 instances = new HashMap<>(); + private ScheduledExecutorService scheduler; + private Map> 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); // 从任务列表中移除 + } + } + +} diff --git a/app/src/main/java/com/bbitcn/bbit_frp2/utils/net/Url.java b/app/src/main/java/com/bbitcn/bbit_frp2/utils/net/Url.java new file mode 100644 index 0000000..4f28858 --- /dev/null +++ b/app/src/main/java/com/bbitcn/bbit_frp2/utils/net/Url.java @@ -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; + +} diff --git a/app/src/main/java/com/bbitcn/bbit_frp2/utils/net/XHttpManager.java b/app/src/main/java/com/bbitcn/bbit_frp2/utils/net/XHttpManager.java new file mode 100644 index 0000000..3ca834d --- /dev/null +++ b/app/src/main/java/com/bbitcn/bbit_frp2/utils/net/XHttpManager.java @@ -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; + } +} diff --git a/app/src/main/java/com/bbitcn/bbit_frp2/utils/net/XHttpShorthand.java b/app/src/main/java/com/bbitcn/bbit_frp2/utils/net/XHttpShorthand.java new file mode 100644 index 0000000..4ce9ad0 --- /dev/null +++ b/app/src/main/java/com/bbitcn/bbit_frp2/utils/net/XHttpShorthand.java @@ -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 implements Callback.CommonCallback { + + public abstract void success(T result) throws JSONException; + + private Class clazz; + + public XHttpShorthand() { + try { + ParameterizedType genericSuperclass = (ParameterizedType) getClass().getGenericSuperclass(); + clazz = (Class) 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()); + } + } + }; +} \ No newline at end of file diff --git a/app/src/main/jniLibs/arm64-v8a/libfrpc.so b/app/src/main/jniLibs/arm64-v8a/libfrpc.so new file mode 100644 index 0000000..47ab8bc Binary files /dev/null and b/app/src/main/jniLibs/arm64-v8a/libfrpc.so differ diff --git a/app/src/main/jniLibs/armeabi-v7a/libfrpc.so b/app/src/main/jniLibs/armeabi-v7a/libfrpc.so new file mode 100644 index 0000000..584ee53 Binary files /dev/null and b/app/src/main/jniLibs/armeabi-v7a/libfrpc.so differ diff --git a/app/src/main/jniLibs/x86_64/libfrpc.so b/app/src/main/jniLibs/x86_64/libfrpc.so new file mode 100644 index 0000000..0653da4 Binary files /dev/null and b/app/src/main/jniLibs/x86_64/libfrpc.so differ diff --git a/app/src/main/res/drawable/ic_launcher_background.xml b/app/src/main/res/drawable/ic_launcher_background.xml new file mode 100644 index 0000000..07d5da9 --- /dev/null +++ b/app/src/main/res/drawable/ic_launcher_background.xml @@ -0,0 +1,170 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/drawable/ic_launcher_foreground.xml b/app/src/main/res/drawable/ic_launcher_foreground.xml new file mode 100644 index 0000000..2b068d1 --- /dev/null +++ b/app/src/main/res/drawable/ic_launcher_foreground.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/logo.xml b/app/src/main/res/drawable/logo.xml new file mode 100644 index 0000000..1d60d6f --- /dev/null +++ b/app/src/main/res/drawable/logo.xml @@ -0,0 +1,10 @@ + + + diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml new file mode 100644 index 0000000..f8c6127 --- /dev/null +++ b/app/src/main/res/values/colors.xml @@ -0,0 +1,10 @@ + + + #FFBB86FC + #FF6200EE + #FF3700B3 + #FF03DAC5 + #FF018786 + #FF000000 + #FFFFFFFF + \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml new file mode 100644 index 0000000..bdff3ba --- /dev/null +++ b/app/src/main/res/values/strings.xml @@ -0,0 +1,3 @@ + + BBIT远程协助 + \ No newline at end of file diff --git a/app/src/main/res/values/themes.xml b/app/src/main/res/values/themes.xml new file mode 100644 index 0000000..a126f1f --- /dev/null +++ b/app/src/main/res/values/themes.xml @@ -0,0 +1,5 @@ + + + + + + + + Gradle Configuration Cache + + + +
+ +
+ Loading... +
+ + + + + + diff --git a/gradle.properties b/gradle.properties new file mode 100644 index 0000000..20e2a01 --- /dev/null +++ b/gradle.properties @@ -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 \ No newline at end of file diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml new file mode 100644 index 0000000..558a5ef --- /dev/null +++ b/gradle/libs.versions.toml @@ -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" } + diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000..e708b1c Binary files /dev/null and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000..190f766 --- /dev/null +++ b/gradle/wrapper/gradle-wrapper.properties @@ -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 diff --git a/gradlew b/gradlew new file mode 100644 index 0000000..4f906e0 --- /dev/null +++ b/gradlew @@ -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" "$@" diff --git a/gradlew.bat b/gradlew.bat new file mode 100644 index 0000000..107acd3 --- /dev/null +++ b/gradlew.bat @@ -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 diff --git a/key/store.jks b/key/store.jks new file mode 100644 index 0000000..d61e608 Binary files /dev/null and b/key/store.jks differ diff --git a/local.properties b/local.properties new file mode 100644 index 0000000..4debd6a --- /dev/null +++ b/local.properties @@ -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 \ No newline at end of file diff --git a/settings.gradle.kts b/settings.gradle.kts new file mode 100644 index 0000000..2f1fa26 --- /dev/null +++ b/settings.gradle.kts @@ -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") + \ No newline at end of file