Sub setKiosk(on As Boolean)
Dim Command, Runner As String
Dim StdOut, StdErr As StringBuilder
Dim Result As Int
Dim Ph As Phone
StdOut.Initialize
StdErr.Initialize
Runner = File.Combine(File.DirInternalCache, "runner")
Command = File.Combine(File.DirInternalCache, "command")
File.WriteString(File.DirInternalCache, "runner", "su < " & Command)
If on Then
File.WriteString(File.DirInternalCache, "command", "dpm set-device-owner cloud.pagamico.boot/anywheresoftware.b4a.objects.AdminReceiver2" & CRLF & "exit") 'Any commands via crlf, and exit at end
Else
File.WriteString(File.DirInternalCache, "command", "dpm set-device-owner com.android.launcher3/anywheresoftware.b4a.objects.AdminReceiver2" & CRLF & "exit") 'Any commands via crlf, and exit at end
End If
Result = Ph.Shell("sh", Array As String(Runner), StdOut, StdErr)
End Sub
Sub setKiosk2(on As Boolean)
Private p As Phone
Private Out, Err As StringBuilder
Out.Initialize
Err.Initialize
If on Then
File.WriteString(File.DirRootExternal, "reboot.sh", "dpm set-device-owner cloud.pagamico.boot/anywheresoftware.b4a.objects.AdminReceiver2")
Else
File.WriteString(File.DirRootExternal, "reboot.sh", "pm clear cloud.pagamico.boot")
End If
p.Shell("sh", Array As String(File.Combine(File.DirRootExternal, "reboot.sh")), Out, Err)
Log(Err)
End Sub
Private Sub btn_SetKiosk_Click
setKiosk(True)
setKiosk2(True)
End Sub
Private Sub btn_SetKioskOff_Click
setKiosk(False)
setKiosk2(False)
End Sub