Nov 26, 2013

Asus Transformer (TF101) bootloader fix

Playing with different ROMs or flashing funny stuff might cause your tablet to not boot correctly or always try to boot on recovery.

How to power it up?

You can try to power the tablet bypassing the bootloader with the following steps:
  1. Turn on the tablet using Vol Down + Power
  2. The tablet should display a couple of white text lines in the top, to let you know that you need to push Vol Up to enter recovery. Just wait there for it to timeout (its around 5 seconds)
  3. In the following screen, the tablet should show two icons (wipe data and android), make sure android is selected and either wait 10 seconds or hit the volume key to select it.
  4. The tablet should start normally again.
This is a workarround, so if you don't fix the problem, you will need to do all steps again every time you power up the tablet.


Whats the problem?

Most of the time, the issue is that the first string of the bootloader partition is corrupted or changed and the tablet either runs recovery or doesn't know what to run at all. To check if this is your table's issue, you need either adb or a terminal app in your device.

$ su
# cat /dev/block/mmcblk0p3
boot-recoverysadkfjl..
(more gibberish)

The solution

First of all, do this at your own risk. Second, check if the output of your boot partition has the 'boot-recovery' string, if it has any other string, this might not work at all. Now with the steps of the solution:

  1. Use either adb or a terminal/shell app with root.
    echo boot | dd of=/dev/block/mmcblk0p3 bs=1 seek=0
    
  2. Check again your boot partition, you should have something like the following
    cat /dev/block/mmcblk0p3
    boot
    recoverysadñlfj
    (more gibberish)
    
  3. Reboot
The tablet should reboot now without problem as well as it should let you enter recovery without issues.

Nov 15, 2013

Restoring chat messages in LINE

As LINE and WhatApp user, I find the lack from LINE to be able to backup your chat history a big draw. Luckily for us, there's a workaround to fix this issue.


What do we need?

  • A rooted Android phone
  • Titanium Backup
  • SQLite Editor

Any other similar app should also do the trick. Before changing your phone, ROM or whatever, you need to create a backup of the LINE app, so we have the saved data of the app before doing anything.

How to restore

  1. Do a fresh install of LINE from the App Store, but don't open it right away.
  2. Restore LINE app data from the Titanium Backup backup.
  3. Open SQLite Editor and in the apps tab select LINE app.
  4. SQLite should open the app and show you the available .db files, select naver_line
  5. You should now see all the tables inside that .db file, select setting
  6. Once you're inside the table, seeing all the data it contains, select Menu > Delete All
  7. Open LINE app and login with your username
  8. You will receive a pop-up telling that the previous account will be deleted along with the chat history. Just click OK.
  9. Follow the rest of the setup process
  10. Once finished, you should be able to see all your saved chat history.
And that is, we now have our restored data in LINE.

Update: Another way to do it


If the above doesn't work for you, there's another way to do it with SQLite Manager
  1. As before, do a previous backup.
  2. Restore your backup on your new phone or ROM
  3. Use a root file explorer to go to /data/data/jp.naver.line.android/databases
  4. Copy naver_line to your PC and rename it as naver_line_old
  5. Do a fresh install and do the whole setup process
  6. Again use a root explorer to get the new version of naver_line and save it as naver_line_new on your PC
  7. In your PC, open naver_line_old and export chat_history table to a file.
  8. In your PC, open naver_line_new and import the exported file.
  9. Copy naver_line_new to /data/data/jp.naver.line.android/databases/naver_line
  10. Restart your phone.
With these steps, you should have all your chat history restored, but it won't be visible until the people in your chat conversations message you again.

Nov 6, 2013

Task management with Cron + Anacron

What is Anacron

Anacron is used to execute commands periodically, with a frequency specified in days. Its a good partner of any machine with cron jobs that it isn't running 24/7. For each job, Anacron checks if it has been executed in the last n days, where n is the period specified for that job. If the job hasn't been executed, Anacron will execute it.

Anacron configuration

Anacron configuration file is located in /etc/anacrontab and looks like this:
SHELL=/bin/bash
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/bin
# format: period delay job-identifier command
##
## If you turn any of the following on, make sure that the
## regular cron daemon does not run them also. This could
## lead to double execution of the jobs.
1       5       cron.daily      run-parts /etc/cron.daily
7       10      cron.weekly     run-parts /etc/cron.weekly
30      15      cron.monthly    run-parts /etc/cron.monthly 

Tasks are represented in the following format:
period  delay   job-identifier  command

The job identifier should be unique for each job, as Anacron uses that name to create a file in /var/spool/anacron with the timestamp of the last time that task was executed.

Conflicts between Cron and Anacron

If the PC is restarted and Cron executes its daily/weekly/monthly routines, it is possible to execute them twice if also Anacron tries to execute them. To avoid this conflict, we can create a file inside the cron folders to update the timestamp of Anacron tasks and avoid running them again.

The simplest example should be to create a script called 0anacron, inside the cron.daily directory, that runs Anacron with the -u option, just to update the timestamps of Anacron's tasks:
#!/bin/bash
/usr/sbin/anacron -u

If you have Anacron configured to execute different tasks in different time frames (such as one daily and one weekly), it is possible to append the task name or job-identifier to the -u option, so Anacron will only refresh that task. This way we can create one script in cron.daily to reflesh the daily Anacron task and one script in cron.weekly to refresh the weekly task.

Anacron on Suspend

Anacron will run automatically everytime you turn on (or reboot) your PC, but what happens when you just suspend it? Anacron won't run when you wake your PC from suspend, but there are a couple of things you can do to avoid this issue:

Use Cron

This might not be the most elegant solution but it works, just create an entry in your crontab that calls Anacron every X hours, where X should be a period short enough that would grant that your PC will be online in at least one period of a whole day. That way all daily tasks should be able to run without problems, for example:
# Run Anacron every two hours
* */2 * * * /usr/sbin/anacron -s

Use pm-utils

You need to configure pm-utils on your kernel, but it is possible to control several events, including wake from suspend. With a custom script on wake from suspend events, we could make a call to Anacron each time the PC wakes up, so we can ensure that all tasks run without problems. You should create a new executable script in /etc/pm/sleep.d. Any script found there on sleep or wake-up routines will be executed, so you can create a script like the following to execute Anacron each time the PC wakes up:
#!/bin/bash
case $1 in
  thaw|resume)
    /usr/sbin/anacron -s
    ;;
esac