retrieve security and network logs

This commit is contained in:
BinTianqi
2024-02-11 20:24:03 +08:00
parent 119222fdfe
commit 1ea203d331
13 changed files with 138 additions and 105 deletions

View File

@@ -184,6 +184,8 @@ adb shell dpm remove-active-admin com.binbin.androidowner/com.binbin.androidowne
需要API34或以上 需要API34或以上
状态栏仍会显示时间和系统图标,但是通知图标会隐藏,并且状态栏不能下拉
### 自动设置时间 ### 自动设置时间
需要的权限Device owner或由组织拥有的工作资料的Profile owner 需要的权限Device owner或由组织拥有的工作资料的Profile owner
@@ -218,12 +220,6 @@ adb shell dpm remove-active-admin com.binbin.androidowner/com.binbin.androidowne
需要API23或以上 需要API23或以上
### 安全日志
需要的权限Device owner
需要API24或以上
### 通用标准模式 ### 通用标准模式
需要的权限Device owner 需要的权限Device owner
@@ -339,6 +335,12 @@ MTE: Memory Tagging Extension内存标记拓展[安卓开发者MTE](htt
或者清除所有用户证书 或者清除所有用户证书
### 安全日志
需要的权限Device owner
需要API24或以上
### 系统更新策略 ### 系统更新策略
需要的权限Device owner 需要的权限Device owner
@@ -388,14 +390,6 @@ MTE: Memory Tagging Extension内存标记拓展[安卓开发者MTE](htt
得到的是设备真实的Wi-Fi Mac地址不是连接Wi-Fi时随机生成的Mac地址 得到的是设备真实的Wi-Fi Mac地址不是连接Wi-Fi时随机生成的Mac地址
### 网络日志记录
需要的权限Device owner或Profile owner
需要API26或以上
功能开发中
### 优先网络服务 ### 优先网络服务
需要的权限Device owner 需要的权限Device owner
@@ -450,6 +444,14 @@ MTE: Memory Tagging Extension内存标记拓展[安卓开发者MTE](htt
也可以设置私人DNS主机名 也可以设置私人DNS主机名
### 网络日志记录
需要的权限Device owner或Profile owner
需要API26或以上
功能开发中
### Wi-Fi密钥对 ### Wi-Fi密钥对
需要的权限Device owner或Profile owner 需要的权限Device owner或Profile owner

View File

@@ -11,8 +11,8 @@ android {
applicationId = "com.binbin.androidowner" applicationId = "com.binbin.androidowner"
minSdk = 21 minSdk = 21
targetSdk = 34 targetSdk = 34
versionCode = 13 versionCode = 14
versionName = "3.0" versionName = "3.1"
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables { vectorDrawables {

View File

@@ -26,6 +26,7 @@
android:roundIcon="@mipmap/ic_launcher_round" android:roundIcon="@mipmap/ic_launcher_round"
android:theme="@style/Theme.AndroidOwner" android:theme="@style/Theme.AndroidOwner"
android:enableOnBackInvokedCallback="true" android:enableOnBackInvokedCallback="true"
android:testOnly="false"
tools:targetApi="34"> tools:targetApi="34">
<activity <activity
android:name=".MainActivity" android:name=".MainActivity"

View File

@@ -6,6 +6,7 @@ import android.content.ComponentName
import android.content.Context import android.content.Context
import android.content.Intent import android.content.Intent
import android.os.Build.VERSION import android.os.Build.VERSION
import android.util.Log
import android.widget.Toast import android.widget.Toast
import androidx.activity.ComponentActivity import androidx.activity.ComponentActivity
import androidx.compose.animation.AnimatedVisibility import androidx.compose.animation.AnimatedVisibility
@@ -54,7 +55,7 @@ fun DeviceControl(){
) )
} }
if(VERSION.SDK_INT>=34&&(isDeviceOwner(myDpm)|| (isProfileOwner(myDpm)&&myDpm.isAffiliatedUser))){ if(VERSION.SDK_INT>=34&&(isDeviceOwner(myDpm)|| (isProfileOwner(myDpm)&&myDpm.isAffiliatedUser))){
DeviceCtrlItem(R.string.hide_status_bar,R.string.may_hide_notifi_icon_only,R.drawable.notifications_fill0, DeviceCtrlItem(R.string.disable_status_bar,R.string.place_holder,R.drawable.notifications_fill0,
{myDpm.isStatusBarDisabled},{b -> myDpm.setStatusBarDisabled(myComponent,b) } {myDpm.isStatusBarDisabled},{b -> myDpm.setStatusBarDisabled(myComponent,b) }
) )
} }
@@ -85,11 +86,6 @@ fun DeviceControl(){
{myDpm.getBluetoothContactSharingDisabled(myComponent)},{b -> myDpm.setBluetoothContactSharingDisabled(myComponent,b)} {myDpm.getBluetoothContactSharingDisabled(myComponent)},{b -> myDpm.setBluetoothContactSharingDisabled(myComponent,b)}
) )
} }
if(VERSION.SDK_INT>=24&&isDeviceOwner(myDpm)){
DeviceCtrlItem(R.string.secure_logging,R.string.no_effect,R.drawable.description_fill0,
{myDpm.isSecurityLoggingEnabled(myComponent)},{b -> myDpm.setSecurityLoggingEnabled(myComponent,b) }
)
}
if(VERSION.SDK_INT>=30&&isDeviceOwner(myDpm)){ if(VERSION.SDK_INT>=30&&isDeviceOwner(myDpm)){
DeviceCtrlItem(R.string.common_criteria_mode,R.string.common_criteria_mode_desc,R.drawable.security_fill0, DeviceCtrlItem(R.string.common_criteria_mode,R.string.common_criteria_mode_desc,R.drawable.security_fill0,
{myDpm.isCommonCriteriaModeEnabled(myComponent)},{b -> myDpm.setCommonCriteriaModeEnabled(myComponent,b)} {myDpm.isCommonCriteriaModeEnabled(myComponent)},{b -> myDpm.setCommonCriteriaModeEnabled(myComponent,b)}
@@ -220,7 +216,6 @@ fun DeviceControl(){
) { ) {
Text("应用") Text("应用")
} }
} }
} }
@@ -256,7 +251,7 @@ fun DeviceControl(){
RadioButtonItem("由用户决定",{appPolicy == NEARBY_STREAMING_NOT_CONTROLLED_BY_POLICY},{appPolicy = NEARBY_STREAMING_NOT_CONTROLLED_BY_POLICY}) RadioButtonItem("由用户决定",{appPolicy == NEARBY_STREAMING_NOT_CONTROLLED_BY_POLICY},{appPolicy = NEARBY_STREAMING_NOT_CONTROLLED_BY_POLICY})
RadioButtonItem("启用",{appPolicy == NEARBY_STREAMING_ENABLED},{appPolicy = NEARBY_STREAMING_ENABLED}) RadioButtonItem("启用",{appPolicy == NEARBY_STREAMING_ENABLED},{appPolicy = NEARBY_STREAMING_ENABLED})
RadioButtonItem("禁用",{appPolicy == NEARBY_STREAMING_DISABLED},{appPolicy = NEARBY_STREAMING_DISABLED}) RadioButtonItem("禁用",{appPolicy == NEARBY_STREAMING_DISABLED},{appPolicy = NEARBY_STREAMING_DISABLED})
RadioButtonItem("如果足够安全(默认)",{appPolicy == NEARBY_STREAMING_SAME_MANAGED_ACCOUNT_ONLY},{appPolicy = NEARBY_STREAMING_SAME_MANAGED_ACCOUNT_ONLY}) RadioButtonItem("足够安全时启用",{appPolicy == NEARBY_STREAMING_SAME_MANAGED_ACCOUNT_ONLY},{appPolicy = NEARBY_STREAMING_SAME_MANAGED_ACCOUNT_ONLY})
Button( Button(
onClick = { onClick = {
myDpm.nearbyAppStreamingPolicy = appPolicy myDpm.nearbyAppStreamingPolicy = appPolicy
@@ -272,7 +267,7 @@ fun DeviceControl(){
RadioButtonItem("由用户决定",{notificationPolicy == NEARBY_STREAMING_NOT_CONTROLLED_BY_POLICY},{notificationPolicy = NEARBY_STREAMING_NOT_CONTROLLED_BY_POLICY}) RadioButtonItem("由用户决定",{notificationPolicy == NEARBY_STREAMING_NOT_CONTROLLED_BY_POLICY},{notificationPolicy = NEARBY_STREAMING_NOT_CONTROLLED_BY_POLICY})
RadioButtonItem("启用",{notificationPolicy == NEARBY_STREAMING_ENABLED},{notificationPolicy = NEARBY_STREAMING_ENABLED}) RadioButtonItem("启用",{notificationPolicy == NEARBY_STREAMING_ENABLED},{notificationPolicy = NEARBY_STREAMING_ENABLED})
RadioButtonItem("禁用",{notificationPolicy == NEARBY_STREAMING_DISABLED},{notificationPolicy = NEARBY_STREAMING_DISABLED}) RadioButtonItem("禁用",{notificationPolicy == NEARBY_STREAMING_DISABLED},{notificationPolicy = NEARBY_STREAMING_DISABLED})
RadioButtonItem("如果足够安全(默认)",{notificationPolicy == NEARBY_STREAMING_SAME_MANAGED_ACCOUNT_ONLY},{notificationPolicy = NEARBY_STREAMING_SAME_MANAGED_ACCOUNT_ONLY}) RadioButtonItem("足够安全时启用",{notificationPolicy == NEARBY_STREAMING_SAME_MANAGED_ACCOUNT_ONLY},{notificationPolicy = NEARBY_STREAMING_SAME_MANAGED_ACCOUNT_ONLY})
Button( Button(
onClick = { onClick = {
myDpm.nearbyNotificationStreamingPolicy = notificationPolicy myDpm.nearbyNotificationStreamingPolicy = notificationPolicy
@@ -472,6 +467,36 @@ fun DeviceControl(){
} }
} }
if(VERSION.SDK_INT>=26&&(isDeviceOwner(myDpm)||isProfileOwner(myDpm))){
Column(modifier = sections()){
Text(text = "收集安全日志", style = typography.titleLarge)
Text(text = "功能开发中", style = bodyTextStyle)
Row(modifier=Modifier.fillMaxWidth().padding(horizontal=8.dp),horizontalArrangement=Arrangement.SpaceBetween,verticalAlignment=Alignment.CenterVertically){
var checked by remember{mutableStateOf(myDpm.isSecurityLoggingEnabled(myComponent))}
Text(text = "启用", style = typography.titleLarge)
Switch(
checked = checked,
onCheckedChange = {myDpm.setSecurityLoggingEnabled(myComponent,!checked);checked=myDpm.isSecurityLoggingEnabled(myComponent)}
)
}
Button(
onClick = {
val log = myDpm.retrieveSecurityLogs(myComponent)
if(log!=null){
for(i in log){ Log.d("NetLog",i.toString()) }
Toast.makeText(myContext,"已输出至Log",Toast.LENGTH_SHORT).show()
}else{
Log.d("NetLog","")
Toast.makeText(myContext,"",Toast.LENGTH_SHORT).show()
}
},
modifier = Modifier.fillMaxWidth()
) {
Text("收集")
}
}
}
if(isDeviceOwner(myDpm)){ if(isDeviceOwner(myDpm)){
SysUpdatePolicy() SysUpdatePolicy()
} }
@@ -481,11 +506,11 @@ fun DeviceControl(){
var confirmed by remember{ mutableStateOf(false) } var confirmed by remember{ mutableStateOf(false) }
Text(text = "清除数据",style = typography.titleLarge,modifier = Modifier.padding(6.dp),color = colorScheme.onErrorContainer) Text(text = "清除数据",style = typography.titleLarge,modifier = Modifier.padding(6.dp),color = colorScheme.onErrorContainer)
RadioButtonItem("默认",{flag==0},{flag=0}, colorScheme.onErrorContainer) RadioButtonItem("默认",{flag==0},{flag=0}, colorScheme.onErrorContainer)
RadioButtonItem("WIPE_EXTERNAL_STORAGE",{flag==WIPE_EXTERNAL_STORAGE},{flag=WIPE_EXTERNAL_STORAGE}, colorScheme.onErrorContainer) RadioButtonItem("清除外部存储",{flag==WIPE_EXTERNAL_STORAGE},{flag=WIPE_EXTERNAL_STORAGE}, colorScheme.onErrorContainer)
if(VERSION.SDK_INT>=22&&isDeviceOwner(myDpm)){ if(VERSION.SDK_INT>=22&&isDeviceOwner(myDpm)){
RadioButtonItem("WIPE_RESET_PROTECTION_DATA",{flag==WIPE_RESET_PROTECTION_DATA},{flag=WIPE_RESET_PROTECTION_DATA}, colorScheme.onErrorContainer) RadioButtonItem("清除受保护的数据",{flag==WIPE_RESET_PROTECTION_DATA},{flag=WIPE_RESET_PROTECTION_DATA}, colorScheme.onErrorContainer)
} }
if(VERSION.SDK_INT>=28){ RadioButtonItem("WIPE_EUICC",{flag==WIPE_EUICC},{flag=WIPE_EUICC}, colorScheme.onErrorContainer) } if(VERSION.SDK_INT>=28){ RadioButtonItem("清除eUICC",{flag==WIPE_EUICC},{flag=WIPE_EUICC}, colorScheme.onErrorContainer) }
if(VERSION.SDK_INT>=29){ RadioButtonItem("WIPE_SILENTLY",{flag==WIPE_SILENTLY},{flag=WIPE_SILENTLY}, colorScheme.onErrorContainer) } if(VERSION.SDK_INT>=29){ RadioButtonItem("WIPE_SILENTLY",{flag==WIPE_SILENTLY},{flag=WIPE_SILENTLY}, colorScheme.onErrorContainer) }
Text(text = "清空数据的不能是系统用户",color = colorScheme.onErrorContainer, Text(text = "清空数据的不能是系统用户",color = colorScheme.onErrorContainer,
style = if(!sharedPref.getBoolean("isWear",false)){typography.bodyLarge}else{typography.bodyMedium}) style = if(!sharedPref.getBoolean("isWear",false)){typography.bodyLarge}else{typography.bodyMedium})
@@ -522,7 +547,7 @@ fun DeviceControl(){
enabled = confirmed, enabled = confirmed,
modifier = Modifier.fillMaxWidth(0.96F) modifier = Modifier.fillMaxWidth(0.96F)
) { ) {
Text("WipeDevice(API34)") Text("WipeDevice")
} }
} }
} }

View File

@@ -225,7 +225,7 @@ fun HomePage(navCtrl:NavHostController){
} }
} }
HomePageItem(R.string.device_ctrl, R.drawable.mobile_phone_fill0, "DeviceControl", navCtrl) HomePageItem(R.string.device_ctrl, R.drawable.mobile_phone_fill0, "DeviceControl", navCtrl)
if(VERSION.SDK_INT>=26){HomePageItem(R.string.network, R.drawable.wifi_fill0, "Network",navCtrl)} if(VERSION.SDK_INT>=24){HomePageItem(R.string.network, R.drawable.wifi_fill0, "Network",navCtrl)}
HomePageItem(R.string.work_profile, R.drawable.work_fill0, "ManagedProfile",navCtrl) HomePageItem(R.string.work_profile, R.drawable.work_fill0, "ManagedProfile",navCtrl)
HomePageItem(R.string.app_manage, R.drawable.apps_fill0, "ApplicationManage", navCtrl) HomePageItem(R.string.app_manage, R.drawable.apps_fill0, "ApplicationManage", navCtrl)
HomePageItem(R.string.user_restrict, R.drawable.manage_accounts_fill0, "UserRestriction", navCtrl) HomePageItem(R.string.user_restrict, R.drawable.manage_accounts_fill0, "UserRestriction", navCtrl)

