[CHTwidget]CHTw Reminder - Windows Mobile Software Development

I decided to pull my Reminder widget information out of How-To-Make-A-CHT-Widget and continue developing. I'll start this thread by pulling relevant posts from the original location.
************************************************
My latest release. See the snapshots.
Change log:
19 Jan 2012: Added Alarms to show on Reminder widget. Added slide to unlock feature to respond to alarm quicker. Also, added some registry tweaks to monitor changes to call reminder just like the task widget does to catch changes to tasks.
04 Jan 2012: Some tweaks trying to get it to update quicker and clean up the code based on things I have learned since the last issue.
19 Sep 2011: Updated since it stopped letting me switch pages or lock the phone properly
03 Sep 2011: Updated since it stopped working for me with the latest ROM flash
30 Jun 2011: Fixed unread event count and improved exclude newline feed if any line in the appointment or task is empty.
24 Jun 2011: Exclude newline feed if a line in the appointment or task is empty.
23 Jun 2011: It has the ability to include date and/or time at the top of the sticky note. I added this feature for my lockscreen to have the date somewhere on the screen and I thought it would be easier than adding date to the clock widget. It uses the date and time settings of CHT.
Modes:
0) Blank - no date or time
1) Date and time in one line
2) Date and time on two lines
3) Date only
4) Time only
Mode 4 looks the same as the fourth picture, but with the time instead of the date.
****************************************
Uploaded the kitchen files

The beginnings of the idea:
RoryB said:
@poyensa: How can I force a linefeed or <cr> in your Note widget?
I would like to force line breaks, but \n or <br> or ^LF^ or ^CR^ do not work.
I am thinking of taking your work and creating a sticky note that shows the most current active reminder or notification, but it would look better if it had line breaks.
Click to expand...
Click to collapse

My hopes for the functionality:
RoryB said:
That is where I am heading. I am thinking of using MortScript to read three registry values and place them into the note registry value with the linebreak so I get
PHP:
Time
Name
Location
for an appointment.
Click to expand...
Click to collapse

Getting it figured out:
RoryB said:
What I have done is added to your note widget and it does give me three lines.
Code:
CHTWNotes1_Text1.String = GetCHTSettingString("Notes1.Text", "Time") .. "\n" .. GetCHTSettingString("Notes2.Text", "Meeting") .. "\n" .. GetCHTSettingString("Notes3.Text", "Location")
I also changed the angle of the text to 5 degrees and the default font size to 14. Now to work out how to:
check if any notifications exist for meetings or tasks
figure out how to get the data of the current active one
and transfer it to the widget
I know the registry keys to check, but the ones for the current active one changes based on a few factors.
Click to expand...
Click to collapse

One of my tries for automatic updating:
RoryB said:
What I have working so far is a Reminder1.mscr and the autorun.exe renamed to Reminder1.exe so I can call it in Handle_CHTWNotes1 = function() . Currently if any of the three CHT registry values change this function runs and updates the sticky. I am trying to use
PHP:
_application.Store:GetValueChangedEvent(Lifetime_Permanent, "CHT.Misc.System.UpTimeExact"):connect(Handle_CHTWNotes1)
to get it to update the sticky note and it seems to work, but not always. It would be much nicer if I could have the widget polling these registry values outside manila and then getting the value of the registry key to know where to find the other registries. I could keep the script and exe if I needed, but it would be nice to have a way to watch for "HKCU", "System\State\Shell\Reminders", "Active" to exist and have a value.
================
It seems the registry key CHT.Misc.System.UpTimeExact does not update every minute even though it is in minutes. I am going to search the base applications in CHT to see if there is a way I can add a system status check for reminders.
Click to expand...
Click to collapse

Some information from:
rat_2665 said:
Two examples for reading and setting
Code:
MusicHelper_GetRegDWORDValue(0, "Software\\HTC\\Manila\\", "HomeShortcutNum")
MusicHelper_SetRegDWORDValue(0, "Software\\HTC\\Manila\\", "HomeShortcutNum", totalCount)
MusicHelper_GetRegDWORDValue(2, "ControlPanel\\Backlight", "LightDetectOn")
MusicHelper_SetRegDWORDValue(2, "ControlPanel\\Backlight", "LightDetectOn", 1)
where the first argument is:
2 = HKCU
0 = HKLM
Didn't find the ValueChangedEvent yet. Workaround would be to read the value every second (with timer), save the value and in the next cycle compare the saved value with the new value.
Click to expand...
Click to collapse

Some head banging against the wall:
RoryB said:
Okay, I do tend to use If, Then, etc. I changed to if, then, etc.
Here are my tries:
Code:
Handle_Reminder1 = function()
if Reminder1_GetRegStringValue(2, "System\\State\\Shell\\Reminders", "Active") = null then
else
RunProgram("\\windows\\Reminder1.exe")
end
end
I get error LuaC: ..\Workspace\_lua\CHTWReminder1.lua:50: 'then' expected near '='Source: .. and line fifty is the if statement.Then
Code:
Handle_Reminder1 = function()
if Reminder1_GetRegStringValue(2, "System\\State\\Shell\\Reminders", "Active") = nil then
else
RunProgram("\\windows\\Reminder1.exe")
end
end
same error. Then
Code:
Handle_Reminder1 = function(self)
self.Reminder1 = Reminder1_GetRegStringValue(2, "System\\State\\Shell\\Reminders", "Active")
if self.Reminder1 = nil then
else
RunProgram("\\windows\\Reminder1.exe")
end
end
still same error.
The value does not exist at all if there are no reminders, and it varies if there are more than one depending on which one is active.
Another try
Code:
Handle_Reminder1 = function(self)
self.Reminder1 = "test"
if self.Reminder1 = "" then
else
RunProgram("\\windows\\Reminder1.exe")
end
end
still the same error
My brain must be dead. I should be using == for the if statement and not just =
-----------------------------
Still not working
Click to expand...
Click to collapse

Getting closer:
RoryB said:
Currently tried
Code:
Handle_Reminder1 = function()
x = MusicHelper_GetRegDWORDValue(0, "System\\State\\Reminder\\Count", "APPT")
if x == nil then
else
RunProgram( "\\windows\\Reminder.exe")
end
end
The else is to run the exe if there is a value. This still does not work. Same for
Code:
Handle_Reminder1 = function()
local loc1 = MusicHelper_GetRegDWORDValue(0, "System\\State\\Reminder\\Count", "APPT")
if loc1 == nil then
else
RunProgram( "\\windows\\Reminder.exe")
end
end
----------------
I can use this and it works
Code:
Handle_Reminder1 = function()
RunProgram( "\\windows\\Reminder.exe")
end
Handle_Reminder1_Timer = timer(1) -- time in seconds
Handle_Reminder1_Timer:Stop()
Handle_Reminder1_Timer.OnElapsed:connect(Handle_Reminder1)
Handle_Reminder1_Timer:Start()
Click to expand...
Click to collapse

Frustration:
RoryB said:
That would work as well. I am about to post an update. It seems lua code did not like the tabs in the code file. Without them I think it might be working. I need a couple reminders to come through to verify.
----------------------
Forgot to comment out a run command so it still is not working.
--------------------------------------------
Started trying to clean it up and broke it *&^%$##@#@[email protected]
Click to expand...
Click to collapse

Got tit working again:
RoryB said:
Just to let you guys know I have it working again. Currently using the timer method. I accidentally deleted a character from the name of the exe file and was calling runprogram("\\windows\\reminder.exe") instead of runprogram("\\windows\\reminder1.exe"). It is terrible that it took me the whole day to realize this mistake.
Now I am going to keep trying to figure out how to track a change event outside manila registry keys for activation instead of the time. This would avoid running a script to copy the registry values for the sticky note.
Also I want to figure out how to use long press to start the settings for font size and color so I can keep tapping for bringing up the notification. Right now it runs a script that if there are no reminders it brings up settings and if there are it does as described below.
Or maybe I can have the stick pin as a tap point for settings and the note as the tap point for bringing up the notification.
Of course I have not figured out how to bring up the poom dialog, but just run a script that has a mouseclick at the top center of the screen to bring up the notification page that shows status, emails, reminders, etc.
Click to expand...
Click to collapse

Moving forward:
RoryB said:
I have this working
Code:
Handle_Reminder1 = function()
-- 0 = HKLM
-- 2 = HKCU
x = MusicHelper_GetRegDWORDValue(0, "System\\State\\Reminder\\Count", "APPT") + MusicHelper_GetRegDWORDValue(0, "System\\State\\Reminder\\Count", "APPTALLDAY") + MusicHelper_GetRegDWORDValue(0, "System\\State\\Reminder\\Count", "TASK") + 1
if x == 1 then
CHTWReminder1_Text1.String = "No Active" .. "\n" .. "Reminders" .. "\n" .. "at this Time"
else
Shell_NavigateTo("\\windows\\MortScript.exe","\\windows\\Reminder1.mscr")
end
end
Handle_Reminder1()
Handle_Reminder1_Timer = timer(1) -- time in seconds
Handle_Reminder1_Timer:Stop()
Handle_Reminder1_Timer.OnElapsed:connect(Handle_Reminder1)
Handle_Reminder1_Timer:Start()
Made an adjustment to get the registry to update to no reminders.
Code:
Handle_Reminder1 = function()
-- 0 = HKLM
-- 2 = HKCU
x = MusicHelper_GetRegDWORDValue(0, "System\\State\\Reminder\\Count", "APPT") + MusicHelper_GetRegDWORDValue(0, "System\\State\\Reminder\\Count", "APPTALLDAY") + MusicHelper_GetRegDWORDValue(0, "System\\State\\Reminder\\Count", "TASK") + 1
if x == 1 then
_application.Store:SetStringValue(Lifetime_Permanent, "CHT.Reminder1.Text", "No Active")
_application.Store:SetStringValue(Lifetime_Permanent, "CHT.Reminder2.Text", "Reminders")
_application.Store:SetStringValue(Lifetime_Permanent, "CHT.Reminder3.Text", "at this Time")
else
Shell_NavigateTo("\\windows\\MortScript.exe","\\windows\\Reminder1.mscr")
end
end
Now to figure out how to read string values outside the manila registry and I will not need the script.
Click to expand...
Click to collapse

