适配Android 11

master
Matthew 12 months ago
parent af14323349
commit 0be21d5c38

@ -12,26 +12,26 @@ android {
buildConfig = true buildConfig = true
} }
signingConfigs { //signingConfigs {
AceKeystore { // AceKeystore {
keyAlias keystoreProperties['keyAlias'] // keyAlias keystoreProperties['keyAlias']
keyPassword keystoreProperties['keyPassword'] // keyPassword keystoreProperties['keyPassword']
storeFile file(keystoreProperties['storeFile']) // storeFile file(keystoreProperties['storeFile'])
storePassword keystoreProperties['storePassword'] // storePassword keystoreProperties['storePassword']
} // }
} //}
defaultConfig { defaultConfig {
applicationId "io.github.acedroidx.frp" applicationId "io.github.acedroidx.frp"
minSdkVersion 23 minSdkVersion 25
targetSdkVersion 34 targetSdkVersion 30
compileSdk 34 compileSdk 31
versionCode 4 versionCode 4
versionName "1.0.3" versionName "1.0.3"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
signingConfig signingConfigs.AceKeystore // signingConfig signingConfigs.AceKeystore
buildConfigField("String", "FrpVersion", '"0.56.0"') buildConfigField("String", "FrpVersion", '"0.56.0"')
buildConfigField("String", "FrpcFileName", '"libfrpc.so"') buildConfigField("String", "FrpcFileName", '"libfrpc.so"')
@ -43,15 +43,15 @@ android {
release { release {
minifyEnabled false minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.AceKeystore // signingConfig signingConfigs.AceKeystore
} }
debug { debug {
signingConfig signingConfigs.AceKeystore // signingConfig signingConfigs.AceKeystore
} }
} }
compileOptions { compileOptions {
sourceCompatibility JavaVersion.VERSION_17 sourceCompatibility JavaVersion.VERSION_11
targetCompatibility JavaVersion.VERSION_17 targetCompatibility JavaVersion.VERSION_11
} }
kotlinOptions { kotlinOptions {
jvmTarget = '17' jvmTarget = '17'
@ -74,10 +74,10 @@ android {
dependencies { dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation 'androidx.core:core-ktx:1.12.0' implementation 'androidx.core:core-ktx:1.6.0'
implementation 'androidx.appcompat:appcompat:1.6.1' implementation 'androidx.appcompat:appcompat:1.3.0'
implementation 'com.google.android.material:material:1.11.0' implementation 'com.google.android.material:material:1.4.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4' implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
testImplementation 'junit:junit:4.13.2' testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.5' androidTestImplementation 'androidx.test.ext:junit:1.1.5'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1' androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'

@ -1,18 +1,59 @@
{ {
"version": 2, "version": 3,
"artifactType": { "artifactType": {
"type": "APK", "type": "APK",
"kind": "Directory" "kind": "Directory"
}, },
"applicationId": "io.github.acedroidx.frp", "applicationId": "io.github.acedroidx.frp",
"variantName": "processReleaseResources", "variantName": "release",
"elements": [ "elements": [
{ {
"type": "SINGLE", "type": "UNIVERSAL",
"filters": [], "filters": [],
"versionCode": 1, "attributes": [],
"versionName": "1.0", "versionCode": 4,
"outputFile": "app-release.apk" "versionName": "1.0.3",
"outputFile": "app-universal-release.apk"
},
{
"type": "ONE_OF_MANY",
"filters": [
{
"filterType": "ABI",
"value": "x86_64"
}
],
"attributes": [],
"versionCode": 4,
"versionName": "1.0.3",
"outputFile": "app-x86_64-release.apk"
},
{
"type": "ONE_OF_MANY",
"filters": [
{
"filterType": "ABI",
"value": "arm64-v8a"
}
],
"attributes": [],
"versionCode": 4,
"versionName": "1.0.3",
"outputFile": "app-arm64-v8a-release.apk"
},
{
"type": "ONE_OF_MANY",
"filters": [
{
"filterType": "ABI",
"value": "armeabi-v7a"
}
],
"attributes": [],
"versionCode": 4,
"versionName": "1.0.3",
"outputFile": "app-armeabi-v7a-release.apk"
} }
] ],
"elementType": "File"
} }

@ -26,7 +26,7 @@
android:name=".ShellService" android:name=".ShellService"
android:enabled="true" android:enabled="true"
android:exported="false" android:exported="false"
android:foregroundServiceType="specialUse"> android:foregroundServiceType="camera">
<property <property
android:name="android.app.PROPERTY_SPECIAL_USE_FGS_SUBTYPE" android:name="android.app.PROPERTY_SPECIAL_USE_FGS_SUBTYPE"
android:value="explanation_for_special_use" /> android:value="explanation_for_special_use" />

@ -1,15 +1,20 @@
serverAddr = "" serverAddr = "61.169.135.146"
serverPort = 7000 serverPort = 7000
dnsServer = "114.114.114.114" dnsServer = "114.114.114.114"
auth.method = "token"
auth.token = "mint"
transport.tls.enable=false
transport.tls.disableCustomTLSFirstByte = false
[log] [log]
level = "debug" level = "debug"
disablePrintColor = true disablePrintColor = true
[[visitors]] [[proxies]]
name = "p2p_visitor" name = "p2p_adb"
type = "xtcp" type = "xtcp"
serverName = "" secretKey = "123456"
secretKey = "" localIP = "127.0.0.1"
bindAddr = "127.0.0.1" localPort = 5555
bindPort = 6000

@ -50,6 +50,8 @@ class MainActivity : AppCompatActivity() {
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main) setContentView(R.layout.activity_main)
var startFrp = intent.getIntExtra("startFrp",0)
val versionName = packageManager.getPackageInfo(packageName, 0).versionName val versionName = packageManager.getPackageInfo(packageName, 0).versionName
val titleText = findViewById<TextView>(R.id.titleText) val titleText = findViewById<TextView>(R.id.titleText)
titleText.text = "frp for Android - ${versionName}/${BuildConfig.FrpVersion}" titleText.text = "frp for Android - ${versionName}/${BuildConfig.FrpVersion}"
@ -60,7 +62,7 @@ class MainActivity : AppCompatActivity() {
mBound = isServiceRunning(ShellService::class.java) mBound = isServiceRunning(ShellService::class.java)
state_switch = findViewById<SwitchCompat>(R.id.state_switch) state_switch = findViewById<SwitchCompat>(R.id.state_switch)
state_switch.isChecked = mBound state_switch.isChecked = mBound || (startFrp != 0)
state_switch.setOnCheckedChangeListener { buttonView, isChecked -> if (isChecked) (startShell()) else (stopShell()) } state_switch.setOnCheckedChangeListener { buttonView, isChecked -> if (isChecked) (startShell()) else (stopShell()) }
val editor = getSharedPreferences("data", AppCompatActivity.MODE_PRIVATE) val editor = getSharedPreferences("data", AppCompatActivity.MODE_PRIVATE)
auto_start_switch = findViewById<SwitchCompat>(R.id.auto_start_switch) auto_start_switch = findViewById<SwitchCompat>(R.id.auto_start_switch)
@ -147,6 +149,7 @@ class MainActivity : AppCompatActivity() {
// decision. // decision.
} }
} }
/*
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
if (ContextCompat.checkSelfPermission( if (ContextCompat.checkSelfPermission(
this, Manifest.permission.POST_NOTIFICATIONS this, Manifest.permission.POST_NOTIFICATIONS
@ -155,6 +158,8 @@ class MainActivity : AppCompatActivity() {
requestPermissionLauncher.launch(Manifest.permission.POST_NOTIFICATIONS) requestPermissionLauncher.launch(Manifest.permission.POST_NOTIFICATIONS)
} }
} }
*/
} }
private fun createBGNotificationChannel() { private fun createBGNotificationChannel() {

@ -106,11 +106,12 @@ class ShellService : Service() {
.setContentText("已启动frp") .setContentText("已启动frp")
//.setTicker("test") //.setTicker("test")
.setContentIntent(pendingIntent) .setContentIntent(pendingIntent)
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) { /*if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
return notification.setForegroundServiceBehavior(Notification.FOREGROUND_SERVICE_IMMEDIATE) return notification.setForegroundServiceBehavior(Notification.FOREGROUND_SERVICE_IMMEDIATE)
.build() .build()
} else { } else {
return notification.build() return notification.build()
} }*/
return notification.build()
} }
} }

