summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Shields <keepcalm444@gmail.com>2016-12-27 21:36:39 +1100
committerZhao Wei Liew <zhaoweiliew@gmail.com>2016-12-31 14:16:01 +0000
commit640c391b1521005d99f54165ff20fd47a2a13d2d (patch)
tree85c9b677a4ba43e36a5c6bed73e91ce02d1e7a06
parent3a22b88a268939c01b9d027308d551a5f7930690 (diff)
downloadpackages_apps_Settings-640c391b1521005d99f54165ff20fd47a2a13d2d.zip
packages_apps_Settings-640c391b1521005d99f54165ff20fd47a2a13d2d.tar.gz
packages_apps_Settings-640c391b1521005d99f54165ff20fd47a2a13d2d.tar.bz2
Settings: cmstats: Stop sending stats to cyngn servers
Change-Id: I30fa515f924f368b6cd7016ba03f366affaa6e5e
-rwxr-xr-xres/values/config.xml5
-rw-r--r--src/com/android/settings/cmstats/ReportingService.java36
-rw-r--r--src/com/android/settings/cmstats/StatsUploadJobService.java100
3 files changed, 15 insertions, 126 deletions
diff --git a/res/values/config.xml b/res/values/config.xml
index aa97d3c..c93d6f3 100755
--- a/res/values/config.xml
+++ b/res/values/config.xml
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2007 The Android Open Source Project
+ (C) 2017 The LineageOS Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -50,10 +51,8 @@
<!-- Config to enable duplicate APN checking. When true, disallows adding new duplicate APNs -->
<bool name="config_enable_duplicate_apn_checking">false</bool>
- <!-- Metrics server endpoints -->
+ <!-- Metrics server endpoint -->
<string name="stats_cm_url">https://stats.cyanogenmod.org/submit</string>
- <string name="stats_cyanogen_url">https://shopvac.cyngn.com/community/heartbeat</string>
- <string name="stats_cyanogen_token_url">https://account.cyngn.com/api/v1/community/heartbeat_token</string>
<!-- Display ro.product.name above Device model -->
<bool name="config_displayDeviceName">false</bool>
diff --git a/src/com/android/settings/cmstats/ReportingService.java b/src/com/android/settings/cmstats/ReportingService.java
index 8410143..5c876b9 100644
--- a/src/com/android/settings/cmstats/ReportingService.java
+++ b/src/com/android/settings/cmstats/ReportingService.java
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2015 The CyanogenMod Project
+ * (C) 2017 The LineageOS Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -51,39 +52,24 @@ public class ReportingService extends IntentService {
String deviceCarrierId = Utilities.getCarrierId(getApplicationContext());
boolean optOut = intent.getBooleanExtra(EXTRA_OPTING_OUT, false);
- final int cyanogenJobId = AnonymousStats.getNextJobId(getApplicationContext());
final int cmOrgJobId = AnonymousStats.getNextJobId(getApplicationContext());
- if (DEBUG) Log.d(TAG, "scheduling jobs id: " + cyanogenJobId + ", " + cmOrgJobId);
+ if (DEBUG) Log.d(TAG, "scheduling job id: " + cmOrgJobId);
- PersistableBundle cyanogenBundle = new PersistableBundle();
- cyanogenBundle.putBoolean(StatsUploadJobService.KEY_OPT_OUT, optOut);
- cyanogenBundle.putString(StatsUploadJobService.KEY_DEVICE_NAME, deviceName);
- cyanogenBundle.putString(StatsUploadJobService.KEY_UNIQUE_ID, deviceId);
- cyanogenBundle.putString(StatsUploadJobService.KEY_VERSION, deviceVersion);
- cyanogenBundle.putString(StatsUploadJobService.KEY_COUNTRY, deviceCountry);
- cyanogenBundle.putString(StatsUploadJobService.KEY_CARRIER, deviceCarrier);
- cyanogenBundle.putString(StatsUploadJobService.KEY_CARRIER_ID, deviceCarrierId);
- cyanogenBundle.putLong(StatsUploadJobService.KEY_TIMESTAMP, System.currentTimeMillis());
-
- // get snapshot and persist it
- PersistableBundle cmBundle = new PersistableBundle(cyanogenBundle);
+ PersistableBundle cmBundle = new PersistableBundle();
+ cmBundle.putBoolean(StatsUploadJobService.KEY_OPT_OUT, optOut);
+ cmBundle.putString(StatsUploadJobService.KEY_DEVICE_NAME, deviceName);
+ cmBundle.putString(StatsUploadJobService.KEY_UNIQUE_ID, deviceId);
+ cmBundle.putString(StatsUploadJobService.KEY_VERSION, deviceVersion);
+ cmBundle.putString(StatsUploadJobService.KEY_COUNTRY, deviceCountry);
+ cmBundle.putString(StatsUploadJobService.KEY_CARRIER, deviceCarrier);
+ cmBundle.putString(StatsUploadJobService.KEY_CARRIER_ID, deviceCarrierId);
+ cmBundle.putLong(StatsUploadJobService.KEY_TIMESTAMP, System.currentTimeMillis());
// set job types
- cyanogenBundle.putInt(StatsUploadJobService.KEY_JOB_TYPE,
- StatsUploadJobService.JOB_TYPE_CYANOGEN);
cmBundle.putInt(StatsUploadJobService.KEY_JOB_TYPE,
StatsUploadJobService.JOB_TYPE_CMORG);
- // schedule cyanogen stats upload
- js.schedule(new JobInfo.Builder(cyanogenJobId, new ComponentName(getPackageName(),
- StatsUploadJobService.class.getName()))
- .setRequiredNetworkType(JobInfo.NETWORK_TYPE_ANY)
- .setMinimumLatency(1000)
- .setExtras(cyanogenBundle)
- .setPersisted(true)
- .build());
-
// schedule cmorg stats upload
js.schedule(new JobInfo.Builder(cmOrgJobId, new ComponentName(getPackageName(),
StatsUploadJobService.class.getName()))
diff --git a/src/com/android/settings/cmstats/StatsUploadJobService.java b/src/com/android/settings/cmstats/StatsUploadJobService.java
index 580a20f..0171988 100644
--- a/src/com/android/settings/cmstats/StatsUploadJobService.java
+++ b/src/com/android/settings/cmstats/StatsUploadJobService.java
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2015 The CyanogenMod Project
+ * (C) 2017 The LineageOS Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -46,8 +47,7 @@ public class StatsUploadJobService extends JobService {
private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG);
public static final String KEY_JOB_TYPE = "job_type";
- public static final int JOB_TYPE_CYANOGEN = 1;
- public static final int JOB_TYPE_CMORG = 2;
+ public static final int JOB_TYPE_CMORG = 1;
public static final String KEY_UNIQUE_ID = "uniqueId";
public static final String KEY_DEVICE_NAME = "deviceName";
@@ -114,25 +114,6 @@ public class StatsUploadJobService extends JobService {
int jobType = extras.getInt(KEY_JOB_TYPE, -1);
if (!isCancelled()) {
switch (jobType) {
- case JOB_TYPE_CYANOGEN:
- try {
- JSONObject json = new JSONObject();
- json.put("optOut", optOut);
- json.put("uniqueId", deviceId);
- json.put("deviceName", deviceName);
- json.put("version", deviceVersion);
- json.put("country", deviceCountry);
- json.put("carrier", deviceCarrier);
- json.put("carrierId", deviceCarrierId);
- json.put("timestamp", timeStamp);
-
- success = uploadToCyanogen(json);
- } catch (IOException | JSONException e) {
- Log.e(TAG, "Could not upload stats checkin to cyanogen server", e);
- success = false;
- }
- break;
-
case JOB_TYPE_CMORG:
try {
success = uploadToCM(deviceId, deviceName, deviceVersion, deviceCountry,
@@ -192,83 +173,6 @@ public class StatsUploadJobService extends JobService {
}
- private boolean uploadToCyanogen(JSONObject json)
- throws IOException, JSONException {
- String authToken = getAuthToken();
-
- if (authToken.isEmpty()) {
- Log.w(TAG, "no auth token!");
- }
-
- URL url = new URL(getString(R.string.stats_cyanogen_url));
- HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection();
- try {
- urlConnection.setInstanceFollowRedirects(true);
- urlConnection.setDoInput(true);
- urlConnection.setDoOutput(true);
-
- urlConnection.setRequestProperty("Accept-Encoding", "identity");
- urlConnection.setRequestProperty("Authorization", authToken);
- urlConnection.setRequestProperty("Content-Type", "application/json");
-
- OutputStream os = urlConnection.getOutputStream();
- BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(os, "UTF-8"));
- writer.write(json.toString());
- writer.flush();
- writer.close();
- os.close();
-
- urlConnection.connect();
-
- final int responseCode = urlConnection.getResponseCode();
- final boolean success = responseCode == HttpURLConnection.HTTP_OK;
-
- final String response = getResponse(urlConnection, !success);
- if (DEBUG)
- Log.d(TAG, "server responseCode: " + responseCode +", response=" + response);
-
- if (!success) {
- Log.w(TAG, "failed sending, server returned: " + response);
- }
- return success;
- } finally {
- urlConnection.disconnect();
- }
- }
-
- private String getAuthToken() {
- HttpURLConnection urlConnection = null;
- try {
- URL url = new URL(getString(R.string.stats_cyanogen_token_url));
- urlConnection = (HttpURLConnection) url.openConnection();
- urlConnection.setInstanceFollowRedirects(true);
- urlConnection.setDoInput(true);
-
- urlConnection.setRequestProperty("Accept-Encoding", "identity");
- urlConnection.setRequestProperty("Content-Type", "text/plain");
-
- urlConnection.connect();
-
- final int responseCode = urlConnection.getResponseCode();
- final boolean success = responseCode == HttpURLConnection.HTTP_OK;
- if (DEBUG) Log.d(TAG, "server auth response code=" + responseCode);
- final String response = getResponse(urlConnection, !success);
- if (DEBUG)
- Log.d(TAG, "server auth response=" + response);
-
- if (success) {
- return response;
- }
- } catch (IOException e) {
- Log.e(TAG, "error getting auth token", e);
- } finally {
- if (urlConnection != null) {
- urlConnection.disconnect();
- }
- }
- return "";
- }
-
private String getResponse(HttpURLConnection httpUrlConnection, boolean errorStream)
throws IOException {
InputStream responseStream = new BufferedInputStream(errorStream