mirror of
https://github.com/awfixers-stuff/OwnDroid.git
synced 2026-03-23 02:56:01 +00:00
simplify apk signing in CI
update dependency upload only release build to Telegram in CI
This commit is contained in:
28
.github/workflows/build.yml
vendored
28
.github/workflows/build.yml
vendored
@@ -41,17 +41,10 @@ jobs:
|
||||
name: OwnDroid-CI-${{ env.SHORT_SHA }}-release-testkey
|
||||
path: app/build/outputs/apk/release/app-release.apk
|
||||
|
||||
- name: Export key
|
||||
env:
|
||||
KEY_BASE64: ${{ secrets.KEY_BASE64 }}
|
||||
run: echo "$KEY_BASE64" | base64 --decode - > app/signature.jks
|
||||
|
||||
- name: Build APK
|
||||
env:
|
||||
KEYSTORE_PASSWORD: ${{ secrets.KEYSTORE_PASSWORD }}
|
||||
KEY_PASSWORD: ${{ secrets.KEY_PASSWORD }}
|
||||
KEY_ALIAS: ${{ secrets.KEY_ALIAS }}
|
||||
run: ./gradlew build
|
||||
run: |
|
||||
echo "${{ secrets.KEY_BASE64 }}" | base64 --decode - > app/release.jks
|
||||
./gradlew build -PStoreFile="$(pwd)/app/release.jks" -PStorePassword="${{ secrets.KEYSTORE_PASSWORD }}" -PKeyPassword="${{ secrets.KEY_PASSWORD }}" -PKeyAlias="${{ secrets.KEY_ALIAS }}"
|
||||
|
||||
- name: Upload Debug APK
|
||||
uses: actions/upload-artifact@v4
|
||||
@@ -77,7 +70,7 @@ jobs:
|
||||
with:
|
||||
path: artifacts
|
||||
|
||||
- name: Download telegram-bot-api-binary
|
||||
- name: Download telegram-bot-api
|
||||
run: |
|
||||
mkdir ./binaries
|
||||
wget "https://github.com/jakbin/telegram-bot-api-binary/releases/download/latest/telegram-bot-api" -O ./binaries/telegram-bot-api
|
||||
@@ -86,27 +79,18 @@ jobs:
|
||||
- name: Start API Server & Upload
|
||||
env:
|
||||
COMMIT_MESSAGE: |+
|
||||
New push to GitHub\!
|
||||
```
|
||||
${{ github.event.head_commit.message }}
|
||||
```by `${{ github.event.head_commit.author.name }}`
|
||||
See commit detail [here](${{ github.event.head_commit.url }})
|
||||
${{ github.event.head_commit.message }}\n
|
||||
[See commit detail here](${{ github.event.head_commit.url }})
|
||||
COMMIT_URL: ${{ github.event.head_commit.url }}
|
||||
run: |
|
||||
ESCAPED=`python3 -c 'import json,os,urllib.parse; msg = json.dumps(os.environ["COMMIT_MESSAGE"]); print(urllib.parse.quote(msg if len(msg) <= 1024 else json.dumps(os.environ["COMMIT_URL"])))'`
|
||||
cd artifacts
|
||||
export DEBUG_TEST_PWD=$(find . -name "*-debug-testkey*")
|
||||
mv ./$DEBUG_TEST_PWD/app-debug.apk ./$DEBUG_TEST_PWD.apk && rm -rf ./$DEBUG_TEST_PWD
|
||||
export RELEASE_TEST_PWD=$(find . -name "*release-testkey*")
|
||||
mv ./$RELEASE_TEST_PWD/app-release.apk ./$RELEASE_TEST_PWD.apk && rm -rf ./$RELEASE_TEST_PWD
|
||||
export DEBUG_SIGNED_PWD=$(find . -name "*-debug-signed*")
|
||||
mv ./$DEBUG_SIGNED_PWD/app-debug.apk ./$DEBUG_SIGNED_PWD.apk && rm -rf ./$DEBUG_SIGNED_PWD
|
||||
export RELEASE_SIGNED_PWD=$(find . -name "*release-signed*")
|
||||
mv ./$RELEASE_SIGNED_PWD/app-release.apk ./$RELEASE_SIGNED_PWD.apk && rm -rf ./$RELEASE_SIGNED_PWD
|
||||
../binaries/telegram-bot-api --api-id=${{ secrets.TELEGRAM_API_APP_ID }} --api-hash=${{ secrets.TELEGRAM_API_HASH }} --local 2>&1 > /dev/null &
|
||||
export token=${{ secrets.TELEGRAM_BOT_KEY }}
|
||||
curl -v "http://127.0.0.1:8081/bot$token/sendMediaGroup?chat_id=-1002216379163&media=%5B%7B%22type%22%3A%22document%22%2C%22media%22%3A%22attach%3A%2F%2FdebugTest%22%7D%2C%7B%22type%22%3A%22document%22%2C%22media%22%3A%22attach%3A%2F%2FreleaseTest%22%7D%2C%7B%22type%22%3A%22document%22%2C%22media%22%3A%22attach%3A%2F%2FdebugSigned%22%7D%2C%7B%22type%22%3A%22document%22%2C%22media%22%3A%22attach%3A%2F%2FreleaseSigned%22%2C%22parse_mode%22%3A%22MarkdownV2%22%2C%22caption%22%3A${ESCAPED}%7D%5D" \
|
||||
-F debugTest="@$DEBUG_TEST_PWD.apk" \
|
||||
-F releaseTest="@$RELEASE_TEST_PWD.apk" \
|
||||
-F debugSigned="@$DEBUG_SIGNED_PWD.apk" \
|
||||
-F releaseSigned="@$RELEASE_SIGNED_PWD.apk"
|
||||
|
||||
1
.gitignore
vendored
1
.gitignore
vendored
@@ -10,5 +10,4 @@ captures
|
||||
app/build
|
||||
app/release
|
||||
app/debug
|
||||
app/signature.jks
|
||||
.androidide
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
[versions]
|
||||
agp = "8.5.0"
|
||||
kt-android = "2.0.0"
|
||||
cc = "2.0.0"
|
||||
kotlin = "2.0.0"
|
||||
|
||||
androidx-activity-compose = "1.8.2"
|
||||
androidx-activity-compose = "1.9.0"
|
||||
navigation-compose = "2.7.7"
|
||||
material3 = "1.2.1"
|
||||
accompanist-drawablepainter = "0.35.0-alpha"
|
||||
@@ -31,5 +30,5 @@ androidx-fragment = { group = "androidx.fragment", name = "fragment", version.re
|
||||
|
||||
[plugins]
|
||||
android-application = { id = "com.android.application", version.ref = "agp" }
|
||||
kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kt-android" }
|
||||
cc = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "cc" }
|
||||
kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
|
||||
cc = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlin" }
|
||||
|
||||
Reference in New Issue
Block a user