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

Commit 7e0edf02 authored by Amit Kumar's avatar Amit Kumar
Browse files

Remove anonymous stats collection

Change-Id: I9452054546512e223df2e0a198dd671441a40a30
parent a1e397ea
Loading
Loading
Loading
Loading
+0 −25
Original line number Diff line number Diff line
@@ -184,31 +184,6 @@
                android:value="status_bar_settings" />
        </activity-alias>

        <!-- 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="org.cyanogenmod.cmparts.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" />

        <service android:name=".cmstats.ReportingService"
                 android:label="ReportingService"
                 android:enabled="true"
                 android:exported="false" />

		<!-- Weather settings -->
        <activity-alias
            android:name=".weather.WeatherServiceSettings"

res/xml/anonymous_stats.xml

deleted100644 → 0
+0 −32
Original line number Diff line number Diff line
<?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:key="cmstats"
    android:title="@string/anonymous_statistics_title">

    <cyanogenmod.preference.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="org.cyanogenmod.cmparts.cmstats.PreviewData" />

</PreferenceScreen>
+0 −5
Original line number Diff line number Diff line
@@ -74,11 +74,6 @@
          android:fragment="org.cyanogenmod.cmparts.statusbar.StatusBarSettings"
          cm:xmlRes="@xml/status_bar_settings" />

    <part android:key="cmstats"
          android:title="@string/anonymous_statistics_title"
          android:fragment="org.cyanogenmod.cmparts.cmstats.AnonymousStats"
          cm:xmlRes="@xml/anonymous_stats" />

    <part android:key="power_menu"
          android:title="@string/power_menu_title"
          android:fragment="org.cyanogenmod.cmparts.input.PowerMenuActions"
+0 −73
Original line number Diff line number Diff line
/*
 * 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 org.cyanogenmod.cmparts.cmstats;

import android.content.Context;
import android.content.SharedPreferences;
import android.os.Bundle;

import org.cyanogenmod.cmparts.R;
import org.cyanogenmod.cmparts.SettingsPreferenceFragment;

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 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);
    }

    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;
    }
}
+0 −49
Original line number Diff line number Diff line
/*
 * Copyright (C) 2012 The CyanogenMod Project
 *               2017 The LineageOS Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * 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 org.cyanogenmod.cmparts.cmstats;

import android.content.Context;
import android.os.Bundle;
import android.support.v7.preference.PreferenceScreen;

import org.cyanogenmod.cmparts.R;
import org.cyanogenmod.cmparts.SettingsPreferenceFragment;

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));
    }
}
Loading