David Blume's GitList
Repositories
dxb_channel.git
Code
Commits
Branches
Tags
Search
Tree:
7679d4e
Branches
Tags
main
dxb_channel.git
components
testtask.brs
Add new volume and memory functions
dblume
commited
7679d4e
at 2024-03-02 13:53:06
testtask.brs
Blame
History
Raw
sub init() m.top.functionName = "executeTest" m.top.ObserveField("pucidHash", "onUpdatePucidHash") end sub function GetRequest() as object r = CreateObject("roUrlTransfer") r.InitClientCertificates() r.SetCertificatesFile("pkg:/certificates/rokuca.pem") ' r.SetCertificatesFile("common:/certs/ca-bundle.crt") r.SetUrl("https://api.roku.com/registrysvc/api/" + CreateObject("roAppInfo").GetDevID()) r.AddHeader("accept", "application/json") r.AddHeader("content-type", "application/*") r.AddHeader("x-roku-registry-aes-key-version", "v1") r.AddHeader("x-roku-reserved-regsvc-token", "") ' Note if called from init(), then m.top.pucidHash won't have been set yet. r.AddHeader("x-roku-registry-aes-encryption-key", m.top.pucidHash) print "GetRequest() x-roku-registry-aes-encryption-key:" + m.top.pucidHash print " URL:" + r.GetUrl() return r end function function onUpdatePucidHash() as void ' Maybe do something with m.top.pucidHash end function sub printAA(aa) for each key in aa.Keys() val = aa[key] if type(val) = "roByteArray" m.top.updateText = " " + key + " = a byte array" elseif type(val) = "roArray" for i=0 to val.Count() - 1 m.top.updateText = " " + key + "[" + i.toStr() + "] = " + val[i] end for else m.top.updateText = " " + key + " = " + val.ToStr() endif end for end sub function executeTest() as void ' This task gets run one at the start, and then ' again every time the OK button is pressed. deviceInfo = CreateObject("roDeviceInfo") aaConnectionInfo = deviceInfo.GetDisplayProperties() m.top.updateText = "roDeviceInfo.GetDisplayProperties" printAA(aaConnectionInfo) aaConnectionInfo = deviceInfo.GetConnectionInfo() m.top.updateText = "roDeviceInfo.GetConnectionInfo" printAA(aaConnectionInfo) request = GetRequest() port = CreateObject("roMessagePort") request.SetMessagePort(port) requestBody = { "token": "auth" } res = request.AsyncPostFromString(FormatJson(requestBody)) if res = true msg = wait(0, port) if type(msg) = "roUrlEvent" if msg.GetInt() = 1 print "PSI Request roUrlEvent = " + msg.GetResponseCode().ToStr() end if ' else if msg = invalid ' request.AsyncCancel() end if else m.top.updateText = "AsyncPostFromString failed" end if appMemMon = CreateObject("roAppMemoryMonitor") if appMemMon <> invalid: m.top.updateText = "roAppMemoryMonitor.GetChannelMemoryLimit" m.top.updateText = " Available Memory MiB = " + (appMemMon.GetChannelAvailableMemory() / 1024).ToStr() + " (" + appMemMon.GetMemoryLimitPercent().ToStr() + "% used)" if FindMemberFunction(appMemMon, "GetChannelMemoryLimit") <> invalid: ' printAA(appMemMon.GetChannelMemoryLimit()) memFields = appMemMon.GetChannelMemoryLimit() m.top.updateText = " maxForegroundMemory MiB = " + (memFields.maxForegroundMemory / 1024).ToStr() m.top.updateText = " maxBackgroundMemory MiB = " + (memFields.maxBackgroundMemory / 1024).ToStr() endif endif end function