Saturday, December 15, 2012

Jailbreaking Windows Phone 7.5 HTC Titan

I have a HTC Titan (X310e) which suddenly turned into garbage when it would only show a garbled home screen after having the screen turned off once (Everything looked fine after reboot). Also all my email "apps" were missing and I could not access anything social (People, or settings about People og social networks).

After lots of Googling, I gave up on finding a solution online. I decided to delete everything on the phone and jailbreak it (since vanilla WP7 didn't have any backup functions anyways).

I followed this tutorial: forum.xda-developers.com/showpost.php?p=26842868&postcount=46
So thanks to dragonide from XDA Developers.

The tutorial was good, but I'll add some minor details that might be useful:
  • Download files from:
    DFT__HSPL_WP7SG1.rar: http://htcfanboys.com/download/cotulla/?action=view&file=10777
    DFT Eternity 24 langs Freedom V1 Pearl Edition.7z: http://forum.xda-developers.com/showthread.php?t=1684907
    RUU_ETERNITY_Radio_Signed_17.5006.08.27_17.08.50.06.7z: http://www.mediafire.com/download.php?6i5r5a5amkwx8h
  • Turn off your phone and disconnect it from the computer.
  • Remove your SIM card.
  • Hold volume up and down then press power. continue holding the volume buttons.
  • When you see green text on white background with for example version PI39100
    Radio 17.0...
    ..., you are in SPL. It should also say "Serial" about 2/3 of the way down the screen
  •  Connect to computer with USB. you might have to try different USB ports. Check"Safely Remove Hardware and Eject Media" in the system tray; My phone came up as Titan USB Sync on some ports, in that case flashing failed with 264 and 266 errors. (See http://forum.xda-developers.com/wiki/index.php?title=Elf_RUU_Error_Codes for explanation of errors). When it came up as Qualcomm CDMA Technologies MSM on a port, flashing worked fine.
  • Unpack DFT__HSPL_WP7SG1.rar using for example 7-Zip (http://www.7-zip.org/), just right click the file and select open archive.
  • Run \DFT_HSPL_WP7SG1\1_SPL205\TITAN\ROMUpdateUtility.exe and follow instructions (takes about 1 min).
  •  You should see the progress bar in parallel on both the computer and the phone.
  • When complete, the phone reboots. Hold the volume buttons until you enter SPL. Notice that it now says "HSPL2.5.160015.3 (137079)" and "Radio-16.23.06.10" (Radio was 17... before flashing on my phone).
  • Run \DFT_HSPL_WP7SG1\2_HSPL\DFT_HSPL_WP7SG1_INSTALL.exe and follow instructions (install HSPL) (takes about 1 min).
  • Phone will reboot after flashing. When rebooting, hold volume to enter SPL.
  •  Unpack DFT Eternity 24 langs Freedom V1 Pearl Edition.7z.
  •  Run \DFT Eternity 24 langs Freedom V1 Pearl Edition\ROMUpdateUtility.exe and follow instructions (takes about 10 min).
  • After completing flashing the phone will reboot and probably hang/freeze on boot (just showing the HTC logo). Reboot phone (just hold the power button or remove the battery). Hold volume buttons to enter SPL.
  • Unpack RUU_ETERNITY_Radio_Signed_17.5006.08.27_17.08.50.06.7z
  • Run \RUU_ETERNITY_Radio_Signed_17.5006.08.27_17.08.50.06\ROMUpdateUtility.exe (takes less than 1 minute).
  • After flashing, the phone reboots, hold volume buttons to enter SPL and check that Radio is now 17.5006.08.27
  • Turn off the phone (remove the battery).
  • Put your SIM card back in.
  • Power on the phone like normal and go through the Windows Phone 7 setup process.
  • Enjoy jailbroken WP7.
Note: My system is a Windows 7 machine, things may differ on your system.

Images of what you should expect to see (sorry for the blur):











Thanks to Sources:
http://windowsphone.stackexchange.com/questions/173/what-are-the-options-for-developer-unlocking-a-wp7-device
http://windowsphonehacker.com/articles/hspl_and_first_custom_roms_out_for_htc_titan_radar-06-01-12
http://forum.xda-developers.com/showthread.php?t=1684912
http://forum.xda-developers.com/showthread.php?t=1684907
http://forum.xda-developers.com/showthread.php?t=1684912&page=11
http://forum.xda-developers.com/showpost.php?p=26842868&postcount=46
http://forum.xda-developers.com/wiki/index.php?title=Elf_RUU_Error_Codes
http://forum.xda-developers.com/wiki/ActiveSync

Thursday, November 15, 2012

Wednesday, November 14, 2012

Play 2 Framework Limit Request Data

My form had more fields than I wanted to save (lists of multiple models). And I only wanted to validate and save one data set (list of models) at a time.

To solve this I added one submit button per list of models and a name tag, with the id of my model list, to each submit button:

<input type="submit" name="@modellist.id" value="Save Model @modellist.id">

In my controller I now wanted to remove all the fields that were irrelevant before validation (So I wouldn't get any errors on those fields). From all the submitted models I wanted to fetch all models that matched my submit button's modelid:

(Note: To accomodate the lists of models, I have created a class which contains a map of all models submitted by the form, so thats why I'm working with maps. If you have a simpler setup this idea might be more easily done)

Form<ModelMap> modelMapForm = form(ModelMap.class);

// Remove unwanted models depending on which submit button has been pressed.
DynamicForm requestData = form().bindFromRequest(); // Doesn't try to match values to a "model"
Form<ModelMap> filledModelMapForm = ModelMapForm.bindFromRequest();
ModelMap allModelMap = filledModelMapForm.get();
ModelMap wantedModelMap = new ModelMap();
for (int modelid : modelids) {
    // Check if modelid is in POST data, if yes than that button was pressed and we want that data.
    if (requestData.get(""   modelid) != null) {
        for (Map.Entry<String, Model> entry : allModelMap.models.entrySet()) {
            if (entry.getKey().endsWith(""   modelid)) {
                wantedModelMap.models.put(entry.getKey(), entry.getValue());
            }
        }
    }
}
// Place wanted values in filledModelMapForm for validation and saving
filledModelMapForm = filledModelMapForm.fill(wantedModelMap);
// Place all values in allModelMapForm so that they are shown in case of errors
Form<ModelMap> allModelMapForm = ModelMapForm.bindFromRequest();

if (filledAnswerMapForm.hasErrors()) {
    allModelMapForm.reject("Error, please correct it.");
    return badRequest(view.render(<other values>, allModelMapForm));
}
else {
    ModelMap saveModelMap = filledModelMapForm.get();
    // Process form...
}


Maybe this solves your problem or helps you solve it. :) If you find a more elegant way, please don't hesitate to tell me below.

Source: https://groups.google.com/forum/?fromgroups=#!topic/play-framework/TRzjAwVvVEM

Tuesday, October 30, 2012

Copy all text in a Gnome terminal

Shamelessly copied from arsane on superuser.com (Thanks)

Instead of dragging mouse to select all text:

1. Triple click the last line of current terminal(do not release the mouse).
2. Press SHIFT+HOME key which will lead us to the first line.
3. Drag mouse to the first line.
4. Right click , edit->copy.

See http://superuser.com/a/80175.

Apache Felix LinkageError

I was getting java.lang.LinkageError when running Felix. I had a big trouble finding out what the problem really was.

Finally, I found that javax.activation was being loaded by two modules differently (See http://frankkieviet.blogspot.no/2009/03/javalanglinkageerror-loader-constraint.html and http://stackoverflow.com/questions/4270950/compile-time-vs-run-time-dependency-java).

I couldn't exclude javax.activation from any of my modules (tried to explicitly ignore it from my pom.xml files (Maven), but that didn't work).

In the end I discovered that felix automatically loads some packages on startup. This is specified in the org.osgi.framework.system.packages.extra variable in config.properties (In the conf folder).
Just adding javax.activation;version=1.1.1 (The version I wanted) there fixed it.
Now Felix loads the package, and my waring modules fetch it from there instead of trying to load it themselves.

Sources: http://devangelist.blogspot.no/2011/04/osgi-bundle-lifecycles.html,
http://stackoverflow.com/questions/6097279/java-lang-linkageerror-loader-constraint-violation-in-grails-project,
http://fusesource.com/forums/message.jspa?messageID=14613,
http://fusesource.com/forums/thread.jspa?messageID=7682

Play 2 Framework as a Windows Service

I wanted to run Play2 as a Windows Service, but had problems getting it to work with the usual methods (SC.exe) (See http://www.herikstad.net/2012/10/run-as-windows-service.html for others).

Ended up using RunAsSvc from PirmaSoft. Here is how:


1. In command prompt. Go to your project folder. Run play dist. This will create a ZIP file in the dist folder of your project.
3. Unzip the ZIP file in a location of your choice-
4. Download RunAsSvc from http://www.pirmasoft.de/runassvc.php and unzip it in a location of your choice.
5. Run RunAsSvc.exe as an Administrator
 5.1 Choose a Name for your service
 5.2 Choose a Description for your service
 5.3 In "Path to executable" browse to your Java/bin folder (e.g. C:\Program Files\Java\jre7\bin) and choose java.exe
 5.4 In "Parameters" Enter: -Dhttp.port=80 -cp "./lib/*;" play.core.server.NettyServer . (you only need the -Dhttp.port=80 flag if you want to set the port to something other than 9000).
 5.5 Set the working directory to the locations where you unzipped the project ZIP file.
 5.6 Press OK and check that you now can find your service in the Service panel (services.msc) and that you can open your webpage in your browser.

To delete the service, go to "Add/Remove Programs" and find PirmaSoft RunAsSvc - <your service name> and select uninstall.

If the service won't run, check that there is no RUNNING_PID file in the folder where you unzipped the ZIP file.

To see the process in Task Manager: Select "Show processes from all users", it will be a java.exe running as SYSTEM.

Sources:  https://groups.google.com/forum/?fromgroups=#!topic/play-framework/xykhfyVu_Y0,
http://stackoverflow.com/questions/9689793/cant-execute-jar-file-no-main-manifest-attribute,
http://stackoverflow.com/questions/10894615/play-framework-bat-windows-java-process,
http://stackoverflow.com/questions/9941689/how-to-change-http-port-that-play2-is-listening-on

Run as Windows Service

Sometimes you want to be able to run a program in the background, and to keep it running even though you are not logged in. Some programs give you the possibility to set them up as services, here are some ways to install any program as a service:

1. Using SC to install it yourself (sc "MyServiceName" binPath= "C:\myservice\my.exe", note the space after binPath)
2. Using instsrv.exe and srvany.exe
3. More types (For 1,2, and 3: http://www.msfn.org/board/topic/83272-how-to-run-a-program-as-a-service/)
4. Adding the script as a Startup Script in Group Policy (http://techsupt.winbatch.com/ts/T000001048F90.html) (gpedit.msc)
5. Using the nice little tool RunAsSvc from Pirmasoft (http://www.pirmasoft.com/runassvc.php)
6. Using YAJSW (Yet Another Java Service Wrapper) (http://yajsw.sourceforge.net/#mozTocId212903)
7. Using JSW (Java Service Wrapper) (http://wrapper.tanukisoftware.com/doc/english/download.jsp)

Source: http://www.msfn.org/board/topic/83272-how-to-run-a-program-as-a-service/