Roku Developer Program

Join our online forum to talk to Roku developers and fellow channel creators. Ask questions, share tips with the community, and find helpful resources.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
ratish
Visitor

Registry not Cleared if App is deleted

Hi

Had some data stored in registry for my App to during launch. But somehow one of the data got wrong. So wanted to delete the app and installed again so that i can start fresh. But looks like even after deleting the app, the data resides in registry which is picked up again by the installed app.
This is happening with the private channel I have created which we test before submitting for publishing.
0 Kudos
15 REPLIES 15
RokuJoel
Binge Watcher

Re: Registry not Cleared if App is deleted

Solution is delete the channel, then reboot

- Joel
0 Kudos
TheEndless
Channel Surfer

Re: Registry not Cleared if App is deleted

The reboot is a new requirement, and an annoying one.. 😛

That aside, you can always explicitly delete the registry information using ifRegistrySection.Delete(key).
My Channels: http://roku.permanence.com - Twitter: @TheEndlessDev
Instant Watch Browser (NetflixIWB), Aquarium Screensaver (AQUARIUM), Clever Clocks Screensaver (CLEVERCLOCKS), iTunes Podcasts (ITPC), My Channels (MYCHANNELS)
0 Kudos
ratish
Visitor

Re: Registry not Cleared if App is deleted

"RokuJoel" wrote:
Solution is delete the channel, then reboot

- Joel


It is not working on the private channel.
Steps applied:
1. Removed the channel from Roku.
2. Rebooted the box.
3. Visited my Roku account and added the private channel again.
4. System update in Roku to install the app.
5. Launch the app and it reads the credential from registry(which means registry was not cleared).
0 Kudos
TheEndless
Channel Surfer

Re: Registry not Cleared if App is deleted

"ratish" wrote:
"RokuJoel" wrote:
Solution is delete the channel, then reboot

- Joel

It is not working on the private channel.
Steps applied:
1. Removed the channel from Roku.
2. Rebooted the box.
3. Visited my Roku account and added the private channel again.
4. System update in Roku to install the app.
5. Launch the app and it reads the credential from registry(which means registry was not cleared).

Deleting the channel will only clear the registry if you have no other channels installed that were signed with the same key.
My Channels: http://roku.permanence.com - Twitter: @TheEndlessDev
Instant Watch Browser (NetflixIWB), Aquarium Screensaver (AQUARIUM), Clever Clocks Screensaver (CLEVERCLOCKS), iTunes Podcasts (ITPC), My Channels (MYCHANNELS)
0 Kudos
RokuJoel
Binge Watcher

Re: Registry not Cleared if App is deleted

Good point. If you have 10 channels signed with the same dev id the registry won't clear until you delete them all. A faster way to test your channels is to create an app that just deletes all the reg keys, run that and no reboot needed.

- Joel
0 Kudos
ratish
Visitor

Re: Registry not Cleared if App is deleted

"Deleting the channel will only clear the registry if you have no other channels installed that were signed with the same key."

With Key do you mean the Dev ID we use to package the zip(channel)?
0 Kudos
TheEndless
Channel Surfer

Re: Registry not Cleared if App is deleted

"ratish" wrote:
"Deleting the channel will only clear the registry if you have no other channels installed that were signed with the same key."

With Key do you mean the Dev ID we use to package the zip(channel)?

Yes.
My Channels: http://roku.permanence.com - Twitter: @TheEndlessDev
Instant Watch Browser (NetflixIWB), Aquarium Screensaver (AQUARIUM), Clever Clocks Screensaver (CLEVERCLOCKS), iTunes Podcasts (ITPC), My Channels (MYCHANNELS)
0 Kudos
EnTerr
Roku Guru

Re: Registry not Cleared if App is deleted

"ratish" wrote:
"Deleting the channel will only clear the registry if you have no other channels installed that were signed with the same key."

With Key do you mean the Dev ID we use to package the zip(channel)?