@ -1,12 +1,13 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules. // Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript { buildscript {
ext.kotlin_version = "1.9.20" ext.kotlin_version = "1.6.10"
repositories { repositories {
google() google()
jcenter()
mavenCentral() mavenCentral()
} }
dependencies { dependencies {
classpath 'com.android.tools.build:gradle:8.3.1' classpath 'com.android.tools.build:gradle:7.2.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
// NOTE: Do not place your application dependencies here; they belong // NOTE: Do not place your application dependencies here; they belong
@ -17,6 +18,7 @@ buildscript {
allprojects { allprojects {
repositories { repositories {
google() google()
jcenter()
mavenCentral() mavenCentral()
} }
} }

@ -1,6 +1,6 @@
#Thu Mar 24 09:47:16 CST 2022 #Thu Mar 24 09:47:16 CST 2022
distributionBase=GRADLE_USER_HOME distributionBase=GRADLE_USER_HOME
distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-rc-1-bin.zip distributionUrl=https\://mirrors.cloud.tencent.com/gradle/gradle-7.5-bin.zip
distributionPath=wrapper/dists distributionPath=wrapper/dists
zipStorePath=wrapper/dists zipStorePath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME

@ -1,4 +0,0 @@
storeFile=C:\\path\\to\\Keystore.jks
storePassword=
keyAlias=
keyPassword=

Binary file not shown.
Loading…
Cancel
Save