mirror of
https://github.com/awfixers-stuff/OwnDroid.git
synced 2026-03-23 11:05:59 +00:00
Add getOrganizationName workaround (#174)
Disable user operation shortcuts when user removed Fix crash when getting password complexity (#178) Update dependencies
This commit is contained in:
@@ -23,6 +23,7 @@ import androidx.compose.foundation.verticalScroll
|
|||||||
import androidx.compose.material.icons.Icons
|
import androidx.compose.material.icons.Icons
|
||||||
import androidx.compose.material.icons.filled.Settings
|
import androidx.compose.material.icons.filled.Settings
|
||||||
import androidx.compose.material3.AlertDialog
|
import androidx.compose.material3.AlertDialog
|
||||||
|
import androidx.compose.material3.Button
|
||||||
import androidx.compose.material3.ExperimentalMaterial3Api
|
import androidx.compose.material3.ExperimentalMaterial3Api
|
||||||
import androidx.compose.material3.Icon
|
import androidx.compose.material3.Icon
|
||||||
import androidx.compose.material3.IconButton
|
import androidx.compose.material3.IconButton
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package com.bintianqi.owndroid
|
package com.bintianqi.owndroid
|
||||||
|
|
||||||
import android.accounts.Account
|
import android.accounts.Account
|
||||||
|
import android.annotation.SuppressLint
|
||||||
import android.app.ActivityOptions
|
import android.app.ActivityOptions
|
||||||
import android.app.Application
|
import android.app.Application
|
||||||
import android.app.KeyguardManager
|
import android.app.KeyguardManager
|
||||||
@@ -521,12 +522,21 @@ class MyViewModel(application: Application): AndroidViewModel(application) {
|
|||||||
false
|
false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@SuppressLint("PrivateApi")
|
||||||
@RequiresApi(24)
|
@RequiresApi(24)
|
||||||
fun getOrgName(): String {
|
fun getOrgName(): String {
|
||||||
return try {
|
return try {
|
||||||
DPM.getOrganizationName(DAR)?.toString() ?: ""
|
DPM.getOrganizationName(DAR)?.toString() ?: ""
|
||||||
} catch (_: Exception) {
|
} catch (_: Exception) {
|
||||||
""
|
try {
|
||||||
|
val method = DevicePolicyManager::class.java.getDeclaredMethod(
|
||||||
|
"getDeviceOwnerOrganizationName"
|
||||||
|
)
|
||||||
|
method.isAccessible = true
|
||||||
|
(method.invoke(DPM) as CharSequence).toString()
|
||||||
|
} catch (_: Exception) {
|
||||||
|
""
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@RequiresApi(24)
|
@RequiresApi(24)
|
||||||
|
|||||||
@@ -104,7 +104,7 @@ class Receiver : DeviceAdminReceiver() {
|
|||||||
super.onUserRemoved(context, intent, removedUser)
|
super.onUserRemoved(context, intent, removedUser)
|
||||||
sendUserRelatedNotification(context, removedUser, NotificationType.UserRemoved)
|
sendUserRelatedNotification(context, removedUser, NotificationType.UserRemoved)
|
||||||
val um = context.getSystemService(Context.USER_SERVICE) as UserManager
|
val um = context.getSystemService(Context.USER_SERVICE) as UserManager
|
||||||
ShortcutUtils.deleteUserOperationShortcut(
|
ShortcutUtils.disableUserOperationShortcut(
|
||||||
context, um.getSerialNumberForUser(removedUser).toInt()
|
context, um.getSerialNumberForUser(removedUser).toInt()
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -111,14 +111,13 @@ object ShortcutUtils {
|
|||||||
val shortcut = buildUserOperationShortcut(context, type, serial)
|
val shortcut = buildUserOperationShortcut(context, type, serial)
|
||||||
return ShortcutManagerCompat.requestPinShortcut(context, shortcut, null)
|
return ShortcutManagerCompat.requestPinShortcut(context, shortcut, null)
|
||||||
}
|
}
|
||||||
fun deleteUserOperationShortcut(context: Context, serial: Int) {
|
fun disableUserOperationShortcut(context: Context, serial: Int) {
|
||||||
val shortcuts = ShortcutManagerCompat.getShortcuts(
|
val shortcuts = UserOperationType.entries.map {
|
||||||
context, ShortcutManagerCompat.FLAG_MATCH_PINNED
|
"USER_OPERATION-${it.name}-$serial"
|
||||||
|
}
|
||||||
|
ShortcutManagerCompat.disableShortcuts(
|
||||||
|
context, shortcuts, context.getString(R.string.user_removed)
|
||||||
)
|
)
|
||||||
val matchedShortcuts = shortcuts.filter {
|
|
||||||
it.id.startsWith("USER_OPERATION-") && it.id.endsWith("-$serial")
|
|
||||||
}.map { it.id }
|
|
||||||
ShortcutManagerCompat.removeLongLivedShortcuts(context, matchedShortcuts)
|
|
||||||
}
|
}
|
||||||
fun setShortcutKey() {
|
fun setShortcutKey() {
|
||||||
if (SP.shortcutKey.isNullOrEmpty()) {
|
if (SP.shortcutKey.isNullOrEmpty()) {
|
||||||
|
|||||||
@@ -213,7 +213,7 @@ fun PasswordInfoScreen(
|
|||||||
val privilege by Privilege.status.collectAsStateWithLifecycle()
|
val privilege by Privilege.status.collectAsStateWithLifecycle()
|
||||||
var dialog by rememberSaveable { mutableIntStateOf(0) } // 0:none, 1:password complexity
|
var dialog by rememberSaveable { mutableIntStateOf(0) } // 0:none, 1:password complexity
|
||||||
MyScaffold(R.string.password_info, onNavigateUp, 0.dp) {
|
MyScaffold(R.string.password_info, onNavigateUp, 0.dp) {
|
||||||
if (VERSION.SDK_INT >= 29) {
|
if (VERSION.SDK_INT >= 31) {
|
||||||
InfoItem(R.string.current_password_complexity, getComplexity().text, true) { dialog = 1 }
|
InfoItem(R.string.current_password_complexity, getComplexity().text, true) { dialog = 1 }
|
||||||
}
|
}
|
||||||
InfoItem(R.string.password_sufficient, isSufficient().yesOrNo)
|
InfoItem(R.string.password_sufficient, isSufficient().yesOrNo)
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
[versions]
|
[versions]
|
||||||
agp = "8.13.0"
|
agp = "8.13.0"
|
||||||
kotlin = "2.2.20"
|
kotlin = "2.2.21"
|
||||||
|
|
||||||
navigation-compose = "2.9.5"
|
navigation-compose = "2.9.5"
|
||||||
composeBom = "2025.10.00"
|
composeBom = "2025.10.01"
|
||||||
accompanist-drawablepainter = "0.37.3"
|
accompanist-drawablepainter = "0.37.3"
|
||||||
accompanist-permissions = "0.37.3"
|
accompanist-permissions = "0.37.3"
|
||||||
shizuku = "13.1.5"
|
shizuku = "13.1.5"
|
||||||
@@ -40,4 +40,4 @@ serialization = { group = "org.jetbrains.kotlinx", name = "kotlinx-serialization
|
|||||||
android-application = { id = "com.android.application", version.ref = "agp" }
|
android-application = { id = "com.android.application", version.ref = "agp" }
|
||||||
kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
|
kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
|
||||||
compose = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlin" }
|
compose = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlin" }
|
||||||
serialization = { id = "org.jetbrains.kotlin.plugin.serialization", version = "2.2.20" }
|
serialization = { id = "org.jetbrains.kotlin.plugin.serialization", version = "2.2.21" }
|
||||||
|
|||||||
Reference in New Issue
Block a user