simplify apk signing in CI

update dependency
upload only release build to Telegram in CI
This commit is contained in:
BinTianqi
2024-08-06 16:39:55 +08:00
parent b908a50686
commit c570296e2d
10 changed files with 29 additions and 72 deletions

View File

@@ -4,17 +4,13 @@ plugins {
alias(libs.plugins.cc)
}
var keyPassword: String? = null
var keystorePassword: String? = null
var keyAlias: String? = null
android {
signingConfigs {
create("defaultSignature") {
storeFile = file("signature.jks")
storePassword = System.getenv("KEYSTORE_PASSWORD") ?: "testkey"
keyPassword = System.getenv("KEY_PASSWORD") ?: "testkey"
keyAlias = System.getenv("KEY_ALIAS") ?: "testkey"
storeFile = file(project.findProperty("StoreFile") ?: "testkey.jks")
storePassword = (project.findProperty("StorePassword") as String?) ?: "testkey"
keyPassword = (project.findProperty("KeyPassword") as String?) ?: "testkey"
keyAlias = (project.findProperty("KeyAlias") as String?) ?: "testkey"
}
}
namespace = "com.bintianqi.owndroid"
@@ -27,8 +23,8 @@ android {
applicationId = "com.bintianqi.owndroid"
minSdk = 21
targetSdk = 34
versionCode = 31
versionName = "5.6"
versionCode = 32
versionName = "6.0"
multiDexEnabled = false
}
@@ -77,26 +73,6 @@ gradle.taskGraph.whenReady {
project.tasks.findByPath(":app:lintAnalyzeDebug")?.enabled = false
}
tasks.findByName("preBuild")?.dependsOn?.plusAssign("prepareSignature")
tasks.register("prepareSignature") {
doFirst {
file("signature.jks").let {
if(!it.exists()) file("testkey.jks").copyTo(it)
}
}
}
tasks.findByName("clean")?.dependsOn?.plusAssign("cleanKey")
tasks.register("cleanKey") {
doFirst {
file("signature.jks").let {
if(it.exists()) it.delete()
}
}
}
dependencies {
implementation(libs.androidx.activity.compose)
implementation(libs.androidx.ui)

View File

@@ -36,7 +36,7 @@ import kotlinx.coroutines.withContext
import java.io.FileInputStream
class InstallAppActivity: FragmentActivity() {
override fun onNewIntent(intent: Intent?) {
override fun onNewIntent(intent: Intent) {
super.onNewIntent(intent)
this.intent = intent
}

View File

@@ -82,7 +82,7 @@ class StopLockTaskModeReceiver: BroadcastReceiver() {
val packages = dpm.getLockTaskPackages(receiver)
dpm.setLockTaskPackages(receiver, arrayOf())
dpm.setLockTaskPackages(receiver, packages)
val nm = context.getSystemService(ComponentActivity.NOTIFICATION_SERVICE) as NotificationManager
val nm = context.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
nm.cancel(1)
}
}

View File

@@ -86,7 +86,7 @@ fun registerActivityResult(context: ComponentActivity){
}
createManagedProfile = context.registerForActivityResult(ActivityResultContracts.StartActivityForResult()) {}
addDeviceAdmin = context.registerForActivityResult(ActivityResultContracts.StartActivityForResult()) {
val dpm = context.applicationContext.getSystemService(ComponentActivity.DEVICE_POLICY_SERVICE) as DevicePolicyManager
val dpm = context.applicationContext.getSystemService(Context.DEVICE_POLICY_SERVICE) as DevicePolicyManager
if(dpm.isAdminActive(ComponentName(context.applicationContext, Receiver::class.java))){
backToHomeStateFlow.value = true
}

View File

@@ -12,8 +12,6 @@ import android.content.Context
import android.content.Intent
import android.content.pm.PackageInstaller
import android.os.Build.VERSION
import androidx.activity.ComponentActivity.CONTEXT_IGNORE_SECURITY
import androidx.activity.ComponentActivity.DEVICE_POLICY_SERVICE
import androidx.activity.result.ActivityResultLauncher
import androidx.annotation.DrawableRes
import androidx.annotation.StringRes
@@ -34,7 +32,7 @@ lateinit var addDeviceAdmin: ActivityResultLauncher<Intent>
val Context.isDeviceOwner: Boolean
get() {
val sharedPref = getSharedPreferences("data", Context.MODE_PRIVATE)
val dpm = getSystemService(DEVICE_POLICY_SERVICE) as DevicePolicyManager
val dpm = getSystemService(Context.DEVICE_POLICY_SERVICE) as DevicePolicyManager
return dpm.isDeviceOwnerApp(
if(sharedPref.getBoolean("dhizuku", false)) {
Dhizuku.getOwnerPackageName()
@@ -46,7 +44,7 @@ val Context.isDeviceOwner: Boolean
val Context.isProfileOwner: Boolean
get() {
val dpm = getSystemService(DEVICE_POLICY_SERVICE) as DevicePolicyManager
val dpm = getSystemService(Context.DEVICE_POLICY_SERVICE) as DevicePolicyManager
return dpm.isProfileOwnerApp("com.bintianqi.owndroid")
}
@@ -90,8 +88,8 @@ fun installPackage(context: Context, inputStream: InputStream) {
@SuppressLint("PrivateApi")
fun binderWrapperDevicePolicyManager(appContext: Context): DevicePolicyManager? {
try {
val context = appContext.createPackageContext(Dhizuku.getOwnerComponent().packageName, CONTEXT_IGNORE_SECURITY)
val manager = context.getSystemService(DEVICE_POLICY_SERVICE) as DevicePolicyManager
val context = appContext.createPackageContext(Dhizuku.getOwnerComponent().packageName, Context.CONTEXT_IGNORE_SECURITY)
val manager = context.getSystemService(Context.DEVICE_POLICY_SERVICE) as DevicePolicyManager
val field = manager.javaClass.getDeclaredField("mService")
field.isAccessible = true
val oldInterface = field[manager] as IDevicePolicyManager
@@ -113,11 +111,11 @@ fun Context.getDPM(): DevicePolicyManager {
if (!Dhizuku.isPermissionGranted()) {
dhizukuErrorStatus.value = 2
backToHomeStateFlow.value = true
return this.getSystemService(DEVICE_POLICY_SERVICE) as DevicePolicyManager
return this.getSystemService(Context.DEVICE_POLICY_SERVICE) as DevicePolicyManager
}
return binderWrapperDevicePolicyManager(this) ?: this.getSystemService(DEVICE_POLICY_SERVICE) as DevicePolicyManager
return binderWrapperDevicePolicyManager(this) ?: this.getSystemService(Context.DEVICE_POLICY_SERVICE) as DevicePolicyManager
} else {
return this.getSystemService(DEVICE_POLICY_SERVICE) as DevicePolicyManager
return this.getSystemService(Context.DEVICE_POLICY_SERVICE) as DevicePolicyManager
}
}

View File

@@ -15,6 +15,7 @@ import android.app.admin.DevicePolicyManager.WIFI_SECURITY_PERSONAL
import android.app.admin.WifiSsidPolicy
import android.app.admin.WifiSsidPolicy.WIFI_SSID_POLICY_TYPE_ALLOWLIST
import android.app.admin.WifiSsidPolicy.WIFI_SSID_POLICY_TYPE_DENYLIST
import android.content.Context
import android.net.ProxyInfo
import android.net.Uri
import android.net.wifi.WifiSsid
@@ -750,7 +751,7 @@ private fun APN() {
RadioButtonItem("PAP/CHAP", selectedAuthType == AUTH_TYPE_PAP_OR_CHAP, { selectedAuthType = AUTH_TYPE_PAP_OR_CHAP })
if(VERSION.SDK_INT>=29) {
val ts = context.getSystemService(ComponentActivity.TELEPHONY_SERVICE) as TelephonyManager
val ts = context.getSystemService(Context.TELEPHONY_SERVICE) as TelephonyManager
carrierId = ts.simCarrierId.toString()
Text(text = "CarrierID", style = typography.titleLarge)
TextField(

View File

@@ -1330,7 +1330,7 @@ fun InstallSystemUpdate() {
@SuppressLint("NewApi")
private fun sendStopLockTaskNotification(context: Context) {
val nm = context.getSystemService(ComponentActivity.NOTIFICATION_SERVICE) as NotificationManager
val nm = context.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
if (VERSION.SDK_INT >= 26) {
val channel = NotificationChannel("LockTaskMode", context.getString(R.string.lock_task_mode), NotificationManager.IMPORTANCE_HIGH).apply {
description = "Notification channel for stop lock task mode"