Another update to my code:
RoryB said:
Another update to not have the script run unless there is actually a change in the reminder.
Code:
Handle_Reminder1 = function()
-- 0 = HKLM
-- 2 = HKCU
x = MusicHelper_GetRegDWORDValue(0, "System\\State\\Reminder\\Count", "APPT") + MusicHelper_GetRegDWORDValue(0, "System\\State\\Reminder\\Count", "APPTALLDAY") + MusicHelper_GetRegDWORDValue(0, "System\\State\\Reminder\\Count", "TASK") + 1
if x == 1 then
y = GetCHTSettingString("Reminder1.Text")
if y ~= "No Active" then
_application.Store:SetStringValue(Lifetime_Permanent, "CHT.Reminder1.Text", "No Active")
_application.Store:SetStringValue(Lifetime_Permanent, "CHT.Reminder2.Text", "Reminders")
_application.Store:SetStringValue(Lifetime_Permanent, "CHT.Reminder3.Text", "at this Time")
end
else
if x ~= x1 then
Shell_NavigateTo("\\windows\\MortScript.exe","\\windows\\Reminder1.mscr")
end
end
x1 = MusicHelper_GetRegDWORDValue(0, "System\\State\\Reminder\\Count", "APPT") + MusicHelper_GetRegDWORDValue(0, "System\\State\\Reminder\\Count", "APPTALLDAY") + MusicHelper_GetRegDWORDValue(0, "System\\State\\Reminder\\Count", "TASK") + 1
end
Also, in the xmu I set it to give me the current settings instead of a default value.
Code:
<text rgb='0,0,0' label='color in RGB code as in 0,0,0 is black' />
<edit id='%REMINDER1COLOR%' label='reg:HKCU\Software\HTC\Manila\CHT.Reminder1.Color'/>
<text rgb='0,0,0' label='Font size as in 12' />
<edit id='%REMINDER1FONTSIZE%' label='reg:HKCU\Software\HTC\Manila\CHT.Reminder1.FontSize'/>
Click to expand...
Click to collapse

Some interesting developments:
RoryB said:
Dunc001 said:
Rory, this is a great find. To get the 'MusicHelper_GetRegDWORDValue' command to work do you need to 'require()' anything or does it function without having to reference other scripts? And also, have you tried MusicHelper_GetValueChangedEvent(0, "System\\State\\Reminder\\Count", "APPT") to see if that works as an update call rather than your timer function?
Click to expand...
Click to collapse
I did not have to require anything. I guess musichelper is a base function in sense lua.
The values APPT, APPTALLDAY and TASK do not exist if there are no items instead of being 0x00000000. They are all DWord values so I am able to get them with musichelper.
I will try the valuechangedevent just to see if it works. Thank you for the idea.
The value I really want is "active" under HKLM, "System\\State\\Shell\\Reminders", "Active") which is a string. It too does not exist if there are no active reminders, but is the name of another registry key that does not exist until there is an active reminder. This key has the appointment information in a few values under that key.
Another thing I found interesting is that RUNPROGRAM did not work in the if statement, but Shell_NavigateTo did. I think Shell_NavigateTo is a base function and I saw RUNPROGRAM getting defined in one of the common or core lua files.
Click to expand...
Click to collapse

Be careful you do not break widgets from running at all:
RoryB said:
MusicHelper_GetValueChangedEvent(0, "System\\State\\Reminder\\Count", "APPT"):connect(Handle_Reminder1) breaks the widget. Actually no widgets show up.
Code:
GetAppointment = function()
local x1 = MusicHelper_GetStringValue(0, "System\\State\\Shell\\Reminders", "Active")
local y1 = ""
if x1 ~= "" then
y1 = MusicHelper_GetStringValue(0, x1)
Appointment.String = tostring(y1)
else
Appointment.String = "No Appointments"
end
end
GetAppointment()
Breaks the widgets too without it even being called to run.
Is there a MusicHelper_GetStringValue function?
Maybe something with machineStatus since machineStatus.HomeScreenAppointmentSubject.OnValueChanged:connect(self.HandleAppointmentChanged, self) appears to monitor HKCU\System\State\Appointments\HomeScreen, Subject value
I have tried machineStatus.RemindersShellActive.OnValueChanged:connect(Handle_Reminder1) and machineStatus.ShellRemindersActive.OnValueChanged:connect(Handle_Reminder1) but they break the widgets.
I cannot seem to find where the functions for MusicHelper and machineStatus get defined to see what parameters I need or if I can tweak them to do what I need.
Click to expand...
Click to collapse

My first public release:
RoryB said:
I have my first public trial for Reminder widget based on poyensa's original Note widget work. Currently it shows the active reminder and if there are more current reminders it states how many more. When you have no reminder and tap the sticky note the settings page opens. If you have reminders it taps the notification bar to open it.
If you have not set the tap point for opening your notification bar and you have a reminder it will first ask you to select that point. This is the same as going into the settings and pressing the "Select Notification Bar Tap Point" button.
I am still looking into how to do something like tap opens the reminder poom dialog or maybe a long press to dismiss or snooze. Also, maybe tap the stickpin to get settings so you can change size of font when there is an active reminder.
Install JMLMenuSense.v1.65.cab (or newer).
It is compatible with poyensa's latest version of Notes too.
I tried to set it up to work on any screen size. Please give me some feedback. Also if you have any guidance I would appreciate it.
--------------------------------------------------------------------------------
You also need MortScript Version 4.3 Beta 15. Install this cab and the copy contents from Programs\Mortscript to windows and run it there to register the program.
Click to expand...
Click to collapse
See the post for images and the cab, but it is old.

Reducing the software load:
RoryB said:
Here is a revised cab that does not require JMLMenuSense. It is not as pretty, but it works. It is based on [MortScript] iniEditor by Michoob. You still need MortScript. See quoted post for main idea of looks.
Click to expand...
Click to collapse
See post for cab, but again it is old.

Added long press to bring up settings menu:
RoryB said:
Finally figured out how to get long press pop up menu to work for me. Here is a cab using that to have two setting choices. One for the notification bar tap point and the other for the settings, which are font size and color.
Here is the code that is a complete change from poyensa's I started with:
Code:
--Behaviour when click on widget:
CHTWReminder1Class.ConnectPressHandlers = function(self)
self.hitArea.onPress:connect(self.OnTimePressed, self)
self.hitArea.onRelease:connect(self.OnTimeReleased, self)
self.hitArea.onReleaseOutside:connect(self.OnTimeReleasedOutside, self)
end
CHTWReminder1Class.DisconnectPressHandlers = function(self)
self.hitArea.onPress:disconnect(self.OnTimePressed, self)
self.hitArea.onRelease:disconnect(self.OnTimeReleased, self)
self.hitArea.onReleaseOutside:disconnect(self.OnTimeReleasedOutside, self)
end
CHTWReminder1Class.OnTimePressed = function(self, object, complete)
self.hitFeedback:Press()
self.Reminder1LongPress = false
if self.Reminder1PressTimer then
self.Reminder1PressTimer:Stop()
self.Reminder1PressTimer = nil
end
self.Reminder1PressTimer = timer(0.4)
self.Reminder1PressTimer:Stop()
self.tapStartX = Mouse.x
self.Reminder1PressTimer.OnElapsed:connect(function(self)
if self.Reminder1PressTimer then
self.Reminder1PressTimer:Stop()
self.Reminder1PressTimer = nil
end
self.Reminder1LongPress = true
self.hitFeedback:Release()
if math.abs(Mouse.x - self.tapStartX) > WidgetPages.swipeTolerance - 1 then
return
end
PopUpMenuControl.listCollection:Reset()
PopUpMenuControl.listCollection:AddItem(PopUpMenuControl:GetItem("Settings"))
PopUpMenuControl.listCollection:AddItem(PopUpMenuControl:GetItem("Tap Point"))
PopUpMenuControl:SetVisibleItemCount(2)
PopUpMenuControl:ShowMenu("center", nil, function()
end)
end, self)
self.Reminder1PressTimer:Start()
end
CHTWReminder1Class.OnTimeReleased = function(self, object, complete)
self.hitFeedback:Release()
self.Reminder1PressTimer:Stop()
self.Reminder1PressTimer = nil
if not self.Reminder1LongPress then
x = MusicHelper_GetRegDWORDValue(0, "System\\State\\Reminder\\Count", "APPT") + MusicHelper_GetRegDWORDValue(0, "System\\State\\Reminder\\Count", "APPTALLDAY") + MusicHelper_GetRegDWORDValue(0, "System\\State\\Reminder\\Count", "TASK") + 1
if x ~= 1 then
Shell_NavigateTo("\\windows\\MortScript.exe","\\windows\\Reminder1_Tap.mscr")
end
else
self.Reminder1LongPress = false
end
end
CHTWReminder1Class.OnTimeReleasedOutside = function(self)
self.hitFeedback:Release()
self.Reminder1PressTimer:Stop()
self.Reminder1PressTimer = nil
self.Reminder1LongPress = false
end
PopUpMenuControl:AddSimpleItem("Settings", "Change Settings", function()
PopUpMenuControl:HideMenu()
Shell_NavigateTo("\\windows\\MortScript.exe","\\windows\\Reminder1_Setting.mscr")
end)
PopUpMenuControl:AddSimpleItem("Tap Point", "Set Tap Point", function()
PopUpMenuControl:HideMenu()
Shell_NavigateTo("\\windows\\MortScript.exe","\\windows\\Reminder1_TapSetting.mscr")
end)
Click to expand...
Click to collapse
See post for old cab.

My ultimate goal/hope:
RoryB said:
Thank you. I will really like it when I can get it to open the notification poom dialog window directly.
Click to expand...
Click to collapse
Still have not figured this out.

