Monday, 29 February 2016

Git - Undo previous commit and push

If you have commited and pushed a change to the repository and you want to undo those changes, do the follow:
1. Open the terminal
2. Type

git log

This will give you a list of commits, with the text and the hash code
3. Then type

git revert --no-commit HASH_CODE

Where HASH_CODE is the hash code of the specific commit.

The changes will be in stage. All you have to do now is commit and push.

Friday, 19 February 2016

Playing with Android bootloaders - Some basic concepts learned

So, I was playing with the Android bootloaders for Asus ZenFone 2 and this are some key concepts.

Step 1 - Go to Fast boot mode

This is the basic and first step where we can go to the boot loader.
1.1 Turn on the phone by holding the power button and volume up button (This my vary depends on the brand/model. It is so in Asus ZenFone 2). Hold them until the phone vibrates.
1.2 As soon as the phone vibrates, release the power button but maintain the finger pressed on the volume button.
The phone will start and enter the recovery mode

Step 2 - Update the boot loader (if needed)
Once the phone is in fast boot mode, there two main options:
1. Go to recovery mode
2. Install a new boot loader

Install the new boot loader if needed. There are three files: droidboot.img, recovery.img and boot.img. You could find it on the manufacturer's we page or a third party web page. This is the one for Asus ZenFone 2:
https://www.asus.com/Phone/ZenFone_2_ZE551ML/HelpDesk_Download/

The latest version for now is WW_2.20.40.168

2.1 Download the latest firmware of your brand/model. Unzip it if needed
2.2 Go to the file
2.3 in a Terminal, type the follow:

fastboot devices
fastboot flash fastboot droidboot.img
fastboot flash recovery recovery.img
fastboot flash boot boot.img

Note that the command fastboot is in the same directory as adb, which comes with Android SDK.

3. Flash the latest firmware
To install the latest firmware, there ware two options:
3.1 If you have an SdCard and your phone support it, copy the file into the SdCard.
3.2 If you don't, update it with cable connected to your computer.

3.1 Updating the latest firmware using sdcard
3.1.1 Download the latest firmware and copy it to the main folder of it. Rename it to

MOFD_SDUPDATE.zip

3.1.2 Insert the sdcard into the phone
3.1.3 Open fast boot and use the volume buttons to select the recovery mode. Press power button to confirm.

Once in recovery mode, the phone will detect automatically the file in the sdcard and starts to update.

3.2 Updating the latest firmware using cable
3.2.1 In this case, open fast boot and use the volume keys and power button to go to recovery mode.
3.2.2 The phone might show an error because the update file is not in the sdcard. It could be solved by holding the power button (just for a couple of seconds) and press on volume up. As soon as you press on the volume up, you should be able to see a list of options and a log screen below.
3.2.3 Choose the option "apply update from ADB"
3.2.4 Download the latest version of firmware. For Asus ZenFone 2 it could be downloaded from here:
3.2.5 Open the terminal and type

adb sideload file.zip

Where file.zip is the zip file you downloaded on the step 3.2.4.

The boot loader should detect the adb version and then, it will start updating the firmware.
3.2.6 (Optional)Once it is finished (it takes a couple of minutes), choose the option "Wipe cache partition".
3.2.7 Choose "Restart device " option.

Source:
Asus Zentalk - How to receive OTA/ Change FIrmware to WW/ Fix Recovery blinking dropid

Thursday, 5 November 2015

Sunday, 4 October 2015

Android: Enabling logs on Snowplow

As the tracking solutions in mobile is increasing, Snowplow could be a good solution to centralize the list of trackers.

By default, the logs on Snowplow is disabled. To enabled, use the follow code:

// Ask Logger level of Snowplow to log data com.snowplowanalytics.snowplow.tracker.utils.Logger.updateLogLevel(LogLevel.VERBOSE);

There are three log levels in Snowplow: e, d, and v, which corresponding to error, debug and verbose, respectively. So, there are four options for the parameter:

  • LogLevel.VERBOSE
  • LogLevel.DEBUG
  • LogLevel.ERROR
  • LogLevel.OFF
The last one is the one which comes by default, which turns offs the logs.

The another thing to take into accounts is the tags for the logging for Snowplow starts with "SnowplowTracker->"

Finally, this options must be done once the emitter and the tracker are set, otherwise they will turn off the logs.

Friday, 26 June 2015

Postman pattern


Postman Pattern is a improved Observer pattern specially for mobile phones. It deals with the problem that from the mobile phone, the observer could be not in the foreground when the data is coming from observable.

For this case, the observable acts like the postman, leaving the data (package) in the observer. When the Observer became visible again, it will check if it has some data (package) to be processed. If so, the data will be processed.

It includes the implementation for Android and some highlight for the source code, which is stored in GitHub here:
https://github.com/jiahaoliuliu/PostmanPattern/tree/simplePostmanPattern