mirror of
https://github.com/Divested-Mobile/DivestOS-Build.git
synced 2025-12-01 20:54:49 -05:00
Initial commit, long overdue
This commit is contained in:
commit
c0083c1519
292 changed files with 951990 additions and 0 deletions
|
|
@ -0,0 +1,604 @@
|
|||
From b2252cf1a4b22d60dae76300415ad5bbc6cd0a89 Mon Sep 17 00:00:00 2001
|
||||
From: Martin Brabham <optedoblivion@cyngn.com>
|
||||
Date: Fri, 9 Jan 2015 14:49:10 -0800
|
||||
Subject: [PATCH] DNSCrypt: Add settings for starting/stopping and configuring
|
||||
the DNSCrypt daemon.
|
||||
|
||||
Wire up to framework Settings.Secure
|
||||
|
||||
Change-Id: I846e30f7121460b1eed9879d9d225ffe1506050b
|
||||
---
|
||||
AndroidManifest.xml | 10 ++
|
||||
res/values/cm_strings.xml | 11 ++
|
||||
res/xml/dns_crypt_settings.xml | 38 +++++
|
||||
res/xml/privacy_settings_cyanogenmod.xml | 10 ++
|
||||
.../dnscrypt/DnsCryptPreferenceActivity.java | 149 ++++++++++++++++++++
|
||||
.../settings/dnscrypt/LoadConfigFileTask.java | 152 ++++++++++++++++++++
|
||||
.../dnscrypt/model/DnsCryptServerEntry.java | 155 +++++++++++++++++++++
|
||||
7 files changed, 525 insertions(+)
|
||||
create mode 100644 res/xml/dns_crypt_settings.xml
|
||||
create mode 100644 src/com/android/settings/dnscrypt/DnsCryptPreferenceActivity.java
|
||||
create mode 100644 src/com/android/settings/dnscrypt/LoadConfigFileTask.java
|
||||
create mode 100644 src/com/android/settings/dnscrypt/model/DnsCryptServerEntry.java
|
||||
|
||||
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
|
||||
index f38e0bc..ed95f32 100755
|
||||
--- a/AndroidManifest.xml
|
||||
+++ b/AndroidManifest.xml
|
||||
@@ -2868,6 +2868,16 @@
|
||||
</intent-filter>
|
||||
</receiver>
|
||||
|
||||
+ <activity
|
||||
+ android:name=".dnscrypt.DnsCryptPreferenceActivity"
|
||||
+ android:label="DNS Encryption"
|
||||
+ android:excludeFromRecents="true">
|
||||
+ <intent-filter>
|
||||
+ <action android:name="com.android.settings.action.ACTION_DNSCRYPT_SETTINGS" />
|
||||
+ <category android:name="android.intent.category.DEFAULT" />
|
||||
+ </intent-filter>
|
||||
+ </activity>
|
||||
+
|
||||
<activity android:name=".applications.ProtectedAppsActivity"
|
||||
android:label="@string/protected_apps"
|
||||
android:excludeFromRecents="true"
|
||||
diff --git a/res/values/cm_strings.xml b/res/values/cm_strings.xml
|
||||
index 6b42f4e..51aff3c 100644
|
||||
--- a/res/values/cm_strings.xml
|
||||
+++ b/res/values/cm_strings.xml
|
||||
@@ -1163,4 +1163,15 @@
|
||||
<string name="restrict_app_cellular_title">Disable app cellular usage</string>
|
||||
<string name="restrict_app_cellular_summary">Prevent app from using cellular data connection</string>
|
||||
<string name="privacy_guard_internet_category">Internet</string>
|
||||
+
|
||||
+ <!-- DNS Encryption -->
|
||||
+ <string name="dns_enc_title">DNS encryption</string>
|
||||
+ <string name="dns_enc_summary">Manage DNS encryption settings</string>
|
||||
+ <string name="dns_enc_switch_title">Enable DNS encryption</string>
|
||||
+ <string name="dns_enc_switch_summary">Toggle execution of local DNS encryption service</string>
|
||||
+ <string name="dns_enc_cat_config_title">Configuration</string>
|
||||
+ <string name="dns_enc_server_title">DNS resolver list</string>
|
||||
+ <string name="dns_enc_server_summary">Select which server you want to use</string>
|
||||
+ <string name="dns_enc_resolver_label">DNS resolver: </string>
|
||||
+ <string name="dns_enc_resolvers_loading">Loading encrypted DNS resolver configuration...</string>
|
||||
</resources>
|
||||
diff --git a/res/xml/dns_crypt_settings.xml b/res/xml/dns_crypt_settings.xml
|
||||
new file mode 100644
|
||||
index 0000000..636f754
|
||||
--- /dev/null
|
||||
+++ b/res/xml/dns_crypt_settings.xml
|
||||
@@ -0,0 +1,38 @@
|
||||
+<?xml version="1.0" encoding="utf-8"?>
|
||||
+<!-- Copyright (C) 2008 The Android Open Source 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.
|
||||
+-->
|
||||
+
|
||||
+<PreferenceScreen
|
||||
+ xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
+ xmlns:settings="http://schemas.android.com/apk/res/com.android.settings"
|
||||
+ android:title="@string/radio_controls_title">
|
||||
+
|
||||
+ <SwitchPreference
|
||||
+ android:key="pref_toggle_dnscrypt"
|
||||
+ android:title="@string/dns_enc_switch_title"
|
||||
+ android:summary="@string/dns_enc_switch_summary"
|
||||
+ android:persistent="false"/>
|
||||
+
|
||||
+ <PreferenceCategory
|
||||
+ android:key="pref_cat_config"
|
||||
+ android:title="@string/dns_enc_cat_config_title">
|
||||
+ <ListPreference
|
||||
+ android:key="pref_server_list"
|
||||
+ android:title="@string/dns_enc_server_title"
|
||||
+ android:summary="@string/dns_enc_server_summary"
|
||||
+ android:persistent="false"/>
|
||||
+ </PreferenceCategory>
|
||||
+
|
||||
+</PreferenceScreen>
|
||||
diff --git a/res/xml/privacy_settings_cyanogenmod.xml b/res/xml/privacy_settings_cyanogenmod.xml
|
||||
index 256ca00..25221c2 100644
|
||||
--- a/res/xml/privacy_settings_cyanogenmod.xml
|
||||
+++ b/res/xml/privacy_settings_cyanogenmod.xml
|
||||
@@ -47,4 +47,14 @@
|
||||
android:targetPackage="com.android.settings"
|
||||
android:targetClass="com.android.settings.applications.ProtectedAppsActivity" />
|
||||
</Preference>
|
||||
+
|
||||
+ <PreferenceScreen
|
||||
+ android:key="key_dns_crypt"
|
||||
+ android:title="@string/dns_enc_title"
|
||||
+ android:summary="@string/dns_enc_summary">
|
||||
+ <intent
|
||||
+ android:action="com.android.settings.action.ACTION_DNSCRYPT_SETTINGS"
|
||||
+ android:targetPackage="com.android.settings"
|
||||
+ android:targetClass="com.android.settings.dnscrypt.DnsCryptPreferenceActivity" />
|
||||
+ </PreferenceScreen>
|
||||
</PreferenceScreen>
|
||||
diff --git a/src/com/android/settings/dnscrypt/DnsCryptPreferenceActivity.java b/src/com/android/settings/dnscrypt/DnsCryptPreferenceActivity.java
|
||||
new file mode 100644
|
||||
index 0000000..64f13c7
|
||||
--- /dev/null
|
||||
+++ b/src/com/android/settings/dnscrypt/DnsCryptPreferenceActivity.java
|
||||
@@ -0,0 +1,149 @@
|
||||
+/*
|
||||
+* Copyright (C) 2014 The CyanogenMod 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.
|
||||
+*/
|
||||
+
|
||||
+package com.android.settings.dnscrypt;
|
||||
+
|
||||
+import android.app.ProgressDialog;
|
||||
+import android.os.Bundle;
|
||||
+import android.preference.ListPreference;
|
||||
+import android.preference.Preference;
|
||||
+import android.preference.Preference.OnPreferenceChangeListener;
|
||||
+import android.preference.PreferenceActivity;
|
||||
+import android.preference.SwitchPreference;
|
||||
+import android.provider.Settings;
|
||||
+import android.util.Log;
|
||||
+import com.android.settings.R;
|
||||
+import com.android.settings.dnscrypt.LoadConfigFileTask.ILoadConfigListener;
|
||||
+
|
||||
+import java.io.File;
|
||||
+
|
||||
+/**
|
||||
+ * DnsCryptSettingsFragment
|
||||
+ * <pre>
|
||||
+ * Screen for configuring and starting stopping encrypted dns daemon
|
||||
+ * </pre>
|
||||
+ *
|
||||
+ * @see {@link android.preference.PreferenceActivity}
|
||||
+ * @see {@link android.preference.Preference.OnPreferenceChangeListener}
|
||||
+ */
|
||||
+public class DnsCryptPreferenceActivity extends PreferenceActivity implements
|
||||
+ OnPreferenceChangeListener, ILoadConfigListener {
|
||||
+
|
||||
+ // Constants
|
||||
+ private static final String TAG = DnsCryptPreferenceActivity.class.getSimpleName();
|
||||
+ private static final String PREF_TOGGLE = "pref_toggle_dnscrypt";
|
||||
+ private static final String PREF_SERVER_LIST = "pref_server_list";
|
||||
+ private static final String CONFIG_FILE = "/system/etc/dnscrypt-resolvers.csv";
|
||||
+
|
||||
+ // Members
|
||||
+ private SwitchPreference mEncryptionSwitchPreference;
|
||||
+ private ListPreference mServerListPreference;
|
||||
+ private LoadConfigFileTask mLoadConfigFileTask;
|
||||
+ private String mDnsResolverLabel = "DNS provider";
|
||||
+
|
||||
+ // Views
|
||||
+ private ProgressDialog mProgressDialog;
|
||||
+
|
||||
+ @Override
|
||||
+ public void onCreate(Bundle savedInstanceState) {
|
||||
+ super.onCreate(savedInstanceState);
|
||||
+ getActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
+ getActionBar().setTitle(R.string.dns_enc_title);
|
||||
+ addPreferencesFromResource(R.xml.dns_crypt_settings);
|
||||
+ mEncryptionSwitchPreference = (SwitchPreference) findPreference(PREF_TOGGLE);
|
||||
+ mEncryptionSwitchPreference.setOnPreferenceChangeListener(this);
|
||||
+ mServerListPreference = (ListPreference) findPreference(PREF_SERVER_LIST);
|
||||
+ mServerListPreference.setOnPreferenceChangeListener(this);
|
||||
+ mDnsResolverLabel = getResources().getString(R.string.dns_enc_resolver_label);
|
||||
+ mProgressDialog = new ProgressDialog(this);
|
||||
+ mProgressDialog.setTitle(R.string.dns_enc_resolvers_loading);
|
||||
+ mProgressDialog.show();
|
||||
+ if (mLoadConfigFileTask == null) {
|
||||
+ mLoadConfigFileTask =
|
||||
+ new LoadConfigFileTask(new File(CONFIG_FILE), mProgressDialog, this);
|
||||
+ mLoadConfigFileTask.execute();
|
||||
+ }
|
||||
+ initPreferences();
|
||||
+ }
|
||||
+
|
||||
+ private void initPreferences() {
|
||||
+ boolean currentCheckedState = (Settings.Secure.getInt(getContentResolver(),
|
||||
+ Settings.Secure.DNS_ENCRYPTION_TOGGLE,
|
||||
+ Settings.Secure.DNS_ENCRYPTION_TOGGLE_DEFAULT) == 1);
|
||||
+ if (mEncryptionSwitchPreference != null) {
|
||||
+ mEncryptionSwitchPreference.setChecked(currentCheckedState);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean onPreferenceChange(Preference preference, Object o) {
|
||||
+ if (preference == mEncryptionSwitchPreference) {
|
||||
+ Boolean newCheckedState = (Boolean) o;
|
||||
+ mServerListPreference.setEnabled(newCheckedState);
|
||||
+ int setValue = (newCheckedState) ? 1 : 0;
|
||||
+ Settings.Secure.putInt(getContentResolver(), Settings.Secure.DNS_ENCRYPTION_TOGGLE,
|
||||
+ setValue);
|
||||
+ return true;
|
||||
+ } else if (preference == mServerListPreference) {
|
||||
+ String value = (String) o;
|
||||
+ int i;
|
||||
+ for (i = 0; i < mServerListPreference.getEntryValues().length; i++) {
|
||||
+ if (value.equals(mServerListPreference.getEntryValues()[i])) {
|
||||
+ break;
|
||||
+ }
|
||||
+ }
|
||||
+ try {
|
||||
+ mServerListPreference.setSummary(mDnsResolverLabel +
|
||||
+ mServerListPreference.getEntries()[i]);
|
||||
+ } catch (ArrayIndexOutOfBoundsException oobe) {
|
||||
+ Log.e(TAG, "Error finding default value!");
|
||||
+ mServerListPreference.setSummary(R.string.dns_enc_server_summary);
|
||||
+ }
|
||||
+ Settings.Secure.putString(getContentResolver(), Settings.Secure
|
||||
+ .DNS_ENCRYPTION_SERVER, value);
|
||||
+ return true;
|
||||
+ }
|
||||
+ return false;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void onConfigLoaded(CharSequence[] entries, CharSequence[] entryValues) {
|
||||
+ if (mServerListPreference != null && entries != null && entryValues != null) {
|
||||
+ mServerListPreference.setEntries(entries);
|
||||
+ mServerListPreference.setEntryValues(entryValues);
|
||||
+ String value = Settings.Secure.getString(getContentResolver(),
|
||||
+ Settings.Secure.DNS_ENCRYPTION_SERVER);
|
||||
+ value = (value == null) ? Settings.Secure.DNS_ENCRYPTION_SERVER_DEFAULT : value;
|
||||
+ mServerListPreference.setValue(value);
|
||||
+ int i;
|
||||
+ for (i = 0; i < mServerListPreference.getEntryValues().length; i++) {
|
||||
+ if (value.equals(mServerListPreference.getEntryValues()[i])) {
|
||||
+ break;
|
||||
+ }
|
||||
+ }
|
||||
+ try {
|
||||
+ mServerListPreference.setSummary(mDnsResolverLabel
|
||||
+ + mServerListPreference.getEntries()[i]);
|
||||
+ } catch (ArrayIndexOutOfBoundsException oobe) {
|
||||
+ Log.e(TAG, "Error finding default value!", oobe);
|
||||
+ mServerListPreference.setSummary(R.string.dns_enc_server_summary);
|
||||
+ }
|
||||
+ mServerListPreference.setEnabled(mEncryptionSwitchPreference.isChecked());
|
||||
+ }
|
||||
+ mLoadConfigFileTask = null;
|
||||
+ mProgressDialog.dismiss();
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/com/android/settings/dnscrypt/LoadConfigFileTask.java b/src/com/android/settings/dnscrypt/LoadConfigFileTask.java
|
||||
new file mode 100644
|
||||
index 0000000..910e6c1
|
||||
--- /dev/null
|
||||
+++ b/src/com/android/settings/dnscrypt/LoadConfigFileTask.java
|
||||
@@ -0,0 +1,152 @@
|
||||
+/*
|
||||
+* Copyright (C) 2014 The CyanogenMod 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.
|
||||
+*/
|
||||
+
|
||||
+package com.android.settings.dnscrypt;
|
||||
+
|
||||
+import android.app.ProgressDialog;
|
||||
+import android.os.AsyncTask;
|
||||
+import android.util.Log;
|
||||
+
|
||||
+import java.io.BufferedReader;
|
||||
+import java.io.File;
|
||||
+import java.io.FileInputStream;
|
||||
+import java.io.IOException;
|
||||
+import java.io.InputStreamReader;
|
||||
+import java.util.ArrayList;
|
||||
+import java.util.List;
|
||||
+
|
||||
+/**
|
||||
+ * LoadConfigFileTask
|
||||
+ * <pre>
|
||||
+ * This task will check if the config file exists in /system/etc and if so will load it for
|
||||
+ * configuration display in Settings
|
||||
+ * </pre>
|
||||
+ */
|
||||
+public class LoadConfigFileTask extends AsyncTask<Void, Integer, Void> {
|
||||
+
|
||||
+ // Constants
|
||||
+ private static final String TAG = LoadConfigFileTask.class.getSimpleName();
|
||||
+
|
||||
+ // Members
|
||||
+ private ILoadConfigListener mListener;
|
||||
+ private File mConfigFile;
|
||||
+ private ProgressDialog mProgressDialog;
|
||||
+ private CharSequence[] mEntries;
|
||||
+ private CharSequence[] mEntryValues;
|
||||
+
|
||||
+ /**
|
||||
+ * Constructor
|
||||
+ *
|
||||
+ * @param configFile {@link java.io.File}
|
||||
+ * @param progressDialog {@link android.app.ProgressDialog}
|
||||
+ * @throws IllegalArgumentException {@link java.lang.IllegalArgumentException}
|
||||
+ */
|
||||
+ public LoadConfigFileTask(File configFile, ProgressDialog progressDialog, ILoadConfigListener
|
||||
+ listener)
|
||||
+ throws IllegalArgumentException {
|
||||
+ if (configFile == null || !configFile.exists()) {
|
||||
+ throw new IllegalArgumentException("'configFile' must not be null and must exist!");
|
||||
+ }
|
||||
+ mConfigFile = configFile;
|
||||
+ mProgressDialog = progressDialog;
|
||||
+ mListener = listener;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void onPreExecute() {
|
||||
+ if (mProgressDialog != null) {
|
||||
+ mProgressDialog.show();
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void onProgressUpdate(Integer... progress) {
|
||||
+ if (mProgressDialog != null) {
|
||||
+ mProgressDialog.setProgress(progress[0]);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public Void doInBackground(Void... params) {
|
||||
+
|
||||
+ if (mConfigFile == null || !mConfigFile.exists()) {
|
||||
+ Log.w(TAG, "No config file found....such strange!");
|
||||
+ // [TODO][MSB]: Download that sucker!
|
||||
+ // [TODO][MSB]: Perform sig check?
|
||||
+ return null;
|
||||
+ }
|
||||
+
|
||||
+ try {
|
||||
+ FileInputStream fis = new FileInputStream(mConfigFile);
|
||||
+ InputStreamReader reader = new InputStreamReader(fis);
|
||||
+ BufferedReader bufferedReader = new BufferedReader(reader);
|
||||
+ List<String> configLines = new ArrayList<String>();
|
||||
+ String line = "";
|
||||
+ while((line = bufferedReader.readLine()) != null) {
|
||||
+ configLines.add(line);
|
||||
+ }
|
||||
+ mEntries = new CharSequence[configLines.size() - 1];
|
||||
+ mEntryValues = new CharSequence[configLines.size() - 1];
|
||||
+ if (mProgressDialog != null) {
|
||||
+ mProgressDialog.setMax(configLines.size());
|
||||
+ }
|
||||
+ boolean skippedTitle = false;
|
||||
+ int progress = 0;
|
||||
+ int i = 0;
|
||||
+ for (String configLine : configLines) {
|
||||
+ if (!skippedTitle) {
|
||||
+ skippedTitle = true;
|
||||
+ progress++;
|
||||
+ continue;
|
||||
+ }
|
||||
+ String[] configParts = configLine.split(",");
|
||||
+ if (configParts.length > 3) {
|
||||
+ String name = configParts[0];
|
||||
+ String fullName = configParts[1];
|
||||
+ mEntries[i] = fullName;
|
||||
+ mEntryValues[i] = name;
|
||||
+ }
|
||||
+ i++;
|
||||
+ progress++;
|
||||
+ publishProgress(progress);
|
||||
+ }
|
||||
+ } catch (IOException e) {
|
||||
+ Log.e(TAG, e.getMessage());
|
||||
+ }
|
||||
+ return null;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void onPostExecute(Void result) {
|
||||
+ if (mListener != null) {
|
||||
+ mListener.onConfigLoaded(mEntries, mEntryValues);
|
||||
+ }
|
||||
+ if (mProgressDialog != null) {
|
||||
+ mProgressDialog.dismiss();
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * ILoadConfigListener
|
||||
+ * <pre>
|
||||
+ * Callback interface for passing back results
|
||||
+ * </pre>
|
||||
+ */
|
||||
+ public interface ILoadConfigListener {
|
||||
+ public void onConfigLoaded(CharSequence[] entries, CharSequence[] entryValues);
|
||||
+ }
|
||||
+
|
||||
+}
|
||||
diff --git a/src/com/android/settings/dnscrypt/model/DnsCryptServerEntry.java b/src/com/android/settings/dnscrypt/model/DnsCryptServerEntry.java
|
||||
new file mode 100644
|
||||
index 0000000..c0f2c75
|
||||
--- /dev/null
|
||||
+++ b/src/com/android/settings/dnscrypt/model/DnsCryptServerEntry.java
|
||||
@@ -0,0 +1,155 @@
|
||||
+/*
|
||||
+* Copyright (C) 2014 The CyanogenMod 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.
|
||||
+*/
|
||||
+
|
||||
+package com.android.settings.dnscrypt.model;
|
||||
+
|
||||
+/**
|
||||
+ * DnsCryptServerEntry
|
||||
+ * <pre>
|
||||
+ * Model object for representing a dns crypt server entry
|
||||
+ * </pre>
|
||||
+ */
|
||||
+public class DnsCryptServerEntry {
|
||||
+
|
||||
+ // Members
|
||||
+ private String mName;
|
||||
+ private String mFullName;
|
||||
+ private String mDescription;
|
||||
+ private String mLocation;
|
||||
+ private String mCoords;
|
||||
+ private String mUrl;
|
||||
+ private String mVersion;
|
||||
+ private String mDnsSecValidation;
|
||||
+ private String mNoLogs;
|
||||
+ private String mNamecoin;
|
||||
+ private String mResolverAddress;
|
||||
+ private String mProviderName;
|
||||
+ private String mProviderPublicKey;
|
||||
+ private String mProviderPublicKeyTextRecord;
|
||||
+
|
||||
+ public String getName() {
|
||||
+ return mName;
|
||||
+ }
|
||||
+
|
||||
+ public void setName(String name) {
|
||||
+ mName = name;
|
||||
+ }
|
||||
+
|
||||
+ public String getFullName() {
|
||||
+ return mFullName;
|
||||
+ }
|
||||
+
|
||||
+ public void setFullName(String fullName) {
|
||||
+ mFullName = fullName;
|
||||
+ }
|
||||
+
|
||||
+ public String getDescription() {
|
||||
+ return mDescription;
|
||||
+ }
|
||||
+
|
||||
+ public void setDescription(String description) {
|
||||
+ mDescription = description;
|
||||
+ }
|
||||
+
|
||||
+ public String getLocation() {
|
||||
+ return mLocation;
|
||||
+ }
|
||||
+
|
||||
+ public void setLocation(String location) {
|
||||
+ mLocation = location;
|
||||
+ }
|
||||
+
|
||||
+ public String getCoords() {
|
||||
+ return mCoords;
|
||||
+ }
|
||||
+
|
||||
+ public void setCoords(String coords) {
|
||||
+ mCoords = coords;
|
||||
+ }
|
||||
+
|
||||
+ public String getUrl() {
|
||||
+ return mUrl;
|
||||
+ }
|
||||
+
|
||||
+ public void setUrl(String url) {
|
||||
+ mUrl = url;
|
||||
+ }
|
||||
+
|
||||
+ public String getVersion() {
|
||||
+ return mVersion;
|
||||
+ }
|
||||
+
|
||||
+ public void setVersion(String version) {
|
||||
+ mVersion = version;
|
||||
+ }
|
||||
+
|
||||
+ public String getDnsSecValidation() {
|
||||
+ return mDnsSecValidation;
|
||||
+ }
|
||||
+
|
||||
+ public void setDnsSecValidation(String dnsSecValidation) {
|
||||
+ mDnsSecValidation = dnsSecValidation;
|
||||
+ }
|
||||
+
|
||||
+ public String getNoLogs() {
|
||||
+ return mNoLogs;
|
||||
+ }
|
||||
+
|
||||
+ public void setNoLogs(String noLogs) {
|
||||
+ mNoLogs = noLogs;
|
||||
+ }
|
||||
+
|
||||
+ public String getNamecoin() {
|
||||
+ return mNamecoin;
|
||||
+ }
|
||||
+
|
||||
+ public void setNamecoin(String namecoin) {
|
||||
+ mNamecoin = namecoin;
|
||||
+ }
|
||||
+
|
||||
+ public String getResolverAddress() {
|
||||
+ return mResolverAddress;
|
||||
+ }
|
||||
+
|
||||
+ public void setResolverAddress(String resolverAddress) {
|
||||
+ mResolverAddress = resolverAddress;
|
||||
+ }
|
||||
+
|
||||
+ public String getProviderName() {
|
||||
+ return mProviderName;
|
||||
+ }
|
||||
+
|
||||
+ public void setProviderName(String providerName) {
|
||||
+ mProviderName = providerName;
|
||||
+ }
|
||||
+
|
||||
+ public String getProviderPublicKey() {
|
||||
+ return mProviderPublicKey;
|
||||
+ }
|
||||
+
|
||||
+ public void setProviderPublicKey(String providerPublicKey) {
|
||||
+ mProviderPublicKey = providerPublicKey;
|
||||
+ }
|
||||
+
|
||||
+ public String getProviderPublicKeyTextRecord() {
|
||||
+ return mProviderPublicKeyTextRecord;
|
||||
+ }
|
||||
+
|
||||
+ public void setProviderPublicKeyTextRecord(String providerPublicKeyTextRecord) {
|
||||
+ mProviderPublicKeyTextRecord = providerPublicKeyTextRecord;
|
||||
+ }
|
||||
+
|
||||
+}
|
||||
--
|
||||
2.7.4
|
||||
|
||||
|
|
@ -0,0 +1,231 @@
|
|||
From ef32dacb30b5c938d48ba294ff660b0cd5777dd6 Mon Sep 17 00:00:00 2001
|
||||
From: Tad <tad@spotco.us>
|
||||
Date: Mon, 18 Apr 2016 09:27:27 -0400
|
||||
Subject: [PATCH] Implement hostname Randomization
|
||||
|
||||
Change-Id: I00bfb9235979c2c80191cb0871716adaa3583e06
|
||||
---
|
||||
MAC_Rand.patch | 120 +++++++++++++++++++++++++
|
||||
res/values/cm_strings.xml | 4 +
|
||||
res/xml/wireless_settings.xml | 6 ++
|
||||
src/com/android/settings/WirelessSettings.java | 14 +++
|
||||
4 files changed, 144 insertions(+)
|
||||
create mode 100644 MAC_Rand.patch
|
||||
|
||||
diff --git a/MAC_Rand.patch b/MAC_Rand.patch
|
||||
new file mode 100644
|
||||
index 0000000..48ad1ec
|
||||
--- /dev/null
|
||||
+++ b/MAC_Rand.patch
|
||||
@@ -0,0 +1,120 @@
|
||||
+From e84a1e030313cbc2875c9d3ee1f016808d33dab3 Mon Sep 17 00:00:00 2001
|
||||
+From: Tad <tad@spotco.us>
|
||||
+Date: Mon, 18 Apr 2016 08:53:03 -0400
|
||||
+Subject: [PATCH] Implement MAC Randomization
|
||||
+
|
||||
+Change-Id: Id074d011eac7c33af267de4c1649670c32770cb5
|
||||
+---
|
||||
+ res/values/cm_strings.xml | 4 ++++
|
||||
+ res/xml/wireless_settings.xml | 6 ++++++
|
||||
+ src/com/android/settings/WirelessSettings.java | 24 +++++++++++++++++++++++-
|
||||
+ 3 files changed, 33 insertions(+), 1 deletion(-)
|
||||
+
|
||||
+diff --git a/res/values/cm_strings.xml b/res/values/cm_strings.xml
|
||||
+index 128660e..8aa4785 100644
|
||||
+--- a/res/values/cm_strings.xml
|
||||
++++ b/res/values/cm_strings.xml
|
||||
+@@ -1187,4 +1187,8 @@
|
||||
+
|
||||
+ <!-- Label for settings shortcut: carrier selection -->
|
||||
+ <string name="shortcut_carrier_title">Network operators</string>
|
||||
++
|
||||
++ <!-- randomize MAC addresses -->
|
||||
++ <string name="randomize_mac_title">Randomize MAC addresses</string>
|
||||
++ <string name="randomize_mac_summary">Assign random MAC addresses when network devices are enabled</string>
|
||||
+ </resources>
|
||||
+diff --git a/res/xml/wireless_settings.xml b/res/xml/wireless_settings.xml
|
||||
+index 8882003..4a2d5d0 100644
|
||||
+--- a/res/xml/wireless_settings.xml
|
||||
++++ b/res/xml/wireless_settings.xml
|
||||
+@@ -19,6 +19,12 @@
|
||||
+ android:title="@string/radio_controls_title">
|
||||
+
|
||||
+ <SwitchPreference
|
||||
++ android:key="randomize_mac"
|
||||
++ android:title="@string/randomize_mac_title"
|
||||
++ android:summary="@string/randomize_mac_summary"
|
||||
++ android:persistent="false" />
|
||||
++
|
||||
++ <SwitchPreference
|
||||
+ android:key="toggle_airplane"
|
||||
+ android:title="@string/airplane_mode"
|
||||
+ android:persistent="false"
|
||||
+diff --git a/src/com/android/settings/WirelessSettings.java b/src/com/android/settings/WirelessSettings.java
|
||||
+index 4a0c9e3..4432940 100644
|
||||
+--- a/src/com/android/settings/WirelessSettings.java
|
||||
++++ b/src/com/android/settings/WirelessSettings.java
|
||||
+@@ -37,6 +37,7 @@ import android.os.SystemProperties;
|
||||
+ import android.os.UserHandle;
|
||||
+ import android.os.UserManager;
|
||||
+ import android.preference.Preference;
|
||||
++import android.preference.Preference.OnPreferenceChangeListener;
|
||||
+ import android.preference.PreferenceCategory;
|
||||
+ import android.preference.PreferenceScreen;
|
||||
+ import android.preference.SwitchPreference;
|
||||
+@@ -58,9 +59,11 @@ import java.util.ArrayList;
|
||||
+ import java.util.Arrays;
|
||||
+ import java.util.List;
|
||||
+
|
||||
+-public class WirelessSettings extends SettingsPreferenceFragment implements Indexable {
|
||||
++public class WirelessSettings extends SettingsPreferenceFragment
|
||||
++ implements OnPreferenceChangeListener, Indexable {
|
||||
+ private static final String TAG = "WirelessSettings";
|
||||
+
|
||||
++ private static final String KEY_RANDOMIZE_MAC = "randomize_mac";
|
||||
+ private static final String KEY_TOGGLE_AIRPLANE = "toggle_airplane";
|
||||
+ private static final String KEY_NFC_CATEGORY_SETTINGS = "nfc_category_settings";
|
||||
+ private static final String KEY_TOGGLE_NFC = "toggle_nfc";
|
||||
+@@ -76,9 +79,12 @@ public class WirelessSettings extends SettingsPreferenceFragment implements Inde
|
||||
+ private static final String KEY_WFC_SETTINGS = "wifi_calling_settings";
|
||||
+ private static final String KEY_NFC_PAYMENT_SETTINGS = "nfc_payment_settings";
|
||||
+
|
||||
++ private static final String RANDOMIZE_PERSIST_PROP = "persist.privacy.randomize_mac";
|
||||
++
|
||||
+ public static final String EXIT_ECM_RESULT = "exit_ecm_result";
|
||||
+ public static final int REQUEST_CODE_EXIT_ECM = 1;
|
||||
+
|
||||
++ private SwitchPreference mRandomizeMac;
|
||||
+ private AirplaneModeEnabler mAirplaneModeEnabler;
|
||||
+ private SwitchPreference mAirplaneModePreference;
|
||||
+ private NfcEnabler mNfcEnabler;
|
||||
+@@ -232,6 +238,8 @@ public class WirelessSettings extends SettingsPreferenceFragment implements Inde
|
||||
+ final boolean isSecondaryUser = myUserId != UserHandle.USER_OWNER;
|
||||
+
|
||||
+ final Activity activity = getActivity();
|
||||
++ mRandomizeMac = (SwitchPreference) findPreference(KEY_RANDOMIZE_MAC);
|
||||
++ mRandomizeMac.setOnPreferenceChangeListener(this);
|
||||
+ mAirplaneModePreference = (SwitchPreference) findPreference(KEY_TOGGLE_AIRPLANE);
|
||||
+ SwitchPreference nfc = (SwitchPreference) findPreference(KEY_TOGGLE_NFC);
|
||||
+ PreferenceScreen androidBeam = (PreferenceScreen) findPreference(KEY_ANDROID_BEAM_SETTINGS);
|
||||
+@@ -370,6 +378,10 @@ public class WirelessSettings extends SettingsPreferenceFragment implements Inde
|
||||
+ public void onResume() {
|
||||
+ super.onResume();
|
||||
+
|
||||
++ if (mRandomizeMac != null) {
|
||||
++ mRandomizeMac.setChecked(SystemProperties.getBoolean(RANDOMIZE_PERSIST_PROP, true));
|
||||
++ }
|
||||
++
|
||||
+ mAirplaneModeEnabler.resume();
|
||||
+ if (mNfcEnabler != null) {
|
||||
+ mNfcEnabler.resume();
|
||||
+@@ -390,6 +402,16 @@ public class WirelessSettings extends SettingsPreferenceFragment implements Inde
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
++ @Override
|
||||
++ public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||
++ if (preference == mRandomizeMac) {
|
||||
++ SystemProperties.set(RANDOMIZE_PERSIST_PROP, (Boolean) newValue ? "1" : "0");
|
||||
++ return true;
|
||||
++ }
|
||||
++
|
||||
++ return false;
|
||||
++ }
|
||||
++
|
||||
+ @Override
|
||||
+ public void onSaveInstanceState(Bundle outState) {
|
||||
+ super.onSaveInstanceState(outState);
|
||||
+--
|
||||
+2.8.0
|
||||
+
|
||||
diff --git a/res/values/cm_strings.xml b/res/values/cm_strings.xml
|
||||
index 8aa4785..cb825c2 100644
|
||||
--- a/res/values/cm_strings.xml
|
||||
+++ b/res/values/cm_strings.xml
|
||||
@@ -1191,4 +1191,8 @@
|
||||
<!-- randomize MAC addresses -->
|
||||
<string name="randomize_mac_title">Randomize MAC addresses</string>
|
||||
<string name="randomize_mac_summary">Assign random MAC addresses when network devices are enabled</string>
|
||||
+
|
||||
+ <!-- randomize hostname -->
|
||||
+ <string name="randomize_hostname_title">Randomize network hostname</string>
|
||||
+ <string name="randomize_hostname_summary">Assign random network hostname on boot</string>
|
||||
</resources>
|
||||
diff --git a/res/xml/wireless_settings.xml b/res/xml/wireless_settings.xml
|
||||
index 4a2d5d0..905e8de 100644
|
||||
--- a/res/xml/wireless_settings.xml
|
||||
+++ b/res/xml/wireless_settings.xml
|
||||
@@ -25,6 +25,12 @@
|
||||
android:persistent="false" />
|
||||
|
||||
<SwitchPreference
|
||||
+ android:key="randomize_hostname"
|
||||
+ android:title="@string/randomize_hostname_title"
|
||||
+ android:summary="@string/randomize_hostname_summary"
|
||||
+ android:persistent="false" />
|
||||
+
|
||||
+ <SwitchPreference
|
||||
android:key="toggle_airplane"
|
||||
android:title="@string/airplane_mode"
|
||||
android:persistent="false"
|
||||
diff --git a/src/com/android/settings/WirelessSettings.java b/src/com/android/settings/WirelessSettings.java
|
||||
index 4432940..6ce772e 100644
|
||||
--- a/src/com/android/settings/WirelessSettings.java
|
||||
+++ b/src/com/android/settings/WirelessSettings.java
|
||||
@@ -64,6 +64,7 @@ public class WirelessSettings extends SettingsPreferenceFragment
|
||||
private static final String TAG = "WirelessSettings";
|
||||
|
||||
private static final String KEY_RANDOMIZE_MAC = "randomize_mac";
|
||||
+ private static final String KEY_RANDOMIZE_HOST = "randomize_hostname";
|
||||
private static final String KEY_TOGGLE_AIRPLANE = "toggle_airplane";
|
||||
private static final String KEY_NFC_CATEGORY_SETTINGS = "nfc_category_settings";
|
||||
private static final String KEY_TOGGLE_NFC = "toggle_nfc";
|
||||
@@ -80,11 +81,13 @@ public class WirelessSettings extends SettingsPreferenceFragment
|
||||
private static final String KEY_NFC_PAYMENT_SETTINGS = "nfc_payment_settings";
|
||||
|
||||
private static final String RANDOMIZE_PERSIST_PROP = "persist.privacy.randomize_mac";
|
||||
+ private static final String RANDOMIZE_HOST_PERSIST_PROP = "persist.privacy.randomize_host";
|
||||
|
||||
public static final String EXIT_ECM_RESULT = "exit_ecm_result";
|
||||
public static final int REQUEST_CODE_EXIT_ECM = 1;
|
||||
|
||||
private SwitchPreference mRandomizeMac;
|
||||
+ private SwitchPreference mRandomizeHost;
|
||||
private AirplaneModeEnabler mAirplaneModeEnabler;
|
||||
private SwitchPreference mAirplaneModePreference;
|
||||
private NfcEnabler mNfcEnabler;
|
||||
@@ -240,6 +243,8 @@ public class WirelessSettings extends SettingsPreferenceFragment
|
||||
final Activity activity = getActivity();
|
||||
mRandomizeMac = (SwitchPreference) findPreference(KEY_RANDOMIZE_MAC);
|
||||
mRandomizeMac.setOnPreferenceChangeListener(this);
|
||||
+ mRandomizeHost = (SwitchPreference) findPreference(KEY_RANDOMIZE_HOST);
|
||||
+ mRandomizeHost.setOnPreferenceChangeListener(this);
|
||||
mAirplaneModePreference = (SwitchPreference) findPreference(KEY_TOGGLE_AIRPLANE);
|
||||
SwitchPreference nfc = (SwitchPreference) findPreference(KEY_TOGGLE_NFC);
|
||||
PreferenceScreen androidBeam = (PreferenceScreen) findPreference(KEY_ANDROID_BEAM_SETTINGS);
|
||||
@@ -382,6 +387,10 @@ public class WirelessSettings extends SettingsPreferenceFragment
|
||||
mRandomizeMac.setChecked(SystemProperties.getBoolean(RANDOMIZE_PERSIST_PROP, true));
|
||||
}
|
||||
|
||||
+ if (mRandomizeHost != null) {
|
||||
+ mRandomizeHost.setChecked(SystemProperties.getBoolean(RANDOMIZE_HOST_PERSIST_PROP, true));
|
||||
+ }
|
||||
+
|
||||
mAirplaneModeEnabler.resume();
|
||||
if (mNfcEnabler != null) {
|
||||
mNfcEnabler.resume();
|
||||
@@ -409,6 +418,11 @@ public class WirelessSettings extends SettingsPreferenceFragment
|
||||
return true;
|
||||
}
|
||||
|
||||
+ if (preference == mRandomizeHost) {
|
||||
+ SystemProperties.set(RANDOMIZE_HOST_PERSIST_PROP, (Boolean) newValue ? "1" : "0");
|
||||
+ return true;
|
||||
+ }
|
||||
+
|
||||
return false;
|
||||
}
|
||||
|
||||
--
|
||||
2.8.0
|
||||
|
||||
|
|
@ -0,0 +1,120 @@
|
|||
From e84a1e030313cbc2875c9d3ee1f016808d33dab3 Mon Sep 17 00:00:00 2001
|
||||
From: Tad <tad@spotco.us>
|
||||
Date: Mon, 18 Apr 2016 08:53:03 -0400
|
||||
Subject: [PATCH] Implement MAC Randomization
|
||||
|
||||
Change-Id: Id074d011eac7c33af267de4c1649670c32770cb5
|
||||
---
|
||||
res/values/cm_strings.xml | 4 ++++
|
||||
res/xml/wireless_settings.xml | 6 ++++++
|
||||
src/com/android/settings/WirelessSettings.java | 24 +++++++++++++++++++++++-
|
||||
3 files changed, 33 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/res/values/cm_strings.xml b/res/values/cm_strings.xml
|
||||
index 128660e..8aa4785 100644
|
||||
--- a/res/values/cm_strings.xml
|
||||
+++ b/res/values/cm_strings.xml
|
||||
@@ -1187,4 +1187,8 @@
|
||||
|
||||
<!-- Label for settings shortcut: carrier selection -->
|
||||
<string name="shortcut_carrier_title">Network operators</string>
|
||||
+
|
||||
+ <!-- randomize MAC addresses -->
|
||||
+ <string name="randomize_mac_title">Randomize MAC addresses</string>
|
||||
+ <string name="randomize_mac_summary">Assign random MAC addresses when network devices are enabled</string>
|
||||
</resources>
|
||||
diff --git a/res/xml/wireless_settings.xml b/res/xml/wireless_settings.xml
|
||||
index 8882003..4a2d5d0 100644
|
||||
--- a/res/xml/wireless_settings.xml
|
||||
+++ b/res/xml/wireless_settings.xml
|
||||
@@ -19,6 +19,12 @@
|
||||
android:title="@string/radio_controls_title">
|
||||
|
||||
<SwitchPreference
|
||||
+ android:key="randomize_mac"
|
||||
+ android:title="@string/randomize_mac_title"
|
||||
+ android:summary="@string/randomize_mac_summary"
|
||||
+ android:persistent="false" />
|
||||
+
|
||||
+ <SwitchPreference
|
||||
android:key="toggle_airplane"
|
||||
android:title="@string/airplane_mode"
|
||||
android:persistent="false"
|
||||
diff --git a/src/com/android/settings/WirelessSettings.java b/src/com/android/settings/WirelessSettings.java
|
||||
index 4a0c9e3..4432940 100644
|
||||
--- a/src/com/android/settings/WirelessSettings.java
|
||||
+++ b/src/com/android/settings/WirelessSettings.java
|
||||
@@ -37,6 +37,7 @@ import android.os.SystemProperties;
|
||||
import android.os.UserHandle;
|
||||
import android.os.UserManager;
|
||||
import android.preference.Preference;
|
||||
+import android.preference.Preference.OnPreferenceChangeListener;
|
||||
import android.preference.PreferenceCategory;
|
||||
import android.preference.PreferenceScreen;
|
||||
import android.preference.SwitchPreference;
|
||||
@@ -58,9 +59,11 @@ import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
-public class WirelessSettings extends SettingsPreferenceFragment implements Indexable {
|
||||
+public class WirelessSettings extends SettingsPreferenceFragment
|
||||
+ implements OnPreferenceChangeListener, Indexable {
|
||||
private static final String TAG = "WirelessSettings";
|
||||
|
||||
+ private static final String KEY_RANDOMIZE_MAC = "randomize_mac";
|
||||
private static final String KEY_TOGGLE_AIRPLANE = "toggle_airplane";
|
||||
private static final String KEY_NFC_CATEGORY_SETTINGS = "nfc_category_settings";
|
||||
private static final String KEY_TOGGLE_NFC = "toggle_nfc";
|
||||
@@ -76,9 +79,12 @@ public class WirelessSettings extends SettingsPreferenceFragment implements Inde
|
||||
private static final String KEY_WFC_SETTINGS = "wifi_calling_settings";
|
||||
private static final String KEY_NFC_PAYMENT_SETTINGS = "nfc_payment_settings";
|
||||
|
||||
+ private static final String RANDOMIZE_PERSIST_PROP = "persist.privacy.randomize_mac";
|
||||
+
|
||||
public static final String EXIT_ECM_RESULT = "exit_ecm_result";
|
||||
public static final int REQUEST_CODE_EXIT_ECM = 1;
|
||||
|
||||
+ private SwitchPreference mRandomizeMac;
|
||||
private AirplaneModeEnabler mAirplaneModeEnabler;
|
||||
private SwitchPreference mAirplaneModePreference;
|
||||
private NfcEnabler mNfcEnabler;
|
||||
@@ -232,6 +238,8 @@ public class WirelessSettings extends SettingsPreferenceFragment implements Inde
|
||||
final boolean isSecondaryUser = myUserId != UserHandle.USER_OWNER;
|
||||
|
||||
final Activity activity = getActivity();
|
||||
+ mRandomizeMac = (SwitchPreference) findPreference(KEY_RANDOMIZE_MAC);
|
||||
+ mRandomizeMac.setOnPreferenceChangeListener(this);
|
||||
mAirplaneModePreference = (SwitchPreference) findPreference(KEY_TOGGLE_AIRPLANE);
|
||||
SwitchPreference nfc = (SwitchPreference) findPreference(KEY_TOGGLE_NFC);
|
||||
PreferenceScreen androidBeam = (PreferenceScreen) findPreference(KEY_ANDROID_BEAM_SETTINGS);
|
||||
@@ -370,6 +378,10 @@ public class WirelessSettings extends SettingsPreferenceFragment implements Inde
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
|
||||
+ if (mRandomizeMac != null) {
|
||||
+ mRandomizeMac.setChecked(SystemProperties.getBoolean(RANDOMIZE_PERSIST_PROP, true));
|
||||
+ }
|
||||
+
|
||||
mAirplaneModeEnabler.resume();
|
||||
if (mNfcEnabler != null) {
|
||||
mNfcEnabler.resume();
|
||||
@@ -390,6 +402,16 @@ public class WirelessSettings extends SettingsPreferenceFragment implements Inde
|
||||
}
|
||||
}
|
||||
|
||||
+ @Override
|
||||
+ public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||
+ if (preference == mRandomizeMac) {
|
||||
+ SystemProperties.set(RANDOMIZE_PERSIST_PROP, (Boolean) newValue ? "1" : "0");
|
||||
+ return true;
|
||||
+ }
|
||||
+
|
||||
+ return false;
|
||||
+ }
|
||||
+
|
||||
@Override
|
||||
public void onSaveInstanceState(Bundle outState) {
|
||||
super.onSaveInstanceState(outState);
|
||||
--
|
||||
2.8.0
|
||||
|
||||
|
|
@ -0,0 +1,971 @@
|
|||
From 20b2e611f53c505bfeb5d76176bc0efab9fdf216 Mon Sep 17 00:00:00 2001
|
||||
From: Tad <tad@spotco.us>
|
||||
Date: Wed, 24 Feb 2016 08:41:10 -0500
|
||||
Subject: [PATCH] Remove analytics
|
||||
|
||||
Change-Id: I8ef6bc93aa3e8a256bfd137a982d50c15100d4f0
|
||||
---
|
||||
AndroidManifest.xml | 26 --
|
||||
res/xml/anonymous_stats.xml | 32 ---
|
||||
res/xml/privacy_settings_cyanogenmod.xml | 8 -
|
||||
.../android/settings/cmstats/AnonymousStats.java | 107 --------
|
||||
src/com/android/settings/cmstats/PreviewData.java | 55 ----
|
||||
.../android/settings/cmstats/ReportingService.java | 106 --------
|
||||
.../settings/cmstats/ReportingServiceManager.java | 123 ---------
|
||||
.../settings/cmstats/StatsUploadJobService.java | 291 ---------------------
|
||||
src/com/android/settings/cmstats/Utilities.java | 102 --------
|
||||
.../settings/cyanogenmod/PrivacySettings.java | 3 -
|
||||
10 files changed, 853 deletions(-)
|
||||
delete mode 100644 res/xml/anonymous_stats.xml
|
||||
delete mode 100644 src/com/android/settings/cmstats/AnonymousStats.java
|
||||
delete mode 100644 src/com/android/settings/cmstats/PreviewData.java
|
||||
delete mode 100644 src/com/android/settings/cmstats/ReportingService.java
|
||||
delete mode 100644 src/com/android/settings/cmstats/ReportingServiceManager.java
|
||||
delete mode 100644 src/com/android/settings/cmstats/StatsUploadJobService.java
|
||||
delete mode 100644 src/com/android/settings/cmstats/Utilities.java
|
||||
|
||||
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
|
||||
index 775dbf0..f0ca92f 100755
|
||||
--- a/AndroidManifest.xml
|
||||
+++ b/AndroidManifest.xml
|
||||
@@ -1556,12 +1556,6 @@
|
||||
|
||||
<activity android:name=".EncryptionInterstitial"/>
|
||||
|
||||
- <service android:label="ReportingService"
|
||||
- android:enabled="true"
|
||||
- android:exported="false"
|
||||
- android:name=".cmstats.ReportingService">
|
||||
- </service>
|
||||
-
|
||||
<!-- Runs in the phone process since it needs access to the Phone object -->
|
||||
<activity android:name=".deviceinfo.Status"
|
||||
android:label="@string/device_status_activity_title"
|
||||
@@ -2674,26 +2668,6 @@
|
||||
</intent-filter>$
|
||||
</receiver>
|
||||
|
||||
- <!-- Anonymous Statistics -->
|
||||
- <receiver android:name=".cmstats.ReportingServiceManager"
|
||||
- android:enabled="true"
|
||||
- android:exported="false"
|
||||
- android:label="ReportingServiceManager">
|
||||
- <intent-filter>
|
||||
- <action android:name="android.intent.action.BOOT_COMPLETED" />
|
||||
- <action android:name="com.android.settings.action.TRIGGER_REPORT_METRICS" />
|
||||
- </intent-filter>
|
||||
- </receiver>
|
||||
-
|
||||
- <service android:label="ReportingService"
|
||||
- android:enabled="true"
|
||||
- android:exported="false"
|
||||
- android:name=".cmstats.ReportingService">
|
||||
- </service>
|
||||
-
|
||||
- <service android:name=".cmstats.StatsUploadJobService"
|
||||
- android:permission="android.permission.BIND_JOB_SERVICE" />
|
||||
-
|
||||
<!-- Watch for ContactsContract.Profile changes and update the user's photo. -->
|
||||
<receiver android:name=".users.ProfileUpdateReceiver">
|
||||
<intent-filter>
|
||||
diff --git a/res/xml/anonymous_stats.xml b/res/xml/anonymous_stats.xml
|
||||
deleted file mode 100644
|
||||
index 0f3b8e2..0000000
|
||||
--- a/res/xml/anonymous_stats.xml
|
||||
+++ /dev/null
|
||||
@@ -1,32 +0,0 @@
|
||||
-<?xml version="1.0" encoding="utf-8"?>
|
||||
-<!-- Copyright (C) 2012 The CyanogenMod 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.
|
||||
--->
|
||||
-
|
||||
-<PreferenceScreen
|
||||
- xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
- android:title="@string/anonymous_statistics_title"
|
||||
- xmlns:settings="http://schemas.android.com/apk/res/com.android.settings">
|
||||
-
|
||||
- <com.android.settings.cyanogenmod.CMSecureSettingSwitchPreference
|
||||
- android:key="stats_collection"
|
||||
- android:title="@string/stats_collection_title"
|
||||
- android:summary="@string/stats_collection_summary"
|
||||
- android:defaultValue="true" />
|
||||
-
|
||||
- <PreferenceScreen
|
||||
- android:title="@string/preview_data_title"
|
||||
- android:fragment="com.android.settings.cmstats.PreviewData" />
|
||||
-
|
||||
-</PreferenceScreen>
|
||||
diff --git a/res/xml/privacy_settings_cyanogenmod.xml b/res/xml/privacy_settings_cyanogenmod.xml
|
||||
index 256ca00..04f8643 100644
|
||||
--- a/res/xml/privacy_settings_cyanogenmod.xml
|
||||
+++ b/res/xml/privacy_settings_cyanogenmod.xml
|
||||
@@ -29,14 +29,6 @@
|
||||
android:summary="@string/blacklist_summary"
|
||||
android:fragment="com.android.settings.blacklist.BlacklistSettings" />
|
||||
|
||||
- <!-- Anonymous statistics - (CMStats) -->
|
||||
- <PreferenceScreen
|
||||
- android:key="cmstats"
|
||||
- android:title="@string/anonymous_statistics_title"
|
||||
- android:summary="@string/anonymous_statistics_summary"
|
||||
- android:fragment="com.android.settings.cmstats.AnonymousStats" >
|
||||
- </PreferenceScreen>
|
||||
-
|
||||
<!-- Protected Apps! -->
|
||||
<Preference
|
||||
android:key="protected_apps_manager"
|
||||
diff --git a/src/com/android/settings/cmstats/AnonymousStats.java b/src/com/android/settings/cmstats/AnonymousStats.java
|
||||
deleted file mode 100644
|
||||
index 232a533..0000000
|
||||
--- a/src/com/android/settings/cmstats/AnonymousStats.java
|
||||
+++ /dev/null
|
||||
@@ -1,107 +0,0 @@
|
||||
-/*
|
||||
- * Copyright (C) 2015 The CyanogenMod 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.
|
||||
- */
|
||||
-
|
||||
-package com.android.settings.cmstats;
|
||||
-
|
||||
-import android.content.Context;
|
||||
-import android.content.SharedPreferences;
|
||||
-import android.os.Bundle;
|
||||
-
|
||||
-import android.os.UserHandle;
|
||||
-import android.preference.Preference;
|
||||
-import android.preference.PreferenceScreen;
|
||||
-import android.preference.SwitchPreference;
|
||||
-import com.android.settings.R;
|
||||
-import com.android.settings.SettingsPreferenceFragment;
|
||||
-
|
||||
-import cyanogenmod.providers.CMSettings;
|
||||
-
|
||||
-import org.cyanogenmod.internal.logging.CMMetricsLogger;
|
||||
-
|
||||
-public class AnonymousStats extends SettingsPreferenceFragment {
|
||||
-
|
||||
- private static final String PREF_FILE_NAME = "CMStats";
|
||||
- /* package */ static final String ANONYMOUS_OPT_IN = "pref_anonymous_opt_in";
|
||||
- /* package */ static final String ANONYMOUS_LAST_CHECKED = "pref_anonymous_checked_in";
|
||||
-
|
||||
- /* package */ static final String KEY_LAST_JOB_ID = "last_job_id";
|
||||
- /* package */ static final int QUEUE_MAX_THRESHOLD = 1000;
|
||||
-
|
||||
- public static final String KEY_STATS = "stats_collection";
|
||||
-
|
||||
- SwitchPreference mStatsSwitch;
|
||||
-
|
||||
- public static SharedPreferences getPreferences(Context context) {
|
||||
- return context.getSharedPreferences(PREF_FILE_NAME, 0);
|
||||
- }
|
||||
-
|
||||
- @Override
|
||||
- public void onCreate(Bundle savedInstanceState) {
|
||||
- super.onCreate(savedInstanceState);
|
||||
- addPreferencesFromResource(R.xml.anonymous_stats);
|
||||
- mStatsSwitch = (SwitchPreference) findPreference(KEY_STATS);
|
||||
- }
|
||||
-
|
||||
- @Override
|
||||
- public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, Preference preference) {
|
||||
- if (preference == mStatsSwitch) {
|
||||
- boolean checked = mStatsSwitch.isChecked();
|
||||
- if (checked) {
|
||||
- // clear opt out flags
|
||||
- CMSettings.Secure.putIntForUser(getContentResolver(),
|
||||
- CMSettings.Secure.STATS_COLLECTION_REPORTED, 0, UserHandle.USER_OWNER);
|
||||
- }
|
||||
- // will initiate opt out sequence if necessary
|
||||
- ReportingServiceManager.setAlarm(getActivity());
|
||||
- return true;
|
||||
- }
|
||||
- return super.onPreferenceTreeClick(preferenceScreen, preference);
|
||||
- }
|
||||
-
|
||||
- public static void updateLastSynced(Context context) {
|
||||
- getPreferences(context)
|
||||
- .edit()
|
||||
- .putLong(ANONYMOUS_LAST_CHECKED,System.currentTimeMillis())
|
||||
- .commit();
|
||||
- }
|
||||
-
|
||||
- private static int getLastJobId(Context context) {
|
||||
- return getPreferences(context).getInt(KEY_LAST_JOB_ID, 0);
|
||||
- }
|
||||
-
|
||||
- private static void setLastJobId(Context context, int id) {
|
||||
- getPreferences(context)
|
||||
- .edit()
|
||||
- .putInt(KEY_LAST_JOB_ID, id)
|
||||
- .commit();
|
||||
- }
|
||||
-
|
||||
- public static int getNextJobId(Context context) {
|
||||
- int lastId = getLastJobId(context);
|
||||
- if (lastId >= QUEUE_MAX_THRESHOLD) {
|
||||
- lastId = 1;
|
||||
- } else {
|
||||
- lastId += 1;
|
||||
- }
|
||||
- setLastJobId(context, lastId);
|
||||
- return lastId;
|
||||
- }
|
||||
-
|
||||
- @Override
|
||||
- protected int getMetricsCategory() {
|
||||
- return CMMetricsLogger.ANONYMOUS_STATS;
|
||||
- }
|
||||
-}
|
||||
diff --git a/src/com/android/settings/cmstats/PreviewData.java b/src/com/android/settings/cmstats/PreviewData.java
|
||||
deleted file mode 100644
|
||||
index 0adacad..0000000
|
||||
--- a/src/com/android/settings/cmstats/PreviewData.java
|
||||
+++ /dev/null
|
||||
@@ -1,55 +0,0 @@
|
||||
-/*
|
||||
- * Copyright (C) 2012 The CyanogenMod 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.
|
||||
- */
|
||||
-
|
||||
-package com.android.settings.cmstats;
|
||||
-
|
||||
-import android.content.Context;
|
||||
-import android.os.Bundle;
|
||||
-import android.preference.Preference;
|
||||
-import android.preference.PreferenceScreen;
|
||||
-
|
||||
-import com.android.settings.R;
|
||||
-import com.android.settings.SettingsPreferenceFragment;
|
||||
-import org.cyanogenmod.internal.logging.CMMetricsLogger;
|
||||
-
|
||||
-public class PreviewData extends SettingsPreferenceFragment {
|
||||
- private static final String UNIQUE_ID = "preview_id";
|
||||
- private static final String DEVICE = "preview_device";
|
||||
- private static final String VERSION = "preview_version";
|
||||
- private static final String COUNTRY = "preview_country";
|
||||
- private static final String CARRIER = "preview_carrier";
|
||||
-
|
||||
- @Override
|
||||
- public void onCreate(Bundle savedInstanceState) {
|
||||
- super.onCreate(savedInstanceState);
|
||||
-
|
||||
- addPreferencesFromResource(R.xml.preview_data);
|
||||
-
|
||||
- final PreferenceScreen prefSet = getPreferenceScreen();
|
||||
- final Context context = getActivity();
|
||||
-
|
||||
- prefSet.findPreference(UNIQUE_ID).setSummary(Utilities.getUniqueID(context));
|
||||
- prefSet.findPreference(DEVICE).setSummary(Utilities.getDevice());
|
||||
- prefSet.findPreference(VERSION).setSummary(Utilities.getModVersion());
|
||||
- prefSet.findPreference(COUNTRY).setSummary(Utilities.getCountryCode(context));
|
||||
- prefSet.findPreference(CARRIER).setSummary(Utilities.getCarrier(context));
|
||||
- }
|
||||
-
|
||||
- @Override
|
||||
- protected int getMetricsCategory() {
|
||||
- return CMMetricsLogger.PREVIEW_DATA;
|
||||
- }
|
||||
-}
|
||||
diff --git a/src/com/android/settings/cmstats/ReportingService.java b/src/com/android/settings/cmstats/ReportingService.java
|
||||
deleted file mode 100644
|
||||
index 8410143..0000000
|
||||
--- a/src/com/android/settings/cmstats/ReportingService.java
|
||||
+++ /dev/null
|
||||
@@ -1,106 +0,0 @@
|
||||
-/*
|
||||
- * Copyright (C) 2015 The CyanogenMod 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.
|
||||
- */
|
||||
-
|
||||
-package com.android.settings.cmstats;
|
||||
-
|
||||
-import android.app.IntentService;
|
||||
-import android.app.job.JobInfo;
|
||||
-import android.app.job.JobScheduler;
|
||||
-import android.content.ComponentName;
|
||||
-import android.content.Context;
|
||||
-import android.content.Intent;
|
||||
-import android.os.PersistableBundle;
|
||||
-import android.os.UserHandle;
|
||||
-import android.util.Log;
|
||||
-import cyanogenmod.providers.CMSettings;
|
||||
-
|
||||
-import java.util.List;
|
||||
-
|
||||
-public class ReportingService extends IntentService {
|
||||
- /* package */ static final String TAG = "CMStats";
|
||||
- private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG);
|
||||
-
|
||||
- public static final String EXTRA_OPTING_OUT = "cmstats::opt_out";
|
||||
-
|
||||
- public ReportingService() {
|
||||
- super(ReportingService.class.getSimpleName());
|
||||
- }
|
||||
-
|
||||
- @Override
|
||||
- protected void onHandleIntent(Intent intent) {
|
||||
- JobScheduler js = (JobScheduler) getSystemService(Context.JOB_SCHEDULER_SERVICE);
|
||||
-
|
||||
- String deviceId = Utilities.getUniqueID(getApplicationContext());
|
||||
- String deviceName = Utilities.getDevice();
|
||||
- String deviceVersion = Utilities.getModVersion();
|
||||
- String deviceCountry = Utilities.getCountryCode(getApplicationContext());
|
||||
- String deviceCarrier = Utilities.getCarrier(getApplicationContext());
|
||||
- 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);
|
||||
-
|
||||
- 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);
|
||||
-
|
||||
- // 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()))
|
||||
- .setRequiredNetworkType(JobInfo.NETWORK_TYPE_ANY)
|
||||
- .setMinimumLatency(1000)
|
||||
- .setExtras(cmBundle)
|
||||
- .setPersisted(true)
|
||||
- .build());
|
||||
-
|
||||
- if (optOut) {
|
||||
- // we've successfully scheduled the opt out.
|
||||
- CMSettings.Secure.putIntForUser(getContentResolver(),
|
||||
- CMSettings.Secure.STATS_COLLECTION_REPORTED, 1, UserHandle.USER_OWNER);
|
||||
- }
|
||||
-
|
||||
- // reschedule
|
||||
- AnonymousStats.updateLastSynced(this);
|
||||
- ReportingServiceManager.setAlarm(this);
|
||||
- }
|
||||
-}
|
||||
diff --git a/src/com/android/settings/cmstats/ReportingServiceManager.java b/src/com/android/settings/cmstats/ReportingServiceManager.java
|
||||
deleted file mode 100644
|
||||
index bce1372..0000000
|
||||
--- a/src/com/android/settings/cmstats/ReportingServiceManager.java
|
||||
+++ /dev/null
|
||||
@@ -1,123 +0,0 @@
|
||||
-/*
|
||||
- * Copyright (C) 2012 The CyanogenMod 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.
|
||||
- */
|
||||
-
|
||||
-package com.android.settings.cmstats;
|
||||
-
|
||||
-import android.app.AlarmManager;
|
||||
-import android.app.PendingIntent;
|
||||
-import android.app.job.JobScheduler;
|
||||
-import android.content.BroadcastReceiver;
|
||||
-import android.content.Context;
|
||||
-import android.content.Intent;
|
||||
-import android.content.SharedPreferences;
|
||||
-import android.os.UserHandle;
|
||||
-import android.util.Log;
|
||||
-import cyanogenmod.providers.CMSettings;
|
||||
-
|
||||
-public class ReportingServiceManager extends BroadcastReceiver {
|
||||
- private static final long MILLIS_PER_HOUR = 60L * 60L * 1000L;
|
||||
- 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 = ReportingServiceManager.class.getSimpleName();
|
||||
-
|
||||
- public static final String ACTION_LAUNCH_SERVICE =
|
||||
- "com.android.settings.action.TRIGGER_REPORT_METRICS";
|
||||
- public static final String EXTRA_FORCE = "force";
|
||||
-
|
||||
- @Override
|
||||
- public void onReceive(Context context, Intent intent) {
|
||||
- if (intent.getAction().equals(Intent.ACTION_BOOT_COMPLETED)) {
|
||||
- setAlarm(context);
|
||||
- } else if (intent.getAction().equals(ACTION_LAUNCH_SERVICE)){
|
||||
- launchService(context, intent.getBooleanExtra(EXTRA_FORCE, false));
|
||||
- }
|
||||
- }
|
||||
-
|
||||
- /**
|
||||
- * opt out if we haven't yet
|
||||
- */
|
||||
- public static void initiateOptOut(Context context) {
|
||||
- final boolean optOutReported = CMSettings.Secure.getIntForUser(context.getContentResolver(),
|
||||
- CMSettings.Secure.STATS_COLLECTION_REPORTED, 0, UserHandle.USER_OWNER) == 1;
|
||||
- if (!optOutReported) {
|
||||
- Intent intent = new Intent();
|
||||
- intent.setClass(context, ReportingService.class);
|
||||
- intent.putExtra(ReportingService.EXTRA_OPTING_OUT, true);
|
||||
- context.startServiceAsUser(intent, UserHandle.OWNER);
|
||||
- }
|
||||
- }
|
||||
-
|
||||
- public static void setAlarm(Context context) {
|
||||
- SharedPreferences prefs = AnonymousStats.getPreferences(context);
|
||||
- if (prefs.contains(AnonymousStats.ANONYMOUS_OPT_IN)) {
|
||||
- migrate(context, prefs);
|
||||
- }
|
||||
- if (!Utilities.isStatsCollectionEnabled(context)) {
|
||||
- initiateOptOut(context);
|
||||
- return;
|
||||
- }
|
||||
- long lastSynced = prefs.getLong(AnonymousStats.ANONYMOUS_LAST_CHECKED, 0);
|
||||
- if (lastSynced == 0) {
|
||||
- launchService(context, true); // service will reschedule the next alarm
|
||||
- return;
|
||||
- }
|
||||
- long millisFromNow = (lastSynced + UPDATE_INTERVAL) - System.currentTimeMillis();
|
||||
-
|
||||
- Intent intent = new Intent(ACTION_LAUNCH_SERVICE);
|
||||
- intent.setClass(context, ReportingServiceManager.class);
|
||||
-
|
||||
- AlarmManager alarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
|
||||
- alarmManager.set(AlarmManager.RTC_WAKEUP, System.currentTimeMillis() + millisFromNow,
|
||||
- PendingIntent.getBroadcast(context, 0, intent, 0));
|
||||
- Log.d(TAG, "Next sync attempt in : "
|
||||
- + (millisFromNow / MILLIS_PER_HOUR) + " hours");
|
||||
- }
|
||||
-
|
||||
- public static void launchService(Context context, boolean force) {
|
||||
- SharedPreferences prefs = AnonymousStats.getPreferences(context);
|
||||
-
|
||||
- if (!Utilities.isStatsCollectionEnabled(context)) {
|
||||
- return;
|
||||
- }
|
||||
-
|
||||
- if (!force) {
|
||||
- long lastSynced = prefs.getLong(AnonymousStats.ANONYMOUS_LAST_CHECKED, 0);
|
||||
- if (lastSynced == 0) {
|
||||
- setAlarm(context);
|
||||
- return;
|
||||
- }
|
||||
- long timeElapsed = System.currentTimeMillis() - lastSynced;
|
||||
- if (timeElapsed < UPDATE_INTERVAL) {
|
||||
- long timeLeft = UPDATE_INTERVAL - timeElapsed;
|
||||
- Log.d(TAG, "Waiting for next sync : "
|
||||
- + timeLeft / MILLIS_PER_HOUR + " hours");
|
||||
- return;
|
||||
- }
|
||||
- }
|
||||
-
|
||||
- Intent intent = new Intent();
|
||||
- intent.setClass(context, ReportingService.class);
|
||||
- context.startServiceAsUser(intent, UserHandle.OWNER);
|
||||
- }
|
||||
-
|
||||
- private static void migrate(Context context, SharedPreferences prefs) {
|
||||
- Utilities.setStatsCollectionEnabled(context,
|
||||
- prefs.getBoolean(AnonymousStats.ANONYMOUS_OPT_IN, true));
|
||||
- prefs.edit().remove(AnonymousStats.ANONYMOUS_OPT_IN).commit();
|
||||
- }
|
||||
-
|
||||
-}
|
||||
diff --git a/src/com/android/settings/cmstats/StatsUploadJobService.java b/src/com/android/settings/cmstats/StatsUploadJobService.java
|
||||
deleted file mode 100644
|
||||
index 580a20f..0000000
|
||||
--- a/src/com/android/settings/cmstats/StatsUploadJobService.java
|
||||
+++ /dev/null
|
||||
@@ -1,291 +0,0 @@
|
||||
-/*
|
||||
- * Copyright (C) 2015 The CyanogenMod 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.
|
||||
- */
|
||||
-
|
||||
-package com.android.settings.cmstats;
|
||||
-
|
||||
-import android.app.job.JobParameters;
|
||||
-import android.app.job.JobService;
|
||||
-import android.net.Uri;
|
||||
-import android.os.AsyncTask;
|
||||
-import android.os.PersistableBundle;
|
||||
-import android.util.ArrayMap;
|
||||
-import android.util.Log;
|
||||
-import com.android.settings.R;
|
||||
-import org.json.JSONException;
|
||||
-import org.json.JSONObject;
|
||||
-
|
||||
-import java.io.BufferedInputStream;
|
||||
-import java.io.BufferedReader;
|
||||
-import java.io.BufferedWriter;
|
||||
-import java.io.IOException;
|
||||
-import java.io.InputStream;
|
||||
-import java.io.InputStreamReader;
|
||||
-import java.io.OutputStream;
|
||||
-import java.io.OutputStreamWriter;
|
||||
-import java.net.HttpURLConnection;
|
||||
-import java.net.URL;
|
||||
-import java.util.Collections;
|
||||
-import java.util.Map;
|
||||
-
|
||||
-public class StatsUploadJobService extends JobService {
|
||||
-
|
||||
- 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_CYANOGEN = 1;
|
||||
- public static final int JOB_TYPE_CMORG = 2;
|
||||
-
|
||||
- public static final String KEY_UNIQUE_ID = "uniqueId";
|
||||
- public static final String KEY_DEVICE_NAME = "deviceName";
|
||||
- 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";
|
||||
- public static final String KEY_TIMESTAMP = "timeStamp";
|
||||
- public static final String KEY_OPT_OUT = "optOut";
|
||||
-
|
||||
- private final Map<JobParameters, StatsUploadTask> mCurrentJobs
|
||||
- = Collections.synchronizedMap(new ArrayMap<JobParameters, StatsUploadTask>());
|
||||
-
|
||||
- @Override
|
||||
- public boolean onStartJob(JobParameters jobParameters) {
|
||||
- if (DEBUG)
|
||||
- Log.d(TAG, "onStartJob() called with " + "jobParameters = [" + jobParameters + "]");
|
||||
- final StatsUploadTask uploadTask = new StatsUploadTask(jobParameters);
|
||||
- mCurrentJobs.put(jobParameters, uploadTask);
|
||||
- uploadTask.execute((Void) null);
|
||||
- return true;
|
||||
- }
|
||||
-
|
||||
- @Override
|
||||
- public boolean onStopJob(JobParameters jobParameters) {
|
||||
- if (DEBUG)
|
||||
- Log.d(TAG, "onStopJob() called with " + "jobParameters = [" + jobParameters + "]");
|
||||
-
|
||||
- final StatsUploadTask cancelledJob;
|
||||
- cancelledJob = mCurrentJobs.remove(jobParameters);
|
||||
-
|
||||
- if (cancelledJob != null) {
|
||||
- // cancel the ongoing background task
|
||||
- cancelledJob.cancel(true);
|
||||
- return true; // reschedule
|
||||
- }
|
||||
-
|
||||
- return false;
|
||||
- }
|
||||
-
|
||||
- private class StatsUploadTask extends AsyncTask<Void, Void, Boolean> {
|
||||
-
|
||||
- private JobParameters mJobParams;
|
||||
-
|
||||
- public StatsUploadTask(JobParameters jobParams) {
|
||||
- this.mJobParams = jobParams;
|
||||
- }
|
||||
-
|
||||
- @Override
|
||||
- protected Boolean doInBackground(Void... params) {
|
||||
-
|
||||
- PersistableBundle extras = mJobParams.getExtras();
|
||||
-
|
||||
- String deviceId = extras.getString(KEY_UNIQUE_ID);
|
||||
- String deviceName = extras.getString(KEY_DEVICE_NAME);
|
||||
- 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);
|
||||
- long timeStamp = extras.getLong(KEY_TIMESTAMP);
|
||||
- boolean optOut = extras.getBoolean(KEY_OPT_OUT);
|
||||
-
|
||||
- boolean success = false;
|
||||
- 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,
|
||||
- deviceCarrier, deviceCarrierId, optOut);
|
||||
- } catch (IOException e) {
|
||||
- Log.e(TAG, "Could not upload stats checkin to commnity server", e);
|
||||
- success = false;
|
||||
- }
|
||||
- break;
|
||||
- }
|
||||
- }
|
||||
- if (DEBUG)
|
||||
- Log.d(TAG, "job id " + mJobParams.getJobId() + ", has finished with success="
|
||||
- + success);
|
||||
- return success;
|
||||
- }
|
||||
-
|
||||
- @Override
|
||||
- protected void onPostExecute(Boolean success) {
|
||||
- mCurrentJobs.remove(mJobParams);
|
||||
- jobFinished(mJobParams, !success);
|
||||
- }
|
||||
- }
|
||||
-
|
||||
-
|
||||
- private boolean uploadToCM(String deviceId, String deviceName, String deviceVersion,
|
||||
- String deviceCountry, String deviceCarrier, String deviceCarrierId,
|
||||
- boolean optOut)
|
||||
- throws IOException {
|
||||
-
|
||||
- final Uri uri = Uri.parse(getString(R.string.stats_cm_url)).buildUpon()
|
||||
- .appendQueryParameter("opt_out", optOut ? "1" : "0")
|
||||
- .appendQueryParameter("device_hash", deviceId)
|
||||
- .appendQueryParameter("device_name", deviceName)
|
||||
- .appendQueryParameter("device_version", deviceVersion)
|
||||
- .appendQueryParameter("device_country", deviceCountry)
|
||||
- .appendQueryParameter("device_carrier", deviceCarrier)
|
||||
- .appendQueryParameter("device_carrier_id", deviceCarrierId).build();
|
||||
- URL url = new URL(uri.toString());
|
||||
- HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection();
|
||||
- try {
|
||||
- urlConnection.setInstanceFollowRedirects(true);
|
||||
- urlConnection.setDoOutput(true);
|
||||
- urlConnection.connect();
|
||||
-
|
||||
- final int responseCode = urlConnection.getResponseCode();
|
||||
- if (DEBUG) Log.d(TAG, "cm server response code=" + responseCode);
|
||||
- final boolean success = responseCode == HttpURLConnection.HTTP_OK;
|
||||
- if (!success) {
|
||||
- Log.w(TAG, "failed sending, server returned: " + getResponse(urlConnection,
|
||||
- !success));
|
||||
- }
|
||||
- return success;
|
||||
- } finally {
|
||||
- urlConnection.disconnect();
|
||||
- }
|
||||
-
|
||||
- }
|
||||
-
|
||||
- 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
|
||||
- ? httpUrlConnection.getErrorStream()
|
||||
- : httpUrlConnection.getInputStream());
|
||||
-
|
||||
- BufferedReader responseStreamReader = new BufferedReader(
|
||||
- new InputStreamReader(responseStream));
|
||||
- String line = "";
|
||||
- StringBuilder stringBuilder = new StringBuilder();
|
||||
- while ((line = responseStreamReader.readLine()) != null) {
|
||||
- stringBuilder.append(line).append("\n");
|
||||
- }
|
||||
- responseStreamReader.close();
|
||||
- responseStream.close();
|
||||
-
|
||||
- return stringBuilder.toString();
|
||||
- }
|
||||
-
|
||||
-}
|
||||
diff --git a/src/com/android/settings/cmstats/Utilities.java b/src/com/android/settings/cmstats/Utilities.java
|
||||
deleted file mode 100644
|
||||
index 1e98888..0000000
|
||||
--- a/src/com/android/settings/cmstats/Utilities.java
|
||||
+++ /dev/null
|
||||
@@ -1,102 +0,0 @@
|
||||
-/*
|
||||
- * Copyright (C) 2012 The CyanogenMod 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.
|
||||
- */
|
||||
-
|
||||
-package com.android.settings.cmstats;
|
||||
-
|
||||
-import android.content.Context;
|
||||
-import android.os.Build;
|
||||
-import android.os.SystemProperties;
|
||||
-import android.provider.Settings;
|
||||
-import android.telephony.TelephonyManager;
|
||||
-import android.text.TextUtils;
|
||||
-
|
||||
-import cyanogenmod.providers.CMSettings;
|
||||
-
|
||||
-import java.math.BigInteger;
|
||||
-import java.net.NetworkInterface;
|
||||
-import java.security.MessageDigest;
|
||||
-
|
||||
-public class Utilities {
|
||||
- public static String getUniqueID(Context context) {
|
||||
- final String id = Settings.Secure.getString(context.getContentResolver(), Settings.Secure.ANDROID_ID);
|
||||
- return digest(context.getPackageName() + id);
|
||||
- }
|
||||
-
|
||||
- public static String getCarrier(Context context) {
|
||||
- TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
|
||||
- String carrier = tm.getNetworkOperatorName();
|
||||
- if (TextUtils.isEmpty(carrier)) {
|
||||
- carrier = "Unknown";
|
||||
- }
|
||||
- return carrier;
|
||||
- }
|
||||
-
|
||||
- public static String getCarrierId(Context context) {
|
||||
- TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
|
||||
- String carrierId = tm.getNetworkOperator();
|
||||
- if (TextUtils.isEmpty(carrierId)) {
|
||||
- carrierId = "0";
|
||||
- }
|
||||
- return carrierId;
|
||||
- }
|
||||
-
|
||||
- public static String getCountryCode(Context context) {
|
||||
- TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
|
||||
- String countryCode = tm.getNetworkCountryIso();
|
||||
- if (TextUtils.isEmpty(countryCode)) {
|
||||
- countryCode = "Unknown";
|
||||
- }
|
||||
- return countryCode;
|
||||
- }
|
||||
-
|
||||
- public static String getDevice() {
|
||||
- return SystemProperties.get("ro.cm.device", Build.PRODUCT);
|
||||
- }
|
||||
-
|
||||
- public static String getModVersion() {
|
||||
- return SystemProperties.get("ro.cm.version", Build.DISPLAY);
|
||||
- }
|
||||
-
|
||||
- public static String digest(String input) {
|
||||
- try {
|
||||
- MessageDigest md = MessageDigest.getInstance("MD5");
|
||||
- return new BigInteger(1, md.digest(input.getBytes())).toString(16).toUpperCase();
|
||||
- } catch (Exception e) {
|
||||
- return null;
|
||||
- }
|
||||
- }
|
||||
-
|
||||
- /**
|
||||
- * Check to see if global stats are enabled.
|
||||
- * @param context
|
||||
- * @return Whether or not stats collection is enabled.
|
||||
- */
|
||||
- public static boolean isStatsCollectionEnabled(Context context) {
|
||||
- return CMSettings.Secure.getInt(context.getContentResolver(),
|
||||
- CMSettings.Secure.STATS_COLLECTION, 1) != 0;
|
||||
- }
|
||||
-
|
||||
- /**
|
||||
- * Enabled or disable stats collection
|
||||
- * @param context
|
||||
- * @param enabled Boolean that sets collection being enabled.
|
||||
- */
|
||||
- public static void setStatsCollectionEnabled(Context context, boolean enabled) {
|
||||
- int enable = (enabled) ? 1 : 0;
|
||||
- CMSettings.Secure.putInt(context.getContentResolver(),
|
||||
- CMSettings.Secure.STATS_COLLECTION, enable);
|
||||
- }
|
||||
-}
|
||||
diff --git a/src/com/android/settings/cyanogenmod/PrivacySettings.java b/src/com/android/settings/cyanogenmod/PrivacySettings.java
|
||||
index f6a9c15..066063a 100644
|
||||
--- a/src/com/android/settings/cyanogenmod/PrivacySettings.java
|
||||
+++ b/src/com/android/settings/cyanogenmod/PrivacySettings.java
|
||||
@@ -32,7 +32,6 @@ import org.cyanogenmod.internal.logging.CMMetricsLogger;
|
||||
public class PrivacySettings extends SettingsPreferenceFragment {
|
||||
|
||||
private static final String KEY_BLACKLIST = "blacklist";
|
||||
- private static final String KEY_STATS = "cmstats";
|
||||
|
||||
private PreferenceScreen mBlacklist;
|
||||
|
||||
@@ -48,8 +47,6 @@ public class PrivacySettings extends SettingsPreferenceFragment {
|
||||
|
||||
boolean isOwner = Utils.isUserOwner();
|
||||
if (!isOwner) {
|
||||
- PreferenceScreen root = getPreferenceScreen();
|
||||
- root.removePreference(findPreference(KEY_STATS));
|
||||
}
|
||||
|
||||
// Determine options based on device telephony support
|
||||
--
|
||||
2.7.2
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue