Skip to content

Commit

Permalink
v6.0
Browse files Browse the repository at this point in the history
Merge pull request #61 from dev
  • Loading branch information
BinTianqi authored Aug 14, 2024
2 parents 30a9c69 + 8c40a5a commit 545eaea
Show file tree
Hide file tree
Showing 31 changed files with 2,060 additions and 1,349 deletions.
30 changes: 7 additions & 23 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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 }})
<blockquote>${{ github.event.head_commit.message }}</blockquote>
<a href="${{ github.event.head_commit.url }}">See commit details here</a>
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" \
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%2FreleaseTest%22%7D%2C%7B%22type%22%3A%22document%22%2C%22media%22%3A%22attach%3A%2F%2FreleaseSigned%22%2C%22parse_mode%22%3A%22HTML%22%2C%22caption%22%3A${ESCAPED}%7D%5D" \
-F releaseTest="@$RELEASE_TEST_PWD.apk" \
-F debugSigned="@$DEBUG_SIGNED_PWD.apk" \
-F releaseSigned="@$RELEASE_SIGNED_PWD.apk"
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,4 @@ captures
app/build
app/release
app/debug
app/signature.jks
.androidide
38 changes: 8 additions & 30 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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
}

Expand Down Expand Up @@ -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)
Expand All @@ -106,6 +82,8 @@ dependencies {
implementation(libs.androidx.navigation.compose)
implementation(libs.shizuku.provider)
implementation(libs.shizuku.api)
implementation(libs.dhizuku.api)
implementation(libs.androidx.biometric)
implementation(libs.androidx.fragment)
implementation(libs.hiddenApiBypass)
}
17 changes: 17 additions & 0 deletions app/src/main/java/android/app/admin/IDevicePolicyManager.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package android.app.admin;

import android.os.Binder;
import android.os.IBinder;
import android.os.IInterface;

import androidx.annotation.Keep;

@Keep
public interface IDevicePolicyManager extends IInterface {
@Keep
abstract class Stub extends Binder implements IDevicePolicyManager {
public static IDevicePolicyManager asInterface(IBinder obj) {
throw new UnsupportedOperationException();
}
}
}
17 changes: 17 additions & 0 deletions app/src/main/java/android/content/pm/IPackageInstaller.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package android.content.pm;

import android.os.Binder;
import android.os.IBinder;
import android.os.IInterface;

import androidx.annotation.Keep;

@Keep
public interface IPackageInstaller extends IInterface {
@Keep
abstract class Stub extends Binder implements IPackageInstaller {
public static IPackageInstaller asInterface(IBinder obj) {
throw new UnsupportedOperationException();
}
}
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
package com.bintianqi.owndroid

import android.annotation.SuppressLint
import android.app.admin.DevicePolicyManager
import android.content.BroadcastReceiver
import android.content.ComponentName
import android.content.Context
import android.content.Intent
import androidx.activity.ComponentActivity
import com.bintianqi.owndroid.dpm.getDPM
import com.bintianqi.owndroid.dpm.getReceiver

class AutomationReceiver: BroadcastReceiver() {
override fun onReceive(context: Context, intent: Intent) {
Expand All @@ -25,8 +24,8 @@ fun handleTask(context: Context, intent: Intent): String {
return "Wrong key"
}
val operation = intent.getStringExtra("operation")
val dpm = context.getSystemService(ComponentActivity.DEVICE_POLICY_SERVICE) as DevicePolicyManager
val receiver = ComponentName(context,Receiver::class.java)
val dpm = context.getDPM()
val receiver = context.getReceiver()
val app = intent.getStringExtra("app")
val restriction = intent.getStringExtra("restriction")
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -58,7 +58,7 @@ class InstallAppActivity: FragmentActivity() {
)
fd?.close()
withContext(Dispatchers.Main) {
status = "waiting"
status = "pending"
apkInfoText = "${context.getString(R.string.package_name)}: ${apkInfo.packageName}\n"
apkInfoText += "${context.getString(R.string.version_name)}: ${apkInfo.versionName}\n"
apkInfoText += "${context.getString(R.string.version_code)}: ${apkInfo.versionCode}"
Expand All @@ -79,7 +79,7 @@ class InstallAppActivity: FragmentActivity() {
},
text = {
Column {
AnimatedVisibility(status != "waiting") {
AnimatedVisibility(status != "pending") {
LinearProgressIndicator(modifier = Modifier.fillMaxWidth())
}
Text(text = apkInfoText, modifier = Modifier.padding(top = 4.dp))
Expand Down
Loading

0 comments on commit 545eaea

Please sign in to comment.