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.filled.Settings
|
||||
import androidx.compose.material3.AlertDialog
|
||||
import androidx.compose.material3.Button
|
||||
import androidx.compose.material3.ExperimentalMaterial3Api
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.IconButton
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.bintianqi.owndroid
|
||||
|
||||
import android.accounts.Account
|
||||
import android.annotation.SuppressLint
|
||||
import android.app.ActivityOptions
|
||||
import android.app.Application
|
||||
import android.app.KeyguardManager
|
||||
@@ -521,14 +522,23 @@ class MyViewModel(application: Application): AndroidViewModel(application) {
|
||||
false
|
||||
}
|
||||
}
|
||||
@SuppressLint("PrivateApi")
|
||||
@RequiresApi(24)
|
||||
fun getOrgName(): String {
|
||||
return try {
|
||||
DPM.getOrganizationName(DAR)?.toString() ?: ""
|
||||
} catch (_: Exception) {
|
||||
try {
|
||||
val method = DevicePolicyManager::class.java.getDeclaredMethod(
|
||||
"getDeviceOwnerOrganizationName"
|
||||
)
|
||||
method.isAccessible = true
|
||||
(method.invoke(DPM) as CharSequence).toString()
|
||||
} catch (_: Exception) {
|
||||
""
|
||||
}
|
||||
}
|
||||
}
|
||||
@RequiresApi(24)
|
||||
fun setOrgName(name: String) {
|
||||
DPM.setOrganizationName(DAR, name)
|
||||
|
||||
@@ -104,7 +104,7 @@ class Receiver : DeviceAdminReceiver() {
|
||||
super.onUserRemoved(context, intent, removedUser)
|
||||
sendUserRelatedNotification(context, removedUser, NotificationType.UserRemoved)
|
||||
val um = context.getSystemService(Context.USER_SERVICE) as UserManager
|
||||
ShortcutUtils.deleteUserOperationShortcut(
|
||||
ShortcutUtils.disableUserOperationShortcut(
|
||||
context, um.getSerialNumberForUser(removedUser).toInt()
|
||||
)
|
||||
}
|
||||
|
||||
@@ -111,14 +111,13 @@ object ShortcutUtils {
|
||||
val shortcut = buildUserOperationShortcut(context, type, serial)
|
||||
return ShortcutManagerCompat.requestPinShortcut(context, shortcut, null)
|
||||
}
|
||||
fun deleteUserOperationShortcut(context: Context, serial: Int) {
|
||||
val shortcuts = ShortcutManagerCompat.getShortcuts(
|
||||
context, ShortcutManagerCompat.FLAG_MATCH_PINNED
|
||||
fun disableUserOperationShortcut(context: Context, serial: Int) {
|
||||
val shortcuts = UserOperationType.entries.map {
|
||||
"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() {
|
||||
if (SP.shortcutKey.isNullOrEmpty()) {
|
||||
|
||||
@@ -213,7 +213,7 @@ fun PasswordInfoScreen(
|
||||
val privilege by Privilege.status.collectAsStateWithLifecycle()
|
||||
var dialog by rememberSaveable { mutableIntStateOf(0) } // 0:none, 1:password complexity
|
||||
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.password_sufficient, isSufficient().yesOrNo)
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
[versions]
|
||||
agp = "8.13.0"
|
||||
kotlin = "2.2.20"
|
||||
kotlin = "2.2.21"
|
||||
|
||||
navigation-compose = "2.9.5"
|
||||
composeBom = "2025.10.00"
|
||||
composeBom = "2025.10.01"
|
||||
accompanist-drawablepainter = "0.37.3"
|
||||
accompanist-permissions = "0.37.3"
|
||||
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" }
|
||||
kotlin-android = { id = "org.jetbrains.kotlin.android", 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