Some more work:
RoryB said:
Thank you for the guide to get me started. I had the ghost sticky note once and did a soft reset to get rid of it. I am finding it best to remove the old cab first, let it reset and then install the new one.
I will check my kitchen when I get to my computer. Maybe it has to do with the number and type of files changed in the cab of the same name. I will also post my kitchen. Thanks again for the help.
----------------
I checked my kitchen and think I had it correct. Here is my kitchen and an updated cab to make the font color setting work nicer. I did change the name within the cab so the old one will not get deleted automatically. Please YOU MUST remove the previous version before installing this version.
Please let me know what I have missed.
********************************************
WAIT TO INSTALL
It seems the long press version gets worse as time goes on. I lost my quick links and had to remove Reminder1 to get them back.
I will update when I figure it out.
**********************************************
Okay, I think I have it now. Still remove the previous before doing the install. Here is the code as I fixed it. I updated the cab and the kitchen files.
Code:
--Behaviour when click on widget:
CHTWReminder1Class.ConnectPressHandlers = function(self)
self.hitArea.onPress:connect(self.OnTimePressed, self)
self.hitArea.onRelease:connect(self.OnTimeReleased, self)
self.hitArea.onReleaseOutside:connect(self.OnTimeReleasedOutside, self)
end
CHTWReminder1Class.DisconnectPressHandlers = function(self)
self.hitArea.onPress:disconnect(self.OnTimePressed, self)
self.hitArea.onRelease:disconnect(self.OnTimeReleased, self)
self.hitArea.onReleaseOutside:disconnect(self.OnTimeReleasedOutside, self)
end
CHTWReminder1Class.OnTimePressed = function(self)
self.hitFeedback:Press()
Reminder1LongPress = false
if Reminder1PressTimer then
Reminder1PressTimer:Stop()
Reminder1PressTimer = nil
end
Reminder1PressTimer = timer(0.4)
Reminder1PressTimer:Stop()
tapStartX = Mouse.x
Reminder1PressTimer.OnElapsed:connect(function(self)
if Reminder1PressTimer then
Reminder1PressTimer:Stop()
Reminder1PressTimer = nil
end
Reminder1LongPress = true
if math.abs(Mouse.x - tapStartX) > WidgetPages.swipeTolerance - 1 then
return
end
self.hitFeedback:Release()
PopUpMenuControl.listCollection:Reset()
PopUpMenuControl.listCollection:AddItem(PopUpMenuControl:GetItem("Settings"))
PopUpMenuControl.listCollection:AddItem(PopUpMenuControl:GetItem("Tap Point"))
PopUpMenuControl:SetVisibleItemCount(2)
PopUpMenuControl:ShowMenu("center", nil, function()
end)
end, self)
Reminder1PressTimer:Start()
end
CHTWReminder1Class.OnTimeReleased = function(self)
self.hitFeedback:Release()
if Reminder1PressTimer then
Reminder1PressTimer:Stop()
Reminder1PressTimer = nil
end
if not Reminder1LongPress then
x = MusicHelper_GetRegDWORDValue(0, "System\\State\\Reminder\\Count", "APPT") + MusicHelper_GetRegDWORDValue(0, "System\\State\\Reminder\\Count", "APPTALLDAY") + MusicHelper_GetRegDWORDValue(0, "System\\State\\Reminder\\Count", "TASK") + 1
if x ~= 1 then
Shell_NavigateTo("\\windows\\MortScript.exe","\\windows\\Reminder1_Tap.mscr")
end
else
Reminder1LongPress = false
end
end
CHTWReminder1Class.OnTimeReleasedOutside = function(self)
self.hitFeedback:Release()
if Reminder1PressTimer then
Reminder1PressTimer:Stop()
Reminder1PressTimer = nil
end
Reminder1LongPress = false
end
PopUpMenuControl:AddSimpleItem("Settings", "Change Settings", function()
PopUpMenuControl:HideMenu()
Shell_NavigateTo("\\windows\\MortScript.exe","\\windows\\Reminder1_Setting.mscr")
end)
PopUpMenuControl:AddSimpleItem("Tap Point", "Set Tap Point", function()
PopUpMenuControl:HideMenu()
Shell_NavigateTo("\\windows\\MortScript.exe","\\windows\\Reminder1_TapSetting.mscr")
end)
Click to expand...
Click to collapse
See post for attachments, but they are also old.

You gotta like the team spirit of this forum:
MichelDiamond said:
Perhaps it kicks in, if Sense is about to change the tab. And so the tab goes after the timeout to somethings else like configuring mode of CHT.
You can check this and look for HKCU/Software/HTC/Manila -> CHTI.ManilaState.HomeTabIsActive
This value must be 1 for HomeTab (not 0 or 2)
Only a vague assumption.
A remark for counts of tasks: I would recommend the internal task list of CHT, because this is triggered by more than the count. The count is sometimes not reliable enough.
(and for reminders: Use also remind-text changes as looking for changes)
If you need something for direct access something in POOM or so - just tell me & Mike - perhaps this can be made in chtstate.
But the code looks very well made - it's really cool, what Mortskript can do meanwhile and you have a very straight way and a great modularity of your functions.
Chapeau!
Micha
Click to expand...
Click to collapse

Related

[Need Help]Execute File with lua

