From a21db0da7024e7d7ee2cb75d841b5738a2c8a2f9 Mon Sep 17 00:00:00 2001 From: BinTianqi Date: Sun, 19 Jan 2025 15:02:26 +0800 Subject: [PATCH] Add FAQ to READMEs Fix #93: list hidden apps in package selector --- Readme-en.md | 51 +++++++++++++++++++ Readme.md | 51 +++++++++++++++++++ .../com/bintianqi/owndroid/PackageSelector.kt | 7 ++- 3 files changed, 107 insertions(+), 2 deletions(-) diff --git a/Readme-en.md b/Readme-en.md index f36a9fb..af9abc5 100644 --- a/Readme-en.md +++ b/Readme-en.md @@ -43,6 +43,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 | diff --git a/Readme.md b/Readme.md index 38a8dc6..fe6ff05 100644 --- a/Readme.md +++ b/Readme.md @@ -43,6 +43,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 | 最小安卓版本 | diff --git a/app/src/main/java/com/bintianqi/owndroid/PackageSelector.kt b/app/src/main/java/com/bintianqi/owndroid/PackageSelector.kt index fef2530..08098ba 100644 --- a/app/src/main/java/com/bintianqi/owndroid/PackageSelector.kt +++ b/app/src/main/java/com/bintianqi/owndroid/PackageSelector.kt @@ -1,7 +1,9 @@ package com.bintianqi.owndroid import android.content.pm.ApplicationInfo +import android.content.pm.PackageManager import android.graphics.drawable.Drawable +import android.os.Build import android.widget.Toast import androidx.compose.animation.AnimatedVisibility import androidx.compose.foundation.Image @@ -69,7 +71,8 @@ data class PackageInfo( fun PackageSelector(navCtrl: NavHostController, vm: MyViewModel) { val context = LocalContext.current val pm = context.packageManager - val apps = pm.getInstalledApplications(0) + val flags = if(Build.VERSION.SDK_INT >= 24) PackageManager.MATCH_DISABLED_COMPONENTS or PackageManager.MATCH_UNINSTALLED_PACKAGES else 0 + val apps = pm.getInstalledApplications(flags) var progress by remember { mutableIntStateOf(0) } var show by remember { mutableStateOf(true) } var hideProgress by remember { mutableStateOf(true) } @@ -79,7 +82,7 @@ fun PackageSelector(navCtrl: NavHostController, vm: MyViewModel) { val scrollState = rememberLazyListState() val focusMgr = LocalFocusManager.current val co = rememberCoroutineScope() - val getPkgList: suspend ()->Unit = { + suspend fun getPkgList() { show = false progress = 0 hideProgress = false