diff --git a/app/src/main/java/com/bintianqi/owndroid/dpm/Network.kt b/app/src/main/java/com/bintianqi/owndroid/dpm/Network.kt index 30fbde7..0736fde 100644 --- a/app/src/main/java/com/bintianqi/owndroid/dpm/Network.kt +++ b/app/src/main/java/com/bintianqi/owndroid/dpm/Network.kt @@ -56,15 +56,18 @@ import androidx.compose.foundation.text.KeyboardActions import androidx.compose.foundation.text.KeyboardOptions import androidx.compose.foundation.text.selection.SelectionContainer import androidx.compose.foundation.verticalScroll +import androidx.compose.material3.AlertDialog import androidx.compose.material3.Button import androidx.compose.material3.MaterialTheme.typography import androidx.compose.material3.OutlinedTextField import androidx.compose.material3.Scaffold import androidx.compose.material3.Switch import androidx.compose.material3.Text +import androidx.compose.material3.TextButton import androidx.compose.material3.TextField import androidx.compose.runtime.Composable import androidx.compose.runtime.LaunchedEffect +import androidx.compose.runtime.MutableState import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableIntStateOf import androidx.compose.runtime.mutableStateListOf @@ -100,6 +103,7 @@ fun Network(navCtrl: NavHostController) { val localNavCtrl = rememberNavController() val backStackEntry by localNavCtrl.currentBackStackEntryAsState() val scrollState = rememberScrollState() + val wifiMacDialog = remember { mutableStateOf(false) } Scaffold( topBar = { TopBar(backStackEntry,navCtrl,localNavCtrl) { @@ -120,7 +124,7 @@ fun Network(navCtrl: NavHostController) { popExitTransition = Animations.navHostPopExitTransition, modifier = Modifier.padding(top = it.calculateTopPadding()) ) { - composable(route = "Home") { Home(localNavCtrl,scrollState) } + composable(route = "Home") { Home(localNavCtrl, scrollState, wifiMacDialog) } composable(route = "Switches") { Switches() } composable(route = "MinWifiSecurityLevel") { WifiSecLevel() } composable(route = "WifiSsidPolicy") { WifiSsidPolicy() } @@ -130,10 +134,22 @@ fun Network(navCtrl: NavHostController) { composable(route = "APN") { APN() } } } + if(wifiMacDialog.value && VERSION.SDK_INT >= 24) { + val context = LocalContext.current + val dpm = context.getSystemService(ComponentActivity.DEVICE_POLICY_SERVICE) as DevicePolicyManager + val receiver = ComponentName(context, Receiver::class.java) + AlertDialog( + onDismissRequest = { wifiMacDialog.value = false }, + confirmButton = { TextButton(onClick = { wifiMacDialog.value = false }) { Text(stringResource(R.string.confirm)) } }, + title = { Text(stringResource(R.string.wifi_mac_addr)) }, + text = { SelectionContainer { Text(dpm.getWifiMacAddress(receiver)?: stringResource(R.string.none)) } }, + modifier = Modifier.fillMaxWidth() + ) + } } @Composable -private fun Home(navCtrl:NavHostController,scrollState: ScrollState) { +private fun Home(navCtrl:NavHostController, scrollState: ScrollState, wifiMacDialog: MutableState) { val context = LocalContext.current val dpm = context.getSystemService(ComponentActivity.DEVICE_POLICY_SERVICE) as DevicePolicyManager val receiver = ComponentName(context, Receiver::class.java) @@ -143,11 +159,9 @@ private fun Home(navCtrl:NavHostController,scrollState: ScrollState) { style = typography.headlineLarge, modifier = Modifier.padding(top = 8.dp, bottom = 5.dp, start = 15.dp) ) - if(VERSION.SDK_INT>=24&&isDeviceOwner(dpm)) { - val wifimac = dpm.getWifiMacAddress(receiver) - Text(text = "WiFi MAC: $wifimac", modifier = Modifier.padding(start = 15.dp)) + if(VERSION.SDK_INT >= 24 && (isDeviceOwner(dpm) || (VERSION.SDK_INT >= 30 && isProfileOwner(dpm) && dpm.isManagedProfile(receiver) && dpm.isOrganizationOwnedDeviceWithManagedProfile))) { + SubPageItem(R.string.wifi_mac_addr, "", R.drawable.wifi_fill0) { wifiMacDialog.value = true } } - Spacer(Modifier.padding(vertical = 3.dp)) if(VERSION.SDK_INT >= 30) { SubPageItem(R.string.options, "", R.drawable.tune_fill0) { navCtrl.navigate("Switches") } } diff --git a/app/src/main/java/com/bintianqi/owndroid/dpm/Permissions.kt b/app/src/main/java/com/bintianqi/owndroid/dpm/Permissions.kt index 7ea26a6..fac9f2d 100644 --- a/app/src/main/java/com/bintianqi/owndroid/dpm/Permissions.kt +++ b/app/src/main/java/com/bintianqi/owndroid/dpm/Permissions.kt @@ -311,6 +311,14 @@ fun DeviceInfo() { if(VERSION.SDK_INT >= 24) { encryptionStatus[DevicePolicyManager.ENCRYPTION_STATUS_ACTIVE_PER_USER] = stringResource(R.string.es_active_per_user) } Text(stringResource(R.string.encrypt_status_is)+encryptionStatus[dpm.storageEncryptionStatus]) Spacer(Modifier.padding(vertical = 2.dp)) + if(VERSION.SDK_INT >= 28) { + Text(stringResource(R.string.support_device_id_attestation) + dpm.isDeviceIdAttestationSupported) + } + Spacer(Modifier.padding(vertical = 2.dp)) + if (VERSION.SDK_INT >= 30) { + Text(stringResource(R.string.support_unique_device_attestation) + dpm.isUniqueDeviceAttestationSupported) + } + Spacer(Modifier.padding(vertical = 2.dp)) val adminList = dpm.activeAdmins if(adminList!=null) { var adminListText = "" @@ -318,7 +326,7 @@ fun DeviceInfo() { var count = adminList.size for(each in adminList) { count -= 1 - adminListText += "$each" + adminListText += "${each.packageName}/${each.className}" if(count>0) {adminListText += "\n"} } SelectionContainer(modifier = Modifier.fillMaxWidth().padding(vertical = 2.dp).horizontalScroll(rememberScrollState())) { diff --git a/app/src/main/res/values-zh-rCN/strings.xml b/app/src/main/res/values-zh-rCN/strings.xml index 6283dea..b1e53be 100644 --- a/app/src/main/res/values-zh-rCN/strings.xml +++ b/app/src/main/res/values-zh-rCN/strings.xml @@ -60,6 +60,8 @@ Device owner 激活Device admin 设备信息 + 支持设备ID认证: + 支持唯一设备认证: Financed device: %1$s 设备策略管理器角色(DPMRH):%1$s 未使用 @@ -198,6 +200,7 @@ 网络 + Wi-Fi Mac地址 最小WiFi安全等级 开放 优先网络服务 diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index f61ef55..dceff34 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -66,6 +66,8 @@ adb shell dpm set-profile-owner com.bintianqi.owndroid/com.bintianqi.owndroid.Receiver adb shell dpm set-device-owner com.bintianqi.owndroid/com.bintianqi.owndroid.Receiver Device info + Support Device ID attestation: + Support unique device attestation: Financed device: %1$s Device policy manager role holder: %1$s @@ -209,6 +211,7 @@ Network + Wi-Fi Mac address Min WiFi security level Open Preferential network service