Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3d473ce5 authored by Adnan Begovic's avatar Adnan Begovic
Browse files

Settings: Rebase against GoogleAnalyticsV3.

Change-Id: Ia015847be4bf985e206a5b4b2362959c6220e2ba
(cherry picked from commit 1d6bc068)
parent 6b090c59
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -7,7 +7,7 @@ LOCAL_STATIC_JAVA_LIBRARIES := \
	android-support-v7-cardview \
	android-support-v13 \
	jsr305 \
    libGoogleAnalyticsV2
        libGoogleAnalyticsV3

LOCAL_MODULE_TAGS := optional

+14 −5
Original line number Diff line number Diff line
@@ -29,6 +29,7 @@ import com.android.settings.Settings;

import com.google.analytics.tracking.android.GoogleAnalytics;
import com.google.analytics.tracking.android.Tracker;
import com.google.analytics.tracking.android.MapBuilder;

import org.apache.http.NameValuePair;
import org.apache.http.client.HttpClient;
@@ -40,6 +41,7 @@ import org.apache.http.message.BasicNameValuePair;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

public class ReportingService extends Service {
    /* package */ static final String TAG = "CMStats";
@@ -81,9 +83,9 @@ public class ReportingService extends Service {
            Log.d(TAG, "SERVICE: Carrier ID=" + deviceCarrierId);

            // report to google analytics
            GoogleAnalytics ga = GoogleAnalytics.getInstance(ReportingService.this);
            Tracker tracker = ga.getTracker(getString(R.string.ga_trackingId));
            tracker.sendEvent(deviceName, deviceVersion, deviceCountry, null);
            Tracker tracker = GoogleAnalytics.getInstance(ReportingService.this)
                    .getTracker(getString(R.string.ga_trackingId));
            tracker.send(createMap(deviceName, deviceVersion,deviceCountry));

            // this really should be set at build time...
            // format of version should be:
@@ -97,9 +99,8 @@ public class ReportingService extends Service {
            }

            if (deviceVersionNoDevice != null) {
                tracker.sendEvent("checkin", deviceName, deviceVersionNoDevice, null);
                tracker.send(createMap("checkin", deviceName, deviceVersionNoDevice));
            }
            tracker.close();

            // report to the cmstats service
            HttpClient httpClient = new DefaultHttpClient();
@@ -146,4 +147,12 @@ public class ReportingService extends Service {
            stopSelf();
        }
    }

    private Map<String, String> createMap(String category, String action, String label) {
        return MapBuilder.createEvent(category,     // Event category (required)
                action,                     // Event action (required)
                label,                      // Event label
                        null)                       // Event value
                .build();
    }
}
+4 −2
Original line number Diff line number Diff line
@@ -69,7 +69,8 @@ public class ReportingServiceManager extends BroadcastReceiver {
        AlarmManager alarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
        alarmManager.set(AlarmManager.RTC_WAKEUP, System.currentTimeMillis() + millisFromNow,
                PendingIntent.getBroadcast(context, 0, intent, 0));
        Log.d(ReportingService.TAG, "Next sync attempt in : " + millisFromNow / MILLIS_PER_HOUR + " hours");
        Log.d(ReportingService.TAG, "Next sync attempt in : "
                + millisFromNow / MILLIS_PER_HOUR + " hours");
    }

    public static void launchService(Context context) {
@@ -95,7 +96,8 @@ public class ReportingServiceManager extends BroadcastReceiver {
        long timeElapsed = System.currentTimeMillis() - lastSynced;
        if (timeElapsed < UPDATE_INTERVAL) {
            long timeLeft = UPDATE_INTERVAL - timeElapsed;
            Log.d(ReportingService.TAG, "Waiting for next sync : " + timeLeft / MILLIS_PER_HOUR + " hours");
            Log.d(ReportingService.TAG, "Waiting for next sync : "
                    + timeLeft / MILLIS_PER_HOUR + " hours");
            return;
        }