diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 5eb926a..06b7c4e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -72,6 +72,12 @@ jobs: with: path: artifacts + - 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 + chmod +x ./binaries/telegram-bot-api + - name: Start API Server & Upload env: COMMIT_MESSAGE: |+ @@ -85,7 +91,8 @@ jobs: mv ./$RELEASE_TEST_PWD/app-release.apk ./$RELEASE_TEST_PWD.apk && rm -rf ./$RELEASE_TEST_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://api.telegram.org/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" \ + 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" diff --git a/Readme-zh_CN.md b/Readme-zh_CN.md index 349d306..eb0c5ad 100644 --- a/Readme-zh_CN.md +++ b/Readme-zh_CN.md @@ -51,11 +51,7 @@ java.lang.IllegalStateException: Not allowed to set the device owner because the java.lang.IllegalStateException: Not allowed to set the device owner because there are already several users on the device ``` -解决办法: -- 删除次级用户。 - -> [!NOTE] -> 一些系统有应用克隆、儿童空间等功能,它们通常是用户。 +解决办法:删除其他用户,包括工作资料、私密空间和应用分身。 ### Device owner 已存在 @@ -89,6 +85,19 @@ user limit reached 三星限制了多用户功能,暂无解决办法。 + +### 创建工作资料 + +在大部分设备上,设置device owner后不能创建工作资料,因为系统在设置device owner时会添加`no_add_managed_profile`等用户限制。 +Device owner不能修改系统设置的用户限制,但如果你有root权限,你可以在adb shell中执行以下命令以关闭这个限制。 + +```shell +pm set-user-restriction no_add_user 0 +pm set-user-restriction no_add_managed_profile 0 +pm set-user-restriction no_add_private_profile 0 +pm set-user-restriction no_add_clone_profile 0 +``` + ## API OwnDroid提供了一个基于Intent的API。你需要在设置中设置密钥并启用API。括号中的数字是最小的安卓版本。 diff --git a/Readme.md b/Readme.md index a462f4d..9a70458 100644 --- a/Readme.md +++ b/Readme.md @@ -51,11 +51,7 @@ Solutions: java.lang.IllegalStateException: Not allowed to set the device owner because there are already several users on the device ``` -Solutions: -- Delete secondary users. - -> [!NOTE] -> Some systems have features such as app cloning and children space, which are usually users. +Solution: Delete secondary users, including work profile, private space and app cloning. ### Device owner is already set @@ -91,6 +87,19 @@ user limit reached Samsung restricts Android's multiple users feature. There is currently no solution. +### Create work profile + +On most devices, creating work profile is not allowed by the system when the device owner exist. +Because the system add `no_add_managed_profile` user restriction when a device owner is set. +Device owner can't modify user restrictions set by the system, but if your device is rooted, you can disable this restriction by executing the following commands in adb shell. + +```shell +pm set-user-restriction no_add_user 0 +pm set-user-restriction no_add_managed_profile 0 +pm set-user-restriction no_add_private_profile 0 +pm set-user-restriction no_add_clone_profile 0 +``` + ## API OwnDroid provides an Intent-based API. You need to set the API key in settings and enable the API. The numbers in brackets represent the minimum Android version required. diff --git a/app/src/main/java/com/bintianqi/owndroid/Utils.kt b/app/src/main/java/com/bintianqi/owndroid/Utils.kt index 5ca0123..a7040f7 100644 --- a/app/src/main/java/com/bintianqi/owndroid/Utils.kt +++ b/app/src/main/java/com/bintianqi/owndroid/Utils.kt @@ -179,7 +179,7 @@ fun registerPackageRemovedReceiver( ctx.registerReceiver(br, filter) } -fun parsePackageNames(input: String) = input.split('\n').filter { it.isNotEmpty() } +fun parsePackageNames(input: String) = input.lines().filter { it.isNotEmpty() } val getInstalledAppsFlags = if(Build.VERSION.SDK_INT >= 24) PackageManager.MATCH_DISABLED_COMPONENTS or PackageManager.MATCH_UNINSTALLED_PACKAGES else 0 diff --git a/app/src/main/java/com/bintianqi/owndroid/ui/Components.kt b/app/src/main/java/com/bintianqi/owndroid/ui/Components.kt index de91904..35709c4 100644 --- a/app/src/main/java/com/bintianqi/owndroid/ui/Components.kt +++ b/app/src/main/java/com/bintianqi/owndroid/ui/Components.kt @@ -423,7 +423,7 @@ fun PackageNameTextField( Icon(Icons.AutoMirrored.Default.List, null) } }, - isError = value.isNotEmpty() && !value.isValidPackageName, + isError = value.lines().filter { it.isNotEmpty() }.all { it.isValidPackageName }, keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Ascii, imeAction = ImeAction.Done), keyboardActions = KeyboardActions { fm.clearFocus() } ) diff --git a/app/src/main/java/com/bintianqi/owndroid/ui/navigation/EntryProvider.kt b/app/src/main/java/com/bintianqi/owndroid/ui/navigation/EntryProvider.kt index eace85a..c3e579d 100644 --- a/app/src/main/java/com/bintianqi/owndroid/ui/navigation/EntryProvider.kt +++ b/app/src/main/java/com/bintianqi/owndroid/ui/navigation/EntryProvider.kt @@ -111,7 +111,7 @@ fun myEntryProvider( backstack += dest } fun navigateUp() { - backstack.removeLastOrNull() + if (backstack.size > 1) backstack.removeLastOrNull() } fun navigateToAppGroups() { navigate(Destination.ManageAppGroups)