-
Notifications
You must be signed in to change notification settings - Fork 5
/
packages_apps_LineageParts.diff
425 lines (385 loc) · 20.7 KB
/
packages_apps_LineageParts.diff
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index a4dbfaa..a322962 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -257,7 +257,7 @@
android:resource="@string/summary_empty" />
</activity-alias> -->
- <!-- Anonymous Statistics -->
+ <!-- Anonymous Statistics
<receiver
android:name=".lineagestats.ReportingServiceManager"
android:enabled="true"
@@ -267,7 +267,7 @@
<action android:name="android.intent.action.BOOT_COMPLETED" />
<action android:name="org.lineageos.lineageparts.action.TRIGGER_REPORT_METRICS" />
</intent-filter>
- </receiver>
+ </receiver> -->
<service
android:name=".lineagestats.ReportingService"
diff --git a/res/drawable/ic_counter.xml b/res/drawable/ic_counter.xml
deleted file mode 100644
index fd8f0b5..0000000
--- a/res/drawable/ic_counter.xml
+++ /dev/null
@@ -1,27 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- Copyright (C) 2017-2022 crDroid Android Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-<vector xmlns:android="http://schemas.android.com/apk/res/android"
- android:width="24dp"
- android:height="24dp"
- android:viewportWidth="24"
- android:viewportHeight="24"
- android:tint="?android:colorControlNormal">
-
- <path
- android:fillColor="#FFFFFFFF"
- android:pathData="M4,4H20A2,2 0 0,1 22,6V18A2,2 0 0,1 20,20H4A2,2 0 0,1 2,18V6A2,2 0 0,1 4,4M4,6V18H11V6H4M20,18V6H18.76C19,6.54 18.95,7.07 18.95,7.13C18.88,7.8 18.41,8.5 18.24,8.75L15.91,11.3L19.23,11.28L19.24,12.5L14.04,12.47L14,11.47C14,11.47 17.05,8.24 17.2,7.95C17.34,7.67 17.91,6 16.5,6C15.27,6.05 15.41,7.3 15.41,7.3L13.87,7.31C13.87,7.31 13.88,6.65 14.25,6H13V18H15.58L15.57,17.14L16.54,17.13C16.54,17.13 17.45,16.97 17.46,16.08C17.5,15.08 16.65,15.08 16.5,15.08C16.37,15.08 15.43,15.13 15.43,15.95H13.91C13.91,15.95 13.95,13.89 16.5,13.89C19.1,13.89 18.96,15.91 18.96,15.91C18.96,15.91 19,17.16 17.85,17.63L18.37,18H20M8.92,16H7.42V10.2L5.62,10.76V9.53L8.76,8.41H8.92V16Z" />
-</vector>
diff --git a/res/values/config.xml b/res/values/config.xml
index 6daf34a..a3ee437 100644
--- a/res/values/config.xml
+++ b/res/values/config.xml
@@ -18,7 +18,7 @@
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<!-- Metrics server endpoint -->
- <string name="stats_crdroid_url">https://stats.crdroid.net/api/</string>
+ <string name="stats_lineage_url">https://stats.lineageos.org/api/v1/stats</string>
<!-- Default action ids for a device's touchscreen gestures
The array should be sorted in the same order as the
diff --git a/res/xml/anonymous_stats.xml b/res/xml/anonymous_stats.xml
index 04d576c..b0b8668 100644
--- a/res/xml/anonymous_stats.xml
+++ b/res/xml/anonymous_stats.xml
@@ -25,7 +25,7 @@
android:key="stats_collection"
android:title="@string/stats_collection_title"
android:summary="@string/stats_collection_summary"
- android:defaultValue="true" />
+ android:defaultValue="false" />
<Preference
android:title="@string/preview_data_title"
diff --git a/res/xml/parts_catalog.xml b/res/xml/parts_catalog.xml
index ad6781f..1070cb1 100644
--- a/res/xml/parts_catalog.xml
+++ b/res/xml/parts_catalog.xml
@@ -75,10 +75,10 @@
android:fragment="org.lineageos.lineageparts.statusbar.StatusBarSettings"
lineage:xmlRes="@xml/status_bar_settings" />-->
- <part android:key="lineagestats"
+ <!--<part android:key="lineagestats"
android:title="@string/anonymous_statistics_title"
android:fragment="org.lineageos.lineageparts.lineagestats.AnonymousStats"
- lineage:xmlRes="@xml/anonymous_stats" />
+ lineage:xmlRes="@xml/anonymous_stats" />-->
<!--<part android:key="power_menu"
android:title="@string/power_menu_title"
diff --git a/res/xml/trust_preferences.xml b/res/xml/trust_preferences.xml
index ba60ebb..4adbe61 100644
--- a/res/xml/trust_preferences.xml
+++ b/res/xml/trust_preferences.xml
@@ -48,10 +48,6 @@
android:entryValues="@array/trust_restrict_usb_values"
android:defaultValue="0" />
- <lineageos.preference.LineagePartsPreference
- android:key="lineagestats"
- android:icon="@drawable/ic_counter" />
-
<ListPreference
android:key="sms_security_check_limit"
android:icon="@drawable/ic_message_alert"
diff --git a/src/org/lineageos/lineageparts/lineagestats/AnonymousStats.java b/src/org/lineageos/lineageparts/lineagestats/AnonymousStats.java
index cdb1eef..114872f 100644
--- a/src/org/lineageos/lineageparts/lineagestats/AnonymousStats.java
+++ b/src/org/lineageos/lineageparts/lineagestats/AnonymousStats.java
@@ -17,32 +17,22 @@
package org.lineageos.lineageparts.lineagestats;
-import android.content.ContentResolver;
import android.content.Context;
import android.content.SharedPreferences;
-import android.database.ContentObserver;
-import android.net.Uri;
import android.os.Bundle;
-import android.os.Handler;
-import android.os.Looper;
-import android.os.UserHandle;
-
-import lineageos.providers.LineageSettings;
import org.lineageos.lineageparts.R;
import org.lineageos.lineageparts.SettingsPreferenceFragment;
public class AnonymousStats extends SettingsPreferenceFragment {
- private static final String PREF_FILE_NAME = "crDroidStats";
+ private static final String PREF_FILE_NAME = "LineageStats";
static final String ANONYMOUS_OPT_IN = "pref_anonymous_opt_in";
static final String ANONYMOUS_LAST_CHECKED = "pref_anonymous_checked_in";
static final String KEY_LAST_JOB_ID = "last_job_id";
static final int QUEUE_MAX_THRESHOLD = 1000;
- private Context mContext;
-
public static SharedPreferences getPreferences(Context context) {
return context.getSharedPreferences(PREF_FILE_NAME, 0);
}
@@ -51,35 +41,6 @@ public class AnonymousStats extends SettingsPreferenceFragment {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.anonymous_stats);
-
- mContext = getActivity().getApplicationContext();
-
- SettingsObserver observer = new SettingsObserver(new Handler(Looper.getMainLooper()));
- observer.observe();
- }
-
- class SettingsObserver extends ContentObserver {
- SettingsObserver(Handler handler) {
- super(handler);
- }
-
- void observe() {
- ContentResolver resolver = mContext.getContentResolver();
-
- resolver.registerContentObserver(LineageSettings.Secure.getUriFor(
- LineageSettings.Secure.STATS_COLLECTION), true, this,
- UserHandle.USER_ALL);
- }
-
- @Override
- public void onChange(boolean selfChange, Uri uri) {
- if (uri.equals(LineageSettings.Secure.getUriFor(
- LineageSettings.Secure.STATS_COLLECTION))) {
- boolean enable = LineageSettings.Secure.getInt(mContext.getContentResolver(),
- LineageSettings.Secure.STATS_COLLECTION, 1) == 1;
- if (enable) ReportingServiceManager.launchService(mContext, true);
- }
- }
}
public static void updateLastSynced(Context context) {
diff --git a/src/org/lineageos/lineageparts/lineagestats/ReportingService.java b/src/org/lineageos/lineageparts/lineagestats/ReportingService.java
index 793a6b8..44279b3 100644
--- a/src/org/lineageos/lineageparts/lineagestats/ReportingService.java
+++ b/src/org/lineageos/lineageparts/lineagestats/ReportingService.java
@@ -27,7 +27,7 @@ import android.os.PersistableBundle;
import android.util.Log;
public class ReportingService extends IntentService {
- static final String TAG = "crDroidStats";
+ /* package */ static final String TAG = "LineageStats";
private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG);
public ReportingService() {
@@ -42,46 +42,40 @@ public class ReportingService extends IntentService {
String deviceId = Utilities.getUniqueID(context);
String deviceName = Utilities.getDevice();
- String deviceCrVersion = Utilities.getModVersion();
- String deviceBuildDate = Utilities.getBuildDate();
- String deviceAndroidVersion = Utilities.getAndroidVersion();
- String deviceTag = Utilities.getTag();
+ String deviceVersion = Utilities.getModVersion();
String deviceCountry = Utilities.getCountryCode(context);
String deviceCarrier = Utilities.getCarrier(context);
String deviceCarrierId = Utilities.getCarrierId(context);
- final int crdroidOldJobId = AnonymousStats.getLastJobId(context);
- final int crdroidOrgJobId = AnonymousStats.getNextJobId(context);
+ final int lineageOldJobId = AnonymousStats.getLastJobId(context);
+ final int lineageOrgJobId = AnonymousStats.getNextJobId(context);
- if (DEBUG) Log.d(TAG, "scheduling job id: " + crdroidOrgJobId);
+ if (DEBUG) Log.d(TAG, "scheduling job id: " + lineageOrgJobId);
- PersistableBundle crdroidBundle = new PersistableBundle();
- crdroidBundle.putString(StatsUploadJobService.KEY_DEVICE_NAME, deviceName);
- crdroidBundle.putString(StatsUploadJobService.KEY_UNIQUE_ID, deviceId);
- crdroidBundle.putString(StatsUploadJobService.KEY_CR_VERSION, deviceCrVersion);
- crdroidBundle.putString(StatsUploadJobService.KEY_BUILD_DATE, deviceBuildDate);
- crdroidBundle.putString(StatsUploadJobService.KEY_ANDROID_VERSION, deviceAndroidVersion);
- crdroidBundle.putString(StatsUploadJobService.KEY_TAG, deviceTag);
- crdroidBundle.putString(StatsUploadJobService.KEY_COUNTRY, deviceCountry);
- crdroidBundle.putString(StatsUploadJobService.KEY_CARRIER, deviceCarrier);
- crdroidBundle.putString(StatsUploadJobService.KEY_CARRIER_ID, deviceCarrierId);
- crdroidBundle.putLong(StatsUploadJobService.KEY_TIMESTAMP, System.currentTimeMillis());
+ PersistableBundle lineageBundle = new PersistableBundle();
+ lineageBundle.putString(StatsUploadJobService.KEY_DEVICE_NAME, deviceName);
+ lineageBundle.putString(StatsUploadJobService.KEY_UNIQUE_ID, deviceId);
+ lineageBundle.putString(StatsUploadJobService.KEY_VERSION, deviceVersion);
+ lineageBundle.putString(StatsUploadJobService.KEY_COUNTRY, deviceCountry);
+ lineageBundle.putString(StatsUploadJobService.KEY_CARRIER, deviceCarrier);
+ lineageBundle.putString(StatsUploadJobService.KEY_CARRIER_ID, deviceCarrierId);
+ lineageBundle.putLong(StatsUploadJobService.KEY_TIMESTAMP, System.currentTimeMillis());
// set job types
- crdroidBundle.putInt(StatsUploadJobService.KEY_JOB_TYPE,
- StatsUploadJobService.JOB_TYPE_CRDROID);
+ lineageBundle.putInt(StatsUploadJobService.KEY_JOB_TYPE,
+ StatsUploadJobService.JOB_TYPE_LINEAGEORG);
- // schedule crdroid stats upload
- js.schedule(new JobInfo.Builder(crdroidOrgJobId, new ComponentName(getPackageName(),
+ // schedule lineage stats upload
+ js.schedule(new JobInfo.Builder(lineageOrgJobId, new ComponentName(getPackageName(),
StatsUploadJobService.class.getName()))
.setRequiredNetworkType(JobInfo.NETWORK_TYPE_ANY)
.setMinimumLatency(1000)
- .setExtras(crdroidBundle)
+ .setExtras(lineageBundle)
.setPersisted(true)
.build());
// cancel old job in case it didn't run yet
- js.cancel(crdroidOldJobId);
+ js.cancel(lineageOldJobId);
// reschedule
AnonymousStats.updateLastSynced(this);
diff --git a/src/org/lineageos/lineageparts/lineagestats/ReportingServiceManager.java b/src/org/lineageos/lineageparts/lineagestats/ReportingServiceManager.java
index 1363554..6faeb89 100644
--- a/src/org/lineageos/lineageparts/lineagestats/ReportingServiceManager.java
+++ b/src/org/lineageos/lineageparts/lineagestats/ReportingServiceManager.java
@@ -31,7 +31,7 @@ public class ReportingServiceManager extends BroadcastReceiver {
private static final long MILLIS_PER_DAY = 24L * MILLIS_PER_HOUR;
private static final long UPDATE_INTERVAL = 1L * MILLIS_PER_DAY;
- private static final String TAG = "crDroidStats";
+ private static final String TAG = ReportingServiceManager.class.getSimpleName();
public static final String ACTION_LAUNCH_SERVICE =
"org.lineageos.lineageparts.action.TRIGGER_REPORT_METRICS";
diff --git a/src/org/lineageos/lineageparts/lineagestats/StatsUploadJobService.java b/src/org/lineageos/lineageparts/lineagestats/StatsUploadJobService.java
index 02e20f5..e19c2e5 100644
--- a/src/org/lineageos/lineageparts/lineagestats/StatsUploadJobService.java
+++ b/src/org/lineageos/lineageparts/lineagestats/StatsUploadJobService.java
@@ -34,18 +34,15 @@ import java.util.concurrent.Executors;
public class StatsUploadJobService extends JobService {
- private static final String TAG = "crDroidStats";
- private static final boolean DEBUG = true;
+ private static final String TAG = StatsUploadJobService.class.getSimpleName();
+ 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_CRDROID = 1;
+ public static final int JOB_TYPE_LINEAGEORG = 1;
public static final String KEY_UNIQUE_ID = "uniqueId";
public static final String KEY_DEVICE_NAME = "deviceName";
- public static final String KEY_CR_VERSION = "crVersion";
- public static final String KEY_BUILD_DATE = "buildDate";
- public static final String KEY_ANDROID_VERSION = "androidVersion";
- public static final String KEY_TAG = "tag";
+ public static final String KEY_VERSION = "version";
public static final String KEY_COUNTRY = "country";
public static final String KEY_CARRIER = "carrier";
public static final String KEY_CARRIER_ID = "carrierId";
@@ -103,10 +100,7 @@ public class StatsUploadJobService extends JobService {
String deviceId = extras.getString(KEY_UNIQUE_ID);
String deviceName = extras.getString(KEY_DEVICE_NAME);
- String deviceCrVersion = extras.getString(KEY_CR_VERSION);
- String deviceBuildDate = extras.getString(KEY_BUILD_DATE);
- String deviceAndroidVersion = extras.getString(KEY_ANDROID_VERSION);
- String deviceTag = extras.getString(KEY_TAG);
+ String deviceVersion = extras.getString(KEY_VERSION);
String deviceCountry = extras.getString(KEY_COUNTRY);
String deviceCarrier = extras.getString(KEY_CARRIER);
String deviceCarrierId = extras.getString(KEY_CARRIER_ID);
@@ -115,12 +109,12 @@ public class StatsUploadJobService extends JobService {
int jobType = extras.getInt(KEY_JOB_TYPE, -1);
if (!mCancelled) {
switch (jobType) {
- case JOB_TYPE_CRDROID:
+ case JOB_TYPE_LINEAGEORG:
try {
JSONObject json = buildStatsRequest(deviceId, deviceName,
- deviceCrVersion, deviceBuildDate, deviceAndroidVersion,
- deviceTag, deviceCountry, deviceCarrier, deviceCarrierId);
- success = uploadToCrdroid(json);
+ deviceVersion, deviceCountry, deviceCarrier,
+ deviceCarrierId);
+ success = uploadToLineage(json);
} catch (IOException | JSONException e) {
Log.e(TAG, "Could not upload stats checkin to community server", e);
}
@@ -146,25 +140,21 @@ public class StatsUploadJobService extends JobService {
}
}
- private JSONObject buildStatsRequest(String deviceId, String deviceName, String deviceCrVersion,
- String deviceBuildDate, String deviceAndroidVersion, String deviceTag,
+ private JSONObject buildStatsRequest(String deviceId, String deviceName, String deviceVersion,
String deviceCountry, String deviceCarrier,
String deviceCarrierId) throws JSONException {
JSONObject request = new JSONObject();
request.put("device_hash", deviceId);
request.put("device_name", deviceName);
- request.put("device_crversion", deviceCrVersion);
- request.put("device_builddate", deviceBuildDate);
- request.put("device_androidversion", deviceAndroidVersion);
- request.put("device_tag", deviceTag);
+ request.put("device_version", deviceVersion);
request.put("device_country", deviceCountry);
request.put("device_carrier", deviceCarrier);
request.put("device_carrier_id", deviceCarrierId);
return request;
}
- private boolean uploadToCrdroid(JSONObject json) throws IOException {
- final Uri uri = Uri.parse(getString(R.string.stats_crdroid_url));
+ private boolean uploadToLineage(JSONObject json) throws IOException {
+ final Uri uri = Uri.parse(getString(R.string.stats_lineage_url));
URL url = new URL(uri.toString());
HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection();
try {
@@ -174,12 +164,11 @@ public class StatsUploadJobService extends JobService {
urlConnection.setRequestProperty("Content-Type", "application/json; charset=UTF-8");
OutputStream os = urlConnection.getOutputStream();
- if (DEBUG) Log.d(TAG, "Sending stats=" + json.toString());
os.write(json.toString().getBytes(StandardCharsets.UTF_8));
os.close();
final int responseCode = urlConnection.getResponseCode();
- if (DEBUG) Log.d(TAG, "crdroid server response code=" + responseCode);
+ if (DEBUG) Log.d(TAG, "lineage server response code=" + responseCode);
final boolean success = responseCode == HttpURLConnection.HTTP_OK;
if (!success) {
Log.w(TAG, "failed sending, server returned: " + getResponse(urlConnection));
diff --git a/src/org/lineageos/lineageparts/lineagestats/Utilities.java b/src/org/lineageos/lineageparts/lineagestats/Utilities.java
index 85d1a5f..6d06079 100644
--- a/src/org/lineageos/lineageparts/lineagestats/Utilities.java
+++ b/src/org/lineageos/lineageparts/lineagestats/Utilities.java
@@ -82,19 +82,6 @@ public class Utilities {
return SystemProperties.get("ro.modversion", Build.DISPLAY);
}
- public static String getBuildDate() {
- return SystemProperties.get("ro.build.date", "Unknown");
- }
-
- public static String getAndroidVersion() {
- return SystemProperties.get("ro.crdroid.version", Build.VERSION.RELEASE);
- }
-
- public static String getTag() {
- String tag = "Official"; // TODO
- return tag;
- }
-
public static String digest(String input) {
try {
MessageDigest md = MessageDigest.getInstance("SHA-256");
@@ -109,8 +96,9 @@ public class Utilities {
* @return Whether or not stats collection is enabled.
*/
public static boolean isStatsCollectionEnabled(Context context) {
- return LineageSettings.Secure.getInt(context.getContentResolver(),
- LineageSettings.Secure.STATS_COLLECTION, 1) != 0;
+ LineageSettings.Secure.putInt(context.getContentResolver(),
+ LineageSettings.Secure.STATS_COLLECTION, 0);
+ return false;
}
/**
@@ -118,9 +106,8 @@ public class Utilities {
* @param enabled Boolean that sets collection being enabled.
*/
public static void setStatsCollectionEnabled(Context context, boolean enabled) {
- int enable = (enabled) ? 1 : 0;
LineageSettings.Secure.putInt(context.getContentResolver(),
- LineageSettings.Secure.STATS_COLLECTION, enable);
+ LineageSettings.Secure.STATS_COLLECTION, 0);
}
private static boolean isCdmaPhone(TelephonyManager tm) {