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

Commit 7b8d9ecd authored by Jonathan Klee's avatar Jonathan Klee
Browse files

Revert "Write telemetry system settings"

This reverts commit c2b025fe.
parent 6fde9db5
Loading
Loading
Loading
Loading
+0 −6
Original line number Diff line number Diff line
@@ -218,12 +218,6 @@
    <string name="use_ota_staging_popup_title">You are about to connect to /e/ OS test channel</string>
    <string name="use_ota_staging_popup_message">It will allow you to download and install test versions of /e/ OS. Those builds may be unstable, and should be used only for test purposes. Please accept only if you know what you are doing.</string>

    <!-- /e/ Telemetry -->
    <string name="enable_telemetry">Enable /e/OS Telemetry</string>
    <string name="telemetry_details">Enable automatic bug reporting</string>
    <string name="telemetry_dialog_title">You are about to enable /e/OS Telemetry</string>
    <string name="telemetry_dialog_message">It will allow automatic bug report when an application crash or when the application ends up in an unexpected state. Please reboot your device after changing this setting.</string>

    <!-- /e/ Advanced Privacy -->
    <string name="advanced_privacy_dashboard_title" translatable="false">Advanced Privacy</string>
    <string name="advanced_privacy_dashboard_summary">Manage trackers, fake location, hide IP address</string>
+0 −5
Original line number Diff line number Diff line
@@ -641,11 +641,6 @@
            android:key="change_update_source"
            android:title="@string/title_ota_server"
            android:summary="@string/use_ota_summary" />

        <SwitchPreference
            android:key="enable_telemetry"
            android:title="@string/enable_telemetry"
            android:summary="@string/telemetry_details" />
    </PreferenceCategory>

    <com.android.settings.development.autofill.AutofillPreferenceCategory
+0 −1
Original line number Diff line number Diff line
@@ -519,7 +519,6 @@ public class DevelopmentSettingsDashboardFragment extends RestrictedDashboardFra
        controllers.add(new BluetoothMaxConnectedAudioDevicesPreferenceController(context));
        controllers.add(new ShowTapsPreferenceController(context));
        controllers.add(new ChangeSourcePreferenceController(context));
        controllers.add(new EnableTelemetryPreferenceController(context));
        controllers.add(new PointerLocationPreferenceController(context));
        controllers.add(new ShowSurfaceUpdatesPreferenceController(context));
        controllers.add(new ShowLayoutBoundsPreferenceController(context));
+0 −101
Original line number Diff line number Diff line
/*
 * Copyright (C) 2022 MURENA SAS
 *
 * 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.development;

import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import androidx.preference.Preference;
import androidx.preference.PreferenceScreen;
import androidx.preference.SwitchPreference;
import android.provider.Settings;
import android.provider.Settings.SettingNotFoundException;

import com.android.settings.R;
import com.android.settings.core.PreferenceControllerMixin;
import com.android.settingslib.development.DeveloperOptionsPreferenceController;

public class EnableTelemetryPreferenceController extends DeveloperOptionsPreferenceController implements
        Preference.OnPreferenceChangeListener, PreferenceControllerMixin {

    private static final String PREFERENCES_ENABLE_TELEMETRY_KEY = "enable_telemetry";
    private static final String TELEMETRY_KEY = "e_telemetry";
    private static final int TELEMETRY_ON = 1;
    private static final int TELEMETRY_OFF = 0;
    private String status;

    public EnableTelemetryPreferenceController(Context context) {
        super(context);
    }

    @Override
    public String getPreferenceKey(){
        return PREFERENCES_ENABLE_TELEMETRY_KEY;
    }

    public void enableTelemetry(Boolean enabled) {
        Settings.System.putInt(mContext.getContentResolver(), TELEMETRY_KEY, enabled ? TELEMETRY_ON : TELEMETRY_OFF);
    }

    @Override
    public boolean onPreferenceChange(Preference preference, Object newValue) {
        final boolean isEnabled = (Boolean) newValue;
        ((SwitchPreference) mPreference).setChecked(isEnabled);

        if (!isEnabled) {
	    enableTelemetry(false);
	    return true;
	}

        new AlertDialog.Builder(mContext)
                .setTitle(R.string.telemetry_dialog_title)
                .setMessage(mContext.getResources().getString(R.string.telemetry_dialog_message))
                .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int which) {
                        ((SwitchPreference) mPreference).setChecked(true);
                        enableTelemetry(true);
                    }
                }).setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int which) {
                        ((SwitchPreference) mPreference).setChecked(false);
                        enableTelemetry(false);
                    }
                }).show();
        return true;
    }

    @Override
    public void updateState(Preference preference) {
	if (Settings.System.getInt(mContext.getContentResolver(), TELEMETRY_KEY, 0) == TELEMETRY_ON) {
            ((SwitchPreference) mPreference).setChecked(true);
	} else {
            ((SwitchPreference) mPreference).setChecked(false);
	}
    }

    @Override
    protected void onDeveloperOptionsSwitchDisabled() {
        super.onDeveloperOptionsSwitchDisabled();
        ((SwitchPreference) mPreference).setChecked(false);
        enableTelemetry(false);
    }

    @Override
    protected void onDeveloperOptionsSwitchEnabled() {
        super.onDeveloperOptionsSwitchEnabled();
    }
}