mirror of
https://github.com/awfixers-stuff/OwnDroid.git
synced 2026-03-23 11:05:59 +00:00
add user manage section
This commit is contained in:
@@ -38,6 +38,7 @@ import androidx.core.content.ContextCompat.startActivity
|
||||
import androidx.navigation.NavGraph.Companion.findStartDestination
|
||||
import androidx.navigation.NavHostController
|
||||
|
||||
|
||||
@Composable
|
||||
fun DpmPermissions(myDpm: DevicePolicyManager, myComponent: ComponentName, myContext:Context,navCtrl:NavHostController){
|
||||
//da:DeviceAdmin do:DeviceOwner
|
||||
@@ -53,7 +54,7 @@ fun DpmPermissions(myDpm: DevicePolicyManager, myComponent: ComponentName, myCon
|
||||
Row(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(bottom = 10.dp)
|
||||
.padding(vertical = 5.dp)
|
||||
.clip(RoundedCornerShape(15))
|
||||
.background(color = MaterialTheme.colorScheme.primaryContainer)
|
||||
.padding(10.dp),
|
||||
@@ -78,15 +79,33 @@ fun DpmPermissions(myDpm: DevicePolicyManager, myComponent: ComponentName, myCon
|
||||
Text("撤销")
|
||||
}
|
||||
}else{
|
||||
Button(onClick = { ActivateDeviceAdmin(myComponent, myContext) }) {
|
||||
/*Button(onClick = { activateDeviceAdmin(myContext,myComponent) }) {
|
||||
Text("激活")
|
||||
}*/
|
||||
}
|
||||
}
|
||||
if(!isda){
|
||||
Column(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(vertical = 5.dp)
|
||||
.clip(RoundedCornerShape(15.dp))
|
||||
.background(color = MaterialTheme.colorScheme.tertiaryContainer)
|
||||
.padding(10.dp),
|
||||
horizontalAlignment = Alignment.Start
|
||||
) {
|
||||
Text("你可以在adb shell中使用以下命令激活Device Admin")
|
||||
SelectionContainer {
|
||||
Text("dpm set-active-admin com.binbin.androidowner/com.binbin.androidowner.MyDeviceAdminReceiver",
|
||||
color = MaterialTheme.colorScheme.onTertiaryContainer)
|
||||
}
|
||||
Text("或者进入设置 -> 安全 -> 更多安全设置 -> 设备管理应用 -> Android Owner")
|
||||
}
|
||||
}
|
||||
Row(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(bottom = 10.dp)
|
||||
.padding(vertical = 5.dp)
|
||||
.clip(RoundedCornerShape(15))
|
||||
.background(color = MaterialTheme.colorScheme.primaryContainer)
|
||||
.padding(10.dp),
|
||||
@@ -112,38 +131,59 @@ fun DpmPermissions(myDpm: DevicePolicyManager, myComponent: ComponentName, myCon
|
||||
}
|
||||
}
|
||||
}
|
||||
Column(
|
||||
horizontalAlignment = Alignment.Start
|
||||
) {
|
||||
if(isdo||isda){
|
||||
Text(
|
||||
text = "注意!在这里撤销权限不会清除配置。比如:被停用的应用会保持停用状态",
|
||||
color = MaterialTheme.colorScheme.onErrorContainer,
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.clip(RoundedCornerShape(15))
|
||||
.background(color = MaterialTheme.colorScheme.errorContainer)
|
||||
.padding(6.dp)
|
||||
)
|
||||
}
|
||||
Spacer(Modifier.padding(5.dp))
|
||||
if(!isda){
|
||||
Text("你可以在adb shell中使用以下命令激活Device Admin")
|
||||
SelectionContainer {
|
||||
Text("dpm set-active-admin com.binbin.androidowner/com.binbin.androidowner.MyDeviceAdminReceiver")
|
||||
if(isdo||isda){
|
||||
Text(
|
||||
text = "注意!在这里撤销权限不会清除配置。比如:被停用的应用会保持停用状态",
|
||||
color = MaterialTheme.colorScheme.onErrorContainer,
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(vertical = 5.dp)
|
||||
.clip(RoundedCornerShape(15))
|
||||
.background(color = MaterialTheme.colorScheme.errorContainer)
|
||||
.padding(6.dp)
|
||||
)
|
||||
}
|
||||
if(isdo){
|
||||
Column(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(vertical = 5.dp)
|
||||
.clip(RoundedCornerShape(15))
|
||||
.background(color = MaterialTheme.colorScheme.primaryContainer)
|
||||
.padding(8.dp)
|
||||
) {
|
||||
Text(text = "设备信息", style = MaterialTheme.typography.titleLarge)
|
||||
if(VERSION.SDK_INT>=30){
|
||||
val orgDevice = myDpm.isOrganizationOwnedDeviceWithManagedProfile
|
||||
Text("由组织拥有的工作资料设备:$orgDevice")
|
||||
}
|
||||
if(VERSION.SDK_INT>=34&&(myDpm.isProfileOwnerApp("com.binbin.androidowner")||myDpm.isManagedProfile(myComponent))){
|
||||
val financed = myDpm.isDeviceFinanced
|
||||
Text("Financed Device : $financed")
|
||||
}
|
||||
Text("或者进入设置 -> 安全 -> 更多安全设置 -> 设备管理应用 -> Android Owner")
|
||||
}
|
||||
if(!isdo){
|
||||
}
|
||||
if(!isdo){
|
||||
Column(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(vertical = 5.dp)
|
||||
.clip(RoundedCornerShape(15.dp))
|
||||
.background(color = MaterialTheme.colorScheme.tertiaryContainer)
|
||||
.padding(10.dp),
|
||||
horizontalAlignment = Alignment.Start
|
||||
) {
|
||||
Text("你可以在adb shell中使用以下命令激活Device Owner")
|
||||
SelectionContainer {
|
||||
Text("dpm set-device-owner com.binbin.androidowner/com.binbin.androidowner.MyDeviceAdminReceiver")
|
||||
Text(text = "dpm set-device-owner com.binbin.androidowner/com.binbin.androidowner.MyDeviceAdminReceiver",
|
||||
color = MaterialTheme.colorScheme.onTertiaryContainer)
|
||||
}
|
||||
if(!isda){
|
||||
Text("使用此命令也会激活Device Admin")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(isdo&&VERSION.SDK_INT>=24){
|
||||
DeviceOwnerInfo(R.string.owner_lockscr_info,R.string.place_holder,R.string.owner_lockscr_info,focusManager,myContext,
|
||||
{myDpm.deviceOwnerLockScreenInfo},{content -> myDpm.setDeviceOwnerLockScreenInfo(myComponent,content)})
|
||||
@@ -152,8 +192,6 @@ fun DpmPermissions(myDpm: DevicePolicyManager, myComponent: ComponentName, myCon
|
||||
DeviceOwnerInfo(R.string.long_support_msg,R.string.long_support_msg_desc,R.string.message,focusManager,myContext,
|
||||
{myDpm.getLongSupportMessage(myComponent)},{content -> myDpm.setLongSupportMessage(myComponent,content)})
|
||||
}
|
||||
DeviceOwnerInfo(R.string.profile_name,R.string.unknown_feature,R.string.profile_name,focusManager,myContext,
|
||||
{null},{content -> myDpm.setProfileName(myComponent,content)})
|
||||
Spacer(Modifier.padding(vertical = 20.dp))
|
||||
}
|
||||
}
|
||||
@@ -171,7 +209,7 @@ fun DeviceOwnerInfo(
|
||||
Column(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(bottom = 10.dp)
|
||||
.padding(vertical = 5.dp)
|
||||
.clip(RoundedCornerShape(12.dp))
|
||||
.background(color = MaterialTheme.colorScheme.primaryContainer)
|
||||
.padding(10.dp)
|
||||
@@ -216,13 +254,10 @@ fun DeviceOwnerInfo(
|
||||
}
|
||||
}
|
||||
|
||||
fun ActivateDeviceAdmin(myComponent: ComponentName,myContext: Context){
|
||||
fun activateDeviceAdmin(inputContext:Context,inputComponent:ComponentName){
|
||||
val intent = Intent(DevicePolicyManager.ACTION_ADD_DEVICE_ADMIN)
|
||||
intent.putExtra(DevicePolicyManager.EXTRA_DEVICE_ADMIN, myComponent)
|
||||
intent.putExtra(
|
||||
DevicePolicyManager.EXTRA_ADD_EXPLANATION,
|
||||
"在这里激活Android Owner"
|
||||
)
|
||||
intent.putExtra(DevicePolicyManager.EXTRA_DEVICE_ADMIN, inputComponent)
|
||||
intent.putExtra(DevicePolicyManager.EXTRA_ADD_EXPLANATION, "在这里激活Android Owner")
|
||||
intent.setFlags(FLAG_ACTIVITY_NEW_TASK)
|
||||
startActivity(myContext,intent,null)
|
||||
startActivity(inputContext,intent,null)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user