[Android Software Development] mcbyte_it:
ROM Stats v2.0 beta is being developed, check what's new here​

CyanogenMod has a feature to report anonymous Statistics to the Cyanogenmod Team: on first boot the user is given the choice to send anonymous statistics to CyanogenMod website (http://stats.cyanogenmod.com).

I needed to track the usage of a ROM i cooked, so I went ahead and pulled the source code of this feature the CyanogenMod GitHub, made some modifications to make it run on any Rom (Android > 2.3.3), and here it is, available for anybody who wants to use it in their ROM.

View attachment 1722734 View attachment 1722735 View attachment 1722736 View attachment 1722737 View attachment 1722738 View attachment 1624677

To use this in a ROM, it should contain the RomStats.apk (attached) as either a User or a System app, and then add these lines in the main build.prop of the ROM (under /system):

# ROM Statistics and ROM Identification
ro.romstats.url=http://www.[domainname].com/[subfolder]/
ro.romstats.name=[[I]The desired ROM name[/I]]
ro.romstats.version=[[I]ROM Version[/I]]
ro.romstats.tframe=7

Then there needs to be a web application on the server as the domain (the URL parameter) where the data is submitted. For that now I wrote a simple php page with a mysql database to save the data. You will find the application attached to this thread (romstats_website.zip).

The submitted data contains:

Device hash: which is an MD5 hash of the IMEI (or wifi MAC, if imei is unavailable for some reason)

Device name: the property "ro.product.model" of build.prop

Device version: the property "ro.build.display.id" of build.prop

Country: from the Android API, getNetworkCountryIso

Carrier: from the Android API, getNetworkOperatorName

Carier ID: from the Android API, getNetworkOperator

ROM Name: from the newly added property "ro.romstats.name"

ROM version: from the newly added property "ro.romstats.version"

in addition to this data, the database has an extra 2 columns:

First registration date: the first time the device registered on the server

Last check-in date: the last time the device (with same device hash) checked in, to remove inactive devices after X days

ROMs that use ROM Stats are:

McByte jkSGS3 (my own ROM)

XenonHD Roms (for 4 different Nexus devices)

BeeGee_Tokyo Ganbarou GT-P7500

broodplank1337 ROM

Installing the Web component:

The web component (romstats_website.zip) is a simple php application that has 2 parts:

1- submit.php

2- stats.php

you will also find the script to create the database table, a single very simple one to collect the data.

The submit.php is the component that receives the stats from the devices, while the stats.php is what displays the information for the users/devs (as CSS, it uses the Bootstrap framework, hosted on the BootstrapCDN provider (no css or javascript in my package).

I also included a .htaccess file, this is because I want the web component to be independent from the server technology. the client will submit the information to the www.domain.com/subfolder/submit (without the .php extension), the .htaccess is what translates the /stats to /stats.php

If you want to implement the Web component with other technologies, just be sure that the submit component works in the same way.

The Stats page has a note that devices which don't report for 90 days are removed from the db, this has not been done yet, it is just a simple query to add in the submit.php or to a cron job.​

I know that users like to remain anonymous, and most don't like to be tracked, but this kind of tracking is a great method for ROM developers to have statistics on the usage of their creation.

Any feedback is welcome.

Source code of the app is available on GitHub

UPDATE 28/01/2013

added a new option (Uninstall) in the main screen which will appear if the app is installed as a User app (not system), this will allow the end user to uninstall the stats app completely from the deivce, and not just opt-out of stat submitting.

UPDATE 02/02/2013

added a new parameter for the build.prop (tframe) that allows developers to decide the interval of checkins, if not set, app will use 7 days as default.

UPDATE 12/02/2013

ROM Stats has been featured on XDA Developers Home page