Skip to content

Commit 9a0fad9

Browse files
committed
v6.2
2 parents 9620e95 + 0c670e9 commit 9a0fad9

36 files changed

+2662
-1355
lines changed

Diff for: Guide.md

-3
This file was deleted.

Diff for: Readme-en.md

+36-24
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,49 @@
1-
# OwnDroid
2-
31
[简体中文](Readme.md)
42

5-
### Description
6-
7-
Use Device admin and Device owner privilege to take full control of your device.
8-
9-
### Docs
10-
11-
A renewed OwnDroid docs are available on [owndroid.pages.dev](https://owndroid.pages.dev)
12-
13-
### Advantage
14-
15-
- Open source. Device owner privilege could be more dangerous than root, close-source software's security is not guaranteed.
16-
- Easy to use. You can use this utility easily. English docs are also provided.
17-
- Modern. This app is built with Kotlin and Jetpack Compose, designed with Material Design 3. And some new features on Android 14 is adapted.
18-
- Maintaining. This project is updating. Any Issue and PR is welcome.
19-
20-
### Disadvantage
3+
# OwnDroid
214

22-
This software may not have as many features as Google's official [TestDPC](https://github.com/googlesamples/android-testdpc)
5+
Use Android Device owner privilege to manage your device.
236

24-
### Features
7+
## Features
258

269
- System
10+
- Options: disable camera, disable screenshot, master volume mute, disable USB signal...
11+
- Permission policy
12+
- _Wipe data_
13+
- ...
2714
- Network
15+
- Minimum Wi-Fi security level
16+
- Always-on VPN
17+
- Network logging
18+
- ...
2819
- Work profile
29-
- App manage
30-
- User restrictions
31-
- User manage
20+
- Create work profile
21+
- Suspend personal apps
22+
- ...
23+
- Applications
24+
- Suspend/hide app
25+
- Block app uninstallation
26+
- Install/uninstall app
27+
- ...
28+
- User restriction
29+
- Network: disable configuring mobile network, disable configuring Wi-Fi, disable SMS, disable outgoing calls...
30+
- Connection: disable bluetooth, disable configuring location, disable USB file transfer, disable printing...
31+
- Applications: disable installing/uninstalling app...
32+
- Users: disable adding/removing/switching user...
33+
- Media: disable configuring brightness, disable adjusting volume...
34+
- Other: disable modifying accounts, disable configuring locale, disable factory reset, disable debug features...
35+
- User manager
36+
- User information
37+
- Start/switch/stop/delete user
38+
- Create user
39+
- ...
3240
- Password and keyguard
41+
- _Reset password_
42+
- Require password complexity
43+
- Set screen timeout
44+
- ...
3345

34-
### License
46+
## License
3547

3648
[License.md](LICENSE.md)
3749

Diff for: Readme.md

+33-21
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,49 @@
1-
# OwnDroid
2-
31
[English](Readme-en.md)
42

5-
### 简介
6-
7-
使用安卓的Device Admin和Device Owner特权,完全掌控你的设备。
8-
9-
### 文档
10-
11-
全新的OwnDroid文档:[owndroid.pages.dev](https://owndroid.pages.dev/zh_CN)
12-
13-
### 优点
14-
15-
- 开源。Device owner权限可能比root权限更危险,闭源软件的安全性没有保证
16-
- 易于使用。应用中的功能清晰明了,并且有在线的文档
17-
- 现代化。使用 Kotlin + Jetpack Compose,使用Material Design 3,适配安卓14的一些新功能
18-
- 维护中。这个项目正在不断更新。欢迎 Issue 和 Pull request
19-
20-
### 缺点
3+
# OwnDroid
214

22-
- 功能没有谷歌官方的 [TestDPC](https://github.com/googlesamples/android-testdpc) 那么全
5+
使用安卓Device owner特权管理你的设备。
236

24-
### 功能
7+
## 功能
258

269
- 系统
10+
- 选项:禁用摄像头、禁止截屏、全局静音、禁用USB信号...
11+
- 权限策略
12+
- 清除数据
13+
- ...
2714
- 网络
15+
- 最小Wi-Fi安全等级
16+
- VPN保持打开
17+
- 网络日志
18+
- ...
2819
- 工作资料
20+
- 创建工作资料
21+
- 挂起个人应用
22+
- ...
2923
- 应用管理
24+
- 挂起/隐藏应用
25+
- 阻止应用卸载
26+
- 安装/卸载应用
27+
- ...
3028
- 用户限制
29+
- 网络:禁止配置移动网络、禁止配置Wi-Fi、禁用短信、禁止拨出电话...
30+
- 连接:禁用蓝牙、禁止配置定位、禁用USB文件传输、禁用打印...
31+
- 应用:禁止安装/卸载应用...
32+
- 用户:禁止添加/删除/切换用户...
33+
- 媒体:禁止调整亮度、禁止调整音量...
34+
- 其他:禁止修改账号、禁止修改语言、禁止恢复出场设置、禁用调试功能...
3135
- 用户管理
36+
- 用户信息
37+
- 启动/切换/停止/删除用户
38+
- 创建用户
39+
- ...
3240
- 密码与锁屏
41+
- 重置密码
42+
- 要求密码复杂度
43+
- 设置屏幕超时
44+
- ...
3345

34-
### 许可证
46+
## 许可证
3547

3648
[License.md](LICENSE.md)
3749

Diff for: app/build.gradle.kts

+12-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ plugins {
22
alias(libs.plugins.android.application)
33
alias(libs.plugins.kotlin.android)
44
alias(libs.plugins.compose)
5-
kotlin("plugin.serialization") version "2.0.0"
5+
kotlin("plugin.serialization") version "2.0.21"
66
}
77

88
android {
@@ -24,8 +24,8 @@ android {
2424
applicationId = "com.bintianqi.owndroid"
2525
minSdk = 21
2626
targetSdk = 34
27-
versionCode = 32
28-
versionName = "6.0"
27+
versionCode = 34
28+
versionName = "6.2"
2929
multiDexEnabled = false
3030
}
3131

@@ -68,6 +68,14 @@ android {
6868
}
6969
}
7070

71+
kotlin {
72+
sourceSets {
73+
all {
74+
languageSettings.optIn("kotlinx.serialization.ExperimentalSerializationApi")
75+
}
76+
}
77+
}
78+
7179
gradle.taskGraph.whenReady {
7280
project.tasks.findByPath(":app:test")?.enabled = false
7381
project.tasks.findByPath(":app:lint")?.enabled = false
@@ -76,6 +84,7 @@ gradle.taskGraph.whenReady {
7684

7785
dependencies {
7886
implementation(libs.androidx.activity.compose)
87+
implementation(platform(libs.androidx.compose.bom))
7988
implementation(libs.accompanist.drawablepainter)
8089
implementation(libs.androidx.material3)
8190
implementation(libs.androidx.navigation.compose)

Diff for: app/src/main/aidl/com/bintianqi/owndroid/IUserService.aidl

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@ package com.bintianqi.owndroid;
33
interface IUserService {
44
void destroy() = 16777114;
55
String execute(String command) = 1;
6-
String getUid() = 2;
6+
int getUid() = 2;
77
}

Diff for: app/src/main/java/com/bintianqi/owndroid/InstallAppActivity.kt

+4-4
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import android.graphics.drawable.ColorDrawable
77
import android.os.Bundle
88
import androidx.activity.compose.setContent
99
import androidx.activity.enableEdgeToEdge
10+
import androidx.activity.viewModels
1011
import androidx.compose.animation.AnimatedVisibility
1112
import androidx.compose.foundation.layout.Column
1213
import androidx.compose.foundation.layout.fillMaxWidth
@@ -64,11 +65,10 @@ class InstallAppActivity: FragmentActivity() {
6465
apkInfoText += "${context.getString(R.string.version_code)}: ${apkInfo.versionCode}"
6566
}
6667
}
68+
val vm by viewModels<MyViewModel>()
69+
if(!vm.initialized) vm.initialize(applicationContext)
6770
setContent {
68-
OwnDroidTheme(
69-
sharedPref.getBoolean("material_you", true),
70-
sharedPref.getBoolean("black_theme", false)
71-
) {
71+
OwnDroidTheme(vm) {
7272
AlertDialog(
7373
properties = DialogProperties(dismissOnBackPress = false, dismissOnClickOutside = false),
7474
title = {

Diff for: app/src/main/java/com/bintianqi/owndroid/MainActivity.kt

+23-20
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import android.os.Bundle
77
import android.widget.Toast
88
import androidx.activity.compose.setContent
99
import androidx.activity.enableEdgeToEdge
10+
import androidx.activity.viewModels
1011
import androidx.compose.foundation.background
1112
import androidx.compose.foundation.clickable
1213
import androidx.compose.foundation.gestures.detectTapGestures
@@ -30,7 +31,6 @@ import androidx.compose.material3.Text
3031
import androidx.compose.material3.TextButton
3132
import androidx.compose.runtime.Composable
3233
import androidx.compose.runtime.LaunchedEffect
33-
import androidx.compose.runtime.MutableState
3434
import androidx.compose.runtime.collectAsState
3535
import androidx.compose.runtime.getValue
3636
import androidx.compose.runtime.mutableIntStateOf
@@ -48,6 +48,7 @@ import androidx.compose.ui.res.stringResource
4848
import androidx.compose.ui.unit.dp
4949
import androidx.core.view.WindowCompat
5050
import androidx.fragment.app.FragmentActivity
51+
import androidx.lifecycle.lifecycleScope
5152
import androidx.navigation.NavHostController
5253
import androidx.navigation.compose.NavHost
5354
import androidx.navigation.compose.composable
@@ -66,12 +67,14 @@ import com.bintianqi.owndroid.dpm.getReceiver
6667
import com.bintianqi.owndroid.dpm.isDeviceAdmin
6768
import com.bintianqi.owndroid.dpm.isDeviceOwner
6869
import com.bintianqi.owndroid.dpm.isProfileOwner
70+
import com.bintianqi.owndroid.dpm.setDefaultAffiliationID
6971
import com.bintianqi.owndroid.dpm.toggleInstallAppActivity
7072
import com.bintianqi.owndroid.ui.Animations
7173
import com.bintianqi.owndroid.ui.theme.OwnDroidTheme
7274
import com.rosan.dhizuku.api.Dhizuku
7375
import kotlinx.coroutines.delay
7476
import kotlinx.coroutines.flow.MutableStateFlow
77+
import kotlinx.coroutines.launch
7578
import org.lsposed.hiddenapibypass.HiddenApiBypass
7679
import java.util.Locale
7780

@@ -85,19 +88,19 @@ class MainActivity : FragmentActivity() {
8588
enableEdgeToEdge()
8689
WindowCompat.setDecorFitsSystemWindows(window, false)
8790
super.onCreate(savedInstanceState)
88-
val sharedPref = applicationContext.getSharedPreferences("data", Context.MODE_PRIVATE)
91+
val context = applicationContext
92+
val sharedPref = context.getSharedPreferences("data", MODE_PRIVATE)
8993
if (VERSION.SDK_INT >= 28) HiddenApiBypass.setHiddenApiExemptions("")
90-
if(sharedPref.getBoolean("auth", false)) {
91-
showAuth.value = true
92-
}
93-
val locale = applicationContext.resources?.configuration?.locale
94+
if(sharedPref.getBoolean("auth", false)) showAuth.value = true
95+
val locale = context.resources?.configuration?.locale
9496
zhCN = locale == Locale.SIMPLIFIED_CHINESE || locale == Locale.CHINESE || locale == Locale.CHINA
9597
toggleInstallAppActivity()
98+
val vm by viewModels<MyViewModel>()
99+
if(!vm.initialized) vm.initialize(context)
100+
lifecycleScope.launch { delay(5000); setDefaultAffiliationID(context) }
96101
setContent {
97-
val materialYou = remember { mutableStateOf(sharedPref.getBoolean("material_you", true)) }
98-
val blackTheme = remember { mutableStateOf(sharedPref.getBoolean("black_theme", false)) }
99-
OwnDroidTheme(materialYou.value, blackTheme.value) {
100-
Home(materialYou, blackTheme)
102+
OwnDroidTheme(vm) {
103+
Home(vm)
101104
if(showAuth.value) {
102105
AuthScreen(this, showAuth)
103106
}
@@ -107,7 +110,7 @@ class MainActivity : FragmentActivity() {
107110

108111
override fun onResume() {
109112
super.onResume()
110-
val sharedPref = applicationContext.getSharedPreferences("data", Context.MODE_PRIVATE)
113+
val sharedPref = applicationContext.getSharedPreferences("data", MODE_PRIVATE)
111114
if(
112115
sharedPref.getBoolean("auth", false) &&
113116
sharedPref.getBoolean("lock_in_background", false)
@@ -128,7 +131,7 @@ class MainActivity : FragmentActivity() {
128131

129132
@ExperimentalMaterial3Api
130133
@Composable
131-
fun Home(materialYou:MutableState<Boolean>, blackTheme:MutableState<Boolean>) {
134+
fun Home(vm: MyViewModel) {
132135
val navCtrl = rememberNavController()
133136
val context = LocalContext.current
134137
val dpm = context.getDPM()
@@ -154,14 +157,14 @@ fun Home(materialYou:MutableState<Boolean>, blackTheme:MutableState<Boolean>) {
154157
popExitTransition = Animations.navHostPopExitTransition
155158
) {
156159
composable(route = "HomePage") { HomePage(navCtrl) }
157-
composable(route = "SystemManage") { SystemManage(navCtrl) }
160+
composable(route = "System") { SystemManage(navCtrl) }
158161
composable(route = "ManagedProfile") { ManagedProfile(navCtrl) }
159162
composable(route = "Permissions") { DpmPermissions(navCtrl) }
160-
composable(route = "ApplicationManage") { ApplicationManage(navCtrl, dialogStatus) }
163+
composable(route = "Applications") { ApplicationManage(navCtrl, dialogStatus) }
161164
composable(route = "UserRestriction") { UserRestriction(navCtrl) }
162-
composable(route = "UserManage") { UserManage(navCtrl) }
165+
composable(route = "Users") { UserManage(navCtrl) }
163166
composable(route = "Password") { Password(navCtrl) }
164-
composable(route = "AppSetting") { AppSetting(navCtrl, materialYou, blackTheme) }
167+
composable(route = "Settings") { AppSetting(navCtrl, vm) }
165168
composable(route = "Network") { Network(navCtrl) }
166169
composable(route = "PackageSelector") { PackageSelector(navCtrl) }
167170
}
@@ -234,7 +237,7 @@ private fun HomePage(navCtrl:NavHostController) {
234237
if(activateType != "") { Text(text = activateType, color = colorScheme.onPrimary) }
235238
}
236239
}
237-
HomePageItem(R.string.system_manage, R.drawable.mobile_phone_fill0, "SystemManage", navCtrl)
240+
HomePageItem(R.string.system, R.drawable.android_fill0, "System", navCtrl)
238241
if(deviceOwner || profileOwner) { HomePageItem(R.string.network, R.drawable.wifi_fill0, "Network", navCtrl) }
239242
if(
240243
(VERSION.SDK_INT < 24 && !deviceOwner) || (
@@ -244,13 +247,13 @@ private fun HomePage(navCtrl:NavHostController) {
244247
) {
245248
HomePageItem(R.string.work_profile, R.drawable.work_fill0, "ManagedProfile", navCtrl)
246249
}
247-
if(deviceOwner || profileOwner) HomePageItem(R.string.app_manager, R.drawable.apps_fill0, "ApplicationManage", navCtrl)
250+
if(deviceOwner || profileOwner) HomePageItem(R.string.applications, R.drawable.apps_fill0, "Applications", navCtrl)
248251
if(VERSION.SDK_INT >= 24 && (profileOwner || deviceOwner)) {
249252
HomePageItem(R.string.user_restrict, R.drawable.person_off, "UserRestriction", navCtrl)
250253
}
251-
HomePageItem(R.string.user_manager,R.drawable.manage_accounts_fill0,"UserManage", navCtrl)
254+
HomePageItem(R.string.users,R.drawable.manage_accounts_fill0,"Users", navCtrl)
252255
HomePageItem(R.string.password_and_keyguard, R.drawable.password_fill0, "Password", navCtrl)
253-
HomePageItem(R.string.setting, R.drawable.settings_fill0, "AppSetting", navCtrl)
256+
HomePageItem(R.string.settings, R.drawable.settings_fill0, "Settings", navCtrl)
254257
Spacer(Modifier.padding(vertical = 20.dp))
255258
}
256259
}

0 commit comments

Comments
 (0)