extract string resource in System

This commit is contained in:
BinTianqi
2024-03-02 12:19:28 +08:00
parent 0beccaa5cb
commit 91c3ef1b0e
2 changed files with 180 additions and 108 deletions

View File

@@ -102,43 +102,45 @@ fun SystemManage(){
{myDpm.isUsbDataSignalingEnabled},{b -> myDpm.isUsbDataSignalingEnabled = b } {myDpm.isUsbDataSignalingEnabled},{b -> myDpm.isUsbDataSignalingEnabled = b }
) )
}else{ }else{
Text(text = "你的设备不支持关闭USB信号",modifier = Modifier.fillMaxWidth(), style = bodyTextStyle, textAlign = TextAlign.Center) Text(text = stringResource(R.string.turn_off_usb_not_support),modifier = Modifier.fillMaxWidth(), style = bodyTextStyle, textAlign = TextAlign.Center)
} }
} }
if(VERSION.SDK_INT>=28){
Column(modifier = sections()) { Column(modifier = sections()) {
Text(text = "锁屏方式", style = typography.titleLarge,color = colorScheme.onPrimaryContainer) Text(text = stringResource(R.string.keyguard), style = typography.titleLarge,color = colorScheme.onPrimaryContainer)
Text(text = "禁用需要无密码",style=bodyTextStyle) if(VERSION.SDK_INT>=23){
Text(text = stringResource(R.string.require_no_password_to_disable),style=bodyTextStyle)
Row(modifier = Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.SpaceBetween) { Row(modifier = Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.SpaceBetween) {
Button( Button(
onClick = { Toast.makeText(myContext, if(myDpm.setKeyguardDisabled(myComponent,true)){"成功"}else{"失败"}, Toast.LENGTH_SHORT).show() }, onClick = {
enabled = isDeviceOwner(myDpm)|| (isProfileOwner(myDpm)&&myDpm.isAffiliatedUser), Toast.makeText(myContext,
myContext.getString(if(myDpm.setKeyguardDisabled(myComponent,true)){R.string.success}else{R.string.fail}), Toast.LENGTH_SHORT).show()
},
enabled = isDeviceOwner(myDpm)|| (VERSION.SDK_INT>=28&&isProfileOwner(myDpm)&&myDpm.isAffiliatedUser),
modifier = Modifier.fillMaxWidth(0.49F) modifier = Modifier.fillMaxWidth(0.49F)
) { ) {
Text("禁用") Text(stringResource(R.string.disable))
} }
Button( Button(
onClick = { Toast.makeText(myContext, if(myDpm.setKeyguardDisabled(myComponent,false)){"成功"}else{"失败"}, Toast.LENGTH_SHORT).show() }, onClick = {
enabled = isDeviceOwner(myDpm)|| (isProfileOwner(myDpm)&&myDpm.isAffiliatedUser), Toast.makeText(myContext,
myContext.getString(if(myDpm.setKeyguardDisabled(myComponent,false)){R.string.success}else{R.string.fail}), Toast.LENGTH_SHORT).show()
},
enabled = isDeviceOwner(myDpm)|| (VERSION.SDK_INT>=28&&isProfileOwner(myDpm)&&myDpm.isAffiliatedUser),
modifier = Modifier.fillMaxWidth(0.96F) modifier = Modifier.fillMaxWidth(0.96F)
) { ) {
Text("启用") Text(stringResource(R.string.enable))
} }
} }
} }
}
Column(modifier = sections()){
Text(text = "锁屏", style = typography.titleLarge, color = titleColor)
var flag by remember{mutableIntStateOf(0)} var flag by remember{mutableIntStateOf(0)}
if(VERSION.SDK_INT>=26){ CheckBoxItem("需要重新输入密码",{flag==FLAG_EVICT_CREDENTIAL_ENCRYPTION_KEY},{flag = if(flag==0){1}else{0} }) }
Button( Button(
onClick = {myDpm.lockNow()}, onClick = {myDpm.lockNow()},
enabled = myDpm.isAdminActive(myComponent), enabled = myDpm.isAdminActive(myComponent),
modifier = Modifier.fillMaxWidth() modifier = Modifier.fillMaxWidth()
) { ) {
Text("立即锁屏") Text(stringResource(R.string.lock_now))
} }
if(VERSION.SDK_INT>=26){ CheckBoxItem(stringResource(R.string.require_enter_password_again),{flag==FLAG_EVICT_CREDENTIAL_ENCRYPTION_KEY},{flag = if(flag==0){1}else{0} }) }
} }
if(VERSION.SDK_INT>=24){ if(VERSION.SDK_INT>=24){
@@ -151,26 +153,26 @@ fun SystemManage(){
modifier = Modifier.fillMaxWidth(), modifier = Modifier.fillMaxWidth(),
enabled = isDeviceOwner(myDpm) enabled = isDeviceOwner(myDpm)
) { ) {
Text("请求错误报告") Text(stringResource(R.string.request_bug_report))
} }
Button( Button(
onClick = {myDpm.reboot(myComponent)}, onClick = {myDpm.reboot(myComponent)},
enabled = isDeviceOwner(myDpm), enabled = isDeviceOwner(myDpm),
modifier = Modifier.fillMaxWidth() modifier = Modifier.fillMaxWidth()
) { ) {
Text("重启") Text(stringResource(R.string.reboot))
} }
} }
} }
if(VERSION.SDK_INT>=28){ if(VERSION.SDK_INT>=28){
Column(modifier = sections()){ Column(modifier = sections()){
Text(text = "修改时间", style = typography.titleLarge, color = titleColor) Text(text = stringResource(R.string.edit_time), style = typography.titleLarge, color = titleColor)
var inputTime by remember{mutableStateOf("")} var inputTime by remember{mutableStateOf("")}
Text(text = "从Epoch(1970/1/1 00:00:00 UTC)到你想设置的时间(毫秒)", style = bodyTextStyle) Text(text = stringResource(R.string.from_epoch_to_target_time), style = bodyTextStyle)
OutlinedTextField( OutlinedTextField(
value = inputTime, value = inputTime,
label = { Text("时间(ms)")}, label = { Text(stringResource(R.string.time_unit_ms))},
onValueChange = {inputTime = it}, onValueChange = {inputTime = it},
keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Number, imeAction = ImeAction.Done), keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Number, imeAction = ImeAction.Done),
keyboardActions = KeyboardActions(onDone = {focusMgr.clearFocus()}), keyboardActions = KeyboardActions(onDone = {focusMgr.clearFocus()}),
@@ -182,7 +184,7 @@ fun SystemManage(){
onClick = {inputTime = System.currentTimeMillis().toString()}, onClick = {inputTime = System.currentTimeMillis().toString()},
modifier = Modifier.fillMaxWidth() modifier = Modifier.fillMaxWidth()
) { ) {
Text("获取当前时间") Text(stringResource(R.string.get_current_time))
} }
} }
Row(modifier = Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.SpaceBetween){ Row(modifier = Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.SpaceBetween){
@@ -198,7 +200,7 @@ fun SystemManage(){
onClick = {inputTime = System.currentTimeMillis().toString()}, onClick = {inputTime = System.currentTimeMillis().toString()},
modifier = Modifier.fillMaxWidth(0.98F) modifier = Modifier.fillMaxWidth(0.98F)
) { ) {
Text("获取当前时间") Text(stringResource(R.string.get_current_time))
} }
} }
} }
@@ -208,43 +210,43 @@ fun SystemManage(){
if(VERSION.SDK_INT>=23&&(isDeviceOwner(myDpm)||isProfileOwner(myDpm))){ if(VERSION.SDK_INT>=23&&(isDeviceOwner(myDpm)||isProfileOwner(myDpm))){
Column(modifier = sections()){ Column(modifier = sections()){
var selectedPolicy by remember{mutableIntStateOf(myDpm.getPermissionPolicy(myComponent))} var selectedPolicy by remember{mutableIntStateOf(myDpm.getPermissionPolicy(myComponent))}
Text(text = "权限策略", style = typography.titleLarge, color = titleColor) Text(text = stringResource(R.string.permission_policy), style = typography.titleLarge, color = titleColor)
RadioButtonItem("默认", {selectedPolicy==PERMISSION_POLICY_PROMPT}, {selectedPolicy= PERMISSION_POLICY_PROMPT}) RadioButtonItem(stringResource(R.string.default_stringres), {selectedPolicy==PERMISSION_POLICY_PROMPT}, {selectedPolicy= PERMISSION_POLICY_PROMPT})
RadioButtonItem("自动允许", {selectedPolicy==PERMISSION_POLICY_AUTO_GRANT}, {selectedPolicy= PERMISSION_POLICY_AUTO_GRANT}) RadioButtonItem(stringResource(R.string.auto_grant), {selectedPolicy==PERMISSION_POLICY_AUTO_GRANT}, {selectedPolicy= PERMISSION_POLICY_AUTO_GRANT})
RadioButtonItem("自动拒绝", {selectedPolicy==PERMISSION_POLICY_AUTO_DENY}, {selectedPolicy= PERMISSION_POLICY_AUTO_DENY}) RadioButtonItem(stringResource(R.string.auto_deny), {selectedPolicy==PERMISSION_POLICY_AUTO_DENY}, {selectedPolicy= PERMISSION_POLICY_AUTO_DENY})
Button( Button(
onClick = { onClick = {
myDpm.setPermissionPolicy(myComponent,selectedPolicy) myDpm.setPermissionPolicy(myComponent,selectedPolicy)
Toast.makeText(myContext, "成功", Toast.LENGTH_SHORT).show() Toast.makeText(myContext, myContext.getString(R.string.success), Toast.LENGTH_SHORT).show()
}, },
modifier = Modifier.fillMaxWidth() modifier = Modifier.fillMaxWidth()
) { ) {
Text("应用") Text(stringResource(R.string.apply))
} }
} }
} }
if(VERSION.SDK_INT>=34&&isDeviceOwner(myDpm)){ if(VERSION.SDK_INT>=34&&isDeviceOwner(myDpm)){
Column(modifier = sections()){ Column(modifier = sections()){
Text(text = "MTE策略", style = typography.titleLarge, color = titleColor) Text(text = stringResource(R.string.mte_policy), style = typography.titleLarge, color = titleColor)
Text("MTE内存标记拓展安卓14和ARMv9的高端功能") Text(stringResource(R.string.mte_policy_desc))
var selectedMtePolicy by remember{mutableIntStateOf(myDpm.mtePolicy)} var selectedMtePolicy by remember{mutableIntStateOf(myDpm.mtePolicy)}
RadioButtonItem("由用户决定", {selectedMtePolicy==MTE_NOT_CONTROLLED_BY_POLICY}, {selectedMtePolicy= MTE_NOT_CONTROLLED_BY_POLICY}) RadioButtonItem(stringResource(R.string.decide_by_user), {selectedMtePolicy==MTE_NOT_CONTROLLED_BY_POLICY}, {selectedMtePolicy= MTE_NOT_CONTROLLED_BY_POLICY})
RadioButtonItem("开启", {selectedMtePolicy==MTE_ENABLED}, {selectedMtePolicy=MTE_ENABLED}) RadioButtonItem(stringResource(R.string.enabled), {selectedMtePolicy==MTE_ENABLED}, {selectedMtePolicy=MTE_ENABLED})
RadioButtonItem("关闭", {selectedMtePolicy==MTE_DISABLED}, {selectedMtePolicy=MTE_DISABLED}) RadioButtonItem(stringResource(R.string.disabled), {selectedMtePolicy==MTE_DISABLED}, {selectedMtePolicy=MTE_DISABLED})
Button( Button(
onClick = { onClick = {
try { try {
myDpm.mtePolicy = selectedMtePolicy myDpm.mtePolicy = selectedMtePolicy
Toast.makeText(myContext, "成功", Toast.LENGTH_SHORT).show() Toast.makeText(myContext, myContext.getString(R.string.success), Toast.LENGTH_SHORT).show()
}catch(e:java.lang.UnsupportedOperationException){ }catch(e:java.lang.UnsupportedOperationException){
Toast.makeText(myContext, "不支持", Toast.LENGTH_SHORT).show() Toast.makeText(myContext, myContext.getString(R.string.unsupported), Toast.LENGTH_SHORT).show()
} }
selectedMtePolicy = myDpm.mtePolicy selectedMtePolicy = myDpm.mtePolicy
}, },
modifier = Modifier.fillMaxWidth() modifier = Modifier.fillMaxWidth()
) { ) {
Text("应用") Text(stringResource(R.string.apply))
} }
} }
} }
@@ -252,11 +254,11 @@ fun SystemManage(){
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 appPolicy by remember{mutableIntStateOf(myDpm.nearbyAppStreamingPolicy)} var appPolicy by remember{mutableIntStateOf(myDpm.nearbyAppStreamingPolicy)}
Text(text = "附近App共享", style = typography.titleLarge, color = titleColor) Text(text = stringResource(R.string.nearby_app_streaming), style = typography.titleLarge, color = titleColor)
RadioButtonItem("由用户决定",{appPolicy == NEARBY_STREAMING_NOT_CONTROLLED_BY_POLICY},{appPolicy = NEARBY_STREAMING_NOT_CONTROLLED_BY_POLICY}) RadioButtonItem(stringResource(R.string.decide_by_user),{appPolicy == NEARBY_STREAMING_NOT_CONTROLLED_BY_POLICY},{appPolicy = NEARBY_STREAMING_NOT_CONTROLLED_BY_POLICY})
RadioButtonItem("启用",{appPolicy == NEARBY_STREAMING_ENABLED},{appPolicy = NEARBY_STREAMING_ENABLED}) RadioButtonItem(stringResource(R.string.enabled),{appPolicy == NEARBY_STREAMING_ENABLED},{appPolicy = NEARBY_STREAMING_ENABLED})
RadioButtonItem("禁用",{appPolicy == NEARBY_STREAMING_DISABLED},{appPolicy = NEARBY_STREAMING_DISABLED}) RadioButtonItem(stringResource(R.string.disabled),{appPolicy == NEARBY_STREAMING_DISABLED},{appPolicy = NEARBY_STREAMING_DISABLED})
RadioButtonItem("在足够安全时启用",{appPolicy == NEARBY_STREAMING_SAME_MANAGED_ACCOUNT_ONLY},{appPolicy = NEARBY_STREAMING_SAME_MANAGED_ACCOUNT_ONLY}) RadioButtonItem(stringResource(R.string.enable_if_secure_enough),{appPolicy == NEARBY_STREAMING_SAME_MANAGED_ACCOUNT_ONLY},{appPolicy = NEARBY_STREAMING_SAME_MANAGED_ACCOUNT_ONLY})
Button( Button(
onClick = { onClick = {
myDpm.nearbyAppStreamingPolicy = appPolicy myDpm.nearbyAppStreamingPolicy = appPolicy
@@ -268,19 +270,19 @@ fun SystemManage(){
} }
Spacer(Modifier.padding(vertical = 3.dp)) Spacer(Modifier.padding(vertical = 3.dp))
var notificationPolicy by remember{mutableIntStateOf(myDpm.nearbyNotificationStreamingPolicy)} var notificationPolicy by remember{mutableIntStateOf(myDpm.nearbyNotificationStreamingPolicy)}
Text(text = "附近通知共享", style = typography.titleLarge, color = titleColor) Text(text = stringResource(R.string.nearby_notifi_streaming), style = typography.titleLarge, color = titleColor)
RadioButtonItem("由用户决定",{notificationPolicy == NEARBY_STREAMING_NOT_CONTROLLED_BY_POLICY},{notificationPolicy = NEARBY_STREAMING_NOT_CONTROLLED_BY_POLICY}) RadioButtonItem(stringResource(R.string.decide_by_user),{notificationPolicy == NEARBY_STREAMING_NOT_CONTROLLED_BY_POLICY},{notificationPolicy = NEARBY_STREAMING_NOT_CONTROLLED_BY_POLICY})
RadioButtonItem("启用",{notificationPolicy == NEARBY_STREAMING_ENABLED},{notificationPolicy = NEARBY_STREAMING_ENABLED}) RadioButtonItem(stringResource(R.string.enabled),{notificationPolicy == NEARBY_STREAMING_ENABLED},{notificationPolicy = NEARBY_STREAMING_ENABLED})
RadioButtonItem("禁用",{notificationPolicy == NEARBY_STREAMING_DISABLED},{notificationPolicy = NEARBY_STREAMING_DISABLED}) RadioButtonItem(stringResource(R.string.disabled),{notificationPolicy == NEARBY_STREAMING_DISABLED},{notificationPolicy = NEARBY_STREAMING_DISABLED})
RadioButtonItem("在足够安全时启用",{notificationPolicy == NEARBY_STREAMING_SAME_MANAGED_ACCOUNT_ONLY},{notificationPolicy = NEARBY_STREAMING_SAME_MANAGED_ACCOUNT_ONLY}) RadioButtonItem(stringResource(R.string.enable_if_secure_enough),{notificationPolicy == NEARBY_STREAMING_SAME_MANAGED_ACCOUNT_ONLY},{notificationPolicy = NEARBY_STREAMING_SAME_MANAGED_ACCOUNT_ONLY})
Button( Button(
onClick = { onClick = {
myDpm.nearbyNotificationStreamingPolicy = notificationPolicy myDpm.nearbyNotificationStreamingPolicy = notificationPolicy
Toast.makeText(myContext, "成功", Toast.LENGTH_SHORT).show() Toast.makeText(myContext, myContext.getString(R.string.success), Toast.LENGTH_SHORT).show()
}, },
modifier = Modifier.fillMaxWidth() modifier = Modifier.fillMaxWidth()
) { ) {
Text("应用") Text(stringResource(R.string.apply))
} }
} }
} }
@@ -320,20 +322,19 @@ fun SystemManage(){
custom = false custom = false
} }
} }
Text(text = "锁定任务模式", style = typography.titleLarge, color = titleColor) Text(text = stringResource(R.string.lock_task_feature), style = typography.titleLarge, color = titleColor)
if(!inited){ refreshFeature();custom=myDpm.getLockTaskFeatures(myComponent)!=0;inited=true } if(!inited){ refreshFeature();custom=myDpm.getLockTaskFeatures(myComponent)!=0;inited=true }
Text(text = "在锁定任务模式下:", style = bodyTextStyle) RadioButtonItem(stringResource(R.string.disable_all),{!custom},{custom=false})
RadioButtonItem("禁用全部",{!custom},{custom=false}) RadioButtonItem(stringResource(R.string.custom),{custom},{custom=true})
RadioButtonItem("自定义",{custom},{custom=true})
AnimatedVisibility(custom) { AnimatedVisibility(custom) {
Column { Column {
CheckBoxItem("允许状态栏信息",{sysInfo},{sysInfo=!sysInfo}) CheckBoxItem(stringResource(R.string.ltf_sys_info),{sysInfo},{sysInfo=!sysInfo})
CheckBoxItem("允许通知",{notifications},{notifications=!notifications}) CheckBoxItem(stringResource(R.string.ltf_notifications),{notifications},{notifications=!notifications})
CheckBoxItem("允许返回主屏幕",{home},{home=!home}) CheckBoxItem(stringResource(R.string.ltf_home),{home},{home=!home})
CheckBoxItem("允许打开后台应用概览",{overview},{overview=!overview}) CheckBoxItem(stringResource(R.string.ltf_overview),{overview},{overview=!overview})
CheckBoxItem("允许全局行为(比如长按电源键对话框)",{globalAction},{globalAction=!globalAction}) CheckBoxItem(stringResource(R.string.ltf_global_actions),{globalAction},{globalAction=!globalAction})
CheckBoxItem("允许锁屏(如果没有选择此项,即使有密码也不会锁屏)",{keyGuard},{keyGuard=!keyGuard}) CheckBoxItem(stringResource(R.string.ltf_keyguard),{keyGuard},{keyGuard=!keyGuard})
if(VERSION.SDK_INT>=30){ CheckBoxItem("阻止启动未允许的应用",{blockAct},{blockAct=!blockAct}) } if(VERSION.SDK_INT>=30){ CheckBoxItem(stringResource(R.string.ltf_block_activity_start_in_task),{blockAct},{blockAct=!blockAct}) }
} }
} }
Button( Button(
@@ -351,10 +352,10 @@ fun SystemManage(){
} }
myDpm.setLockTaskFeatures(myComponent,result) myDpm.setLockTaskFeatures(myComponent,result)
refreshFeature() refreshFeature()
Toast.makeText(myContext, "成功", Toast.LENGTH_SHORT).show() Toast.makeText(myContext, myContext.getString(R.string.success), Toast.LENGTH_SHORT).show()
} }
) { ) {
Text("应用") Text(stringResource(R.string.apply))
} }
Spacer(Modifier.padding(vertical = 4.dp)) Spacer(Modifier.padding(vertical = 4.dp))
val whitelist = myDpm.getLockTaskPackages(myComponent).toMutableList() val whitelist = myDpm.getLockTaskPackages(myComponent).toMutableList()
@@ -371,18 +372,18 @@ fun SystemManage(){
} }
} }
refreshWhitelist() refreshWhitelist()
Text(text = "白名单应用", style = typography.titleLarge, color = titleColor) Text(text = stringResource(R.string.whitelist_app), style = typography.titleLarge, color = titleColor)
if(listText!=""){ if(listText!=""){
SelectionContainer { SelectionContainer {
Text(text = listText, style = bodyTextStyle) Text(text = listText, style = bodyTextStyle)
} }
}else{ }else{
Text(text = "", style = bodyTextStyle) Text(text = stringResource(R.string.none), style = bodyTextStyle)
} }
OutlinedTextField( OutlinedTextField(
value = inputPkg, value = inputPkg,
onValueChange = {inputPkg=it}, onValueChange = {inputPkg=it},
label = {Text("包名")}, label = {Text(stringResource(R.string.package_name))},
keyboardOptions = KeyboardOptions(imeAction = ImeAction.Done), keyboardOptions = KeyboardOptions(imeAction = ImeAction.Done),
keyboardActions = KeyboardActions(onDone = {focusMgr.clearFocus()}), keyboardActions = KeyboardActions(onDone = {focusMgr.clearFocus()}),
modifier = Modifier.focusable().fillMaxWidth().padding(vertical = 3.dp) modifier = Modifier.focusable().fillMaxWidth().padding(vertical = 3.dp)
@@ -393,12 +394,12 @@ fun SystemManage(){
focusMgr.clearFocus() focusMgr.clearFocus()
whitelist.add(inputPkg) whitelist.add(inputPkg)
myDpm.setLockTaskPackages(myComponent,whitelist.toTypedArray()) myDpm.setLockTaskPackages(myComponent,whitelist.toTypedArray())
Toast.makeText(myContext, "成功", Toast.LENGTH_SHORT).show() Toast.makeText(myContext, myContext.getString(R.string.success), Toast.LENGTH_SHORT).show()
refreshWhitelist() refreshWhitelist()
}, },
modifier = Modifier.fillMaxWidth(0.49F) modifier = Modifier.fillMaxWidth(0.49F)
) { ) {
Text("添加") Text(stringResource(R.string.add))
} }
Button( Button(
onClick = { onClick = {
@@ -406,15 +407,15 @@ fun SystemManage(){
if(inputPkg in whitelist){ if(inputPkg in whitelist){
whitelist.remove(inputPkg) whitelist.remove(inputPkg)
myDpm.setLockTaskPackages(myComponent,whitelist.toTypedArray()) myDpm.setLockTaskPackages(myComponent,whitelist.toTypedArray())
Toast.makeText(myContext, "成功", Toast.LENGTH_SHORT).show() Toast.makeText(myContext, myContext.getString(R.string.success), Toast.LENGTH_SHORT).show()
}else{ }else{
Toast.makeText(myContext, "不存在", Toast.LENGTH_SHORT).show() Toast.makeText(myContext, myContext.getString(R.string.not_exist), Toast.LENGTH_SHORT).show()
} }
refreshWhitelist() refreshWhitelist()
}, },
modifier = Modifier.fillMaxWidth(0.96F) modifier = Modifier.fillMaxWidth(0.96F)
) { ) {
Text("移除") Text(stringResource(R.string.remove))
} }
} }
} }
@@ -429,8 +430,8 @@ fun SystemManage(){
} }
LaunchedEffect(exist){ isCaCertSelected(600){refresh()} } LaunchedEffect(exist){ isCaCertSelected(600){refresh()} }
Column(modifier = sections()){ Column(modifier = sections()){
Text(text = "Ca证书", style = typography.titleLarge, color = titleColor) Text(text = stringResource(R.string.ca_cert), style = typography.titleLarge, color = titleColor)
if(isEmpty){ Text(text = "请选择Ca证书(.0)") }else{ Text(text = "证书已安装:$exist") } if(isEmpty){ Text(text = stringResource(R.string.please_select_ca_cert)) }else{ Text(text = stringResource(R.string.cacert_installed, exist)) }
Button( Button(
onClick = { onClick = {
val caCertIntent = Intent(Intent.ACTION_GET_CONTENT) val caCertIntent = Intent(Intent.ACTION_GET_CONTENT)
@@ -440,53 +441,53 @@ fun SystemManage(){
}, },
modifier = Modifier.fillMaxWidth() modifier = Modifier.fillMaxWidth()
) { ) {
Text("选择证书...") Text(stringResource(R.string.select_ca_cert))
} }
AnimatedVisibility(!isEmpty) { AnimatedVisibility(!isEmpty) {
Row(modifier = Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.SpaceBetween){ Row(modifier = Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.SpaceBetween){
Button( Button(
onClick = { onClick = {
val result = myDpm.installCaCert(myComponent, caCert) val result = myDpm.installCaCert(myComponent, caCert)
Toast.makeText(myContext, if(result){"成功"}else{"失败"}, Toast.LENGTH_SHORT).show() Toast.makeText(myContext, myContext.getString(if(result){R.string.success}else{R.string.fail}), Toast.LENGTH_SHORT).show()
refresh() refresh()
}, },
modifier = Modifier.fillMaxWidth(0.49F) modifier = Modifier.fillMaxWidth(0.49F)
) { ) {
Text("安装") Text(stringResource(R.string.install))
} }
Button( Button(
onClick = { onClick = {
if(exist){ if(exist){
myDpm.uninstallCaCert(myComponent, caCert) myDpm.uninstallCaCert(myComponent, caCert)
exist = myDpm.hasCaCertInstalled(myComponent, caCert) exist = myDpm.hasCaCertInstalled(myComponent, caCert)
Toast.makeText(myContext, if(exist){"失败"}else{"成功"}, Toast.LENGTH_SHORT).show() Toast.makeText(myContext, myContext.getString(if(exist){R.string.fail}else{R.string.success}), Toast.LENGTH_SHORT).show()
}else{ Toast.makeText(myContext, "不存在", Toast.LENGTH_SHORT).show() } }else{ Toast.makeText(myContext, myContext.getString(R.string.not_exist), Toast.LENGTH_SHORT).show() }
}, },
modifier = Modifier.fillMaxWidth(0.96F) modifier = Modifier.fillMaxWidth(0.96F)
) { ) {
Text("卸载") Text(stringResource(R.string.uninstall))
} }
} }
} }
Button( Button(
onClick = { onClick = {
myDpm.uninstallAllUserCaCerts(myComponent) myDpm.uninstallAllUserCaCerts(myComponent)
Toast.makeText(myContext, "成功", Toast.LENGTH_SHORT).show() Toast.makeText(myContext, myContext.getString(R.string.success), Toast.LENGTH_SHORT).show()
}, },
modifier = Modifier.fillMaxWidth() modifier = Modifier.fillMaxWidth()
){ ){
Text("清除用户Ca证书") Text(stringResource(R.string.uninstall_all_user_ca_cert))
} }
} }
} }
if(VERSION.SDK_INT>=26&&(isDeviceOwner(myDpm)||(VERSION.SDK_INT>=30&&isProfileOwner(myDpm)&&myDpm.isOrganizationOwnedDeviceWithManagedProfile))){ if(VERSION.SDK_INT>=26&&(isDeviceOwner(myDpm)||(VERSION.SDK_INT>=30&&isProfileOwner(myDpm)&&myDpm.isOrganizationOwnedDeviceWithManagedProfile))){
Column(modifier = sections()){ Column(modifier = sections()){
Text(text = "收集安全日志", style = typography.titleLarge, color = titleColor) Text(text = stringResource(R.string.retrieve_security_logs), style = typography.titleLarge, color = titleColor)
Text(text = "功能开发中", style = bodyTextStyle) Text(text = stringResource(R.string.developing), style = bodyTextStyle)
Row(modifier=Modifier.fillMaxWidth().padding(horizontal=8.dp),horizontalArrangement=Arrangement.SpaceBetween,verticalAlignment=Alignment.CenterVertically){ Row(modifier=Modifier.fillMaxWidth().padding(horizontal=8.dp),horizontalArrangement=Arrangement.SpaceBetween,verticalAlignment=Alignment.CenterVertically){
var checked by remember{mutableStateOf(myDpm.isSecurityLoggingEnabled(myComponent))} var checked by remember{mutableStateOf(myDpm.isSecurityLoggingEnabled(myComponent))}
Text(text = "启用", style = typography.titleLarge) Text(text = stringResource(R.string.enabled), style = typography.titleLarge)
Switch( Switch(
checked = checked, checked = checked,
onCheckedChange = {myDpm.setSecurityLoggingEnabled(myComponent,!checked);checked=myDpm.isSecurityLoggingEnabled(myComponent)} onCheckedChange = {myDpm.setSecurityLoggingEnabled(myComponent,!checked);checked=myDpm.isSecurityLoggingEnabled(myComponent)}
@@ -497,30 +498,30 @@ fun SystemManage(){
val log = myDpm.retrieveSecurityLogs(myComponent) val log = myDpm.retrieveSecurityLogs(myComponent)
if(log!=null){ if(log!=null){
for(i in log){ Log.d("SecureLog",i.toString()) } for(i in log){ Log.d("SecureLog",i.toString()) }
Toast.makeText(myContext,"已输出至Log",Toast.LENGTH_SHORT).show() Toast.makeText(myContext,myContext.getString(R.string.success),Toast.LENGTH_SHORT).show()
}else{ }else{
Log.d("Secure5Log","") Log.d("SecureLog",myContext.getString(R.string.none))
Toast.makeText(myContext,"无日志",Toast.LENGTH_SHORT).show() Toast.makeText(myContext, myContext.getString(R.string.no_logs),Toast.LENGTH_SHORT).show()
} }
}, },
modifier = Modifier.fillMaxWidth() modifier = Modifier.fillMaxWidth()
) { ) {
Text("安全日志") Text(stringResource(R.string.security_logs))
} }
Button( Button(
onClick = { onClick = {
val log = myDpm.retrievePreRebootSecurityLogs(myComponent) val log = myDpm.retrievePreRebootSecurityLogs(myComponent)
if(log!=null){ if(log!=null){
for(i in log){ Log.d("SecureLog",i.toString()) } for(i in log){ Log.d("SecureLog",i.toString()) }
Toast.makeText(myContext,"已输出至Log",Toast.LENGTH_SHORT).show() Toast.makeText(myContext,myContext.getString(R.string.success),Toast.LENGTH_SHORT).show()
}else{ }else{
Log.d("SecureLog","") Log.d("SecureLog",myContext.getString(R.string.none))
Toast.makeText(myContext,"无日志",Toast.LENGTH_SHORT).show() Toast.makeText(myContext,myContext.getString(R.string.no_logs),Toast.LENGTH_SHORT).show()
} }
}, },
modifier = Modifier.fillMaxWidth() modifier = Modifier.fillMaxWidth()
) { ) {
Text("重启前安全日志") Text(stringResource(R.string.pre_reboot_security_logs))
} }
} }
} }
@@ -537,17 +538,17 @@ fun SystemManage(){
var euicc by remember{mutableStateOf(false)} var euicc by remember{mutableStateOf(false)}
var silent by remember{mutableStateOf(false)} var silent by remember{mutableStateOf(false)}
var reason by remember{mutableStateOf("")} var reason by remember{mutableStateOf("")}
Text(text = "清除数据",style = typography.titleLarge,modifier = Modifier.padding(6.dp),color = colorScheme.onErrorContainer) Text(text = stringResource(R.string.wipe_data),style = typography.titleLarge,modifier = Modifier.padding(6.dp),color = colorScheme.onErrorContainer)
CheckBoxItem("清除外部存储",{externalStorage},{externalStorage=!externalStorage;confirmed=false}, colorScheme.onErrorContainer) CheckBoxItem(stringResource(R.string.wipe_external_storage),{externalStorage},{externalStorage=!externalStorage;confirmed=false}, colorScheme.onErrorContainer)
if(VERSION.SDK_INT>=22&&isDeviceOwner(myDpm)){ if(VERSION.SDK_INT>=22&&isDeviceOwner(myDpm)){
CheckBoxItem("清除受保护的数据",{protectionData},{protectionData=!protectionData;confirmed=false}, colorScheme.onErrorContainer) CheckBoxItem(stringResource(R.string.wipe_reset_protection_data),{protectionData},{protectionData=!protectionData;confirmed=false}, colorScheme.onErrorContainer)
} }
if(VERSION.SDK_INT>=28){ CheckBoxItem("清除eUICC",{euicc},{euicc=!euicc;confirmed=false}, colorScheme.onErrorContainer) } if(VERSION.SDK_INT>=28){ CheckBoxItem(stringResource(R.string.wipe_euicc),{euicc},{euicc=!euicc;confirmed=false}, colorScheme.onErrorContainer) }
if(VERSION.SDK_INT>=29){ CheckBoxItem("静默清除",{silent},{silent=!silent;confirmed=false}, colorScheme.onErrorContainer) } if(VERSION.SDK_INT>=29){ CheckBoxItem(stringResource(R.string.wipe_silently),{silent},{silent=!silent;confirmed=false}, colorScheme.onErrorContainer) }
AnimatedVisibility(!silent&&VERSION.SDK_INT>=28) { AnimatedVisibility(!silent&&VERSION.SDK_INT>=28) {
OutlinedTextField( OutlinedTextField(
value = reason, onValueChange = {reason=it}, value = reason, onValueChange = {reason=it},
label = {Text("原因")}, label = {Text(stringResource(R.string.reason))},
enabled = !confirmed, enabled = !confirmed,
keyboardOptions = KeyboardOptions(imeAction = ImeAction.Done), keyboardOptions = KeyboardOptions(imeAction = ImeAction.Done),
keyboardActions = KeyboardActions(onDone = {focusMgr.clearFocus()}), keyboardActions = KeyboardActions(onDone = {focusMgr.clearFocus()}),
@@ -572,7 +573,7 @@ fun SystemManage(){
enabled = myDpm.isAdminActive(myComponent), enabled = myDpm.isAdminActive(myComponent),
modifier = Modifier.fillMaxWidth() modifier = Modifier.fillMaxWidth()
) { ) {
Text(text = if(confirmed){"取消"}else{"确定"}) Text(text = stringResource(if(confirmed){ R.string.cancel }else{ R.string.confirm }))
} }
Row(modifier = Modifier.fillMaxWidth(),horizontalArrangement = Arrangement.SpaceBetween) { Row(modifier = Modifier.fillMaxWidth(),horizontalArrangement = Arrangement.SpaceBetween) {
Button( Button(
@@ -598,10 +599,10 @@ fun SystemManage(){
} }
} }
if(VERSION.SDK_INT>=24&&isProfileOwner(myDpm)&&myDpm.isManagedProfile(myComponent)){ if(VERSION.SDK_INT>=24&&isProfileOwner(myDpm)&&myDpm.isManagedProfile(myComponent)){
Text(text = "将会删除工作资料", style = bodyTextStyle) Text(text = stringResource(R.string.will_delete_work_profile), style = bodyTextStyle)
} }
if(VERSION.SDK_INT>=34&&Binder.getCallingUid()/100000==0){ if(VERSION.SDK_INT>=34&&Binder.getCallingUid()/100000==0){
Text(text = "API34或以上将不能在系统用户中使用WipeData", style = bodyTextStyle) Text(text = stringResource(R.string.api34_or_above_wipedata_cannot_in_system_user), style = bodyTextStyle)
} }
} }
Spacer(Modifier.padding(vertical = 30.dp)) Spacer(Modifier.padding(vertical = 30.dp))

View File

@@ -1,22 +1,97 @@
<resources> <resources xmlns:tools="http://schemas.android.com/tools">
<!--Global-->
<string name="app_name">Android Owner</string> <string name="app_name">Android Owner</string>
<string name="disabled">禁用</string>
<string name="enabled">启用</string>
<string name="disable">禁用</string>
<string name="enable">启用</string>
<string name="success">成功</string>
<string name="fail">失败</string>
<string name="add">添加</string>
<string name="remove">移除</string>
<string name="install">安装</string>
<string name="uninstall">卸载</string>
<string name="cancel">取消</string>
<string name="confirm">确定</string>
<string name="reason">原因</string>
<string name="custom">自定义</string>
<string name="time_unit_ms">时间(ms)</string>
<string name="none"></string>
<string name="no_logs">无日志</string>
<string name="default_stringres">默认</string>
<string name="apply">应用</string>
<string name="decide_by_user">由用户决定</string>
<string name="unsupported">不支持</string>
<string name="place_holder" />
<!--Permissions-->
<!--System-->
<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="disable_status_bar">禁用状态栏</string> <string name="disable_status_bar">禁用状态栏</string>
<string name="aosp_scrrec_also_work">对AOSP的录屏也起作用</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>
<string name="backup_service">备份服务</string> <string name="backup_service">备份服务</string>
<string name="disable_bt_contact_share">禁止蓝牙分享联系人</string>
<string name="common_criteria_mode">通用标准模式</string>
<string name="common_criteria_mode_desc">Common Criteria</string>
<string name="usb_signal">USB信号</string>
<string name="turn_off_usb_not_support">你的设备不支持关闭USB信号</string>
<string name="keyguard">锁屏</string>
<string name="require_no_password_to_disable">禁用需要无密码</string>
<string name="lock_now">立即锁屏</string>
<string name="require_enter_password_again">需要重新输入密码</string>
<string name="request_bug_report">请求错误报告</string>
<string name="reboot">重启</string>
<string name="edit_time">修改时间</string>
<string name="from_epoch_to_target_time">从Epoch(1970/1/1 00:00:00 UTC)到你想设置的时间(毫秒)</string>
<string name="get_current_time">获取当前时间</string>
<string name="permission_policy">权限策略</string>
<string name="auto_grant">自动允许</string>
<string name="auto_deny">自动拒绝</string>
<string name="mte_policy">MTE策略</string>
<string name="mte_policy_desc">MTE内存标记拓展安卓14和ARMv9的高端功能</string>
<string name="nearby_app_streaming">附近App共享</string>
<string name="nearby_notifi_streaming">附近通知共享</string>
<string name="enable_if_secure_enough">在足够安全时启用</string>
<string name="lock_task_feature">锁定任务功能</string>
<string name="disable_all">禁用全部</string>
<string name="ltf_sys_info">允许状态栏信息</string>
<string name="ltf_notifications">允许通知</string>
<string name="ltf_home">允许返回主屏幕</string>
<string name="ltf_overview">允许打开后台应用概览</string>
<string name="ltf_global_actions">允许全局行为(比如长按电源键对话框)</string>
<string name="ltf_keyguard">允许锁屏</string>
<string name="ltf_block_activity_start_in_task">阻止启动未允许的应用</string>
<string name="whitelist_app">白名单应用</string>
<string name="package_name">包名</string>
<string name="not_exist">不存在</string>
<string name="ca_cert">Ca证书</string>
<string name="please_select_ca_cert">请选择Ca证书(.0)</string>
<string name="cacert_installed">证书已安装:%1$s</string>
<string name="select_ca_cert" tools:ignore="TypographyEllipsis">选择证书...</string>
<string name="uninstall_all_user_ca_cert">卸载所有用户证书</string>
<string name="retrieve_security_logs">收集安全日志</string>
<string name="security_logs">安全日志</string>
<string name="pre_reboot_security_logs">重启前安全日志</string>
<string name="wipe_data">清除数据</string>
<string name="wipe_external_storage">清除外部存储</string>
<string name="wipe_reset_protection_data">清除受保护的数据</string>
<string name="wipe_euicc">清除eUICC</string>
<string name="wipe_silently">静默清除</string>
<string name="will_delete_work_profile">将会删除工作资料</string>
<string name="api34_or_above_wipedata_cannot_in_system_user">API34或以上将不能在系统用户中使用WipeData</string>
<string name="app_manage">应用管理</string> <string name="app_manage">应用管理</string>
<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="permission">权限</string> <string name="permission">权限</string>
<string name="place_holder" />
<string name="user_restrict">用户限制</string> <string name="user_restrict">用户限制</string>
<string name="config_mobile_network">配置移动数据</string> <string name="config_mobile_network">配置移动数据</string>
@@ -92,7 +167,6 @@
<string name="pwd_history">密码历史记录长度</string> <string name="pwd_history">密码历史记录长度</string>
<string name="pwd_history_desc">用户输入的密码不能与历史记录中的任何密码相同0为无限制</string> <string name="pwd_history_desc">用户输入的密码不能与历史记录中的任何密码相同0为无限制</string>
<string name="pwd_history_textfield">历史记录长度</string> <string name="pwd_history_textfield">历史记录长度</string>
<string name="usb_signal">USB信号</string>
<string name="owner_lockscr_info">锁屏信息</string> <string name="owner_lockscr_info">锁屏信息</string>
<string name="support_msg">提供支持的短消息</string> <string name="support_msg">提供支持的短消息</string>
@@ -100,7 +174,6 @@
<string name="message">消息</string> <string name="message">消息</string>
<string name="long_support_msg">提供支持的长消息</string> <string name="long_support_msg">提供支持的长消息</string>
<string name="long_support_msg_desc">都是显示短消息,长消息不知道在哪里显示</string> <string name="long_support_msg_desc">都是显示短消息,长消息不知道在哪里显示</string>
<string name="disable_bt_contact_share">禁止蓝牙分享联系人</string>
<string name="user_manage">用户管理</string> <string name="user_manage">用户管理</string>
<string name="setting">设置</string> <string name="setting">设置</string>
<string name="always_on_vpn">VPN保持打开</string> <string name="always_on_vpn">VPN保持打开</string>
@@ -108,8 +181,6 @@
<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="common_criteria_mode">通用标准模式</string>
<string name="common_criteria_mode_desc">Common Criteria</string>
<string name="preferential_network_service">优先网络服务</string> <string name="preferential_network_service">优先网络服务</string>
<string name="network">网络</string> <string name="network">网络</string>
<string name="developing">功能开发中</string> <string name="developing">功能开发中</string>