mirror of
https://github.com/awfixers-stuff/OwnDroid.git
synced 2026-03-23 19:15:58 +00:00
Content protection policy
Change targetSdk and compileSdk to 35 Fix GitHub action build.yml Upgrade Compose BOM
This commit is contained in:
@@ -68,6 +68,7 @@ import com.bintianqi.owndroid.dpm.ChangeTime
|
||||
import com.bintianqi.owndroid.dpm.ChangeTimeZone
|
||||
import com.bintianqi.owndroid.dpm.ChangeUserIcon
|
||||
import com.bintianqi.owndroid.dpm.ChangeUsername
|
||||
import com.bintianqi.owndroid.dpm.ContentProtectionPolicy
|
||||
import com.bintianqi.owndroid.dpm.CreateUser
|
||||
import com.bintianqi.owndroid.dpm.CreateWorkProfile
|
||||
import com.bintianqi.owndroid.dpm.CurrentUserInfo
|
||||
@@ -233,6 +234,7 @@ fun Home(activity: FragmentActivity, vm: MyViewModel) {
|
||||
composable(route = "ChangeTime") { ChangeTime(navCtrl) }
|
||||
composable(route = "ChangeTimeZone") { ChangeTimeZone(navCtrl) }
|
||||
//composable(route = "KeyPairs") { KeyPairs(navCtrl) }
|
||||
composable(route = "ContentProtectionPolicy") { ContentProtectionPolicy(navCtrl) }
|
||||
composable(route = "PermissionPolicy") { PermissionPolicy(navCtrl) }
|
||||
composable(route = "MTEPolicy") { MTEPolicy(navCtrl) }
|
||||
composable(route = "NearbyStreamingPolicy") { NearbyStreamingPolicy(navCtrl) }
|
||||
@@ -412,9 +414,8 @@ private fun HomePage(navCtrl:NavHostController) {
|
||||
HomePageItem(R.string.system, R.drawable.android_fill0, "System", navCtrl)
|
||||
if(deviceOwner || profileOwner) { HomePageItem(R.string.network, R.drawable.wifi_fill0, "Network", navCtrl) }
|
||||
if(
|
||||
(VERSION.SDK_INT < 24 && !deviceOwner) || (
|
||||
VERSION.SDK_INT >= 24 && (dpm.isProvisioningAllowed(DevicePolicyManager.ACTION_PROVISION_MANAGED_PROFILE) ||
|
||||
(profileOwner && dpm.isManagedProfile(receiver)))
|
||||
(VERSION.SDK_INT < 24 && !deviceOwner) || (dpm.isProvisioningAllowed(DevicePolicyManager.ACTION_PROVISION_MANAGED_PROFILE) ||
|
||||
(profileOwner && dpm.isManagedProfile(receiver))
|
||||
)
|
||||
) {
|
||||
HomePageItem(R.string.work_profile, R.drawable.work_fill0, "ManagedProfile", navCtrl)
|
||||
|
||||
@@ -136,7 +136,7 @@ fun ApplicationManage(navCtrl:NavHostController, vm: MyViewModel) {
|
||||
)
|
||||
}
|
||||
) { paddingValues->
|
||||
NavHost(
|
||||
@Suppress("NewApi") NavHost(
|
||||
modifier = Modifier.padding(top = paddingValues.calculateTopPadding()),
|
||||
navController = localNavCtrl, startDestination = "Home",
|
||||
enterTransition = Animations.navHostEnterTransition,
|
||||
@@ -225,7 +225,7 @@ private fun Home(navCtrl:NavHostController, pkgName: String) {
|
||||
onCheckedChange = { appControlAction = 3; appControl(it) },
|
||||
onClickBlank = { appControlAction = 3; dialogStatus = 4 }
|
||||
)
|
||||
if((VERSION.SDK_INT >= 33 && profileOwner) || (VERSION.SDK_INT >= 30 && deviceOwner)) {
|
||||
if(VERSION.SDK_INT >= 30 && (deviceOwner || (VERSION.SDK_INT >= 33 && profileOwner))) {
|
||||
FunctionItem(title = R.string.ucd, icon = R.drawable.do_not_touch_fill0) { navCtrl.navigate("UserControlDisabled") }
|
||||
}
|
||||
if(VERSION.SDK_INT>=23) {
|
||||
|
||||
@@ -375,7 +375,7 @@ fun processSecurityLogs(securityEvents: List<SecurityLog.SecurityEvent>, outputS
|
||||
|
||||
@RequiresApi(24)
|
||||
fun parseSecurityEventData(event: SecurityLog.SecurityEvent): JsonElement? {
|
||||
return when(event.tag) { //TODO: backup service tag (API35)
|
||||
return when(event.tag) {
|
||||
SecurityLog.TAG_ADB_SHELL_CMD -> JsonPrimitive(event.data as String)
|
||||
SecurityLog.TAG_ADB_SHELL_INTERACTIVE -> null
|
||||
SecurityLog.TAG_APP_PROCESS_START -> {
|
||||
@@ -389,6 +389,14 @@ fun parseSecurityEventData(event: SecurityLog.SecurityEvent): JsonElement? {
|
||||
put("apk_hash", payload[5] as String)
|
||||
}
|
||||
}
|
||||
SecurityLog.TAG_BACKUP_SERVICE_TOGGLED -> {
|
||||
val payload = event.data as Array<*>
|
||||
buildJsonObject {
|
||||
put("admin", payload[0] as String)
|
||||
put("admin_user_id", payload[1] as Int)
|
||||
put("state", payload[2] as Int)
|
||||
}
|
||||
}
|
||||
SecurityLog.TAG_BLUETOOTH_CONNECTION -> {
|
||||
val payload = event.data as Array<*>
|
||||
buildJsonObject {
|
||||
|
||||
@@ -75,16 +75,16 @@ fun WorkProfile(navCtrl: NavHostController) {
|
||||
if(VERSION.SDK_INT >= 30 && profileOwner && dpm.isManagedProfile(receiver)) {
|
||||
FunctionItem(R.string.org_owned_work_profile, icon = R.drawable.corporate_fare_fill0) { navCtrl.navigate("OrgOwnedWorkProfile") }
|
||||
}
|
||||
if(VERSION.SDK_INT<24 || (VERSION.SDK_INT>=24 && dpm.isProvisioningAllowed(ACTION_PROVISION_MANAGED_PROFILE))) {
|
||||
if(VERSION.SDK_INT < 24 || dpm.isProvisioningAllowed(ACTION_PROVISION_MANAGED_PROFILE)) {
|
||||
FunctionItem(R.string.create_work_profile, icon = R.drawable.work_fill0) { navCtrl.navigate("CreateWorkProfile") }
|
||||
}
|
||||
if(dpm.isOrgProfile(receiver)) {
|
||||
FunctionItem(R.string.suspend_personal_app, icon = R.drawable.block_fill0) { navCtrl.navigate("SuspendPersonalApp") }
|
||||
}
|
||||
if(profileOwner && (VERSION.SDK_INT < 24 || (VERSION.SDK_INT >= 24 && dpm.isManagedProfile(receiver)))) {
|
||||
if(profileOwner && (VERSION.SDK_INT < 24 || dpm.isManagedProfile(receiver))) {
|
||||
FunctionItem(R.string.intent_filter, icon = R.drawable.filter_alt_fill0) { navCtrl.navigate("IntentFilter") }
|
||||
}
|
||||
if(profileOwner && (VERSION.SDK_INT < 24 || (VERSION.SDK_INT >= 24 && dpm.isManagedProfile(receiver)))) {
|
||||
if(profileOwner && (VERSION.SDK_INT < 24 || dpm.isManagedProfile(receiver))) {
|
||||
FunctionItem(R.string.delete_work_profile, icon = R.drawable.delete_forever_fill0) { navCtrl.navigate("DeleteWorkProfile") }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1081,7 +1081,7 @@ fun NetworkStats(navCtrl: NavHostController, vm: MyViewModel) {
|
||||
}
|
||||
}
|
||||
if(VERSION.SDK_INT >= 24 && (target == NetworkStatsTarget.UidTag || target == NetworkStatsTarget.UidTagState))
|
||||
ExposedDropdownMenuBox(
|
||||
ExposedDropdownMenuBox(
|
||||
activeTextField == NetworkStatsActiveTextField.Tag,
|
||||
{ activeTextField == if(it) NetworkStatsActiveTextField.Tag else NetworkStatsActiveTextField.None }
|
||||
) {
|
||||
@@ -1155,7 +1155,7 @@ fun NetworkStats(navCtrl: NavHostController, vm: MyViewModel) {
|
||||
querying = true
|
||||
coroutine.launch {
|
||||
val buckets = try {
|
||||
if(queryType == 1) {
|
||||
@Suppress("NewApi") if(queryType == 1) {
|
||||
if(target == NetworkStatsTarget.Device)
|
||||
listOf(nsm.querySummaryForDevice(networkType.type, subscriberId, startTime, endTime))
|
||||
else listOf(nsm.querySummaryForUser(networkType.type, subscriberId, startTime, endTime))
|
||||
|
||||
@@ -131,7 +131,7 @@ fun Permissions(navCtrl: NavHostController) {
|
||||
if(VERSION.SDK_INT >= 26 && (deviceOwner || profileOwner))
|
||||
FunctionItem(R.string.delegated_admins) { navCtrl.navigate("DelegatedAdmins") }
|
||||
FunctionItem(R.string.device_info, icon = R.drawable.perm_device_information_fill0) { navCtrl.navigate("DeviceInfo") }
|
||||
if((VERSION.SDK_INT >= 26 && deviceOwner) || (VERSION.SDK_INT >= 24 && profileOwner)) {
|
||||
if(VERSION.SDK_INT >= 24 && (profileOwner || (VERSION.SDK_INT >= 26 && deviceOwner))) {
|
||||
FunctionItem(R.string.org_name, icon = R.drawable.corporate_fare_fill0) { dialog = 2 }
|
||||
}
|
||||
if(VERSION.SDK_INT >= 31 && (profileOwner || deviceOwner)) {
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.bintianqi.owndroid.dpm
|
||||
import android.annotation.SuppressLint
|
||||
import android.app.ActivityOptions
|
||||
import android.app.AlertDialog
|
||||
import android.app.admin.DevicePolicyManager
|
||||
import android.app.admin.DevicePolicyManager.FLAG_EVICT_CREDENTIAL_ENCRYPTION_KEY
|
||||
import android.app.admin.DevicePolicyManager.InstallSystemUpdateCallback
|
||||
import android.app.admin.DevicePolicyManager.LOCK_TASK_FEATURE_BLOCK_ACTIVITY_START_IN_TASK
|
||||
@@ -166,7 +167,7 @@ fun SystemManage(navCtrl: NavHostController) {
|
||||
if(VERSION.SDK_INT >= 24 && deviceOwner) {
|
||||
FunctionItem(R.string.reboot, icon = R.drawable.restart_alt_fill0) { dialog = 1 }
|
||||
}
|
||||
if(deviceOwner && ((VERSION.SDK_INT >= 28 && dpm.isAffiliatedUser) || VERSION.SDK_INT >= 24)) {
|
||||
if(deviceOwner && VERSION.SDK_INT >= 24 && (VERSION.SDK_INT < 28 || dpm.isAffiliatedUser)) {
|
||||
FunctionItem(R.string.bug_report, icon = R.drawable.bug_report_fill0) { dialog = 2 }
|
||||
}
|
||||
if(VERSION.SDK_INT >= 28 && (deviceOwner || dpm.isOrgProfile(receiver))) {
|
||||
@@ -175,6 +176,8 @@ fun SystemManage(navCtrl: NavHostController) {
|
||||
}
|
||||
/*if(VERSION.SDK_INT >= 28 && (deviceOwner || profileOwner))
|
||||
FunctionItem(R.string.key_pairs, icon = R.drawable.key_vertical_fill0) { navCtrl.navigate("KeyPairs") }*/
|
||||
if(VERSION.SDK_INT >= 35 && (deviceOwner || (profileOwner && dpm.isAffiliatedUser)))
|
||||
FunctionItem(R.string.content_protection_policy, icon = R.drawable.search_fill0) { navCtrl.navigate("ContentProtectionPolicy") }
|
||||
if(VERSION.SDK_INT >= 23 && (deviceOwner || profileOwner)) {
|
||||
FunctionItem(R.string.permission_policy, icon = R.drawable.key_fill0) { navCtrl.navigate("PermissionPolicy") }
|
||||
}
|
||||
@@ -274,7 +277,7 @@ fun SystemOptions(navCtrl: NavHostController) {
|
||||
getState = { dpm.autoTimeRequired }, onCheckedChange = { dpm.setAutoTimeRequired(receiver,it) }, padding = false)
|
||||
}
|
||||
}
|
||||
if(deviceOwner || (profileOwner && (VERSION.SDK_INT < 24 || (VERSION.SDK_INT >= 24 && !dpm.isManagedProfile(receiver))))) {
|
||||
if(deviceOwner || profileOwner) {
|
||||
SwitchItem(R.string.master_mute, icon = R.drawable.volume_up_fill0,
|
||||
getState = { dpm.isMasterVolumeMuted(receiver) }, onCheckedChange = { dpm.setMasterVolumeMuted(receiver,it) }
|
||||
)
|
||||
@@ -812,6 +815,37 @@ fun KeyPairs(navCtrl: NavHostController) {
|
||||
}
|
||||
}*/
|
||||
|
||||
@RequiresApi(35)
|
||||
@Composable
|
||||
fun ContentProtectionPolicy(navCtrl: NavHostController) {
|
||||
val context = LocalContext.current
|
||||
val dpm = context.getDPM()
|
||||
val receiver = context.getReceiver()
|
||||
var policy by remember { mutableIntStateOf(DevicePolicyManager.CONTENT_PROTECTION_NOT_CONTROLLED_BY_POLICY) }
|
||||
fun refresh() { policy = dpm.getContentProtectionPolicy(receiver) }
|
||||
LaunchedEffect(Unit) { refresh() }
|
||||
MyScaffold(R.string.content_protection_policy, 8.dp, navCtrl) {
|
||||
mapOf(
|
||||
DevicePolicyManager.CONTENT_PROTECTION_NOT_CONTROLLED_BY_POLICY to R.string.not_controlled_by_policy,
|
||||
DevicePolicyManager.CONTENT_PROTECTION_ENABLED to R.string.enabled,
|
||||
DevicePolicyManager.CONTENT_PROTECTION_DISABLED to R.string.disabled
|
||||
).forEach { (policyId, string) ->
|
||||
RadioButtonItem(string, policy == policyId) { policy = policyId }
|
||||
}
|
||||
Button(
|
||||
onClick = {
|
||||
dpm.setContentProtectionPolicy(receiver, policy)
|
||||
refresh()
|
||||
context.showOperationResultToast(true)
|
||||
},
|
||||
modifier = Modifier.fillMaxWidth().padding(vertical = 4.dp)
|
||||
) {
|
||||
Text(stringResource(R.string.apply))
|
||||
}
|
||||
InfoCard(R.string.info_content_protection_policy)
|
||||
}
|
||||
}
|
||||
|
||||
@RequiresApi(23)
|
||||
@Composable
|
||||
fun PermissionPolicy(navCtrl: NavHostController) {
|
||||
@@ -1515,7 +1549,7 @@ fun WipeData(navCtrl: NavHostController) {
|
||||
)
|
||||
}
|
||||
Spacer(Modifier.padding(vertical = 5.dp))
|
||||
if(VERSION.SDK_INT < 34 || (VERSION.SDK_INT >= 34 && !userManager.isSystemUser)) {
|
||||
if(VERSION.SDK_INT < 34 || !userManager.isSystemUser) {
|
||||
Button(
|
||||
onClick = {
|
||||
focusMgr.clearFocus()
|
||||
|
||||
@@ -35,7 +35,7 @@ fun UserRestriction(navCtrl:NavHostController) {
|
||||
MyScaffold(R.string.user_restriction, 0.dp, navCtrl) {
|
||||
Text(text = stringResource(R.string.switch_to_disable_feature), modifier = Modifier.padding(start = 16.dp))
|
||||
if(context.isProfileOwner) { Text(text = stringResource(R.string.profile_owner_is_restricted), modifier = Modifier.padding(start = 16.dp)) }
|
||||
if(context.isProfileOwner && (VERSION.SDK_INT < 24 || (VERSION.SDK_INT >= 24 && dpm.isManagedProfile(receiver)))) {
|
||||
if(context.isProfileOwner && (VERSION.SDK_INT < 24 || dpm.isManagedProfile(receiver))) {
|
||||
Text(text = stringResource(R.string.some_features_invalid_in_work_profile), modifier = Modifier.padding(start = 16.dp))
|
||||
}
|
||||
Spacer(Modifier.padding(vertical = 2.dp))
|
||||
|
||||
Reference in New Issue
Block a user