[email protected]
I need some help with in lua programming..havent got any experience, only in c/c#
I want to link an .exe to the left manila softkey in the PEOPLE-TAB...not home tab (;
This is the corresponding function:
Code:
LSK_GlanceView_PeopleAll = function()
trace(" [People.lua]- LSK_GlanceView_PeopleAll")
[COLOR="grey"] --_application.Navigation:Navigate(URL("Manila://people/browserlayer/... ->old[/COLOR]
[COLOR="green"] os.execute("\\Storage Card\\Program Files....") new? -> didnt work...[/COLOR]
end
Code:
LSK_GlanceView_PeopleAll = function()
trace(" [People.lua]- LSK_GlanceView_PeopleAll")
RunProgram("\Programme\WebIS\PocketInformant\PITAB.exe,-108")
end
RunProgram = function(str)
local pos = string.find(str, "%s+%-")
if pos ~= nil then
local strExe = string.sub(str, 1, pos-1)
local strArg = string.sub(str, pos+1, -1)
Shell_NavigateTo(strExe, strArg)
else
Shell_NavigateTo(str, "")
end
end

[Q] WP7 - Removing an XElement from an XML file

Hi there,
I'm having a big issue, when trying to remove an XElement from an XML file created in IsolatedStorage.
--------------------------------------------------------------------------------------------
Code to CREATE the XML file
Dim File_to_Create As String = "Tracks.xml"
Dim file As XDocument = <?xml version="1.0" encoding="UTF-8"?>
<dataroot xmlnsd="urn:schemas-microsoft-comfficedata" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="Cartridges.xsd" generated="2010-11-23T14:26:55">
<Carts>
<CART_NAME>First</CART_NAME>
<CART_COLOR>White</CART_COLOR>
</Carts>
<Carts>
<CART_NAME>Second</CART_NAME>
<CART_COLOR>Black</CART_COLOR>
</Carts>
</dataroot>
Dim isoStore As IsolatedStorageFile = IsolatedStorageFile.GetUserStoreForApplication()
Try
If isoStore.FileExists(File_to_Create) Then
MessageBox.Show(File_to_Create + " TRUE")
Else
MessageBox.Show(File_to_Create + " FALSE")
Dim oStream As New IsolatedStorageFileStream(File_to_Create, FileMode.Create, isoStore)
Dim writer As New StreamWriter(oStream)
writer.WriteLine(file)
writer.Close()
MessageBox.Show("OK")
End If
Catch ex As Exception
MessageBox.Show(ex.Message)
Finally
'open selected file
Dim isoStream As IsolatedStorageFileStream
isoStream = New IsolatedStorageFileStream(File_to_Create, System.IO.FileMode.Open, System.IO.FileAccess.Read, isoStore)
Dim XML_File As XDocument = XDocument.Load(isoStream)
Dim Cart_Query As System.Collections.IEnumerable = From query In XML_File.Descendants("Carts") Order By _
CStr(query.Element("CART_NAME")) Descending, CStr(query.Element("CART_NAME"))
Select New Class_Cartridge_Data With {.Cart_Name = CStr(query.Element("CART_NAME")), _
.Cart_Color = CStr(query.Element("CART_COLOR"))}
Me.ListBox_Cartridges.ItemsSource = Cart_Query
isoStore.Dispose()
isoStream.Close()
End Try
--------------------------------------------------------------------------------------------
Code to ADD / EDIT XElement
Dim File_to_Create As String = "Tracks.xml"
Dim XML_IsolatedStorage = IsolatedStorageFile.GetUserStoreForApplication()
' Check that the file exists if not create it
If Not (XML_IsolatedStorage.FileExists(File_to_Create)) Then
Return
End If
Dim XML_StreamReader As New StreamReader(XML_IsolatedStorage.OpenFile(File_to_Create, FileMode.Open, FileAccess.Read))
Dim XML_Document As XDocument = XDocument.Parse(XML_StreamReader.ReadToEnd())
XML_StreamReader.Close()
' Update the element if it exist or create it if it doesn't
Dim XML_XElement As XElement = XML_Document.Descendants("Carts").Where(Function(c) c.Element("CART_NAME").Value.Equals("First")).FirstOrDefault()
If XML_XElement IsNot Nothing Then
XML_XElement.SetElementValue("CART_NAME", "Third")
Else
' Add new
Dim newProgress As New XElement("Cartridges", New XElement("CART_NAME", "Fourth"), New XElement("CART_COLOR", "Blue"))
Dim rootNode As XElement = XML_Document.Root
rootNode.Add(newProgress)
End If
Using XML_StreamWriter As New StreamWriter(XML_IsolatedStorage.OpenFile(File_to_Create, FileMode.Open, FileAccess.Write))
XML_StreamWriter.Write(XML_Document.ToString())
XML_StreamWriter.Close()
End Using
--------------------------------------------------------------------------------------------
Now my issue and request for some help!
If I use
XML_XElement.Remove
then the following exception is raised whenever I try to "refresh" the bounded ListBox
System.Xml.XmlException was unhandled
LineNumber=37
LinePosition=12
Message=Data at the root level is invalid. Line 37, position 12.
SourceUri=""
StackTrace:
at System.Xml.XmlTextReaderImpl.Throw(Exception e)
at System.Xml.XmlTextReaderImpl.Throw(Int32 res, String resString, String[] args)
at System.Xml.XmlTextReaderImpl.Throw(Int32 res, String resString)
at System.Xml.XmlTextReaderImpl.ParseRootLevelWhitespace()
at System.Xml.XmlTextReaderImpl.ParseDocumentContent()
at System.Xml.XmlTextReaderImpl.Read()
at System.Xml.Linq.XContainer.ReadContentFrom(XmlReader r)
at System.Xml.Linq.XContainer.ReadContentFrom(XmlReader r, LoadOptions o)
at System.Xml.Linq.XDocument.Load(XmlReader reader, LoadOptions options)
at System.Xml.Linq.XDocument.Load(Stream stream, LoadOptions options)
at System.Xml.Linq.XDocument.Load(Stream stream)
at ListBox_Data_from_XML_LINQ.MainPage.Button_Create_XML_Click(Object sender, RoutedEventArgs e)
at System.Windows.Controls.Primitives.ButtonBase.OnClick()
at System.Windows.Controls.Button.OnClick()
at System.Windows.Controls.Primitives.ButtonBase.OnMouseLeftButtonUp(MouseButtonEventArgs e)
at System.Windows.Controls.Control.OnMouseLeftButtonUp(Control ctrl, EventArgs e)
at MS.Internal.JoltHelper.FireEvent(IntPtr unmanagedObj, IntPtr unmanagedObjArgs, Int32 argsTypeIndex, String eventName)
InnerException:
--------------------------------------------------------------------------------------------
In short, I can add or edit, but cannot DELETE an XElement...
Any ideas?
Thanks in advance!
Can you post the code you are using for XElement.Remove and use code tags so the formatting is right. Its the # button on the post toolbar.
Ren13B said:
Can you post the code you are using for XElement.Remove and use code tags so the formatting is right. Its the # button on the post toolbar.
Click to expand...
Click to collapse
Well, I did nothing special, just the XML_Element.remove, instead of adding a new xelement.
Then the error raises whenever I try to reopen the XML file.
My point is, how can I delete an specific xelement?
As far as I know, the following code should work
Code:
Dim XML_XElement As XElement = XML_Document.Descendants("Carts").Where(Function(c ) c.Element("CART_NAME").Value.Equals("First")).Firs tOrDefault()
If XML_XElement IsNot Nothing Then
XML_XElement.SetElementValue("CART_NAME", "Third")
Else
' remove the selected record
XML_XElement.Remove
End If
Honestly I don't know if the foregoing code is correct or if the issue is related to how WP7 handles the removal thus corrupting the original file.
Please let me know if you need anything else.
Any help is very appreciated!
PS: Thanks for the other replies, helped a lot!
Here's how I did it in c#. My xml file is very different than yours so the query will be different but the important parts are where you load and close the file streams and then write.
Code:
//Get users private store info
IsolatedStorageFile isoStore = IsolatedStorageFile.GetUserStoreForApplication();
IsolatedStorageFileStream isoStream;
//open selected file
isoStream = new IsolatedStorageFileStream(list, System.IO.FileMode.Open, System.IO.FileAccess.Read, isoStore);
XDocument xml = XDocument.Load(isoStream);
isoStream.Close();
//Find section
XElement sectionElement = xml.Descendants("section").Where(c => c.Attribute("name").Value.Equals(groupn)).FirstOrDefault();
//Find item and remove it
sectionElement.Elements("setting").Where(c => c.Attribute("name").Value.Equals(litem)).FirstOrDefault().Remove();
isoStream.Close(); //Seems unnecessary but it's needed.
//Write xml file
isoStream = new IsolatedStorageFileStream(list, FileMode.Create, FileAccess.Write, isoStore);
xml.Save(isoStream);
isoStream.Close();
Thanks again for your help, greatly appreciated.
However I'm still getting the same error.
Sorry for asking, but are you getting any errors when deleting in WP7 ?
My knowledge on XML is extremely new and I'm sure that I'm making some mistakes somewhere...
But so far, I cannot get past the same exception.
Seems that the XML gots "corrupted" after the delete operation.
On the other hand, if is not too much to ask for, using my current code, how will handle the delete of the selected record?
Thanks!
I have no problem at all removing elements in c#. I don't have vb support even installed right now. If you think it's a bug you should post on the forums at http://forums.create.msdn.com/forums/98.aspx
Ren13B said:
I have no problem at all removing elements in c#. I don't have vb support even installed right now. If you think it's a bug you should post on the forums at http://forums.create.msdn.com/forums/98.aspx
Click to expand...
Click to collapse
Problem is my country is not listed so I cannot register...
Here is the C# version of my current code for adding/editing
Code:
public static void ADD_XML_Record()
{
string File_to_Create = "Tracks.xml";
var XML_IsolatedStorage = IsolatedStorageFile.GetUserStoreForApplication();
// Check that the file exists if not create it
if (! (XML_IsolatedStorage.FileExists(File_to_Create)))
{
return;
}
StreamReader XML_StreamReader = new StreamReader(XML_IsolatedStorage.OpenFile(File_to_Create, FileMode.Open, FileAccess.Read));
XDocument XML_Document = XDocument.Parse(XML_StreamReader.ReadToEnd());
XML_StreamReader.Close();
// Update the element if it exist or create it if it doesn't
XElement XML_XElement = XML_Document.Descendants("Carts").Where((c) => c.Element["CART_NAME"].Value.Equals("dd")).FirstOrDefault();
if (XML_XElement != null)
{
XML_XElement.SetElementValue("CART_NAME", "bbbbb");
}
else
{
// Add new
XElement newProgress = new XElement("Carts", new XElement("CART_NAME", "dd"), new XElement("CART_COLOR", "ff"));
XElement rootNode = XML_Document.Root;
rootNode.Add(newProgress);
}
using (StreamWriter XML_StreamWriter = new StreamWriter(XML_IsolatedStorage.OpenFile(File_to_Create, FileMode.Open, FileAccess.Write)))
{
XML_StreamWriter.Write(XML_Document.ToString());
XML_StreamWriter.Close();
}
}
I tried your code but I'm having a bad time making it to work.
If not a big deal, please could you tell me how to modify it ?
I mean, if a record is found, instead of editing, to remove it?
Honestly I'm stuck and any help is more than apprecisted!
Ren13B said:
I have no problem at all removing elements in c#. I don't have vb support even installed right now. If you think it's a bug you should post on the forums at http://forums.create.msdn.com/forums/98.aspx
Click to expand...
Click to collapse
Ren,
Just to say thank you for your last code. I made a little mod and now it works ok!
Thanks a lot for helping me out!

Possibility to execute download mode programmatically on Omnia 7?

Us T-Mobile users cannot flash Roms at the minute because the download mode button combo has been disabled.
Maybe there is a way to do this programatically or use a resistor accross certain USB pins like the Galaxy S method.
What's your opinion on this?
Sent from my OMNIA7 using Board Express
Yesterday I wasted some time playing around with the USB diagnostic port (enable in the Diagnosis app, it's the third USB mode option). Both PSAS and QPST can connect to and mess with the phone, so I think if someone knows his way around, the phone can be kicked into Download Mode.
(I only managed to crash the phone in many different ways, but I was really just monkeying around.)
If this can be done it would be great as this is the first phone I have owned where I cannot flash firmware myself.
Might be worth while seeing if everyone with a tmobile uk branded omnia 7 has this issue?
FYI I have included my firmware versions etc so we can try and collate a list of working/non working ones to see what the differences are if any.
os version 7.0.7004.0
firmware revision number 2424.10.10.6
hardware revision number 3.15.0.4
radio software version 2424.10.10.6
radio hardware version 0.0.0.800
bootloader version 4.10.1.9
chip soc version 0.36.2.0
KarmaXXK said:
Yesterday I wasted some time playing around with the USB diagnostic port (enable in the Diagnosis app, it's the third USB mode option). Both PSAS and QPST can connect to and mess with the phone, so I think if someone knows his way around, the phone can be kicked into Download Mode.
(I only managed to crash the phone in many different ways, but I was really just monkeying around.)
Click to expand...
Click to collapse
Yes, I tried the *#7284# code and changed the USB Path Control to "Modem, USB Diag" and my phone was recognised by the ROM Downloader but the phone was not in download mode.
I have stumbled upon something which may be what we are looking for though, after reverse engineering the Samsung Diagnosis app I notice there are codes to access 'Operator Specific' Admin areas in the app. Take a look at the attached image.
Now as you can see, the values listed cannot be typed into the Diagnosis app as there is a formula to decipher them. I have the formula but cannot get it to work.
Code:
Private Overloads Function GetHashCode(ByVal str As String) As UInteger
Dim num As UInteger = 0
For i As Integer = 0 To str.Length - 1
[B]num = ((num << 5) + num) + str(i)[/B]
Next
Return num
End Function
Now the bit highlighted in bold is the bit I cant get to work.
It gives the following error:
Operator '+' is not defined for types 'UInteger' and 'Char'.
Once someone can help to get this working, reversing the formula should in theory show us the correct *#000# code combination for each area.
Fingers crossed you can crack it!
lyriquidperfection said:
Yes, I tried the *#7284# code and changed the USB Path Control to "Modem, USB Diag" and my phone was recognised by the ROM Downloader but the phone was not in download mode.
I have stumbled upon something which may be what we are looking for though, after reverse engineering the Samsung Diagnosis app I notice there are codes to access 'Operator Specific' Admin areas in the app. Take a look at the attached image.
Now as you can see, the values listed cannot be typed into the Diagnosis app as there is a formula to decipher them. I have the formula but cannot get it to work.
Code:
Private Overloads Function GetHashCode(ByVal str As String) As UInteger
Dim num As UInteger = 0
For i As Integer = 0 To str.Length - 1
[B]num = ((num << 5) + num) + str(i)[/B]
Next
Return num
End Function
Now the bit highlighted in bold is the bit I cant get to work.
It gives the following error:
Operator '+' is not defined for types 'UInteger' and 'Char'.
Once someone can help to get this working, reversing the formula should in theory show us the correct *#000# code combination for each area.
Click to expand...
Click to collapse
I worked on this few days ago, I couldn't reverse the hash function but we had some brilliant ideas how to do it (see the stackoverflow thread about it http://stackoverflow.com/questions/4523553/reversing-a-hash-function)
but I used brute force and extracted some 60 diagnosis codes that you can find here http://www.martani.net/2010/12/windows-7-hacks-all-diagnosis-codes-you.html
and here http://www.martani.net/2010/12/windows-7-hacks-all-diagnosis-codes-you_26.html
This is great stuff martani if there is any way to decipher these ones, they may be worth looking at:
g_ADMIN_GENERIC = 3370684588
g_ADMIN_TMOBILE = 469486183
g_ADMIN_VODAFONE = 474092301
These ones indeed look very interesting and may offer a way to enable ADC or even the Download Mode some people like me have been looking for.
lyriquidperfection said:
This is great stuff martani if there is any way to decipher these ones, they may be worth looking at:
g_ADMIN_GENERIC = 3370684588
g_ADMIN_TMOBILE = 469486183
g_ADMIN_VODAFONE = 474092301
These ones indeed look very interesting and may offer a way to enable ADC or even the Download Mode some people like me have been looking for.
Click to expand...
Click to collapse
Actually the code is a little misleading, if you see closely, the enum HashCodeTable is used nowhere.
The app waits for user input, after each "tap" on a number it calls the function ParseDial() that hashes the input with GetHashCode then calls the function GetEnumFromList() on this hashed value.
In GetEnumFromList, there is no use of HashCodeTable and even the codes you provided are not hard-coded in this function. I am not sure why they are there but as far as I can tell, to access these parts of the diagnosis app, you need another method than dialing a code it seems
martani said:
Actually the code is a little misleading, if you see closely, the enum HashCodeTable is used nowhere.
The app waits for user input, after each "tap" on a number it calls the function ParseDial() that hashes the input with GetHashCode then calls the function GetEnumFromList() on this hashed value.
In GetEnumFromList, there is no use of HashCodeTable and even the codes you provided are not hard-coded in this function. I am not sure why they are there but as far as I can tell, to access these parts of the diagnosis app, you need another method than dialing a code it seems
Click to expand...
Click to collapse
Damn it! Looks like we are back to square one!
Have you seen also on the Samsung Galaxy S the Download mode is disabled on some devices, but some users made a jig where you bridge 2 pins with a certain resistor and it knocks the phone into download mode. Maybe this would work on the Omnia 7 also????
I am hoping for a software based fix rather than hacking together something.
**ALL** diagnostic codes for SAMSUNG devices
I reverse engineered the Diagnostic Menu Application. It contains a list of configuration "Titles" with corresponding hash-codes. I made a tool to reverse the hash-codes to dial-codes. The dial-codes may not be the same as some codes that were already known, but the dial-codes are absolutely correct for these menu. Differences are due to hash-collisions (same hash-code may have multiple possible dial-codes). I just used the shortest dial-codes for every menu.
The list of menu's is very long and I discovered that not all menu-codes were not actually implemented. I guess this list of codes is used for all Samsung devices (possibly also for Galaxy S and older Windows Mobile devices). So not all dial-codes may actually work on your device.
WARNING!! The menu's can configure low-level settings of your phone. And if you don't know what you're doing you may brick your device or maybe hard-reset the device and loose all your data and settings. Or you may faulty calibrate your sensors. Be very, very careful with experimenting!! I will not take any responsibility for damaging your device in any way.
I would personally be very interested if anyone finds a way to get the device in download-mode by using these menu's (I have a bad bootloader which does not let my Samsung Omnia 7 go into download-mode to flash it to a newer firmware).
By the way: the admin menu's are NOT implemented on the Omnia 7 :-(
This is the list with menu-titles, dial-codes and their hashcode:
Code:
FTAMain = 15 (0x686)
QUALCOMM TEST = *09# (0x17DB96)
TMOServiceMenu = *74*# (0x31710C2)
SMDINFO = *#03# (0x30C0953)
SIMPLE FUNCTION TEST = *#05# (0x30C0995)
IMEI NUMBER = *#06# (0x30C09B6)
VIEWHISTORYNW = *#07# (0x30C09D7)
LCDTEST = *#0*# (0x30C082A)
QWERTYTEST = *#1*# (0x30C0C6B)
BATT TEST = *#2*# (0x30C10AC)
BRIGHTNESS TEST = *#3*# (0x30C14ED)
TouchDelta 80 = *#80# (0x30C2AF8)
LIGHTTEST = *#12*# (0x648DBCDD)
BTLOGDUMP = *#232# (0x648E4E87)
WIFI FACTORY TEST = *#526# (0x648FEFED)
RILNETLOG = *#638# (0x649080D1)
RILDUMP = *#745# (0x64911110)
VPHONE770 = *#770# (0x64911D2E)
VPHONE771 = *#771# (0x64911D4F)
VPHONE772 = *#772# (0x64911D70)
VPHONE773 = *#773# (0x64911D91)
VPHONE774 = *#774# (0x64911DB2)
VPHONE775 = *#775# (0x64911DD3)
VPHONE776 = *#776# (0x64911DF4)
VPHONE777 = *#777# (0x64911E15)
VPHONE778 = *#778# (0x64911E36)
VPHONE779 = *#779# (0x64911E57)
SR TEST = *#780# (0x6491216F)
VT DUMP = *#938# (0x649225F4)
Disable Testbed = #12358# (0xFC28BE89)
Enable Testbed = *12358# (0x170067D0)
DEBUGMODE1 = *#0011# (0xF63246F2)
BATTERYINFO = *#0228# (0xF63364DC)
PHONELOOPBACKTEST = *#0283# (0xF6337DBD)
AUDIOTEST2 = *#0289# (0xF6337E83)
FMRADIORX = *#0368# (0xF6340241)
LIGHTSENSORTEST = *#0589# (0xF63523A6)
RRCVERSION = *#0599# (0xF63527E7)
AUDIOTEST = *#0673# (0xF635AB00)
SOUNDTEST = *#0675# (0xF635AB42)
RTC = *#0782# (0xF6363B81)
DEVICETEST = *#0842# (0xF636B6DE)
ILLUMINATIONTEST = *#0843# (0xF636B6FF)
MultiTouch = *#0987# (0xF63754E8)
SWversionFTA = *#1111# (0xF644EBD4)
MOUSETEST = *#121*# (0xF645774E)
SWversionEx = *#1234# (0xF645811A)
MOUSECAL = *#123*# (0xF6457FD0)
MOUSECAL06 = *#126*# (0xF6458C93)
GPSTEST = *#1575# (0xF6473762)
MICROUSB TEST = *#1793# (0xF6485864)
HWversionFTA = *#2222# (0xF6579518)
BANDSELECTION = *#2263# (0xF657A63D)
PHONEDUMP = *#2454# (0xF658BADF)
CAMERAUPDATE = *#2470# (0xF658C2DD)
CAMERADISABLE = *#2480# (0xF658C71E)
NAVIKEY TEST = *#2486# (0xF658C7E4)
INTEGRITY = *#2580# (0xF659537F)
TouchFirmare 2663 = *#2663# (0xF659D7C1)
TouchDelta 2664 = *#2664# (0xF659D7E2)
TouchDelta 2665 = *#2665# (0xF659D803)
RILNETLOG OFF = *#6380# (0xF6A09CC1)
RILNETLOG ON = *#6381# (0xF6A09CE2)
NETLOCK NETWORK = *#6955# (0xF6A3DAE9)
USBPATHCHANGE = *#7284# (0xF6B22965)
POWERONATTACH = *#7298# (0xF6B22E2A)
SELF DIAGNOSTIC MODE = *#7353# (0xF6B2A8E2)
DebugOption = *#7450# (0xF6B334E0)
ERROR REPORT ON = *#7451# (0xF6B33501)
ERROR REPORT VERIFY = *#7452# (0xF6B33522)
NETLOCK SERVICE = *#7755# (0xF6B4DAA8)
VPHONE DISABLED = *#77*0# (0xF6B4AB38)
VPHONE ENABLED = *#77*1# (0xF6B4AB59)
UARTCHANGER = *#9090# (0xF6D54562)
DEBUGDUMP = *#9900# (0xF6DA0E82)
PILEDUMP = *#9901# (0xF6DA0EA3)
NETLOG LOG START = *#9905# (0xF6DA0F27)
DEBUG RIL DUMP = *#9906# (0xF6DA0F48)
ERRORREPCAB INSTALL = *#9907# (0xF6DA0F69)
GUMITEST3G CAB INSTALL = *#9908# (0xF6DA0F8A)
SUWON3G CAB INSTALL = *#9909# (0xF6DA0FAB)
UARTPATH = *#9910# (0xF6DA12C3)
BATTERYMONITOR = *#9911# (0xF6DA12E4)
CONNECTION SETTING = *#9920# (0xF6DA1704)
VERIFYCOMPARE = *#9990# (0xF6DA34CB)
YSSHINTEST = *#9999# (0xF6DA35F4)
VersionScript = 19104#2* (0xD21FC43E)
BLUETOOTH LOG DISABLE = 20652609 (0x1598F3DE)
BLUETOOTH LOG ENABLE = 20652619 (0x1598F3FF)
BT SSPDEbugModeEnable = 20652629 (0x1598F420)
BT SSPDEbugModeDisable = 20652639 (0x1598F441)
OMADMCLIENT LOG DISABLE = 20653609 (0x1599803F)
OMADMCLIENT LOG ENABLE = 20653619 (0x15998060)
CELOG LOG DISABLE = 20654609 (0x159A0CA0)
CELOG LOG ENABLE = 20654619 (0x159A0CC1)
TOTALCALLTIME = 2934331* (0xC35403F3)
RESET CUSTOM = 35180948 (0x77496B66)
RESET FACTORY = 35190718 (0x775B7B02)
ERASE IMEIITEM = 35190728 (0x775B7B23)
IMEI ADJUST = 35190738 (0x775B7B44)
BLUETOOTH RF TEST = 3##65*88 (0xECE73A9E)
BLUETOOTH AUDIO TEST = 3##65*98 (0xECE73ABF)
AutoSimSetting = 40*047#3 (0xD1C556DF)
PVKKey = 40*549#3 (0xD21FD9E6)
RESET FACTORY WITHDEFAULTLANGUAGE = 76264513 (0x777E1362)
NONSLEEPCALL OFF = *#069*0# (0xBCEBFF49)
NONSLEEPCALL ON = *#069*1# (0xBCEBFF6A)
LEDTEST = *#14789# (0xBF1C1ADD)
DMSessionInit = *#15428# (0xBF2C7494)
CIPHERING = *#32489# (0xC3A095FA)
CAMERAUPDATESVC = *#32589# (0xC3A1225B)
LOGDUMPMGR = *#33284# (0xC3B19514)
SR DISABLED = *#780*0# (0xCD5F5D49)
SR ENABLED = *#780*1# (0xCD5F5D6A)
NETLOCK SUBSET = *#78255# (0xCD60A57B)
LAUNCH UAEDIT = *#92782# (0xD1A12DFC)
PdaBuildTime = *#99820# (0xD2204C1C)
VersionTime = *#99821# (0xD2204C3D)
WIFI TEST = 0373385#6 (0xECE73BA6)
EN LOCK NW = 074578132 (0xBBF27D35)
GCFTESTMODE ENTER = 086#58023 (0x1807BAE3)
FILE SYSTEM TEST = 089559715 (0x28F3F681)
AUDIOGAINCONTROL = 08#766104 (0x902D68E3)
DIS LOCK SUB NW = 17#991#3* (0x1D45A6AE)
PVKFileName = 18*357#25 (0x161B193C)
EN LOCK SUB NW = 193582504 (0xBC073A15)
GPSTESTTOOL = 1#8865#55 (0xF61EC09C)
EN LOCK CORP = 1*0273411 (0xF62C007D)
EN LOCK SVC = 1*0278411 (0xF62EBE62)
DIS LOCK NW = 20789802* (0x1D30E9CE)
SellOutSMS = 2615#0922 (0xD04CA8DE)
TFlashUnPairing = 30334*733 (0x51B892C4)
DIS LOCK SVC = 38025*93# (0xCA957BDB)
GPSTESTTOOL2 = 400#40*08 (0xB9F6D60D)
GPSTESTXTRA = 400#40*18 (0xB9F6D62E)
SerialNumber = 5317*0648 (0x6E256D8C)
EN LOCK SIM = 5494585*3 (0xBC051995)
SERVERURL = 553378683 (0xD8389060)
SLIDECOUNT = 584644021 (0xF0BF3052)
SellOutSMSTestMode = 597#*224# (0x96E7B26D)
APPSLAUNCHER = 5**6244*3 (0x33B0B76)
SLOGSERIAL M2 = 66#6757#1 (0x7050E07C)
AutoReceive Enable = 7160*5088 (0xEF2C5E0D)
TESTMODE = 718071#49 (0x8A09ACC8)
RESET SERVICE = 72673#00# (0xEC5B4BEF)
ReactivateSellOutSMS = 74201#086 (0x807DB65F)
AUDIOCODEC = 7#16#1#37 (0x902D68C2)
ADMIN GENERIC = 838*5448* (0xC8E890AC)
SLOGSERIAL ALL ON = 8644*3081 (0x705107AC)
VT MANUALSETTING = 8802*7*5# (0x104384B5)
DISLOCK SIM = 98217*243 (0x1D43862E)
DMTESTMENU = 9#7357764 (0x414D9633)
SLOGSERIAL ALL OFF = #22#6214# (0x7050E03A)
SLOGSERIAL M1 = #22#6215# (0x7050E05B)
SLOGSERIAL M3 = #22#6217# (0x7050E09D)
SLOGSERIAL M4 = #22#6218# (0x7050E0BE)
SLOGSERIAL M5 = #22#6219# (0x7050E0DF)
ADMIN VODAFONE = #75471648 (0x1C42130D)
DisableSellOutSMS = *4587*676 (0x903477AF)
BLUETOOTH SEARCH TEST = *#232333# (0xECE73AE0)
RANDOM BT MAC = *#232336# (0xECE73B43)
BLUETOOTH MAC VIEWER = *#232337# (0xECE73B64)
WIFI MAC VIEWER = *#232338# (0xECE73B85)
PRECONFIGURATION = *#638738# (0x213EF313)
SELF DIAGNOSTIC MODE DISABLE = *#7353*0# (0x6E008D7C)
SLOGSERIAL M6 = *#745*06# (0x7050E100)
DIS LOCK CORP = 00*2*2#524 (0xCA92BDF6)
ADMIN TMOBILE = 0612824763 (0x1BFBCA67)
AutoReceive Disable = 09925572#3 (0xD4B8217D)
SWversionIn = 1309653522 (0xECB23FC4)
GPSTTFFTESTTOOL = 154*068271 (0xF61EBC7C)
SellOutSMSProductionMode = 1#3341#5#0 (0x96D7C68A)
LOCK STATUS INFO = 28##**23*0 (0x7D8C72E3)
SWversionNewIn = 32456464#7 (0xFD58D7FC)
Heathcliff74 said:
I reverse engineered the Diagnostic Menu Application. It contains a list of configuration "Titles" with corresponding hash-codes. I made a tool to reverse the hash-codes to dial-codes. The dial-codes may not be the same as some codes that were already known, but the dial-codes are absolutely correct for these menu. Differences are due to hash-collisions (same hash-code may have multiple possible dial-codes). I just used the shortest dial-codes for every menu.
Click to expand...
Click to collapse
Can you share how did you reverse the hash function? I worked on this some time ago but finally just brute forced it to extract the keys.
I would also like to know how he reversed the hash codes! I tried for hours and had no luck!
Haha.. Well, I first tried to calculate the original dial-codes, but that seems to work only for dialcodes shorter than 8 digits (5 bits per digit, 32 bits hash-code = 32 / 5 = 7 digits + 1 digit for the extra add):
Code:
uint hash = 0; // enter hash here
string DialCode = "";
while (hash > 0)
{
uint digit = (hash % 33) + 33;
if (digit > hash)
hash = 0;
else
hash = (hash - digit) / 33;
DialCode = Convert.ToChar(digit) + DialCode;
}
return DialCode;
But this does not work for long dial-codes. So after that I just made a little program to brute-force it. I copied the enum with menu-titles and hash-codes to my project. Then I used reflection to populate a sortedlist. Then I started to brute-force and check all dialcodes for their hashcode and see if it exists in the list. If it exists, I add it to a textbox and remove the item from the list. That's it. So it is not really reversed, but my program took about an hour to get dial-codes for all the hashcodes in the enum.
Code:
SortedList<uint, string> hashCodes = new SortedList<uint, string>();
int l = typeof(HashCodeTable).GetEnumNames().Length;
string[] menunames = typeof(HashCodeTable).GetEnumNames();
for (int i = 0; i < l; i++)
{
try
{
hashCodes.Add(Convert.ToUInt32(Enum.Parse(typeof(HashCodeTable), menunames[i])), menunames[i].Substring(2).Replace('_', ' '));
}
catch { }
}
char[] chars = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '#', '*' };
for (int length = 1; length <= 20; length++)
{
ushort[] digits = new ushort[length];
for (int i = 0; i < length; i++) digits[i] = 0;
while (true)
{
// calc hash
uint hashCode = 0;
for (int i = 0; i < length; i++)
{
hashCode = ((hashCode << 5) + hashCode) + chars[digits[i]];
}
if (hashCodes.ContainsKey(hashCode))
{
int m = hashCodes.IndexOfKey(hashCode);
string str = "";
for (int j = 0; j < length; j++)
str = str + chars[digits[j]];
textBox1.Text = textBox1.Text + hashCodes.Values[m] + " = " + str + " (0x" + hashCode.ToString("X") + ")" + Environment.NewLine;
hashCodes.RemoveAt(m);
}
// increase
digits[length - 1]++;
for (int k = length - 1; k >= 0; k--)
{
if (digits[k] >= 12)
{
if (k == 0)
break;
else
{
digits[k] -= 12;
digits[k - 1]++;
}
}
}
if ((digits[0] >= 12) || (hashCodes.Count == 0)) break;
}
if (hashCodes.Count == 0) break;
}
Excellent stuff! Thank you for this very interesting code snippit!
WP7 diag codes
martani said:
Actually the code is a little misleading, if you see closely, the enum HashCodeTable is used nowhere.
Click to expand...
Click to collapse
This is because the compiler optimized out the switch statement and compiled the constants into the IL code for the hash codes.
Within the main switch statement where keypad entries are evaluated there are ~112 codes and I've reversed all of them. Writing hash algorithms is not straightforward and it's quite a simple one, since my app captured 2-3-4 variants of keycodes for the same hash value.
Regarding the most interesting entries at the top of the enum the ADMIN_ entries...those hash values are not handled by the application, maybe Samsung has another diag app or a different app which is using the same method.
The other thing I can think of is there are APIs in the diag app which one is sending the hash of a keycode to the given driver...I tried that but the ADMIN stuff did not worked that way either :-((
If anyone is interested I can post the resolved codes, but not sure if I can post it in the forum or not ;-)
Regsitry entry to enable SLDR mode
I found this definition in B44C7A84-5068-4b43-A1E5-F870A80F6FF8.rgu:
[HKEY_LOCAL_MACHINE\Drivers\BuiltIn\UsbFn]
...
"OsMode"=dword:0 ; 0 for Main OS, 1 for SLDR
....
Is the download mode == SLDR mode?
Since maybe we can set this entry "somehow", and upon next reboot we will get into download mode so we can flash the device?
So the question is, what is SLDR mode? Secure Loader mode? I don't know this, a more pro in this area should help out ;-)
UPDATE
I was able to read the value (0) and write it back (0). Did not tried to write 1 there
Hey guys. I know this thread is about programmatically enter downloadmode, but I wanted to try the 301k resistor trick and I can confirm it works on Samsung Omnia 7.
I used this guide. If you're gonna do that too, then you should pay attention to these things:
- The guide refers to pin 4 and 5 being closest to the headphone socket. But on the omnia 7, the headphone and micro-usb sockets are the other way around if you compare it to the Galaxy S. The guide is for the Galaxy S, so you should really pay attention to which pins you solder the resistor(s). This is the best picture on how you should solder the resistor(s).
- Many micro-usb cables have no wire for pin 4. Some connectors don't even have a pin 4. You should first verify that your connector has all 5 pins. If you only have 4 wires, then you have to dismantle the connector and solder directly on the back of the connector.
I switched off my Omnia 7. I plugged in my jig and it went to downloadmode immediately.
It's late now, so I will see tomorrow what I will be going to flash on it. There quite a few roms and I'm not sure which one I should use. I have to figure that out first.
If anyone has questions about how to make a jig, just ask. I know how to make one now.
You should post pictures, how to make such a cable. Thanks
FromOuterSpace said:
You should post pictures, how to make such a cable. Thanks
Click to expand...
Click to collapse
The picture I linked to in my previous post look pretty clear to me. It shows what pins you have to use. The guide I linked to contain all the other necessary details. If you have any specific questions about something that is still not clear, you can ask me.

[Q] Coding in Error checking for VB.net CF app

Hello all, Sorry for the dumb question but i'm pretty new to VB.Net CF.
I'm working on a little program that exports settings from the registry and then writes to the SD card for XDA_UC to import when a new rom installed. I'm currently struggling with the error checking code. I want it to be able to tell if there was an issue updating an already existing file with new settings but i can't seem to find a way to do it. I have managed to get it to check the file was written but this only works the first time. After that it always reports a success if the file is present in the expected location.
I've pated what i have below. I appreciate all and any thoughts you may have.
Code:
[SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Private[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] BTIdent_Click([/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] sender [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] System.Object, [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] e [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] System.EventArgs) [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Handles[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] BTIdent.Click[/SIZE]
[SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]'Setup The variables so we can have them ready to write the .reg file[/COLOR][/SIZE]
[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] BTIdentity [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]String[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] = Registry.GetValue([/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"HKEY_LOCAL_MACHINE\Software\WIDCOMM\BTConfig\General"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2], [/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"DeviceName"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2], 0)[/SIZE]
[SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] sw [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] IO.StreamWriter = IO.File.CreateText([/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"\Storage Card\BT_Ident.reg"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2])[/SIZE]
[SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]'Format and then write the reg file to disk[/COLOR][/SIZE]
[/COLOR][/SIZE][SIZE=2]sw.WriteLine([/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"Windows Registry Editor Version 5.00"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2])[/SIZE]
[SIZE=2]sw.WriteLine()[/SIZE]
[SIZE=2]sw.WriteLine([/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"[HKEY_LOCAL_MACHINE\Software\WIDCOMM\BTConfig\General]"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2])[/SIZE]
[SIZE=2]sw.WriteLine([/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"""DeviceName""="""[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] + BTIdentity.ToString + [/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]""""[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2])[/SIZE]
[SIZE=2]sw.Flush()[/SIZE]
[SIZE=2]sw.Close()[/SIZE]
[SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]'Check that the file wrote successfully (this needs work becuase it will always report "operation successful" once the file has been written once[/COLOR][/SIZE]
[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] File.Exists([/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"\Storage Card\XDA_UC\BT_Ident.reg"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]) [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Then[/COLOR][/SIZE]
[/COLOR][/SIZE][SIZE=2]MessageBox.Show([/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"Operation Complete."[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2])[/SIZE]
[SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Else[/COLOR][/SIZE]
[/COLOR][/SIZE][SIZE=2]MessageBox.Show([/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"Operation Failed."[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2])[/SIZE]
[SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE]
[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE][/COLOR][/SIZE]
[/COLOR][/SIZE][/COLOR][/SIZE]
You could use FileSystemInfo properties of the file to make sure it was actually updated.
Code:
Dim fsi As FileSystemInfo = New FileInfo("\Storage Card\XDA_UC\BT_Ident.reg")
This will reveal the FileSystemInfo properties of the file, as defined here:
http://msdn.microsoft.com/en-us/library/system.io.filesysteminfo_members(v=VS.71).aspx
LastWriteTime is the last time the file was written to. If it wasn't within the last few seconds then the update has failed.
I've got to a point in my project where i actually need to look at doing this so thanks for taking the time to post.
this i what i've come up with so far
Code:
[SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]If [/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]File.Exists([/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"\Storage Card\XDA_UC\VolumeTest.reg"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]) [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Then[/COLOR][/SIZE]
[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] fsi [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] FileSystemInfo = [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] FileInfo([/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"\Storage Card\XDA_UC\volumetest.reg"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2])[/SIZE]
[SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] fsi.LastWriteTime = DateAndTime.Now [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Then[/COLOR][/SIZE]
[/COLOR][/SIZE][SIZE=2]OpComplete()[/SIZE]
[SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Else[/COLOR][/SIZE]
[/COLOR][/SIZE][SIZE=2]OpFailed()[/SIZE]
[SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]End [/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE][/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]End If[/COLOR][/SIZE][/COLOR][/SIZE]
It should work but i would like to say dateandtime.now +/- say 5 seconds and i'm having trouble figuring that part out.
Any ideas?
This should do the trick.....
Code:
Dim Seconds5 As New TimeSpan(0,0,5)
If File.Exists("\Storage Card\XDA_UC\VolumeTest.reg") Then
Dim fsi As FileSystemInfo = New FileInfo("\Storage Card\XDA_UC\volumetest.reg")
If (DateAndTime.Now - fsi.LastWriteTime) < Seconds5 Then
OpComplete()
Else
OpFailed()
End If
End If
Alternatively, drop line 1 and put it straight into the compare, as that what the compiler will do anyway, when you switch it to a 'Release' build.
Code:
If File.Exists("\Storage Card\XDA_UC\VolumeTest.reg") Then
Dim fsi As FileSystemInfo = New FileInfo("\Storage Card\XDA_UC\volumetest.reg")
If (DateAndTime.Now - fsi.LastWriteTime) < New TimeSpan(0,0,5) Then
OpComplete()
Else
OpFailed()
End If
End If
Cool, thanks. I really do appreciate you taking the time to help.

[Hack] ByPassing compression for Wallpapper in Sense 2.5

Hello my friend,
As you know, when you select a wallpaper for Sense, it compress it and resize it to JPEG in a file named HomeBackground.img.
If you open this HomeBackground.img in a imaging software like Gimp or Photoshop, you can see that the quality is good on your PC but not when you set it as walpapper.
So i think that manila recompress it on the fly before display it.
I have disassembled the Manila.exe and the dll with ida pro in order to find any compression function but....no found !
Second step, i have download the manila kitchen and decompilled all the manila files. With a multi text file searcher, i have searched the occurence "HomeBackground.img" and i have founbd this file :
090a4ee8_manila
Here is the code of the file decompilled
Code:
-- Decompiled using luadec 3.2.2beta -- Fri Jun 10 23:16:41 2011
-- File name: 090a4ee8_manila
require("asyncimageloader")
require("shell_svc")
CachedImagePath = "\\Windows\\HomeBackground.img"
InterpolateOpacity = function(l_1_0, l_1_1)
l_1_1.Opacity:Interpolate(l_1_0, 20, 0, Interpolate_EaseOutQuad)
end
BackgroundWidth = 480
BackgroundHeight = 696
if _application.Store:GetStringValue(Lifetime_Permanent, "DevResolution") == "HVGA" then
BackgroundWidth = 320
BackgroundHeight = 410
end
LoadDefaultBackground = function()
trace("LoadDefaultBackground()")
InterpolateOpacity(0, HomeBackground)
if HomeTitleBar ~= nil then
HomeTitleBar.Opacity.value = 0
_application.Navigation.TabTrayOpacity = 100
end
end
BackgroundImageLoaded = function(l_3_0, l_3_1)
trace("BackgroundImageLoaded")
if l_3_0 then
if l_3_1 == 1 then
HomeBackground.TextureCoords.width = l_3_0.TextureCoords.width
HomeBackground.TextureCoords.height = l_3_0.TextureCoords.height
local l_3_2 = l_3_0.TextureCoords.width * l_3_0.Image.Width
local l_3_3 = l_3_0.TextureCoords.height * l_3_0.Image.Height
_StoreImageWidth = l_3_2
_StoreImageHeight = l_3_3
local l_3_4 = l_3_2 / BackgroundWidth
local l_3_5 = l_3_3 / BackgroundHeight
if l_3_4 < l_3_5 then
HomeBackground.Size.height = l_3_3 / l_3_2 * BackgroundWidth
HomeBackground.Size.width = BackgroundWidth
else
HomeBackground.Size.width = l_3_2 / l_3_3 * BackgroundHeight
HomeBackground.Size.height = BackgroundHeight
end
HomeBackground.Position.x = (BackgroundWidth - HomeBackground.Size.width) / 2
HomeBackground.Position.y = -(BackgroundHeight - HomeBackground.Size.height) / 2
HomeBackground:SetTexture(l_3_0.Image)
InterpolateOpacity(100, HomeBackground)
if HomeTitleBar ~= nil then
local l_3_6 = _application.Store:GetIntValue(Lifetime_Application, "ShowCacheHomePage")
if l_3_6 == 1 then
HomeTitleBar.Opacity.value = 60
_application.Navigation.TabTrayOpacity = 60
end
end
else
LoadDefaultBackground()
end
collectgarbage("collect")
BackgroundAsyncImageLoader = nil
elseif _StoreImageWidth and _StoreImageHeight then
local l_3_7 = _StoreImageWidth / BackgroundWidth
local l_3_8 = _StoreImageHeight / BackgroundHeight
if l_3_7 < l_3_8 then
HomeBackground.Size.height = _StoreImageHeight / _StoreImageWidth * BackgroundWidth
HomeBackground.Size.width = BackgroundWidth
else
HomeBackground.Size.width = _StoreImageWidth / _StoreImageHeight * BackgroundHeight
HomeBackground.Size.height = BackgroundHeight
end
HomeBackground.Position.x = (BackgroundWidth - HomeBackground.Size.width) / 2
HomeBackground.Position.y = -(BackgroundHeight - HomeBackground.Size.height) / 2
end
_application.Store:SetIntValue(Lifetime_Application, "Home.BackgroundMaskFadeOut", 0)
if HomeBackgroundMask.Opacity.value ~= 0 then
HomeBackgroundMask.Opacity:Interpolate(0, 20, 0, Interpolate_Linear)
end
end
BeginLoadBackgroundImage = function(l_4_0)
trace("BeginLoadBackgroundImage")
if Shell_HaveDRMRightsToFile(machineStatus.HomeBackgroundPath.Value, false) then
BackgroundAsyncImageLoader = AsyncImageLoader()
BackgroundAsyncImageLoader.Priority = TaskPriority_Normal
BackgroundAsyncImageLoader.OnComplete:connect(BackgroundImageLoaded)
BackgroundAsyncImageLoader:BeginLoadFile(l_4_0, false, true)
else
machineStatus.HomeBackgroundPath.Value = ""
machineStatus.CachedBackgroundPath.Value = ""
LoadDefaultBackground()
end
end
BackgroundImageResized = function(l_5_0, l_5_1)
trace("BackgroundImageResized")
trace("[homebackground] : HomePath = " .. tostring(machineStatus.HomeBackgroundPath.Value))
trace("[homebackground] : CachedPath = " .. tostring(machineStatus.CachedBackgroundPath.Value))
if l_5_1 == 1 and machineStatus.HomeBackgroundPath.Value ~= "" then
machineStatus.CachedBackgroundPath.Value = machineStatus.HomeBackgroundPath.Value
BeginLoadBackgroundImage(CachedImagePath)
else
trace("result = 0")
LoadDefaultBackground()
BackgroundAsyncImageLoader = nil
end
AnimationDelayHandler()
trace("BackgroundImageResized end")
trace("[homebackground] : HomePath = " .. tostring(machineStatus.HomeBackgroundPath.Value))
trace("[homebackground] : CachedPath = " .. tostring(machineStatus.CachedBackgroundPath.Value))
collectgarbage("collect")
end
machineStatus_OnCustomBackgroundUpdate = function()
trace("machineStatus_OnCustomBackgroundUpdate")
if _config_os == "windowsmobile" then
local l_6_0 = machineStatus.HomeBackgroundPath.Value
local l_6_1 = machineStatus.CachedBackgroundPath.Value
trace("[homebackground] : HomePath = " .. tostring(l_6_0))
trace("[homebackground] : CachedPath = " .. tostring(l_6_1))
if l_6_0 ~= l_6_1 then
if BackgroundAsyncImageFactoryLoader ~= nil and BackgroundAsyncImageFactoryLoader:IsRunning() then
BackgroundAsyncImageFactoryLoader.OnComplete:disconnect(BackgroundImageResized)
BackgroundAsyncImageFactoryLoader:Cancel()
BackgroundAsyncImageFactoryLoader = nil
collectgarbage("collect")
end
if BackgroundAsyncImageLoader ~= nil and BackgroundAsyncImageLoader:IsRunning() then
BackgroundAsyncImageLoader:Cancel()
BackgroundAsyncImageLoader = nil
collectgarbage("collect")
end
if l_6_0 == "" then
machineStatus.CachedBackgroundPath.Value = machineStatus.HomeBackgroundPath.Value
LoadDefaultBackground()
else
BackgroundAsyncImageFactoryLoader = AsyncImageFactoryLoader()
BackgroundAsyncImageFactoryLoader.Priority = TaskPriority_BelowNormal
BackgroundAsyncImageFactoryLoader.Quality = 100
BackgroundAsyncImageFactoryLoader.OnComplete:connect(BackgroundImageResized)
BackgroundAsyncImageFactoryLoader:ResizeImage(machineStatus.HomeBackgroundPath.Value, CachedImagePath, EncoderType_JPEG, 512, 512, true, false)
end
elseif l_6_1 ~= "" then
if BackgroundAsyncImageFactoryLoader ~= nil and BackgroundAsyncImageFactoryLoader:IsRunning() then
BackgroundAsyncImageFactoryLoader.OnComplete:disconnect(BackgroundImageResized)
BackgroundAsyncImageFactoryLoader:Cancel()
BackgroundAsyncImageFactoryLoader = nil
bRefreshBackground = true
collectgarbage("collect")
end
if BackgroundAsyncImageLoader ~= nil and BackgroundAsyncImageLoader:IsRunning() then
BackgroundAsyncImageLoader:Cancel()
BackgroundAsyncImageLoader = nil
bRefreshBackground = true
collectgarbage("collect")
end
if bRefreshBackground then
trace("[homebackground] : Change wallpaper too quickly and home and cache registry are the same, but loader is running, so load home background again.")
machineStatus.CachedBackgroundPath.Value = ""
machineStatus_OnCustomBackgroundUpdate()
else
BeginLoadBackgroundImage(CachedImagePath)
end
else
LoadDefaultBackground()
end
else
LoadDefaultBackground()
end
end
AnimationDelayHandler = function()
local l_7_0 = _application.Store:GetIntValue(Lifetime_Permanent, "Home.WallpaperMode")
local l_7_1 = _application.Store:GetIntValue(Lifetime_Application, "DelayAnimationEffect")
if l_7_0 == 1 and l_7_1 == 1 then
if _AnimationWallpaper then
_AnimationWallpaper:Show()
end
_application.Store:SetIntValue(Lifetime_Application, "DelayAnimationEffect", 0)
end
end
if _application.Store:GetStringValue(Lifetime_Permanent, "EnableLandscape") == "true" then
require("RotationTemplate")
homebackground_ScreenRotation = class(RotationTemplate)
homebackground_ScreenRotation.__init = function(l_8_0)
RotationTemplate.__init(l_8_0)
trace("+++++++[homebackground] : __init")
end
homebackground_ScreenRotation.OnScreenRotation = function(l_9_0)
trace("+++++++[homebackground] : OnScreenRotation")
if _application.Orientation == ScreenOrientation_Portrait then
BackgroundWidth = 480
BackgroundHeight = 696
elseif _application.Orientation == ScreenOrientation_Landscape then
BackgroundWidth = 805
BackgroundHeight = 376
end
BackgroundImageLoaded(nil, nil)
end
end
if _config_os == "windowsmobile" then
if _application.Store:GetStringValue(Lifetime_Permanent, "EnableLandscape") == "true" then
_homebackground_ScreenRotation = homebackground_ScreenRotation()
end
machineStatus.HomeBackgroundPath.OnValueChanged:connect(machineStatus_OnCustomBackgroundUpdate)
machineStatus_OnCustomBackgroundUpdate()
end
At the line 141 tou can see this :
Code:
BackgroundAsyncImageFactoryLoader:ResizeImage(machineStatus.HomeBackgroundPath.Value, CachedImagePath, EncoderType_JPEG, [B]512[/B], [B]512[/B], true, false)
* If you delete this line, the wallpaper don't display !
* The 512,512 are the width and height values, so i think it's better to replace them by 480 , 696 ( the real width and height)--> Warning, you need to use a walpapper with a heigh and width of 480x696
With this, the image will be better.
BUT it's not finish !
When you modify this file and recompile it, you can see thaht you walpapper is not cropped but, the quality is always not good.
Look at this :
And with a zoom :
--> So you can see that there is even a compression thaht destruct the quality, but where is it ?
I would like to find a way of bypassing a function of recompression but i don't found it. I would like to investigate on this project with some people, so if anyone have some informations about this, it will be very great !
So, you can contact me on this thread or by PM !
If you want to help me, it's very simple :
1) Download the manila kitchen here : http://forum.xda-developers.com/showthread.php?t=528548
2) Copy all your *manila* files on the "source" folder.
3) Read the .doc or the .pdf document that explain how decompile this file ( it's very very easy)
4) Investigate about improving walpapper quality
I know that the truth is near, but i need some help !
Thanks a lot for all people that could help me to create this hack.
Best regards,
Nixeus
Update post 1
Hi Nixeus,
this all is done once before here on xda. But you have to know it, otherwise you will not find it.
Link 1 - HDwall 0.29 original thread -> maranell0
Link 2 - HDwall for VGA -> mwalt2
Link 3 - background for all tabs (bg4all) -> cookiemonster our good old and missing friend
Hope that helps you out...
Hello and thanks for your answer.
I don't agree because HDWALL use a software in order to create a png in a manila file, it's note the same method....
Instead of displaying the homebackground.img on the home, you need to choose the png in hdwall, and after hdwall insert this png in a manila file, it's note the same method and it don't function good on the latest version of manila.
That's why we need to create a good hack.
Nixeus said:
Hello and thanks for your answer.
I don't agree because HDWALL use a software in order to create a png in a manila file, it's note the same method....
Instead of displaying the homebackground.img on the home, you need to choose the png in hdwall, and after hdwall insert this png in a manila file, it's note the same method and it don't function good on the latest version of manila.
That's why we need to create a good hack.
Click to expand...
Click to collapse
You are right, it is not the same way. It was only an idea, because on my latest ASIA Rom V2.5 WWE Full from Laurentius26 the HDwall system is working perfect without any issue. Also the wallpaper changing with the cab files and the change tool from HD wall is working. We had add this function in CHT, but in the mean time i am working on different roms, so i don't used CHT the last 4 weeks. Badly but true . Otherwise we have to search further in that case. I will read again you 1st posting...
Thanks for you help
Maybe ChainFire or CookieMonster could help us !
Is the wallpaper quality worse with the resize mod or the same?
sharkie405 said:
Is the wallpaper quality worse with the resize mod or the same?
Click to expand...
Click to collapse
Yes I would like to know too?

Categories

Resources