Yes. Registry hives are on per-DevID basis, meaning all channels signed with the same ID share the same registry (and kinda-sorta can share data between themselves that way). A registry will be deleted for realz only after the lastest channel of a DevID is flushed from the device - and TIL (Today I Learn) that a bonus reboot might be required. (re)see also http://sdkdocs.roku.com/display/sdkdoc/roRegistry
0 Kudos
belltown
Roku Guru

Re: Registry not Cleared if App is deleted

"RokuJoel" wrote:
A faster way to test your channels is to create an app that just deletes all the reg keys, run that and no reboot needed.

For anyone looking for such a channel, here is some code I wrote that does just that.

You can dump the entire registry contents on an roTextScreen, wipe the entire registry clean, or delete individual registry sections.

Tested on firmware 3.1 and 6.1.


Sub Main ()
displayMainUI ()
End Sub

'
' UI component for the top-level menu
'
Function displayMainUI () As Void
contentList = [
{ShortDescriptionLine1: "Dump the whole registry"},
{ShortDescriptionLine1: "Wipe the whole registry"},
{ShortDescriptionLine1: "Delete an individual section"},
]
port = CreateObject ("roMessagePort")
ui = CreateObject ("roPosterScreen")
ui.SetMessagePort (port)
ui.SetListStyle ("flat-category")
ui.SetContentList (contentList)
ui.Show ()
While True
msg = Wait (0, port)
If Type (msg) = "roPosterScreenEvent"
If msg.IsScreenClosed ()
Exit While
Else If msg.IsListItemSelected ()
index = msg.GetIndex ()
If index = 0
dumpRegistryUI ()
Else If index = 1
wipeRegistryUI ()
Else If index = 2
deleteSectionUI ()
EndIf
EndIf
EndIf
End While
End Function

'
' UI component for dumping the entire registry
'
Function dumpRegistryUI () As Void
regText = getRegText ()
If regText = ""
displayMessage ("Registry is empty")
Else
port = CreateObject ("roMessagePort")
ui = CreateObject ("roTextScreen")
ui.SetMessagePort (port)
ui.SetText (fixup (regText)) ' Use fw3.1 bug workaround
ui.AddButton (0, "Quit")
ui.Show ()
While True
msg = Wait (0, port)
If Type (msg) = "roTextScreenEvent"
If msg.IsScreenClosed ()
Exit While
Else If msg.IsButtonPressed ()
ui.Close ()
EndIf
EndIf
End While
EndIf
End Function

'
' UI component for deleting the entire registry
'
Function wipeRegistryUI () As Void
If confirmUI ("Wipe Registry", "Select 'Wipe Registry' to delete the entire registry")
deleteReg ("") ' Delete all sections
EndIf
End Function

'
' UI component for deleting an individual registry section
'
Function deleteSectionUI () As Void
regSectionList = getRegSectionList ()
If regSectionList.Count () = 0
displayMessage ("Registry is empty")
Else
contentList = []
For Each section In regSectionList
If section.keyCount = 0
keyCountStr = "No keys in section"
Else If section.keyCount = 1
keyCountStr = "1 key in section"
Else
keyCountStr = section.keyCount.ToStr () + " keys in section"
EndIf
contentList.Push ({Title: section.name, ShortDescriptionLine1: keyCountStr})
End For
port = CreateObject ("roMessagePort")
ui = CreateObject ("roListScreen")
ui.SetMessagePort (port)
ui.SetupBehaviorAtTopRow ("exit") ' Give fw3.1 users a way back
ui.SetHeader ("Press 'OK' to delete section")
ui.SetContent (contentList)
ui.Show ()
While True
msg = Wait (0, port)
If Type (msg) = "roListScreenEvent"
If msg.IsScreenClosed ()
Exit While
Else If msg.IsListItemSelected ()
section = contentList [msg.GetIndex ()].Title
If confirmUI ("Delete Section", "Select 'Delete Section' to delete the " + section + " section")
deleteReg (section)
ui.Close ()
EndIf
EndIf
EndIf
End While
EndIf
End Function

