Skip to content

Commit

Permalink
v6.4
Browse files Browse the repository at this point in the history
Merge branch 'dev'
  • Loading branch information
BinTianqi committed Feb 9, 2025
2 parents 4e6393b + 9ecd87d commit f83a63f
Show file tree
Hide file tree
Showing 39 changed files with 2,369 additions and 956 deletions.
15 changes: 10 additions & 5 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,21 @@
name: Build APK

on:
workflow_dispatch:
push:
branches: ["master", "dev"]
paths-ignore:
- '**.md'
tags-ignore:
- '**'

concurrency:
group: "main"
cancel-in-progress: false

jobs:
build:
name: Build CI
name: Build
runs-on: ubuntu-latest
steps:
- name: Check out repository
Expand Down Expand Up @@ -61,10 +67,9 @@ jobs:

upload-telegram:
name: Upload Builds
if: ${{ success() && github.ref_name == 'dev' }}
runs-on: ubuntu-latest
needs:
- build
if: github.ref_name == 'dev'
needs: build
steps:
- name: Download Artifacts
uses: actions/download-artifact@v4
Expand Down Expand Up @@ -92,6 +97,6 @@ jobs:
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%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" \
curl -v "http://127.0.0.1:8081/bot$token/sendMediaGroup?chat_id=-1002203528169&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 releaseSigned="@$RELEASE_SIGNED_PWD.apk"
52 changes: 52 additions & 0 deletions Readme-en.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Use Android Device owner privilege to manage your device.
- _Wipe data_
- ...
- Network
- Add/modify/delete Wi-Fi
- Minimum Wi-Fi security level
- Always-on VPN
- Network logging
Expand Down Expand Up @@ -43,6 +44,57 @@ Use Android Device owner privilege to manage your device.
- Set screen timeout
- ...

## Activate

- Shizuku (recommended)
- Execute command in adb shell: `dpm set-device-owner com.bintianqi.owndroid/.Receiver`

## FAQ

### Activating

#### Already some accounts on the device

```text
java.lang.IllegalStateException: Not allowed to set the device owner because there are already some accounts on the device
```