View File

@@ -11,6 +11,7 @@ import android.os.Build.VERSION
import android.telephony.TelephonyManager import android.telephony.TelephonyManager
import android.telephony.TelephonyManager.UNKNOWN_CARRIER_ID import android.telephony.TelephonyManager.UNKNOWN_CARRIER_ID
import android.telephony.data.ApnSetting.* import android.telephony.data.ApnSetting.*
import android.util.Log
import android.widget.Toast import android.widget.Toast
import androidx.activity.ComponentActivity import androidx.activity.ComponentActivity
import androidx.compose.animation.AnimatedVisibility import androidx.compose.animation.AnimatedVisibility
@@ -52,11 +53,6 @@ fun Network(){
Text(text = "WiFi MAC: $wifimac",modifier=Modifier.fillMaxWidth(), textAlign = TextAlign.Center,style=bodyTextStyle) Text(text = "WiFi MAC: $wifimac",modifier=Modifier.fillMaxWidth(), textAlign = TextAlign.Center,style=bodyTextStyle)
} }
if(VERSION.SDK_INT>=26&&(isDeviceOwner(myDpm)||isProfileOwner(myDpm))){
DeviceCtrlItem(R.string.network_logging,R.string.developing,R.drawable.wifi_fill0,
{myDpm.isNetworkLoggingEnabled(myComponent)},{b -> myDpm.setNetworkLoggingEnabled(myComponent,b) }
)
}
if(VERSION.SDK_INT>=33&&isDeviceOwner(myDpm)){ if(VERSION.SDK_INT>=33&&isDeviceOwner(myDpm)){
DeviceCtrlItem(R.string.preferential_network_service,R.string.developing,R.drawable.globe_fill0, DeviceCtrlItem(R.string.preferential_network_service,R.string.developing,R.drawable.globe_fill0,
{myDpm.isPreferentialNetworkServiceEnabled},{b -> myDpm.isPreferentialNetworkServiceEnabled = b} {myDpm.isPreferentialNetworkServiceEnabled},{b -> myDpm.isPreferentialNetworkServiceEnabled = b}
@@ -220,6 +216,36 @@ fun Network(){
} }
} }
if(VERSION.SDK_INT>=26&&(isDeviceOwner(myDpm)||isProfileOwner(myDpm))){
Column(modifier = sections()){
Text(text = "收集网络日志", style = typography.titleLarge)
Text(text = "功能开发中", style = bodyTextStyle)
Row(modifier=Modifier.fillMaxWidth().padding(horizontal=8.dp),horizontalArrangement=Arrangement.SpaceBetween,verticalAlignment=Alignment.CenterVertically){
var checked by remember{mutableStateOf(myDpm.isNetworkLoggingEnabled(myComponent))}
Text(text = "启用", style = typography.titleLarge)
Switch(
checked = checked,
onCheckedChange = {myDpm.setNetworkLoggingEnabled(myComponent,!checked);checked = myDpm.isNetworkLoggingEnabled(myComponent)}
)
}
Button(
onClick = {
val log = myDpm.retrieveNetworkLogs(myComponent,1234567890)
if(log!=null){
for(i in log){ Log.d("NetLog",i.toString()) }
Toast.makeText(myContext,"已输出至Log",Toast.LENGTH_SHORT).show()
}else{
Log.d("NetLog","")
Toast.makeText(myContext,"",Toast.LENGTH_SHORT).show()
}
},
modifier = Modifier.fillMaxWidth()
) {
Text("收集")
}
}
}
if(VERSION.SDK_INT>=31&&(isDeviceOwner(myDpm)||isProfileOwner(myDpm))){ if(VERSION.SDK_INT>=31&&(isDeviceOwner(myDpm)||isProfileOwner(myDpm))){
Column(modifier = sections()){ Column(modifier = sections()){
var keyPair by remember{mutableStateOf("")} var keyPair by remember{mutableStateOf("")}
@@ -292,7 +318,6 @@ fun Network(){
} }
var result = Builder().build() var result = Builder().build()
AnimatedVisibility(nextStep) { AnimatedVisibility(nextStep) {
/*TODO*/
var carrierEnabled by remember{mutableStateOf(false)} var carrierEnabled by remember{mutableStateOf(false)}
var inputApnName by remember{mutableStateOf("")} var inputApnName by remember{mutableStateOf("")}
var user by remember{mutableStateOf("")} var user by remember{mutableStateOf("")}

View File

@@ -157,50 +157,52 @@ fun Password(){
Text(text = stringResource(R.string.reset_pwd_desc), modifier = Modifier.padding(vertical = 3.dp),style=bodyTextStyle) Text(text = stringResource(R.string.reset_pwd_desc), modifier = Modifier.padding(vertical = 3.dp),style=bodyTextStyle)
var resetPwdFlag by remember{ mutableIntStateOf(0) } var resetPwdFlag by remember{ mutableIntStateOf(0) }
if(VERSION.SDK_INT>=23){ if(VERSION.SDK_INT>=23){
RadioButtonItem("开机时不要求密码(如果有指纹等其他解锁方式)", {resetPwdFlag==RESET_PASSWORD_DO_NOT_ASK_CREDENTIALS_ON_BOOT}, {resetPwdFlag=RESET_PASSWORD_DO_NOT_ASK_CREDENTIALS_ON_BOOT}) RadioButtonItem("启动(boot)时不要求密码", {resetPwdFlag==RESET_PASSWORD_DO_NOT_ASK_CREDENTIALS_ON_BOOT}, {resetPwdFlag=RESET_PASSWORD_DO_NOT_ASK_CREDENTIALS_ON_BOOT})
} }
RadioButtonItem("要求立即输入新密码",{resetPwdFlag==RESET_PASSWORD_REQUIRE_ENTRY}, {resetPwdFlag=RESET_PASSWORD_REQUIRE_ENTRY}) RadioButtonItem("不允许其他设备管理员重置密码直至用户输入一次密码",{resetPwdFlag==RESET_PASSWORD_REQUIRE_ENTRY}, {resetPwdFlag=RESET_PASSWORD_REQUIRE_ENTRY})
RadioButtonItem("",{resetPwdFlag==0},{resetPwdFlag=0}) RadioButtonItem("",{resetPwdFlag==0},{resetPwdFlag=0})
Row(modifier = if(!isWear){Modifier.fillMaxWidth()}else{Modifier.horizontalScroll(rememberScrollState())},horizontalArrangement = Arrangement.SpaceBetween) { Button(
onClick = {
if(newPwd.length>=4||newPwd.isEmpty()){ confirmed=!confirmed
}else{ Toast.makeText(myContext, "需要4位密码", Toast.LENGTH_SHORT).show() }
},
enabled = isDeviceOwner(myDpm) || isProfileOwner(myDpm) || myDpm.isAdminActive(myComponent),
modifier = if(isWear){Modifier}else{Modifier.fillMaxWidth(0.3F)},
colors = ButtonDefaults.buttonColors(
containerColor = if(confirmed){ colorScheme.primary }else{ colorScheme.error },
contentColor = if(confirmed){ colorScheme.onPrimary }else{ colorScheme.onError }
)
) {
Text(text = if(confirmed){"取消"}else{"确定"})
}
if(VERSION.SDK_INT>=26){
Button( Button(
onClick = { onClick = {
if(newPwd.length>=4||newPwd.isEmpty()){ confirmed=!confirmed val resetSuccess = myDpm.resetPasswordWithToken(myComponent,newPwd,myByteArray,resetPwdFlag)
}else{ Toast.makeText(myContext, "需要4位密码", Toast.LENGTH_SHORT).show() }
},
enabled = isDeviceOwner(myDpm) || isProfileOwner(myDpm) || myDpm.isAdminActive(myComponent),
modifier = if(isWear){Modifier}else{Modifier.fillMaxWidth(0.3F)}
) {
Text(text = if(confirmed){"取消"}else{"确定"})
}
if(VERSION.SDK_INT>=26){
Button(
onClick = {
val resetSuccess = myDpm.resetPasswordWithToken(myComponent,newPwd,myByteArray,resetPwdFlag)
if(resetSuccess){ Toast.makeText(myContext, "设置成功", Toast.LENGTH_SHORT).show()
}else{ Toast.makeText(myContext, "设置失败", Toast.LENGTH_SHORT).show() }
confirmed=false
},
colors = ButtonDefaults.buttonColors(containerColor = colorScheme.error, contentColor = colorScheme.onError),
enabled = confirmed&&(isDeviceOwner(myDpm)||isProfileOwner(myDpm)),
modifier = if(isWear){Modifier}else{Modifier.fillMaxWidth(0.42F)}
) {
Text("应用")
}
}
Button(
onClick = {
val resetSuccess = myDpm.resetPassword(newPwd,resetPwdFlag)
if(resetSuccess){ Toast.makeText(myContext, "设置成功", Toast.LENGTH_SHORT).show() if(resetSuccess){ Toast.makeText(myContext, "设置成功", Toast.LENGTH_SHORT).show()
}else{ Toast.makeText(myContext, "设置失败", Toast.LENGTH_SHORT).show() } }else{ Toast.makeText(myContext, "设置失败", Toast.LENGTH_SHORT).show() }
confirmed=false confirmed=false
}, },
enabled = confirmed,
colors = ButtonDefaults.buttonColors(containerColor = colorScheme.error, contentColor = colorScheme.onError), colors = ButtonDefaults.buttonColors(containerColor = colorScheme.error, contentColor = colorScheme.onError),
modifier = if(isWear){Modifier}else{Modifier.fillMaxWidth(0.9F)} enabled = confirmed&&(isDeviceOwner(myDpm)||isProfileOwner(myDpm)),
modifier = if(isWear){Modifier}else{Modifier.fillMaxWidth(0.42F)}
) { ) {
Text("应用(旧)") Text("使用令牌重置密码")
} }
} }
Button(
onClick = {
val resetSuccess = myDpm.resetPassword(newPwd,resetPwdFlag)
if(resetSuccess){ Toast.makeText(myContext, "设置成功", Toast.LENGTH_SHORT).show()
}else{ Toast.makeText(myContext, "设置失败", Toast.LENGTH_SHORT).show() }
confirmed=false
},
enabled = confirmed,
colors = ButtonDefaults.buttonColors(containerColor = colorScheme.error, contentColor = colorScheme.onError),
modifier = if(isWear){Modifier}else{Modifier.fillMaxWidth(0.9F)}
) {
Text("重置密码(弃用)")
}
} }
PasswordItem(R.string.max_pwd_fail,R.string.max_pwd_fail_desc,R.string.max_pwd_fail_textfield, false, PasswordItem(R.string.max_pwd_fail,R.string.max_pwd_fail_desc,R.string.max_pwd_fail_textfield, false,
@@ -315,13 +317,13 @@ fun Password(){
CheckBoxItem("禁用未经编辑的通知",{unredacted},{unredacted=!unredacted}) CheckBoxItem("禁用未经编辑的通知",{unredacted},{unredacted=!unredacted})
CheckBoxItem("禁用可信代理",{agents},{agents=!agents}) CheckBoxItem("禁用可信代理",{agents},{agents=!agents})
CheckBoxItem("禁用指纹解锁",{fingerprint},{fingerprint=!fingerprint}) CheckBoxItem("禁用指纹解锁",{fingerprint},{fingerprint=!fingerprint})
if(VERSION.SDK_INT>=24){ CheckBoxItem("禁止在锁屏通知中输入(弃用)",{remote}, {remote=!remote}) } if(VERSION.SDK_INT>=24){ CheckBoxItem("禁止远程输入(弃用)",{remote}, {remote=!remote}) }
if(VERSION.SDK_INT>=28){ if(VERSION.SDK_INT>=28){
CheckBoxItem("禁用人脸解锁",{face},{face=!face}) CheckBoxItem("禁用人脸解锁",{face},{face=!face})
CheckBoxItem("禁用虹膜解锁(?)",{iris},{iris=!iris}) CheckBoxItem("禁用虹膜解锁(?)",{iris},{iris=!iris})
CheckBoxItem("禁用生物识别",{biometrics},{biometrics=!biometrics}) CheckBoxItem("禁用生物识别",{biometrics},{biometrics=!biometrics})
} }
if(VERSION.SDK_INT>=34){ CheckBoxItem("禁用锁屏快捷方式",{shortcuts},{shortcuts=!shortcuts}) } if(VERSION.SDK_INT>=34){ CheckBoxItem("禁用快捷方式",{shortcuts},{shortcuts=!shortcuts}) }
} }
} }
Button( Button(
@@ -346,7 +348,7 @@ fun Password(){
Toast.makeText(myContext, "成功", Toast.LENGTH_SHORT).show() Toast.makeText(myContext, "成功", Toast.LENGTH_SHORT).show()
calculateCustomFeature() calculateCustomFeature()
}, },
enabled = isDeviceOwner(myDpm), enabled = isDeviceOwner(myDpm)||isProfileOwner(myDpm),
modifier = Modifier.fillMaxWidth() modifier = Modifier.fillMaxWidth()
) { ) {
Text(text = "应用") Text(text = "应用")

View File

@@ -218,9 +218,9 @@ fun DpmPermissions(navCtrl:NavHostController){
} }
if(VERSION.SDK_INT>=31&&(isProfileOwner(myDpm)|| isDeviceOwner(myDpm))){ if(VERSION.SDK_INT>=31&&(isProfileOwner(myDpm)|| isDeviceOwner(myDpm))){
Column(modifier = sections()) { Column(modifier = sections()) {
val specificId:String = myDpm.enrollmentSpecificId val specificId = myDpm.enrollmentSpecificId
Text(text = "设备唯一标识码", style = typography.titleLarge,color = titleColor) Text(text = "设备唯一标识码", style = typography.titleLarge,color = titleColor)
Text("(恢复出厂设置不变)",style=bodyTextStyle) Text(text = "(恢复出厂设置不变)",style=bodyTextStyle)
if(specificId!=""){ if(specificId!=""){
SelectionContainer{ Text(specificId, style = bodyTextStyle) } SelectionContainer{ Text(specificId, style = bodyTextStyle) }
}else{ }else{

View File

@@ -42,11 +42,11 @@ fun SysUpdatePolicy(){
Text(text = "Update first available: ${Date(sysUpdateInfo.receivedTime)}", style = bodyTextStyle) Text(text = "Update first available: ${Date(sysUpdateInfo.receivedTime)}", style = bodyTextStyle)
Text(text = "Hash code: ${sysUpdateInfo.hashCode()}", style = bodyTextStyle) Text(text = "Hash code: ${sysUpdateInfo.hashCode()}", style = bodyTextStyle)
val securityStateDesc = when(sysUpdateInfo.securityPatchState){ val securityStateDesc = when(sysUpdateInfo.securityPatchState){
SystemUpdateInfo.SECURITY_PATCH_STATE_UNKNOWN->"SECURITY_PATCH_STATE_UNKNOWN" SystemUpdateInfo.SECURITY_PATCH_STATE_UNKNOWN->"未知"
SystemUpdateInfo.SECURITY_PATCH_STATE_TRUE->"SECURITY_PATCH_STATE_TRUE" SystemUpdateInfo.SECURITY_PATCH_STATE_TRUE->""
else->"SECURITY_PATCH_STATE_FALSE" else->""
} }
Text(text = "Security patch state: $securityStateDesc", style = bodyTextStyle) Text(text = "安全补丁: $securityStateDesc", style = bodyTextStyle)
}else{ }else{
Text(text = "暂无系统更新", style = bodyTextStyle) Text(text = "暂无系统更新", style = bodyTextStyle)
} }

View File

@@ -54,7 +54,8 @@ fun UserManage(navCtrl:NavHostController){
Text("支持多用户:${UserManager.supportsMultipleUsers()}",style = bodyTextStyle) Text("支持多用户:${UserManager.supportsMultipleUsers()}",style = bodyTextStyle)
if(isWear&&UserManager.supportsMultipleUsers()){Text(text = "实际上手表可能不支持", style = typography.bodyMedium, color = colorScheme.error)} if(isWear&&UserManager.supportsMultipleUsers()){Text(text = "实际上手表可能不支持", style = typography.bodyMedium, color = colorScheme.error)}
} }
if(VERSION.SDK_INT>=31){ Text("系统用户: ${UserManager.isHeadlessSystemUserMode()}",style = bodyTextStyle) } if(VERSION.SDK_INT>=23){Text(text = "系统用户${userManager.isSystemUser}")}
if(VERSION.SDK_INT>=31){ Text(text = "无头系统用户: ${UserManager.isHeadlessSystemUserMode()}",style = bodyTextStyle) }
Spacer(Modifier.padding(vertical = if(isWear){2.dp}else{5.dp})) Spacer(Modifier.padding(vertical = if(isWear){2.dp}else{5.dp}))
if (VERSION.SDK_INT >= 28) { if (VERSION.SDK_INT >= 28) {
val logoutable = myDpm.isLogoutEnabled val logoutable = myDpm.isLogoutEnabled
@@ -63,10 +64,9 @@ fun UserManage(navCtrl:NavHostController){
val ephemeralUser = myDpm.isEphemeralUser(myComponent) val ephemeralUser = myDpm.isEphemeralUser(myComponent)
Text(text = "临时用户: $ephemeralUser",style = bodyTextStyle) Text(text = "临时用户: $ephemeralUser",style = bodyTextStyle)
} }
Text(text = "次级用户: ${myDpm.isAffiliatedUser}",style = bodyTextStyle) Text(text = "附属用户: ${myDpm.isAffiliatedUser}",style = bodyTextStyle)
} }
Spacer(Modifier.padding(vertical = if(isWear){2.dp}else{5.dp})) Spacer(Modifier.padding(vertical = if(isWear){2.dp}else{5.dp}))
Text(text = "当前UID${android.os.Process.myUid()}",style = bodyTextStyle)
Text(text = "当前UserID${getCurrentUserId()}",style = bodyTextStyle) Text(text = "当前UserID${getCurrentUserId()}",style = bodyTextStyle)
Text(text = "当前用户序列号:${userManager.getSerialNumberForUser(android.os.Process.myUserHandle())}",style = bodyTextStyle) Text(text = "当前用户序列号:${userManager.getSerialNumberForUser(android.os.Process.myUserHandle())}",style = bodyTextStyle)
} }

View File

@@ -216,7 +216,6 @@ private class RestrictionData{
list += Restriction(UserManager.DISALLOW_CELLULAR_2G,R.string.cellular_2g,"",R.drawable.network_cell_fill0) list += Restriction(UserManager.DISALLOW_CELLULAR_2G,R.string.cellular_2g,"",R.drawable.network_cell_fill0)
list += Restriction(UserManager.DISALLOW_ULTRA_WIDEBAND_RADIO,R.string.ultra_wideband_radio,"",R.drawable.android_fill0) list += Restriction(UserManager.DISALLOW_ULTRA_WIDEBAND_RADIO,R.string.ultra_wideband_radio,"",R.drawable.android_fill0)
} }
list += Restriction(UserManager.DISALLOW_CONFIG_WIFI,R.string.config_wifi,"",R.drawable.wifi_fill0)
if(VERSION.SDK_INT>=33){ if(VERSION.SDK_INT>=33){
list += Restriction(UserManager.DISALLOW_ADD_WIFI_CONFIG,R.string.add_wifi_conf,"",R.drawable.wifi_fill0) list += Restriction(UserManager.DISALLOW_ADD_WIFI_CONFIG,R.string.add_wifi_conf,"",R.drawable.wifi_fill0)
list += Restriction(UserManager.DISALLOW_CHANGE_WIFI_STATE,R.string.change_wifi_state,"",R.drawable.wifi_fill0) list += Restriction(UserManager.DISALLOW_CHANGE_WIFI_STATE,R.string.change_wifi_state,"",R.drawable.wifi_fill0)
@@ -280,10 +279,6 @@ private class RestrictionData{
if(VERSION.SDK_INT>=28){list += Restriction(UserManager.DISALLOW_USER_SWITCH,R.string.switch_user,"",R.drawable.account_circle_fill0)} if(VERSION.SDK_INT>=28){list += Restriction(UserManager.DISALLOW_USER_SWITCH,R.string.switch_user,"",R.drawable.account_circle_fill0)}
if(VERSION.SDK_INT>=24){list += Restriction(UserManager.DISALLOW_SET_USER_ICON,R.string.set_user_icon,"",R.drawable.account_circle_fill0)} if(VERSION.SDK_INT>=24){list += Restriction(UserManager.DISALLOW_SET_USER_ICON,R.string.set_user_icon,"",R.drawable.account_circle_fill0)}
list += Restriction(UserManager.DISALLOW_CROSS_PROFILE_COPY_PASTE,R.string.cross_profile_copy, "在不同用户和工作资料之间复制粘贴",R.drawable.content_paste_fill0) list += Restriction(UserManager.DISALLOW_CROSS_PROFILE_COPY_PASTE,R.string.cross_profile_copy, "在不同用户和工作资料之间复制粘贴",R.drawable.content_paste_fill0)
if(VERSION.SDK_INT>=26){
list += Restriction(UserManager.DISALLOW_ADD_MANAGED_PROFILE,R.string.add_managed_profile,"",R.drawable.work_fill0)
list += Restriction(UserManager.DISALLOW_REMOVE_MANAGED_PROFILE,R.string.remove_managed_profile,"",R.drawable.work_fill0)
}
if(VERSION.SDK_INT>=28){ if(VERSION.SDK_INT>=28){
list += Restriction(UserManager.DISALLOW_SHARE_INTO_MANAGED_PROFILE,R.string.share_into_managed_profile,"",R.drawable.share_fill0) list += Restriction(UserManager.DISALLOW_SHARE_INTO_MANAGED_PROFILE,R.string.share_into_managed_profile,"",R.drawable.share_fill0)
list += Restriction(UserManager.DISALLOW_UNIFIED_PASSWORD,R.string.unifiied_pwd,"",R.drawable.work_fill0) list += Restriction(UserManager.DISALLOW_UNIFIED_PASSWORD,R.string.unifiied_pwd,"",R.drawable.work_fill0)

View File

@@ -1,9 +0,0 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="960"
android:viewportHeight="960">
<path
android:fillColor="#FF000000"
android:pathData="M320,720h320v-80L320,640v80ZM320,560h320v-80L320,480v80ZM240,880q-33,0 -56.5,-23.5T160,800v-640q0,-33 23.5,-56.5T240,80h320l240,240v480q0,33 -23.5,56.5T720,880L240,880ZM520,360v-200L240,160v640h480v-440L520,360ZM240,160v200,-200 640,-640Z"/>
</vector>

View File

@@ -1,12 +1,11 @@
<resources> <resources>
<string name="app_name">Android Owner</string> <string name="app_name">Android Owner</string>
<string name="device_ctrl">设备控制</string> <string name="device_ctrl">系统</string>
<string name="disable_cam">禁用相机</string> <string name="disable_cam">禁用相机</string>
<string name="disable_scrcap">禁止截屏</string> <string name="disable_scrcap">禁止截屏</string>
<string name="aosp_scrrec_also_work">对AOSP的录屏也起作用</string> <string name="aosp_scrrec_also_work">对AOSP的录屏也起作用</string>
<string name="hide_status_bar">隐藏状态栏</string> <string name="disable_status_bar">禁用状态栏</string>
<string name="may_hide_notifi_icon_only">也许只能隐藏状态栏上的通知图标</string>
<string name="auto_time">自动设置时间</string> <string name="auto_time">自动设置时间</string>
<string name="auto_timezone">自动设置时区</string> <string name="auto_timezone">自动设置时区</string>
<string name="master_mute">全局静音</string> <string name="master_mute">全局静音</string>
@@ -16,8 +15,6 @@
<string name="suspend">挂起</string> <string name="suspend">挂起</string>
<string name="hide">隐藏</string> <string name="hide">隐藏</string>
<string name="isapphidden_desc">如果隐藏,有可能是没安装</string> <string name="isapphidden_desc">如果隐藏,有可能是没安装</string>
<string name="user_ctrl_disabled">禁止用户控制</string>
<string name="user_ctrl_disabled_desc">阻止清除应用数据和缓存</string>
<string name="permission">权限</string> <string name="permission">权限</string>
<string name="place_holder" /> <string name="place_holder" />
@@ -43,7 +40,7 @@
<string name="add_wifi_conf">添加WiFi配置</string> <string name="add_wifi_conf">添加WiFi配置</string>
<string name="change_wifi_state">修改WiFi状态</string> <string name="change_wifi_state">修改WiFi状态</string>
<string name="config_cell_broadcasts">配置小区广播</string> <string name="config_cell_broadcasts">配置小区广播</string>
<string name="config_credentials">配置可信凭据</string> <string name="config_credentials">配置凭据</string>
<string name="config_locale">修改语言</string> <string name="config_locale">修改语言</string>
<string name="cellular_2g">使用2G(GSM)</string> <string name="cellular_2g">使用2G(GSM)</string>
<string name="config_date_time">修改日期、时间</string> <string name="config_date_time">修改日期、时间</string>
@@ -83,8 +80,6 @@
<string name="switch_user">切换用户</string> <string name="switch_user">切换用户</string>
<string name="wifi_direct">WiFi直连</string> <string name="wifi_direct">WiFi直连</string>
<string name="wifi_tethering">WiFi共享</string> <string name="wifi_tethering">WiFi共享</string>
<string name="add_managed_profile">添加工作资料</string>
<string name="remove_managed_profile">移除工作资料</string>
<string name="password">密码与锁屏</string> <string name="password">密码与锁屏</string>
<string name="reset_pwd_desc">留空可以清除密码纯数字将使用PIN码</string> <string name="reset_pwd_desc">留空可以清除密码纯数字将使用PIN码</string>
@@ -110,12 +105,9 @@
<string name="setting">设置</string> <string name="setting">设置</string>
<string name="always_on_vpn">VPN常开</string> <string name="always_on_vpn">VPN常开</string>
<string name="experimental_feature">实验性功能</string> <string name="experimental_feature">实验性功能</string>
<string name="network_logging">网络日志记录</string>
<string name="no_effect">没啥用</string>
<string name="max_time_to_lock">屏幕超时</string> <string name="max_time_to_lock">屏幕超时</string>
<string name="max_time_to_lock_desc">超时后锁屏(毫秒)0为由用户决定</string> <string name="max_time_to_lock_desc">超时后锁屏(毫秒)0为由用户决定</string>
<string name="max_time_to_lock_textfield">超时时间(ms)</string> <string name="max_time_to_lock_textfield">超时时间(ms)</string>
<string name="secure_logging">安全日志</string>
<string name="common_criteria_mode">通用标准模式</string> <string name="common_criteria_mode">通用标准模式</string>
<string name="common_criteria_mode_desc">Common Criteria</string> <string name="common_criteria_mode_desc">Common Criteria</string>
<string name="preferential_network_service">优先网络服务</string> <string name="preferential_network_service">优先网络服务</string>