October 01, 2017

Motoactv hacking: Updating golf info

Posted at October 1, 2017 02:20 AM in Software .

   Ongoing theme of many products or features that I enjoy are either discontinued, modified, or closed down. This occurrence happened when I brought my motoactv out to the Torrey Pines North golf course. In preparation I reset to stock firmware, rooted it, and then downloaded the California courses through the official app.

The next day got to the first tee and the yardage did not match the scorecard. We were paired with some strangers, so I asked if something changed recently. They said the course was re-designed last year mainly swapping the back nine with the front. This article provides more details of the changes.

The redesign meant I couldn't use my motoactv as a range finder for the day. No problem, use the course markers and estimations for the day. However, there's an upcoming tee time next week and I needed to make things right.

As you see, course info from 2012 would not cut it.

More info after the click.

The rest of this post will describe how I made it right. Note: the last entry in the list is truncated but reads Torrey Pines North New. That's the one I put into there.

  • Figuring out the app structure
  • Seeing known good data
  • Getting relevant updated data
  • Inserting back into the app

Figuring out the app structure

This is much easier with a rooted device. Combined with websearching I Was able to get all the info needed to figure out the app structure. The app downloads zip packages from a server with a format like CountryAbbr-StateAbbr_Version.zip. For example, US-CA_753.0.zip. Other countries have a similar, but slightly different format.

The downloaded data package

Within the zip package there's a folder with the same state abbreviation, in this example: CA. Within that folder there are many numbered files with an extension .xml.enc. There's also a database index file.

The xml is encouraging to see, so the data will be easy to format for loading back to the software. However the .enc extension is a bit worrisome as it indicates some encoding. Opening the file confirms this as there's no recognizable xml data within.

Now that I know what to look for it is time to go poking around the motoactv itself. Logging into it's adb shell and doing a search for a known good numbered filename shows the unzipped data stored in /mnt/sdcard/golfcourses in the directory matching the state abbreviation, in this example /mnt/sdcard/golfcourses/CA.

The databases

Under /mnt/sdcard/golfcourses there's a database for looking up zipcodes based on gps coordinates location. This one seems won't be needing to be edited for my purpose. I don't live in a new unregistered city or area.

The state's index was interesting and will need to be edited to add an entry once I make a new entry. Here's the schema:

CREATE TABLE courses ( _id INTEGER PRIMARY KEY, name TEXT, city TEXT, latitude REAL, longitude REAL, filename TEXT );
CREATE INDEX IDX_LAT_LON ON courses(latitude, longitude);

Under /data/data/com.motorola.motogolf there's also a directory called databases which contains golf.db and courses.db. Poking around at those it looks like neither of these will need to be altered. If you're loading courses only by side-loading and not receiving from the server then the courses.db will need to be altered to signal that the course is presently available. Here's the schema:
CREATE TABLE android_metadata (locale TEXT);
CREATE TABLE course_country (_id INTEGER PRIMARY KEY NOT NULL, country_name TEXT);
CREATE TABLE course_state_country (_id INTEGER PRIMARY KEY NOT NULL, state_name TEXT, state_abb TEXT, country_id INTEGER NOT NULL, version_number REAL, status INTEGER );
CREATE TABLE course_download_requests (request_id INTEGER PRIMARY KEY NOT NULL, state_id INTEGER, file_name TEXT, request_status INTEGER, action INTEGER);

Here's my listing with CA loaded and with MA not loaded:

Now I think I will know how to make the app see the data once I can create it. In order to create it I need to see known good data.

Seeing known good data

Best place to begin is where you are familiar. After looking at the database the file 5497.xml.enc matches the errant Torrey Pines north data set. Doing some websearches and happening upon an article by a beta tester it was determined that the data comes from SkyDroid. Looking at SkyDroid's Torrey Pines North listing showed correct data. They've updated it, but since Motorola discontinued this product many years ago I don't hope to see the updated via the official channel.

One observation was that the Torrey Pines North course_id in the URL did not match with 5497. However their Torrey Pines South listing matched my motoactv database ID of 216.

Now I have a data source, but I still don't know how to see the formatting. There's two ways to go about this, but I am not smart enough about encryption to take the method of reversing the encoding.

I chose to see how motorola did it and now know take to my compiler to write a program in C with openssl crypto library in order to decode the .xml.enc file into a simple .xml file. Later I would write an encrypt function into the same program. Here's the top of the code.

Success, the schema is pretty simple to follow with nodes such as course and subcourses. Within subcourses there's holes and features within them to describe the green or hazards and positions such as front, center, and back.

Getting relevant updated data

Poking around a couple hours on SkyDroid's website and within their javascript and php sites I was unable to download the data in the same xml format. Then I tried to figure out how to turn the markers on the map into manual gps coordinates with google and their sites/APIs. That was also a dead end for me.

Then I figured why not do the same as I did with the motorola approach and see how SkyDroid does it. Success.

Inserting back into the app

Two approaches were considered. Since the old data is stale I could simply replace it and have less work. However, to ensure I didn't mess anything up I decided to make a new original entry.

I took my newly obtained data, inserted it into a file called 46028.xml, then I wrote the encrypter function in my program, encrypted it, and finally gave it the .enc extension.

Then pulled the index.db from the CA directory of the device and cloned the Torrey Pines North entry. Updated the entry to point the file to 46028.xml. Put the file back on the device in the right spot and rebooted the device to find the playable course on there! Next week will put this to good use.


You can ping this entry by using http://www.wanderinghuman.com/cgi-bin/mt-tb.cgi/119 .


Posting of new comments has been disabled for this post.