Solutions:
- Freeze apps who hold those accounts.
- Delete these accounts.
- Use LSPosed module [HookDPM](https://github.com/BinTianqi/HookDPM).

#### Already several users on the device

```text
java.lang.IllegalStateException: Not allowed to set the device owner because there are already several users on the device
```

Solutions:
- Delete secondary users.
- Use LSPosed module [HookDPM](https://github.com/BinTianqi/HookDPM).

> [!NOTE]
> Some systems have features such as app cloning and children space, which are usually users.
#### MIUI

```text
java.lang.SecurityException: Neither user 2000 nor current process has android.permission.MANAGE_DEVICE_ADMINS.
```

Solutions:
- Enable `USB debugging (Security setting)` in developer options.
- Execute activating command in root shell.

#### ColorOS

```text
java.lang.IllegalStateException: Unexpected @ProvisioningPreCondition
```

Solution: Use OwnDroid testkey version

## API

| ID | Description | Extras | Minimum Android version |
Expand Down
52 changes: 52 additions & 0 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
- 清除数据
- ...
- 网络
- 添加/修改/删除 Wi-Fi
- 最小Wi-Fi安全等级
- VPN保持打开
- 网络日志
Expand Down Expand Up @@ -43,6 +44,57 @@
- 设置屏幕超时
- ...

## 激活

- Shizuku (推荐)
- 在ADB命令行中执行命令: `dpm set-device-owner com.bintianqi.owndroid/.Receiver`

## FAQ

### 激活

#### 设备上有账号

```text
java.lang.IllegalStateException: Not allowed to set the device owner because there are already some accounts on the device
```

解决办法:
- 冻结持有这些账号的app。
- 删除这些账号。
- 使用LSPosed模块 [HookDPM](https://github.com/BinTianqi/HookDPM)

#### 设备上有多个用户

```text
java.lang.IllegalStateException: Not allowed to set the device owner because there are already several users on the device
```

解决办法:
- 删除次级用户。
- 使用LSPosed模块[HookDPM](https://github.com/BinTianqi/HookDPM)

> [!NOTE]
> 一些系统有应用克隆、儿童空间等功能,它们通常是用户。
#### MIUI

```text
java.lang.SecurityException: Neither user 2000 nor current process has android.permission.MANAGE_DEVICE_ADMINS.
```

解决办法:
- 在开发者设置中打开`USB debugging (Security setting)`
- 在root命令行中执行激活命令

#### ColorOS

```text
java.lang.IllegalStateException: Unexpected @ProvisioningPreCondition
```

解决办法:使用 OwnDroid testkey 版本

## API

| ID | 描述 | Extras | 最小安卓版本 |
Expand Down
17 changes: 13 additions & 4 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,17 @@ android {
}
}
namespace = "com.bintianqi.owndroid"
compileSdk = 34
compileSdk = 35

lint.checkReleaseBuilds = false
lint.disable += "All"

defaultConfig {
applicationId = "com.bintianqi.owndroid"
minSdk = 21
targetSdk = 34
versionCode = 35
versionName = "6.3"
targetSdk = 35
versionCode = 36
versionName = "6.4"
multiDexEnabled = false
}

Expand All @@ -38,6 +38,10 @@ android {
"proguard-rules.pro"
)
signingConfig = signingConfigs.getByName("defaultSignature")
composeCompiler {
includeSourceInformation = false
includeTraceMarkers = false
}
}
debug {
signingConfig = signingConfigs.getByName("defaultSignature")
Expand All @@ -57,6 +61,9 @@ android {
androidResources {
generateLocaleConfig = true
}
dependenciesInfo {
includeInApk = false
}
}

kotlin {
Expand All @@ -76,6 +83,8 @@ gradle.taskGraph.whenReady {
dependencies {
implementation(libs.androidx.activity.compose)
implementation(platform(libs.androidx.compose.bom))
implementation(libs.androidx.compose.ui.tooling.preview)
debugImplementation(libs.androidx.compose.ui.tooling)
implementation(libs.accompanist.drawablepainter)
implementation(libs.accompanist.permissions)
implementation(libs.androidx.material3)
Expand Down
41 changes: 6 additions & 35 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,6 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
<uses-permission android:name="android.permission.POST_NOTIFICATIONS"/>
<uses-permission android:name="android.permission.DISABLE_KEYGUARD" />
<uses-permission android:name="android.permission.MANAGE_DEVICE_POLICY_KEYGUARD"/>
<uses-permission android:name="android.permission.MANAGE_DEVICE_POLICY_WIPE_DATA"/>
<uses-permission android:name="android.permission.MANAGE_DEVICE_POLICY_ACROSS_USERS"/>
<uses-permission android:name="android.permission.MANAGE_DEVICE_POLICY_RESET_PASSWORD"/>
<uses-permission android:name="android.permission.REQUEST_PASSWORD_COMPLEXITY"/>
<uses-permission android:name="android.permission.MANAGE_DEVICE_POLICY_INPUT_METHODS"/>
<uses-permission android:name="android.permission.MANAGE_DEVICE_POLICY_LOCK_CREDENTIALS"/>
<uses-permission android:name="android.permission.MANAGE_DEVICE_POLICY_APPS_CONTROL"/>
<uses-permission android:name="android.permission.MANAGE_DEVICE_POLICY_SYSTEM_UPDATES"/>
<uses-permission android:name="android.permission.MANAGE_DEVICE_POLICY_LOCK_TASK"/>
<uses-permission android:name="android.permission.MANAGE_DEVICE_POLICY_WIFI"/>
<uses-permission android:name="android.permission.MANAGE_DEVICE_POLICY_RUNTIME_PERMISSIONS"/>
<uses-permission android:name="android.permission.MANAGE_DEVICE_POLICY_ORGANIZATION_IDENTITY"/>
<uses-permission android:name="android.permission.MANAGE_DEVICE_POLICY_PROFILE_INTERACTION"/>
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES"/>
<uses-permission android:name="android.permission.REQUEST_DELETE_PACKAGES"/>
<uses-permission android:name="android.permission.QUERY_ALL_PACKAGES" tools:ignore="QueryAllPackagesPermission" />
Expand All @@ -35,7 +20,7 @@
android:enableOnBackInvokedCallback="true"
android:testOnly="false"
android:manageSpaceActivity=".ManageSpaceActivity"
tools:targetApi="34">
tools:targetApi="35">
<activity
android:name=".MainActivity"
android:exported="true"
Expand All @@ -57,18 +42,16 @@
android:theme="@style/Theme.Transparent">
</activity>
<activity
android:name=".InstallAppActivity"
android:name=".AppInstallerActivity"
android:label="@string/app_installer"
android:exported="true"
android:windowSoftInputMode="adjustResize|stateHidden"
android:excludeFromRecents="true"
android:launchMode="singleInstance"
android:theme="@style/Theme.Transparent">
android:launchMode="singleInstance">
<intent-filter>
<category android:name="android.intent.category.DEFAULT"/>
<action android:name="android.intent.action.VIEW"/>
<action android:name="android.intent.action.INSTALL_PACKAGE"/>
<data android:scheme="content"/>
<data android:scheme="file"/>
<action android:name="android.intent.action.SEND"/>
<action android:name="android.intent.action.SEND_MULTIPLE"/>
<data android:mimeType="application/vnd.android.package-archive"/>
</intent-filter>
</activity>
Expand All @@ -90,21 +73,9 @@
<action android:name="android.app.action.DEVICE_ADMIN_DISABLED"/>
</intent-filter>
</receiver>
<receiver
android:name=".PackageInstallerReceiver"
android:description="@string/app_name"
android:permission="android.permission.BIND_DEVICE_ADMIN">
</receiver>
<receiver
android:name=".ApiReceiver"
android:exported="true">
<intent-filter>
<action android:name="com.bintianqi.owndroid.action.HIDE"/>
<action android:name="com.bintianqi.owndroid.action.UNHIDE"/>
<action android:name="com.bintianqi.owndroid.action.SUSPEND"/>
<action android:name="com.bintianqi.owndroid.action.UNSUSPEND"/>
<action android:name="com.bintianqi.owndroid.action.LOCK"/>
</intent-filter>
</receiver>
<provider
android:name="rikka.shizuku.ShizukuProvider"
Expand Down
4 changes: 4 additions & 0 deletions app/src/main/aidl/com/bintianqi/owndroid/IUserService.aidl
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
package com.bintianqi.owndroid;

import android.accounts.Account;

interface IUserService {
String execute(String command) = 1;
int getUid() = 2;
Account[] listAccounts() = 3;
void destroy() = 16777114;
}
32 changes: 15 additions & 17 deletions app/src/main/java/com/bintianqi/owndroid/ApiReceiver.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.bintianqi.owndroid

import android.annotation.SuppressLint
import android.content.BroadcastReceiver
import android.content.Context
import android.content.Intent
Expand All @@ -9,41 +8,40 @@ import com.bintianqi.owndroid.dpm.getDPM
import com.bintianqi.owndroid.dpm.getReceiver

class ApiReceiver: BroadcastReceiver() {
@SuppressLint("NewApi")
override fun onReceive(context: Context, intent: Intent) {
val sharedPrefs = context.getSharedPreferences("data", Context.MODE_PRIVATE)
if(sharedPrefs.getBoolean("enable_api", false)) return
val key = sharedPrefs.getString("api_key", null)
if(key != null && key == intent.getStringExtra("key")) {
val requestKey = intent.getStringExtra("key") ?: ""
var log = "OwnDroid API request received. action: ${intent.action}\nkey: $requestKey"
val sp = SharedPrefs(context)
if(!sp.isApiEnabled) return
val key = sp.apiKey
if(!key.isNullOrEmpty() && key == requestKey) {
val dpm = context.getDPM()
val receiver = context.getReceiver()
val app = intent.getStringExtra("package") ?: ""
val app = intent.getStringExtra("package")
if(!app.isNullOrEmpty()) log += "\npackage: $app"
try {
@SuppressWarnings("NewApi")
val ok = when(intent.action) {
"com.bintianqi.owndroid.action.HIDE" -> dpm.setApplicationHidden(receiver, app, true)
"com.bintianqi.owndroid.action.UNHIDE" -> dpm.setApplicationHidden(receiver, app, false)
"com.bintianqi.owndroid.action.SUSPEND" -> dpm.setPackagesSuspended(receiver, arrayOf(app), true).isEmpty()
"com.bintianqi.owndroid.action.UNSUSPEND" -> dpm.setPackagesSuspended(receiver, arrayOf(app), false).isEmpty()
"com.bintianqi.owndroid.action.LOCK" -> { dpm.lockNow(); true }
"com.bintianqi.owndroid.action.LOCK" -> { dpm.lockNow(); null }
else -> {
Log.w(TAG, "Invalid action")
resultData = "Invalid action"
log += "\nInvalid action"
false
}
}
if(!ok) resultCode = 1
log += "success: $ok"
} catch(e: Exception) {
e.printStackTrace()
val message = (e::class.qualifiedName ?: "Exception") + ": " + (e.message ?: "")
Log.w(TAG, message)
resultCode = 1
resultData = message
log += "\n$message"
}
} else {
Log.w(TAG, "Unauthorized")
resultCode = 1
resultData = "Unauthorized"
log += "\nUnauthorized"
}
Log.d(TAG, log)
}
companion object {
private const val TAG = "API"
Expand Down
Loading

0 comments on commit f83a63f

Please sign in to comment.