Message Backup

Gaurav Mittal
The work we do at hike messenger
4 min readJan 23, 2015

I’m part of the Android army @hikeapp, the fastest growing messaging app in India and today I’m going talk about how we built Message Backup.

What is Message Backup?

One of the biggest feature requests we received last year was for Message Backup. Message Backup simply put is a way for people to backup their chat history and conversation list and with a tap of a button (or none in most cases) recover everything as if nothing was missing.

Why people want it?

You’d think just for a change of phone right? Well, that’s one part of the story. We build for India, a Mobile First market. Most people globally underestimate what that means. I think we did to early on. Mobile First means that most people in this country are coming on to the internet for the first time in their lives on a mobile device. This is the first time that most people in this country will witness any kind of powerful compute. On top of that, 81% of all smartphone shipped were under $150 in India last quarter. That means most people in the market are coming on to low-mid end smartphones with extremely low Storage and RAM. Low supply of Storage and RAM makes them a very scarce resource especially given the onslaught of apps in the market today. As a result of this, people un-install apps quite often to make room on their device even if temporarily.

We’ve seen people literally un-install an app to make space for a big game, install the game, play it for a few hours, un-install the game and then re-load the un-installed app again to use it!

So we decided to build Message Backup to ensure if and when this ever happens for a hiker, we can ensure a great user experience.

Step 1 : Figuring out what to do.

The TO DO

This was the most fun part. Here we didn’t think about how we’ll do it, but what all we can possibly do to create an amazing user experience. We do get some real crazy ideas in such brainstorming sessions. But to start with we kept it super simple, backup chat history and the conversation list.

Step 2: Design

The way we designed this was in the following steps:

  1. Content: The content which was to be backed-up was copied to a new file. The file was then encrypted and saved to a specific location.
  2. Encryption: The encryption was done using a secure key and we ensured that every key was different for every user, which made sure that the files wouldn’t be able to be decrypted even if any other person got a hold of the backup files.
  3. Media Files: The shared files i.e. the media files and the documents were duplicated during the process, only the location and the names of these files would be stored. They would be retrieved when the backup was restored.

Auto-backup

We also added an auto backup feature to allow the users to have automatic, hassle free backup. The alarm manager was scheduled to take backup at 3am everyday, a time when most phones aren’t used at all.

Encryption. How it works.

We chose ‘Block Cipher Mode’ as our way of encryption. The key specs for this process are generated using:

  1. a salt
  2. an initialization vector
  3. a password(different for every user)

A salt and an initialization vector are mostly the same thing in a sense; they are public data, which should be generated anew for each instance. A salt is about being able to use the same password several times without opening weaknesses.

Restoring

After successfully decrypting the backup, the content retrieved is initialised. An upgrade is executed if required. Here’s a flow chart as to how this all works.

How it works

Step 3 : CODE!

Finally, it was time to code the entire piece. We wrote it, got it reviewed and merged it into our main branch ready to go. We did multiple design reviews with the whole team before the implementation. As always, we hit a few snags that we quickly fixed. In the process, we also added some awesome animations and made the interaction delightful.

No matter how many times you do it, its always as exciting. Now that I think about it, this was actually more fun than step 1.

Step 4 :

Then come the final stage of integration and testing. As anticipated we ran into some issues, bugs mostly. We fixed some, changed others. Personally I was glad there were bugs, I find code that runs without any of them rather scary.

Finally, we launched Message Backup on 24th Dec 2014. Download hike on Android to check it out!

Useful Links

--

--