'
' Return a list of all registry sections and the number of keys in each section
'
Function getRegSectionList () As Object
regSectionList = []
r = CreateObject ("roRegistry")
For Each section In r.GetSectionList ()
rs = CreateObject ("roRegistrySection", section)
regSectionList.Push ({name: section, keyCount: rs.GetKeyList ().Count ()})
End For
Return regSectionList
End Function

'
' Get the contents of a registry section as a text string
'
Function getRegTextSection (sectionName = "" As String) As String
regText = "Registry Section: " + sectionName + LF ()
rs = CreateObject ("roRegistrySection", sectionName)
For Each key In rs.GetKeyList ()
regText = regText + " " + key + ": " + rs.Read (key) + LF ()
End For
Return regText
End Function

'
' Get the contents of a registry or registry section as a text string
'
Function getRegText (sectionName = "" As String) As String
regText = ""
If sectionName = ""
r = CreateObject ("roRegistry")
For Each section In r.GetSectionList ()
regText = regText + getRegTextSection (section) + LF ()
End For
Else
regText = regText + getRegTextSection (sectionName)
Endif
Return regText
End Function

'
' Roku 3.1 firmware roTextScreen bug workaround (buttons don't work unless enough text to scroll)
'
Function fixup (regText As String) As String
fixedText = regText
lfCount = 0
' Count the number of line-ending characters
For i = 1 To Len (regText)
If Mid (regText, i, 1) = LF () Then lfCount = lfCount + 1
End For
' Ensure there are at least 18 lines to guarantee a scroll bar appears
If lfCount < 18 Then fixedText = fixedText + String (18 - lfCount, LF ())
Return fixedText
End Function

'
' Delete the entire registry or an individual registry section
'
Function deleteReg (section = "" As String) As Void
r = CreateObject ("roRegistry")
If section = ""
For Each regSection In r.GetSectionList ()
r.Delete (regSection)
End For
Else
r.Delete (section)
Endif
r.Flush ()
End Function

'
' Display a confirmation before an irreversible action
'
Function confirmUI (buttonText As String, buttonDesc As String) As Boolean
confirm = False
port = CreateObject ("roMessagePort")
ui = CreateObject ("roMessageDialog")
ui.SetMessagePort (port)
ui.SetTitle ("DANGER -- This Action Cannot Be Undone")
ui.SetText ("Select 'Cancel' to go back")
ui.SetText (buttonDesc)
ui.AddButton (0, "Cancel")
ui.AddButton (1, buttonText)
ui.Show ()
While True
msg = Wait (0, port)
If Type (msg) = "roMessageDialogEvent"
If msg.IsScreenClosed ()
Exit While
Else If msg.IsButtonPressed ()
If msg.GetIndex () = 1
confirm = True
EndIf
ui.Close ()
EndIf
EndIf
End While
Return confirm
End Function

'
' Display an informational message
'
Function displayMessage (text As String) As Void
port = CreateObject ("roMessagePort")
ui = CreateObject ("roMessageDialog")
ui.SetMessagePort (port)
ui.SetTitle (text)
ui.AddButton (0, "OK")
ui.Show ()
While True
msg = Wait (0, port)
If Type (msg) = "roMessageDialogEvent"
If msg.IsScreenClosed ()
Exit While
Else If msg.IsButtonPressed ()
ui.Close ()
EndIf
EndIf
End While
End Function

'
' Line-ending character to use in a text string
'
Function LF () As String : Return Chr (10) : End Function
0 Kudos
Need Assistance?
Welcome to the Roku Community! Feel free to search our Community for answers or post your question to get help.

Become a Roku Streaming Expert!

Share your expertise, help fellow streamers, and unlock exclusive rewards as part of the Roku Community. Learn more.