mirror of
https://github.com/awfixers-stuff/OwnDroid.git
synced 2026-03-23 19:15:58 +00:00
clean codes
use res id to make toast convert class RestrictionData to a object simplify some UI components
This commit is contained in:
@@ -6,7 +6,6 @@ import android.content.ComponentName
|
||||
import android.content.Context
|
||||
import android.os.Build.VERSION
|
||||
import android.os.Bundle
|
||||
import android.util.DisplayMetrics
|
||||
import android.widget.Toast
|
||||
import androidx.activity.ComponentActivity
|
||||
import androidx.activity.compose.setContent
|
||||
@@ -130,7 +129,7 @@ fun MyScaffold(){
|
||||
if(profileNotActivated){
|
||||
myDpm.setProfileEnabled(myComponent)
|
||||
sharedPref.edit().putBoolean("ManagedProfileActivated",true).apply()
|
||||
Toast.makeText(myContext, myContext.getString(R.string.work_profile_activated), Toast.LENGTH_SHORT).show()
|
||||
Toast.makeText(myContext, R.string.work_profile_activated, Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -77,59 +77,54 @@ fun PackageSelector(navCtrl:NavHostController){
|
||||
Scaffold(
|
||||
topBar = {
|
||||
TopAppBar(
|
||||
title = {
|
||||
Row(
|
||||
horizontalArrangement = Arrangement.SpaceBetween, modifier = Modifier.fillMaxWidth().padding(bottom = 2.dp),
|
||||
verticalAlignment = Alignment.CenterVertically
|
||||
){
|
||||
Text(text = stringResource(R.string.pkg_selector))
|
||||
Row {
|
||||
Icon(
|
||||
painter = painterResource(R.drawable.filter_alt_fill0),
|
||||
contentDescription = "filter",
|
||||
modifier = Modifier
|
||||
.padding(horizontal = 6.dp)
|
||||
.clip(RoundedCornerShape(50))
|
||||
.combinedClickable(
|
||||
onClick = {
|
||||
when(filter){
|
||||
"data"-> {
|
||||
filter = "system"; co.launch {scrollState.scrollToItem(0)}
|
||||
Toast.makeText(context, context.getString(R.string.show_system_app), Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
"system"-> {
|
||||
filter = "priv"; co.launch {scrollState.scrollToItem(0)}
|
||||
Toast.makeText(context, context.getString(R.string.show_priv_app), Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
else-> {
|
||||
filter = "data"; co.launch {scrollState.scrollToItem(0)}
|
||||
Toast.makeText(context, context.getString(R.string.show_user_app), Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
}
|
||||
},
|
||||
onLongClick = {
|
||||
filter = "apex"
|
||||
Toast.makeText(context, context.getString(R.string.show_apex_app), Toast.LENGTH_SHORT).show()
|
||||
actions = {
|
||||
Icon(
|
||||
painter = painterResource(R.drawable.filter_alt_fill0),
|
||||
contentDescription = "filter",
|
||||
modifier = Modifier
|
||||
.padding(horizontal = 6.dp)
|
||||
.clip(RoundedCornerShape(50))
|
||||
.combinedClickable(
|
||||
onClick = {
|
||||
when(filter){
|
||||
"data"-> {
|
||||
filter = "system"; co.launch {scrollState.scrollToItem(0)}
|
||||
Toast.makeText(context, R.string.show_system_app, Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
)
|
||||
.padding(5.dp)
|
||||
)
|
||||
Icon(
|
||||
painter = painterResource(R.drawable.refresh_fill0),
|
||||
contentDescription = "refresh",
|
||||
modifier = Modifier
|
||||
.padding(horizontal = 6.dp)
|
||||
.clip(RoundedCornerShape(50))
|
||||
.clickable{
|
||||
co.launch{
|
||||
delay(100)
|
||||
getPkgList()
|
||||
"system"-> {
|
||||
filter = "priv"; co.launch {scrollState.scrollToItem(0)}
|
||||
Toast.makeText(context, R.string.show_priv_app, Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
else-> {
|
||||
filter = "data"; co.launch {scrollState.scrollToItem(0)}
|
||||
Toast.makeText(context, R.string.show_user_app, Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
}
|
||||
.padding(5.dp)
|
||||
},
|
||||
onLongClick = {
|
||||
filter = "apex"
|
||||
Toast.makeText(context, R.string.show_apex_app, Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
.padding(5.dp)
|
||||
)
|
||||
Icon(
|
||||
painter = painterResource(R.drawable.refresh_fill0),
|
||||
contentDescription = "refresh",
|
||||
modifier = Modifier
|
||||
.padding(horizontal = 6.dp)
|
||||
.clip(RoundedCornerShape(50))
|
||||
.clickable{
|
||||
co.launch{
|
||||
delay(100)
|
||||
getPkgList()
|
||||
}
|
||||
}
|
||||
.padding(5.dp)
|
||||
)
|
||||
},
|
||||
title = {
|
||||
Text(text = stringResource(R.string.pkg_selector))
|
||||
},
|
||||
navigationIcon = {NavIcon{navCtrl.navigateUp()}},
|
||||
colors = TopAppBarDefaults.topAppBarColors(containerColor = bgColor)
|
||||
|
||||
@@ -24,12 +24,12 @@ class Receiver : DeviceAdminReceiver() {
|
||||
|
||||
override fun onDisabled(context: Context, intent: Intent) {
|
||||
super.onDisabled(context, intent)
|
||||
Toast.makeText(context, context.getString(R.string.onDisabled), Toast.LENGTH_SHORT).show()
|
||||
Toast.makeText(context, R.string.onDisabled, Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
|
||||
override fun onProfileProvisioningComplete(context: Context, intent: Intent) {
|
||||
super.onProfileProvisioningComplete(context, intent)
|
||||
Toast.makeText(context, context.getString(R.string.create_work_profile_success), Toast.LENGTH_SHORT).show()
|
||||
Toast.makeText(context, R.string.create_work_profile_success, Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -3,16 +3,12 @@ package com.bintianqi.owndroid
|
||||
import android.content.ClipData
|
||||
import android.content.ClipboardManager
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.net.Uri
|
||||
import android.os.Build.VERSION
|
||||
import android.widget.Toast
|
||||
import androidx.core.content.ContextCompat.startActivity
|
||||
import java.io.FileNotFoundException
|
||||
import java.io.IOException
|
||||
import java.io.InputStream
|
||||
|
||||
|
||||
fun uriToStream(
|
||||
context: Context,
|
||||
uri: Uri?,
|
||||
|
||||
@@ -186,9 +186,9 @@ private fun Home(navCtrl:NavHostController, pkgName: String){
|
||||
try {
|
||||
myDpm.setAlwaysOnVpnPackage(myComponent, pkgName, it)
|
||||
} catch(e: UnsupportedOperationException) {
|
||||
Toast.makeText(myContext, myContext.getString(R.string.unsupported), Toast.LENGTH_SHORT).show()
|
||||
Toast.makeText(myContext, R.string.unsupported, Toast.LENGTH_SHORT).show()
|
||||
} catch(e: NameNotFoundException) {
|
||||
Toast.makeText(myContext, myContext.getString(R.string.not_installed), Toast.LENGTH_SHORT).show()
|
||||
Toast.makeText(myContext, R.string.not_installed, Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
}
|
||||
)
|
||||
@@ -196,7 +196,7 @@ private fun Home(navCtrl:NavHostController, pkgName: String){
|
||||
if(isDeviceOwner(myDpm)||isProfileOwner(myDpm)){
|
||||
SubPageItem(R.string.block_uninstall,"",R.drawable.delete_forever_fill0){navCtrl.navigate("BlockUninstall")}
|
||||
}
|
||||
if((VERSION.SDK_INT>=30&&isDeviceOwner(myDpm))||(VERSION.SDK_INT>=33&&isProfileOwner(myDpm))){
|
||||
if((VERSION.SDK_INT>=33&&isProfileOwner(myDpm))||(VERSION.SDK_INT>=30&&isDeviceOwner(myDpm))){
|
||||
SubPageItem(R.string.ucd,"",R.drawable.do_not_touch_fill0){navCtrl.navigate("UserControlDisabled")}
|
||||
}
|
||||
if(VERSION.SDK_INT>=23&&(isDeviceOwner(myDpm)||isProfileOwner(myDpm))){
|
||||
@@ -265,7 +265,7 @@ private fun UserCtrlDisabledPkg(pkgName:String){
|
||||
myDpm.setUserControlDisabledPackages(myComponent,pkgList)
|
||||
refresh()
|
||||
}else{
|
||||
Toast.makeText(myContext, myContext.getString(R.string.fail), Toast.LENGTH_SHORT).show()
|
||||
Toast.makeText(myContext, R.string.fail, Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
},
|
||||
modifier = Modifier.fillMaxWidth(0.49F)
|
||||
@@ -279,7 +279,7 @@ private fun UserCtrlDisabledPkg(pkgName:String){
|
||||
myDpm.setUserControlDisabledPackages(myComponent,pkgList)
|
||||
refresh()
|
||||
}else{
|
||||
Toast.makeText(myContext, myContext.getString(R.string.not_exist), Toast.LENGTH_SHORT).show()
|
||||
Toast.makeText(myContext, R.string.not_exist, Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
},
|
||||
modifier = Modifier.fillMaxWidth(0.96F)
|
||||
@@ -317,7 +317,7 @@ private fun BlockUninstall(pkgName: String){
|
||||
onClick = {
|
||||
focusMgr.clearFocus()
|
||||
myDpm.setUninstallBlocked(myComponent,pkgName,true)
|
||||
Toast.makeText(myContext, myContext.getString(R.string.success), Toast.LENGTH_SHORT).show()
|
||||
Toast.makeText(myContext, R.string.success, Toast.LENGTH_SHORT).show()
|
||||
state = myDpm.isUninstallBlocked(myComponent,pkgName)
|
||||
},
|
||||
modifier = Modifier.fillMaxWidth(0.49F)
|
||||
@@ -328,7 +328,7 @@ private fun BlockUninstall(pkgName: String){
|
||||
onClick = {
|
||||
focusMgr.clearFocus()
|
||||
myDpm.setUninstallBlocked(myComponent,pkgName,false)
|
||||
Toast.makeText(myContext, myContext.getString(R.string.success), Toast.LENGTH_SHORT).show()
|
||||
Toast.makeText(myContext, R.string.success, Toast.LENGTH_SHORT).show()
|
||||
state = myDpm.isUninstallBlocked(myComponent,pkgName)
|
||||
},
|
||||
modifier = Modifier.fillMaxWidth(0.96F)
|
||||
@@ -578,9 +578,9 @@ private fun CredentialManagePolicy(pkgName: String){
|
||||
}else{
|
||||
myDpm.credentialManagerPolicy = null
|
||||
}
|
||||
Toast.makeText(myContext, myContext.getString(R.string.success), Toast.LENGTH_SHORT).show()
|
||||
Toast.makeText(myContext, R.string.success, Toast.LENGTH_SHORT).show()
|
||||
}catch(e:java.lang.IllegalArgumentException){
|
||||
Toast.makeText(myContext, myContext.getString(R.string.fail), Toast.LENGTH_SHORT).show()
|
||||
Toast.makeText(myContext, R.string.fail, Toast.LENGTH_SHORT).show()
|
||||
}finally {
|
||||
refreshPolicy()
|
||||
credentialListText = credentialList.toText()
|
||||
@@ -745,7 +745,7 @@ private fun KeepUninstalledApp(pkgName: String){
|
||||
val getList = myDpm.getKeepUninstalledPackages(myComponent)
|
||||
if(getList!=null){ keepUninstallPkg = getList }
|
||||
listText = keepUninstallPkg.toText()
|
||||
Toast.makeText(myContext, myContext.getString(R.string.success), Toast.LENGTH_SHORT).show()
|
||||
Toast.makeText(myContext, R.string.success, Toast.LENGTH_SHORT).show()
|
||||
},
|
||||
modifier = Modifier.fillMaxWidth()
|
||||
){
|
||||
@@ -875,9 +875,9 @@ private fun DefaultDialerApp(pkgName: String){
|
||||
onClick = {
|
||||
try{
|
||||
myDpm.setDefaultDialerApplication(pkgName)
|
||||
Toast.makeText(myContext, myContext.getString(R.string.success), Toast.LENGTH_SHORT).show()
|
||||
Toast.makeText(myContext, R.string.success, Toast.LENGTH_SHORT).show()
|
||||
}catch(e:IllegalArgumentException){
|
||||
Toast.makeText(myContext, myContext.getString(R.string.fail), Toast.LENGTH_SHORT).show()
|
||||
Toast.makeText(myContext, R.string.fail, Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
},
|
||||
enabled = isDeviceOwner(myDpm)||isProfileOwner(myDpm),
|
||||
|
||||
@@ -129,7 +129,7 @@ private fun CreateWorkProfile(){
|
||||
if(VERSION.SDK_INT>=33){intent.putExtra(EXTRA_PROVISIONING_ALLOW_OFFLINE,true)}
|
||||
createManagedProfile.launch(intent)
|
||||
}catch(e:ActivityNotFoundException){
|
||||
Toast.makeText(myContext,myContext.getString(R.string.unsupported),Toast.LENGTH_SHORT).show()
|
||||
Toast.makeText(myContext, R.string.unsupported, Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
},
|
||||
modifier = Modifier.fillMaxWidth()
|
||||
@@ -157,7 +157,7 @@ private fun OrgOwnedProfile(){
|
||||
color = colorScheme.onTertiaryContainer
|
||||
)
|
||||
}
|
||||
CopyTextButton(myContext, R.string.copy_command, stringResource(R.string.activate_org_profile_command, Binder.getCallingUid()/100000))
|
||||
CopyTextButton(R.string.copy_command, stringResource(R.string.activate_org_profile_command, Binder.getCallingUid()/100000))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -188,7 +188,7 @@ private fun OrgID(){
|
||||
Button(
|
||||
onClick = {
|
||||
myDpm.setOrganizationId(orgId)
|
||||
Toast.makeText(myContext, myContext.getString(R.string.success),Toast.LENGTH_SHORT).show()
|
||||
Toast.makeText(myContext, R.string.success,Toast.LENGTH_SHORT).show()
|
||||
},
|
||||
enabled = orgId.length in 6..64,
|
||||
modifier = Modifier.fillMaxWidth()
|
||||
@@ -229,7 +229,7 @@ private fun SuspendPersonalApp(){
|
||||
Button(
|
||||
onClick = {
|
||||
myDpm.setManagedProfileMaximumTimeOff(myComponent,time.toLong())
|
||||
Toast.makeText(myContext, myContext.getString(R.string.success), Toast.LENGTH_SHORT).show()
|
||||
Toast.makeText(myContext, R.string.success, Toast.LENGTH_SHORT).show()
|
||||
},
|
||||
modifier = Modifier.fillMaxWidth()
|
||||
) {
|
||||
@@ -260,7 +260,7 @@ private fun IntentFilter(){
|
||||
Button(
|
||||
onClick = {
|
||||
myDpm.addCrossProfileIntentFilter(myComponent, IntentFilter(action), FLAG_PARENT_CAN_ACCESS_MANAGED)
|
||||
Toast.makeText(myContext, myContext.getString(R.string.success),Toast.LENGTH_SHORT).show()
|
||||
Toast.makeText(myContext, R.string.success, Toast.LENGTH_SHORT).show()
|
||||
},
|
||||
modifier = Modifier.fillMaxWidth()
|
||||
) {
|
||||
@@ -269,7 +269,7 @@ private fun IntentFilter(){
|
||||
Button(
|
||||
onClick = {
|
||||
myDpm.addCrossProfileIntentFilter(myComponent, IntentFilter(action), FLAG_MANAGED_CAN_ACCESS_PARENT)
|
||||
Toast.makeText(myContext, myContext.getString(R.string.success),Toast.LENGTH_SHORT).show()
|
||||
Toast.makeText(myContext, R.string.success,Toast.LENGTH_SHORT).show()
|
||||
},
|
||||
modifier = Modifier.fillMaxWidth()
|
||||
) {
|
||||
@@ -279,7 +279,7 @@ private fun IntentFilter(){
|
||||
Button(
|
||||
onClick = {
|
||||
myDpm.clearCrossProfileIntentFilters(myComponent)
|
||||
Toast.makeText(myContext, myContext.getString(R.string.success),Toast.LENGTH_SHORT).show()
|
||||
Toast.makeText(myContext, R.string.success, Toast.LENGTH_SHORT).show()
|
||||
},
|
||||
modifier = Modifier.fillMaxWidth()
|
||||
){
|
||||
|
||||
@@ -41,7 +41,6 @@ import androidx.navigation.compose.NavHost
|
||||
import androidx.navigation.compose.composable
|
||||
import androidx.navigation.compose.currentBackStackEntryAsState
|
||||
import androidx.navigation.compose.rememberNavController
|
||||
import com.bintianqi.owndroid.dpm.scrollAnim
|
||||
import com.bintianqi.owndroid.R
|
||||
import com.bintianqi.owndroid.Receiver
|
||||
import com.bintianqi.owndroid.toText
|
||||
@@ -177,7 +176,7 @@ private fun WifiSecLevel(){
|
||||
enabled = isDeviceOwner(myDpm)||(isProfileOwner(myDpm)&&myDpm.isOrganizationOwnedDeviceWithManagedProfile),
|
||||
onClick = {
|
||||
myDpm.minimumRequiredWifiSecurityLevel=selectedWifiSecLevel
|
||||
Toast.makeText(myContext, myContext.getString(R.string.success), Toast.LENGTH_SHORT).show()
|
||||
Toast.makeText(myContext, R.string.success, Toast.LENGTH_SHORT).show()
|
||||
},
|
||||
modifier = Modifier.fillMaxWidth()
|
||||
){
|
||||
@@ -232,9 +231,9 @@ private fun WifiSsidPolicy(){
|
||||
Button(
|
||||
onClick = {
|
||||
if(inputSsid==""){
|
||||
Toast.makeText(myContext, myContext.getString(R.string.cannot_be_empty), Toast.LENGTH_SHORT).show()
|
||||
Toast.makeText(myContext, R.string.cannot_be_empty, Toast.LENGTH_SHORT).show()
|
||||
}else if(WifiSsid.fromBytes(inputSsid.toByteArray()) in ssidSet){
|
||||
Toast.makeText(myContext, myContext.getString(R.string.already_exist), Toast.LENGTH_SHORT).show()
|
||||
Toast.makeText(myContext, R.string.already_exist, Toast.LENGTH_SHORT).show()
|
||||
}else{
|
||||
ssidSet.add(WifiSsid.fromBytes(inputSsid.toByteArray()))
|
||||
ssidList = ssidSet.toText()
|
||||
@@ -248,13 +247,13 @@ private fun WifiSsidPolicy(){
|
||||
Button(
|
||||
onClick = {
|
||||
if(inputSsid==""){
|
||||
Toast.makeText(myContext, myContext.getString(R.string.cannot_be_empty), Toast.LENGTH_SHORT).show()
|
||||
Toast.makeText(myContext, R.string.cannot_be_empty, Toast.LENGTH_SHORT).show()
|
||||
}else if(WifiSsid.fromBytes(inputSsid.toByteArray()) in ssidSet){
|
||||
ssidSet.remove(WifiSsid.fromBytes(inputSsid.toByteArray()))
|
||||
inputSsid = ""
|
||||
ssidList = ssidSet.toText()
|
||||
}else{
|
||||
Toast.makeText(myContext, myContext.getString(R.string.not_exist), Toast.LENGTH_SHORT).show()
|
||||
Toast.makeText(myContext, R.string.not_exist, Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
},
|
||||
modifier = Modifier.fillMaxWidth(0.96F)
|
||||
@@ -267,16 +266,16 @@ private fun WifiSsidPolicy(){
|
||||
focusMgr.clearFocus()
|
||||
if(selectedPolicyType==-1){
|
||||
if(policy==null&&ssidSet.isNotEmpty()){
|
||||
Toast.makeText(myContext, myContext.getString(R.string.please_select_a_policy), Toast.LENGTH_SHORT).show()
|
||||
Toast.makeText(myContext, R.string.please_select_a_policy, Toast.LENGTH_SHORT).show()
|
||||
}else{
|
||||
myDpm.wifiSsidPolicy = null
|
||||
refreshPolicy()
|
||||
Toast.makeText(myContext, myContext.getString(R.string.success), Toast.LENGTH_SHORT).show()
|
||||
Toast.makeText(myContext, R.string.success, Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
}else{
|
||||
myDpm.wifiSsidPolicy = if(ssidSet.size==0){ null }else{ WifiSsidPolicy(selectedPolicyType, ssidSet) }
|
||||
refreshPolicy()
|
||||
Toast.makeText(myContext, myContext.getString(R.string.success), Toast.LENGTH_SHORT).show()
|
||||
Toast.makeText(myContext, R.string.success, Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
},
|
||||
modifier = Modifier.fillMaxWidth()
|
||||
@@ -343,9 +342,9 @@ private fun PrivateDNS(){
|
||||
result = myDpm.setGlobalPrivateDnsModeSpecifiedHost(myComponent,inputHost)
|
||||
Toast.makeText(myContext, operationResult[result], Toast.LENGTH_SHORT).show()
|
||||
}catch(e:IllegalArgumentException){
|
||||
Toast.makeText(myContext, myContext.getString(R.string.invalid_hostname), Toast.LENGTH_SHORT).show()
|
||||
Toast.makeText(myContext, R.string.invalid_hostname, Toast.LENGTH_SHORT).show()
|
||||
}catch(e:SecurityException){
|
||||
Toast.makeText(myContext, myContext.getString(R.string.security_exception), Toast.LENGTH_SHORT).show()
|
||||
Toast.makeText(myContext, R.string.security_exception, Toast.LENGTH_SHORT).show()
|
||||
}finally {
|
||||
status = dnsStatus[myDpm.getGlobalPrivateDnsMode(myComponent)]
|
||||
}
|
||||
@@ -376,10 +375,10 @@ private fun NetLog(){
|
||||
val log = myDpm.retrieveNetworkLogs(myComponent,1234567890)
|
||||
if(log!=null){
|
||||
for(i in log){ Log.d("NetLog",i.toString()) }
|
||||
Toast.makeText(myContext, myContext.getString(R.string.success),Toast.LENGTH_SHORT).show()
|
||||
Toast.makeText(myContext, R.string.success, Toast.LENGTH_SHORT).show()
|
||||
}else{
|
||||
Log.d("NetLog",myContext.getString(R.string.none))
|
||||
Toast.makeText(myContext, myContext.getString(R.string.none),Toast.LENGTH_SHORT).show()
|
||||
Toast.makeText(myContext, R.string.none, Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
},
|
||||
modifier = Modifier.fillMaxWidth()
|
||||
@@ -416,7 +415,7 @@ private fun WifiKeypair(){
|
||||
Button(
|
||||
onClick = {
|
||||
val result = myDpm.grantKeyPairToWifiAuth(keyPair)
|
||||
Toast.makeText(myContext, myContext.getString(if(result){R.string.success}else{R.string.fail}), Toast.LENGTH_SHORT).show()
|
||||
Toast.makeText(myContext, if(result){R.string.success}else{R.string.fail}, Toast.LENGTH_SHORT).show()
|
||||
},
|
||||
modifier = Modifier.fillMaxWidth(0.49F)
|
||||
) {
|
||||
@@ -425,7 +424,7 @@ private fun WifiKeypair(){
|
||||
Button(
|
||||
onClick = {
|
||||
val result = myDpm.revokeKeyPairFromWifiAuth(keyPair)
|
||||
Toast.makeText(myContext, myContext.getString(if(result){R.string.success}else{R.string.fail}), Toast.LENGTH_SHORT).show()
|
||||
Toast.makeText(myContext, if(result){R.string.success}else{R.string.fail}, Toast.LENGTH_SHORT).show()
|
||||
},
|
||||
modifier = Modifier.fillMaxWidth(0.96F)
|
||||
) {
|
||||
@@ -784,7 +783,7 @@ private fun APN(){
|
||||
Button(
|
||||
onClick = {
|
||||
val success = myDpm.updateOverrideApn(myComponent,id,result)
|
||||
Toast.makeText(myContext, myContext.getString(if(success){R.string.success}else{R.string.fail}), Toast.LENGTH_SHORT).show()
|
||||
Toast.makeText(myContext, if(success){R.string.success}else{R.string.fail}, Toast.LENGTH_SHORT).show()
|
||||
},
|
||||
Modifier.fillMaxWidth(0.49F)
|
||||
){
|
||||
|
||||
@@ -163,8 +163,8 @@ private fun ResetPasswordToken(){
|
||||
Spacer(Modifier.padding(vertical = 5.dp))
|
||||
Button(
|
||||
onClick = {
|
||||
if(myDpm.clearResetPasswordToken(myComponent)){ Toast.makeText(myContext, myContext.getString(R.string.success), Toast.LENGTH_SHORT).show()
|
||||
}else{ Toast.makeText(myContext, myContext.getString(R.string.fail), Toast.LENGTH_SHORT).show() }
|
||||
if(myDpm.clearResetPasswordToken(myComponent)){ Toast.makeText(myContext, R.string.success, Toast.LENGTH_SHORT).show()
|
||||
}else{ Toast.makeText(myContext, R.string.fail, Toast.LENGTH_SHORT).show() }
|
||||
},
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
enabled = isDeviceOwner(myDpm)||isProfileOwner(myDpm)
|
||||
@@ -175,12 +175,12 @@ private fun ResetPasswordToken(){
|
||||
onClick = {
|
||||
try {
|
||||
if(myDpm.setResetPasswordToken(myComponent, myByteArray)){
|
||||
Toast.makeText(myContext, myContext.getString(R.string.success), Toast.LENGTH_SHORT).show()
|
||||
Toast.makeText(myContext, R.string.success, Toast.LENGTH_SHORT).show()
|
||||
}else{
|
||||
Toast.makeText(myContext, myContext.getString(R.string.fail), Toast.LENGTH_SHORT).show()
|
||||
Toast.makeText(myContext, R.string.fail, Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
}catch(e:SecurityException){
|
||||
Toast.makeText(myContext, myContext.getString(R.string.security_exception), Toast.LENGTH_SHORT).show()
|
||||
Toast.makeText(myContext, R.string.security_exception, Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
},
|
||||
enabled = isDeviceOwner(myDpm)||isProfileOwner(myDpm),
|
||||
@@ -192,8 +192,8 @@ private fun ResetPasswordToken(){
|
||||
onClick = {
|
||||
if(!myDpm.isResetPasswordTokenActive(myComponent)){
|
||||
try{ activateToken(myContext) }
|
||||
catch(e:NullPointerException){ Toast.makeText(myContext, myContext.getString(R.string.please_set_a_token), Toast.LENGTH_SHORT).show() }
|
||||
}else{ Toast.makeText(myContext, myContext.getString(R.string.token_already_activated), Toast.LENGTH_SHORT).show() }
|
||||
catch(e:NullPointerException){ Toast.makeText(myContext, R.string.please_set_a_token, Toast.LENGTH_SHORT).show() }
|
||||
}else{ Toast.makeText(myContext, R.string.token_already_activated, Toast.LENGTH_SHORT).show() }
|
||||
},
|
||||
enabled = isDeviceOwner(myDpm)||isProfileOwner(myDpm),
|
||||
modifier = Modifier.fillMaxWidth()
|
||||
@@ -243,7 +243,7 @@ private fun ResetPassword(){
|
||||
Button(
|
||||
onClick = {
|
||||
if(newPwd.length>=4||newPwd.isEmpty()){ confirmed=!confirmed
|
||||
}else{ Toast.makeText(myContext, myContext.getString(R.string.require_4_digit_password), Toast.LENGTH_SHORT).show() }
|
||||
}else{ Toast.makeText(myContext, R.string.require_4_digit_password, Toast.LENGTH_SHORT).show() }
|
||||
},
|
||||
enabled = isDeviceOwner(myDpm) || isProfileOwner(myDpm) || myDpm.isAdminActive(myComponent),
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
@@ -259,8 +259,8 @@ private fun ResetPassword(){
|
||||
Button(
|
||||
onClick = {
|
||||
val resetSuccess = myDpm.resetPasswordWithToken(myComponent,newPwd,myByteArray,resetPwdFlag)
|
||||
if(resetSuccess){ Toast.makeText(myContext, myContext.getString(R.string.success), Toast.LENGTH_SHORT).show();newPwd=""}
|
||||
else{ Toast.makeText(myContext, myContext.getString(R.string.fail), Toast.LENGTH_SHORT).show() }
|
||||
if(resetSuccess){ Toast.makeText(myContext, R.string.success, Toast.LENGTH_SHORT).show();newPwd=""}
|
||||
else{ Toast.makeText(myContext, R.string.fail, Toast.LENGTH_SHORT).show() }
|
||||
confirmed=false
|
||||
},
|
||||
colors = ButtonDefaults.buttonColors(containerColor = colorScheme.error, contentColor = colorScheme.onError),
|
||||
@@ -273,8 +273,8 @@ private fun ResetPassword(){
|
||||
Button(
|
||||
onClick = {
|
||||
val resetSuccess = myDpm.resetPassword(newPwd,resetPwdFlag)
|
||||
if(resetSuccess){ Toast.makeText(myContext, myContext.getString(R.string.success), Toast.LENGTH_SHORT).show(); newPwd=""}
|
||||
else{ Toast.makeText(myContext, myContext.getString(R.string.fail), Toast.LENGTH_SHORT).show() }
|
||||
if(resetSuccess){ Toast.makeText(myContext, R.string.success, Toast.LENGTH_SHORT).show(); newPwd=""}
|
||||
else{ Toast.makeText(myContext, R.string.fail, Toast.LENGTH_SHORT).show() }
|
||||
confirmed=false
|
||||
},
|
||||
enabled = confirmed,
|
||||
@@ -315,7 +315,7 @@ private fun PasswordComplexity(){
|
||||
Button(
|
||||
onClick = {
|
||||
myDpm.requiredPasswordComplexity = selectedItem
|
||||
Toast.makeText(myContext, myContext.getString(R.string.success), Toast.LENGTH_SHORT).show()
|
||||
Toast.makeText(myContext, R.string.success, Toast.LENGTH_SHORT).show()
|
||||
},
|
||||
enabled = isDeviceOwner(myDpm)|| isProfileOwner(myDpm),
|
||||
modifier = Modifier.fillMaxWidth()
|
||||
@@ -563,7 +563,7 @@ private fun KeyguardDisabledFeatures(){
|
||||
if(widgets){result+=KEYGUARD_DISABLE_WIDGETS_ALL}
|
||||
}
|
||||
myDpm.setKeyguardDisabledFeatures(myComponent,result)
|
||||
Toast.makeText(myContext, myContext.getString(R.string.success), Toast.LENGTH_SHORT).show()
|
||||
Toast.makeText(myContext, R.string.success, Toast.LENGTH_SHORT).show()
|
||||
calculateCustomFeature()
|
||||
},
|
||||
enabled = isDeviceOwner(myDpm)||isProfileOwner(myDpm),
|
||||
@@ -611,7 +611,7 @@ private fun PasswordQuality(){
|
||||
Button(
|
||||
onClick = {
|
||||
myDpm.setPasswordQuality(myComponent,selectedItem)
|
||||
Toast.makeText(myContext, myContext.getString(R.string.success), Toast.LENGTH_SHORT).show()
|
||||
Toast.makeText(myContext, R.string.success, Toast.LENGTH_SHORT).show()
|
||||
},
|
||||
enabled = isDeviceOwner(myDpm) || isProfileOwner(myDpm),
|
||||
modifier = Modifier.fillMaxWidth()
|
||||
@@ -629,6 +629,6 @@ private fun activateToken(myContext: Context){
|
||||
if (confirmIntent != null) {
|
||||
startActivity(myContext,confirmIntent, null)
|
||||
} else {
|
||||
Toast.makeText(myContext, myContext.getString(R.string.fail), Toast.LENGTH_SHORT).show()
|
||||
Toast.makeText(myContext, R.string.fail, Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -167,7 +167,7 @@ private fun LockScreenInfo(){
|
||||
onClick = {
|
||||
focusMgr.clearFocus()
|
||||
myDpm.setDeviceOwnerLockScreenInfo(myComponent,infoText)
|
||||
Toast.makeText(myContext, myContext.getString(R.string.success), Toast.LENGTH_SHORT).show()
|
||||
Toast.makeText(myContext, R.string.success, Toast.LENGTH_SHORT).show()
|
||||
},
|
||||
modifier = Modifier.fillMaxWidth()
|
||||
) {
|
||||
@@ -177,7 +177,7 @@ private fun LockScreenInfo(){
|
||||
onClick = {
|
||||
focusMgr.clearFocus()
|
||||
myDpm.setDeviceOwnerLockScreenInfo(myComponent,null)
|
||||
Toast.makeText(myContext, myContext.getString(R.string.success), Toast.LENGTH_SHORT).show()
|
||||
Toast.makeText(myContext, R.string.success, Toast.LENGTH_SHORT).show()
|
||||
},
|
||||
modifier = Modifier.fillMaxWidth()
|
||||
) {
|
||||
@@ -219,7 +219,7 @@ private fun DeviceAdmin(){
|
||||
SelectionContainer {
|
||||
Text(text = stringResource(R.string.activate_device_admin_command))
|
||||
}
|
||||
CopyTextButton(myContext, R.string.copy_command, stringResource(R.string.activate_device_admin_command))
|
||||
CopyTextButton(R.string.copy_command, stringResource(R.string.activate_device_admin_command))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -256,7 +256,7 @@ private fun ProfileOwner(){
|
||||
SelectionContainer{
|
||||
Text(text = stringResource(R.string.activate_profile_owner_command))
|
||||
}
|
||||
CopyTextButton(myContext, R.string.copy_command, stringResource(R.string.activate_profile_owner_command))
|
||||
CopyTextButton(R.string.copy_command, stringResource(R.string.activate_profile_owner_command))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -289,7 +289,7 @@ private fun DeviceOwner(){
|
||||
SelectionContainer{
|
||||
Text(text = stringResource(R.string.activate_device_owner_command))
|
||||
}
|
||||
CopyTextButton(myContext, R.string.copy_command, stringResource(R.string.activate_device_owner_command))
|
||||
CopyTextButton(R.string.copy_command, stringResource(R.string.activate_device_owner_command))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -357,7 +357,7 @@ private fun SpecificID(){
|
||||
Spacer(Modifier.padding(vertical = 5.dp))
|
||||
if(specificId!=""){
|
||||
SelectionContainer(modifier = Modifier.horizontalScroll(rememberScrollState())){ Text(specificId) }
|
||||
CopyTextButton(myContext, R.string.copy, specificId)
|
||||
CopyTextButton(R.string.copy, specificId)
|
||||
}else{
|
||||
Text(stringResource(R.string.require_set_org_id))
|
||||
}
|
||||
@@ -387,7 +387,7 @@ private fun OrgName(){
|
||||
onClick = {
|
||||
focusMgr.clearFocus()
|
||||
myDpm.setOrganizationName(myComponent,orgName)
|
||||
Toast.makeText(myContext, myContext.getString(R.string.success), Toast.LENGTH_SHORT).show()
|
||||
Toast.makeText(myContext, R.string.success, Toast.LENGTH_SHORT).show()
|
||||
},
|
||||
modifier = Modifier.fillMaxWidth()
|
||||
){
|
||||
@@ -428,7 +428,7 @@ private fun SupportMsg(){
|
||||
focusMgr.clearFocus()
|
||||
myDpm.setShortSupportMessage(myComponent, shortMsg)
|
||||
myDpm.setLongSupportMessage(myComponent, longMsg)
|
||||
Toast.makeText(myContext, myContext.getString(R.string.success), Toast.LENGTH_SHORT).show()
|
||||
Toast.makeText(myContext, R.string.success, Toast.LENGTH_SHORT).show()
|
||||
},
|
||||
modifier = Modifier.fillMaxWidth()
|
||||
) {
|
||||
@@ -440,7 +440,7 @@ private fun SupportMsg(){
|
||||
focusMgr.clearFocus()
|
||||
myDpm.setShortSupportMessage(myComponent, null)
|
||||
myDpm.setLongSupportMessage(myComponent, null)
|
||||
Toast.makeText(myContext, myContext.getString(R.string.success), Toast.LENGTH_SHORT).show()
|
||||
Toast.makeText(myContext, R.string.success, Toast.LENGTH_SHORT).show()
|
||||
},
|
||||
modifier = Modifier.fillMaxWidth()
|
||||
) {
|
||||
@@ -539,9 +539,9 @@ private fun TransformOwnership(){
|
||||
onClick = {
|
||||
try {
|
||||
myDpm.transferOwnership(myComponent,ComponentName(pkg, cls),null)
|
||||
Toast.makeText(myContext, myContext.getString(R.string.success), Toast.LENGTH_SHORT).show()
|
||||
Toast.makeText(myContext, R.string.success, Toast.LENGTH_SHORT).show()
|
||||
}catch(e:IllegalArgumentException){
|
||||
Toast.makeText(myContext, myContext.getString(R.string.fail), Toast.LENGTH_SHORT).show()
|
||||
Toast.makeText(myContext, R.string.fail, Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
},
|
||||
modifier = Modifier.fillMaxWidth()
|
||||
@@ -559,6 +559,6 @@ private fun activateDeviceAdmin(inputContext:Context,inputComponent:ComponentNam
|
||||
intent.putExtra(DevicePolicyManager.EXTRA_ADD_EXPLANATION, inputContext.getString(R.string.activate_device_admin_here))
|
||||
addDeviceAdmin.launch(intent)
|
||||
}catch(e:ActivityNotFoundException){
|
||||
Toast.makeText(inputContext,inputContext.getString(R.string.unsupported),Toast.LENGTH_SHORT).show()
|
||||
Toast.makeText(inputContext, R.string.unsupported, Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -225,12 +225,12 @@ fun userServiceControl(context:Context, status:Boolean){
|
||||
if (binder.pingBinder()) {
|
||||
service = IUserService.Stub.asInterface(binder)
|
||||
} else {
|
||||
Toast.makeText(context,context.getString(R.string.invalid_binder),Toast.LENGTH_SHORT).show()
|
||||
Toast.makeText(context, R.string.invalid_binder, Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
}
|
||||
override fun onServiceDisconnected(componentName: ComponentName) {
|
||||
service = null
|
||||
Toast.makeText(context,context.getString(R.string.shizuku_service_disconnected),Toast.LENGTH_SHORT).show()
|
||||
Toast.makeText(context, R.string.shizuku_service_disconnected, Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
}
|
||||
val userServiceArgs = Shizuku.UserServiceArgs(
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.bintianqi.owndroid.dpm
|
||||
|
||||
import android.os.IBinder
|
||||
import android.system.Os
|
||||
import androidx.annotation.Keep
|
||||
import com.bintianqi.owndroid.IUserService
|
||||
@@ -11,10 +10,6 @@ var service:IUserService? = null
|
||||
|
||||
@Keep
|
||||
class ShizukuService: IUserService.Stub() {
|
||||
override fun asBinder(): IBinder {
|
||||
TODO("Not yet implemented")
|
||||
}
|
||||
|
||||
override fun destroy(){ }
|
||||
|
||||
override fun execute(command: String?): String {
|
||||
|
||||
@@ -217,7 +217,7 @@ private fun Switches(){
|
||||
if(myDpm.canUsbDataSignalingBeDisabled()){
|
||||
myDpm.isUsbDataSignalingEnabled = it
|
||||
}else{
|
||||
Toast.makeText(myContext,myContext.getString(R.string.unsupported),Toast.LENGTH_SHORT).show()
|
||||
Toast.makeText(myContext, R.string.unsupported, Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
}
|
||||
)
|
||||
@@ -238,8 +238,7 @@ private fun Keyguard(){
|
||||
if(VERSION.SDK_INT>=23){
|
||||
Button(
|
||||
onClick = {
|
||||
Toast.makeText(myContext,
|
||||
myContext.getString(if(myDpm.setKeyguardDisabled(myComponent,true)){R.string.success}else{R.string.fail}), Toast.LENGTH_SHORT).show()
|
||||
Toast.makeText(myContext, 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()
|
||||
@@ -248,8 +247,7 @@ private fun Keyguard(){
|
||||
}
|
||||
Button(
|
||||
onClick = {
|
||||
Toast.makeText(myContext,
|
||||
myContext.getString(if(myDpm.setKeyguardDisabled(myComponent,false)){R.string.success}else{R.string.fail}), Toast.LENGTH_SHORT).show()
|
||||
Toast.makeText(myContext, 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()
|
||||
@@ -370,7 +368,7 @@ private fun PermissionPolicy(){
|
||||
Button(
|
||||
onClick = {
|
||||
myDpm.setPermissionPolicy(myComponent,selectedPolicy)
|
||||
Toast.makeText(myContext, myContext.getString(R.string.success), Toast.LENGTH_SHORT).show()
|
||||
Toast.makeText(myContext, R.string.success, Toast.LENGTH_SHORT).show()
|
||||
},
|
||||
modifier = Modifier.fillMaxWidth()
|
||||
) {
|
||||
@@ -396,9 +394,9 @@ private fun MTEPolicy(){
|
||||
onClick = {
|
||||
try {
|
||||
myDpm.mtePolicy = selectedMtePolicy
|
||||
Toast.makeText(myContext, myContext.getString(R.string.success), Toast.LENGTH_SHORT).show()
|
||||
Toast.makeText(myContext, R.string.success, Toast.LENGTH_SHORT).show()
|
||||
}catch(e:java.lang.UnsupportedOperationException){
|
||||
Toast.makeText(myContext, myContext.getString(R.string.unsupported), Toast.LENGTH_SHORT).show()
|
||||
Toast.makeText(myContext, R.string.unsupported, Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
selectedMtePolicy = myDpm.mtePolicy
|
||||
},
|
||||
@@ -448,7 +446,7 @@ private fun NearbyStreamingPolicy(){
|
||||
Button(
|
||||
onClick = {
|
||||
myDpm.nearbyNotificationStreamingPolicy = notificationPolicy
|
||||
Toast.makeText(myContext, myContext.getString(R.string.success), Toast.LENGTH_SHORT).show()
|
||||
Toast.makeText(myContext, R.string.success, Toast.LENGTH_SHORT).show()
|
||||
},
|
||||
modifier = Modifier.fillMaxWidth()
|
||||
) {
|
||||
@@ -531,7 +529,7 @@ private fun LockTaskFeatures(){
|
||||
}
|
||||
myDpm.setLockTaskFeatures(myComponent,result)
|
||||
refreshFeature()
|
||||
Toast.makeText(myContext, myContext.getString(R.string.success), Toast.LENGTH_SHORT).show()
|
||||
Toast.makeText(myContext, R.string.success, Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
) {
|
||||
Text(stringResource(R.string.apply))
|
||||
@@ -564,7 +562,7 @@ private fun LockTaskFeatures(){
|
||||
focusMgr.clearFocus()
|
||||
whitelist.add(inputPkg)
|
||||
myDpm.setLockTaskPackages(myComponent,whitelist.toTypedArray())
|
||||
Toast.makeText(myContext, myContext.getString(R.string.success), Toast.LENGTH_SHORT).show()
|
||||
Toast.makeText(myContext, R.string.success, Toast.LENGTH_SHORT).show()
|
||||
refreshWhitelist()
|
||||
},
|
||||
modifier = Modifier.fillMaxWidth(0.49F)
|
||||
@@ -577,9 +575,9 @@ private fun LockTaskFeatures(){
|
||||
if(inputPkg in whitelist){
|
||||
whitelist.remove(inputPkg)
|
||||
myDpm.setLockTaskPackages(myComponent,whitelist.toTypedArray())
|
||||
Toast.makeText(myContext, myContext.getString(R.string.success), Toast.LENGTH_SHORT).show()
|
||||
Toast.makeText(myContext, R.string.success, Toast.LENGTH_SHORT).show()
|
||||
}else{
|
||||
Toast.makeText(myContext, myContext.getString(R.string.not_exist), Toast.LENGTH_SHORT).show()
|
||||
Toast.makeText(myContext, R.string.not_exist, Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
refreshWhitelist()
|
||||
},
|
||||
@@ -626,7 +624,7 @@ private fun CaCert(){
|
||||
Button(
|
||||
onClick = {
|
||||
val result = myDpm.installCaCert(myComponent, caCert)
|
||||
Toast.makeText(myContext, myContext.getString(if(result){R.string.success}else{R.string.fail}), Toast.LENGTH_SHORT).show()
|
||||
Toast.makeText(myContext, if(result){R.string.success}else{R.string.fail}, Toast.LENGTH_SHORT).show()
|
||||
refresh()
|
||||
},
|
||||
modifier = Modifier.fillMaxWidth(0.49F)
|
||||
@@ -638,8 +636,8 @@ private fun CaCert(){
|
||||
if(exist){
|
||||
myDpm.uninstallCaCert(myComponent, caCert)
|
||||
exist = myDpm.hasCaCertInstalled(myComponent, caCert)
|
||||
Toast.makeText(myContext, myContext.getString(if(exist){R.string.fail}else{R.string.success}), Toast.LENGTH_SHORT).show()
|
||||
}else{ Toast.makeText(myContext, myContext.getString(R.string.not_exist), Toast.LENGTH_SHORT).show() }
|
||||
Toast.makeText(myContext, if(exist){R.string.fail}else{R.string.success}, Toast.LENGTH_SHORT).show()
|
||||
}else{ Toast.makeText(myContext, R.string.not_exist, Toast.LENGTH_SHORT).show() }
|
||||
},
|
||||
modifier = Modifier.fillMaxWidth(0.96F)
|
||||
) {
|
||||
@@ -650,7 +648,7 @@ private fun CaCert(){
|
||||
Button(
|
||||
onClick = {
|
||||
myDpm.uninstallAllUserCaCerts(myComponent)
|
||||
Toast.makeText(myContext, myContext.getString(R.string.success), Toast.LENGTH_SHORT).show()
|
||||
Toast.makeText(myContext, R.string.success, Toast.LENGTH_SHORT).show()
|
||||
},
|
||||
modifier = Modifier.fillMaxWidth()
|
||||
){
|
||||
@@ -676,10 +674,10 @@ private fun SecurityLogs(){
|
||||
val log = myDpm.retrieveSecurityLogs(myComponent)
|
||||
if(log!=null){
|
||||
for(i in log){ Log.d("SecureLog",i.toString()) }
|
||||
Toast.makeText(myContext,myContext.getString(R.string.success),Toast.LENGTH_SHORT).show()
|
||||
Toast.makeText(myContext, R.string.success, Toast.LENGTH_SHORT).show()
|
||||
}else{
|
||||
Log.d("SecureLog",myContext.getString(R.string.none))
|
||||
Toast.makeText(myContext, myContext.getString(R.string.no_logs),Toast.LENGTH_SHORT).show()
|
||||
Toast.makeText(myContext, R.string.no_logs, Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
},
|
||||
modifier = Modifier.fillMaxWidth()
|
||||
@@ -691,10 +689,10 @@ private fun SecurityLogs(){
|
||||
val log = myDpm.retrievePreRebootSecurityLogs(myComponent)
|
||||
if(log!=null){
|
||||
for(i in log){ Log.d("SecureLog",i.toString()) }
|
||||
Toast.makeText(myContext,myContext.getString(R.string.success),Toast.LENGTH_SHORT).show()
|
||||
Toast.makeText(myContext, R.string.success, Toast.LENGTH_SHORT).show()
|
||||
}else{
|
||||
Log.d("SecureLog",myContext.getString(R.string.none))
|
||||
Toast.makeText(myContext,myContext.getString(R.string.no_logs),Toast.LENGTH_SHORT).show()
|
||||
Toast.makeText(myContext, R.string.no_logs, Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
},
|
||||
modifier = Modifier.fillMaxWidth()
|
||||
|
||||
@@ -224,10 +224,7 @@ private fun UserOperation(){
|
||||
Button(
|
||||
onClick = {
|
||||
focusMgr.clearFocus()
|
||||
Toast.makeText(
|
||||
myContext,
|
||||
myContext.getString(if(myDpm.switchUser(myComponent,userHandleById)) { R.string.success }else{ R.string.fail }), Toast.LENGTH_SHORT
|
||||
).show()
|
||||
Toast.makeText(myContext, if(myDpm.switchUser(myComponent,userHandleById)) { R.string.success }else{ R.string.fail }, Toast.LENGTH_SHORT).show()
|
||||
},
|
||||
enabled = isDeviceOwner(myDpm),
|
||||
modifier = Modifier.fillMaxWidth()
|
||||
@@ -242,7 +239,7 @@ private fun UserOperation(){
|
||||
val result = myDpm.stopUser(myComponent,userHandleById)
|
||||
Toast.makeText(myContext, userOperationResultCode(result,myContext), Toast.LENGTH_SHORT).show()
|
||||
}catch(e:IllegalArgumentException){
|
||||
Toast.makeText(myContext, myContext.getString(R.string.fail), Toast.LENGTH_SHORT).show()
|
||||
Toast.makeText(myContext, R.string.fail, Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
},
|
||||
enabled = isDeviceOwner(myDpm),
|
||||
@@ -255,10 +252,10 @@ private fun UserOperation(){
|
||||
onClick = {
|
||||
focusMgr.clearFocus()
|
||||
if(myDpm.removeUser(myComponent,userHandleById)){
|
||||
Toast.makeText(myContext, myContext.getString(R.string.success), Toast.LENGTH_SHORT).show()
|
||||
Toast.makeText(myContext, R.string.success, Toast.LENGTH_SHORT).show()
|
||||
idInput=""
|
||||
}else{
|
||||
Toast.makeText(myContext, myContext.getString(R.string.fail), Toast.LENGTH_SHORT).show()
|
||||
Toast.makeText(myContext, R.string.fail, Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
},
|
||||
enabled = isDeviceOwner(myDpm),
|
||||
@@ -369,14 +366,14 @@ private fun AffiliationID(){
|
||||
Button(
|
||||
onClick = {
|
||||
if("" in affiliationID) {
|
||||
Toast.makeText(myContext, myContext.getString(R.string.include_empty_string), Toast.LENGTH_SHORT).show()
|
||||
Toast.makeText(myContext, R.string.include_empty_string, Toast.LENGTH_SHORT).show()
|
||||
}else if(affiliationID.isEmpty()){
|
||||
Toast.makeText(myContext, myContext.getString(R.string.cannot_be_empty), Toast.LENGTH_SHORT).show()
|
||||
Toast.makeText(myContext, R.string.cannot_be_empty, Toast.LENGTH_SHORT).show()
|
||||
}else{
|
||||
myDpm.setAffiliationIds(myComponent, affiliationID)
|
||||
affiliationID = myDpm.getAffiliationIds(myComponent)
|
||||
list = affiliationID.toText()
|
||||
Toast.makeText(myContext,myContext.getString(R.string.success),Toast.LENGTH_SHORT).show()
|
||||
Toast.makeText(myContext, R.string.success, Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
},
|
||||
modifier = Modifier.fillMaxWidth()
|
||||
@@ -411,7 +408,7 @@ private fun Username(){
|
||||
Button(
|
||||
onClick = {
|
||||
myDpm.setProfileName(myComponent,inputUsername)
|
||||
Toast.makeText(myContext, myContext.getString(R.string.success), Toast.LENGTH_SHORT).show()
|
||||
Toast.makeText(myContext, R.string.success, Toast.LENGTH_SHORT).show()
|
||||
},
|
||||
enabled = isDeviceOwner(myDpm)||isProfileOwner(myDpm),
|
||||
modifier = Modifier.fillMaxWidth()
|
||||
@@ -469,7 +466,7 @@ private fun UserSessionMessage(){
|
||||
onClick = {
|
||||
myDpm.setStartUserSessionMessage(myComponent,start)
|
||||
myDpm.setEndUserSessionMessage(myComponent,end)
|
||||
Toast.makeText(myContext, myContext.getString(R.string.success), Toast.LENGTH_SHORT).show()
|
||||
Toast.makeText(myContext, R.string.success, Toast.LENGTH_SHORT).show()
|
||||
},
|
||||
enabled = isDeviceOwner(myDpm)||isProfileOwner(myDpm),
|
||||
modifier = Modifier.fillMaxWidth()
|
||||
@@ -480,7 +477,7 @@ private fun UserSessionMessage(){
|
||||
onClick = {
|
||||
myDpm.setStartUserSessionMessage(myComponent,null)
|
||||
myDpm.setEndUserSessionMessage(myComponent,null)
|
||||
Toast.makeText(myContext, myContext.getString(R.string.success), Toast.LENGTH_SHORT).show()
|
||||
Toast.makeText(myContext, R.string.success, Toast.LENGTH_SHORT).show()
|
||||
},
|
||||
enabled = isDeviceOwner(myDpm)||isProfileOwner(myDpm),
|
||||
modifier = Modifier.fillMaxWidth()
|
||||
@@ -525,7 +522,7 @@ private fun UserIcon(){
|
||||
uriToStream(myContext, userIconUri){stream ->
|
||||
val bitmap = BitmapFactory.decodeStream(stream)
|
||||
myDpm.setUserIcon(myComponent,bitmap)
|
||||
Toast.makeText(myContext, myContext.getString(R.string.success), Toast.LENGTH_SHORT).show()
|
||||
Toast.makeText(myContext, R.string.success, Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
},
|
||||
modifier = Modifier.fillMaxWidth()
|
||||
|
||||
@@ -124,7 +124,7 @@ private fun Home(navCtrl:NavHostController,scrollState: ScrollState){
|
||||
@Composable
|
||||
private fun Internet(){
|
||||
Column(modifier = Modifier.fillMaxSize().verticalScroll(rememberScrollState())){
|
||||
for(internetItem in RestrictionData().internet()){
|
||||
for(internetItem in RestrictionData.internet()){
|
||||
UserRestrictionItem(internetItem.restriction,internetItem.name,internetItem.desc,internetItem.ico)
|
||||
}
|
||||
Spacer(Modifier.padding(vertical = 30.dp))
|
||||
@@ -133,9 +133,8 @@ private fun Internet(){
|
||||
|
||||
@Composable
|
||||
private fun Connectivity(){
|
||||
val myContext = LocalContext.current
|
||||
Column(modifier = Modifier.fillMaxSize().verticalScroll(rememberScrollState())){
|
||||
for(connectivityItem in RestrictionData().connectivity(myContext)){
|
||||
for(connectivityItem in RestrictionData.connectivity()){
|
||||
UserRestrictionItem(connectivityItem.restriction,connectivityItem.name,connectivityItem.desc,connectivityItem.ico)
|
||||
}
|
||||
Spacer(Modifier.padding(vertical = 30.dp))
|
||||
@@ -146,7 +145,7 @@ private fun Connectivity(){
|
||||
fun Application(){
|
||||
val myContext = LocalContext.current
|
||||
Column(modifier = Modifier.fillMaxSize().verticalScroll(rememberScrollState())){
|
||||
for(applicationItem in RestrictionData().application(myContext)){
|
||||
for(applicationItem in RestrictionData.application(myContext)){
|
||||
UserRestrictionItem(applicationItem.restriction,applicationItem.name,applicationItem.desc,applicationItem.ico)
|
||||
}
|
||||
Spacer(Modifier.padding(vertical = 30.dp))
|
||||
@@ -156,7 +155,7 @@ fun Application(){
|
||||
@Composable
|
||||
private fun User(){
|
||||
Column(modifier = Modifier.fillMaxSize().verticalScroll(rememberScrollState())){
|
||||
for(userItem in RestrictionData().user()){
|
||||
for(userItem in RestrictionData.user()){
|
||||
UserRestrictionItem(userItem.restriction,userItem.name,userItem.desc,userItem.ico)
|
||||
}
|
||||
Spacer(Modifier.padding(vertical = 30.dp))
|
||||
@@ -166,7 +165,7 @@ private fun User(){
|
||||
@Composable
|
||||
private fun Media(){
|
||||
Column(modifier = Modifier.fillMaxSize().verticalScroll(rememberScrollState())){
|
||||
for(mediaItem in RestrictionData().media()){
|
||||
for(mediaItem in RestrictionData.media()){
|
||||
UserRestrictionItem(mediaItem.restriction,mediaItem.name,mediaItem.desc,mediaItem.ico)
|
||||
}
|
||||
Spacer(Modifier.padding(vertical = 30.dp))
|
||||
@@ -177,7 +176,7 @@ private fun Media(){
|
||||
private fun Other(){
|
||||
val myContext = LocalContext.current
|
||||
Column(modifier = Modifier.fillMaxSize().verticalScroll(rememberScrollState())){
|
||||
for(otherItem in RestrictionData().other(myContext)){
|
||||
for(otherItem in RestrictionData.other(myContext)){
|
||||
UserRestrictionItem(otherItem.restriction,otherItem.name,otherItem.desc,otherItem.ico)
|
||||
}
|
||||
Spacer(Modifier.padding(vertical = 30.dp))
|
||||
@@ -206,7 +205,7 @@ private fun UserRestrictionItem(
|
||||
}
|
||||
}catch(e:SecurityException){
|
||||
if(isProfileOwner(myDpm)){
|
||||
Toast.makeText(myContext, myContext.getString(R.string.require_device_owner), Toast.LENGTH_SHORT).show()
|
||||
Toast.makeText(myContext, R.string.require_device_owner, Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -214,7 +213,7 @@ private fun UserRestrictionItem(
|
||||
)
|
||||
}
|
||||
|
||||
private class RestrictionData{
|
||||
private object RestrictionData{
|
||||
fun internet():List<Restriction>{
|
||||
val list:MutableList<Restriction> = mutableListOf()
|
||||
list += Restriction(UserManager.DISALLOW_CONFIG_MOBILE_NETWORKS, R.string.config_mobile_network,"",R.drawable.signal_cellular_alt_fill0)
|
||||
@@ -241,7 +240,7 @@ private class RestrictionData{
|
||||
list += Restriction(UserManager.DISALLOW_OUTGOING_CALLS,R.string.outgoing_calls,"",R.drawable.phone_forwarded_fill0)
|
||||
return list
|
||||
}
|
||||
fun connectivity(myContext:Context):List<Restriction>{
|
||||
fun connectivity():List<Restriction>{
|
||||
val list:MutableList<Restriction> = mutableListOf()
|
||||
if(VERSION.SDK_INT>=26){
|
||||
list += Restriction(UserManager.DISALLOW_BLUETOOTH,R.string.bluetooth,"",R.drawable.bluetooth_fill0)
|
||||
|
||||
@@ -168,7 +168,8 @@ fun TopBar(
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun CopyTextButton(context: Context, @StringRes label: Int, content: String){
|
||||
fun CopyTextButton(@StringRes label: Int, content: String){
|
||||
val context = LocalContext.current
|
||||
var ok by remember{mutableStateOf(false)}
|
||||
val scope = rememberCoroutineScope()
|
||||
Button(
|
||||
@@ -176,7 +177,7 @@ fun CopyTextButton(context: Context, @StringRes label: Int, content: String){
|
||||
if(!ok){
|
||||
scope.launch{
|
||||
if(writeClipBoard(context,content)){ ok = true; delay(2000); ok = false }
|
||||
else{ Toast.makeText(context,context.getString(R.string.fail),Toast.LENGTH_SHORT).show() }
|
||||
else{ Toast.makeText(context, R.string.fail, Toast.LENGTH_SHORT).show() }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user